blob: 01fb92dd5dd2de1947c89b0c47e278c6cc9e6611 [file] [log] [blame]
jaegonkim6a7b5242018-09-12 23:09:42 +09001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.workflow.api;
17
18import java.net.URI;
mohamedrahilr63a921c2019-02-27 19:48:25 +053019import java.util.List;
nitinanandc8b70252019-04-17 15:35:43 +053020import java.util.Optional;
jaegonkim6a7b5242018-09-12 23:09:42 +090021import java.util.Set;
22
23/**
24 * An interface representing workflow.
25 */
26public interface Workflow {
27
28 /**
29 * Id of workflow.
m.rahil09251882019-04-15 22:58:33 +053030 *
jaegonkim6a7b5242018-09-12 23:09:42 +090031 * @return id
32 */
33 URI id();
34
35 /**
36 * Returns init worklet.
m.rahil09251882019-04-15 22:58:33 +053037 *
jaegonkim6a7b5242018-09-12 23:09:42 +090038 * @param context workflow context
39 * @return init worklet
40 * @throws WorkflowException workflow exception
41 */
42 Worklet init(WorkflowContext context) throws WorkflowException;
43
44 /**
jaegonkime0f45b52018-10-09 20:23:26 +090045 * Returns next program counter.
m.rahil09251882019-04-15 22:58:33 +053046 *
jaegonkim6a7b5242018-09-12 23:09:42 +090047 * @param context workflow context
jaegonkime0f45b52018-10-09 20:23:26 +090048 * @return next program counter
jaegonkim6a7b5242018-09-12 23:09:42 +090049 * @throws WorkflowException workflow exception
50 */
jaegonkime0f45b52018-10-09 20:23:26 +090051 ProgramCounter next(WorkflowContext context) throws WorkflowException;
52
53 /**
54 * Gets increased program coounter.
m.rahil09251882019-04-15 22:58:33 +053055 *
jaegonkime0f45b52018-10-09 20:23:26 +090056 * @param pc program counter
57 * @return increased program counter
58 * @throws WorkflowException workflow exception
59 */
60 ProgramCounter increased(ProgramCounter pc) throws WorkflowException;
jaegonkim6a7b5242018-09-12 23:09:42 +090061
62 /**
63 * Returns instance of worklet.
m.rahil09251882019-04-15 22:58:33 +053064 *
jaegonkimf85ee3c2019-04-21 11:10:25 +090065 * @param pc program counter
66 * @return instance of worklet
67 * @throws WorkflowException workflow exception
68 */
69 Worklet getWorkletInstance(ProgramCounter pc) throws WorkflowException;
70
71 /**
jaegonkim6a7b5242018-09-12 23:09:42 +090072 * Builds workflow context.
m.rahil09251882019-04-15 22:58:33 +053073 *
jaegonkim6a7b5242018-09-12 23:09:42 +090074 * @param workplace workplace of system workflow
m.rahil09251882019-04-15 22:58:33 +053075 * @param data data model of system workflow context
jaegonkim6a7b5242018-09-12 23:09:42 +090076 * @return workflow context
77 * @throws WorkflowException workflow exception
78 */
79 WorkflowContext buildContext(Workplace workplace, DataModelTree data) throws WorkflowException;
80
81 /**
82 * Builds system workflow context.
m.rahil09251882019-04-15 22:58:33 +053083 *
jaegonkim6a7b5242018-09-12 23:09:42 +090084 * @param workplace workplace of system workflow
m.rahil09251882019-04-15 22:58:33 +053085 * @param data data model of system workflow context
jaegonkim6a7b5242018-09-12 23:09:42 +090086 * @return system workflow context
87 * @throws WorkflowException workflow exception
88 */
89 WorkflowContext buildSystemContext(Workplace workplace, DataModelTree data) throws WorkflowException;
90
91 /**
92 * Returns workflow attributes.
m.rahil09251882019-04-15 22:58:33 +053093 *
jaegonkim6a7b5242018-09-12 23:09:42 +090094 * @return attributes
95 */
96 Set<WorkflowAttribute> attributes();
mohamedrahilr63a921c2019-02-27 19:48:25 +053097
98 /**
jaegonkim4064ed12019-05-18 11:34:45 +090099 * Build the list of ProgramCounters, and returns.
m.rahil09251882019-04-15 22:58:33 +0530100 *
jaegonkim4064ed12019-05-18 11:34:45 +0900101 * @return program counter list
mohamedrahilr63a921c2019-02-27 19:48:25 +0530102 */
jaegonkim4064ed12019-05-18 11:34:45 +0900103 List<ProgramCounter> getProgram();
m.rahil09251882019-04-15 22:58:33 +0530104
105 /**
nitinanandc8b70252019-04-17 15:35:43 +0530106 * Returns worklet instance with given worklet Name.
107 * @param workletType worklet name
108 * @return Worklet
109 * @throws WorkflowException workflow exception
110 */
111
112 Worklet getTriggerWorkletInstance(String workletType) throws WorkflowException;
113
114 /**
m.rahil09251882019-04-15 22:58:33 +0530115 * Returns worklet description.
116 * @param pc program counter
117 * @return worklet description list
118 */
119 WorkletDescription getWorkletDesc(ProgramCounter pc);
120
nitinanandc8b70252019-04-17 15:35:43 +0530121 /**
122 * Returns trigger worklet class name if any.
123 * @return trigger worklet class name
124 */
125 Optional<String> getTriggerWorkletClassName();
126
127 }