blob: 3849afe3546bec46544d61c39e52425793f8acbc [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;
jaegonkim6a7b5242018-09-12 23:09:42 +090020import java.util.Set;
21
22/**
23 * An interface representing workflow.
24 */
25public interface Workflow {
26
27 /**
28 * Id of workflow.
m.rahil09251882019-04-15 22:58:33 +053029 *
jaegonkim6a7b5242018-09-12 23:09:42 +090030 * @return id
31 */
32 URI id();
33
34 /**
35 * Returns init worklet.
m.rahil09251882019-04-15 22:58:33 +053036 *
jaegonkim6a7b5242018-09-12 23:09:42 +090037 * @param context workflow context
38 * @return init worklet
39 * @throws WorkflowException workflow exception
40 */
41 Worklet init(WorkflowContext context) throws WorkflowException;
42
43 /**
jaegonkime0f45b52018-10-09 20:23:26 +090044 * Returns next program counter.
m.rahil09251882019-04-15 22:58:33 +053045 *
jaegonkim6a7b5242018-09-12 23:09:42 +090046 * @param context workflow context
jaegonkime0f45b52018-10-09 20:23:26 +090047 * @return next program counter
jaegonkim6a7b5242018-09-12 23:09:42 +090048 * @throws WorkflowException workflow exception
49 */
jaegonkime0f45b52018-10-09 20:23:26 +090050 ProgramCounter next(WorkflowContext context) throws WorkflowException;
51
52 /**
53 * Gets increased program coounter.
m.rahil09251882019-04-15 22:58:33 +053054 *
jaegonkime0f45b52018-10-09 20:23:26 +090055 * @param pc program counter
56 * @return increased program counter
57 * @throws WorkflowException workflow exception
58 */
59 ProgramCounter increased(ProgramCounter pc) throws WorkflowException;
jaegonkim6a7b5242018-09-12 23:09:42 +090060
61 /**
62 * Returns instance of worklet.
m.rahil09251882019-04-15 22:58:33 +053063 *
jaegonkimf85ee3c2019-04-21 11:10:25 +090064 * @param pc program counter
65 * @return instance of worklet
66 * @throws WorkflowException workflow exception
67 */
68 Worklet getWorkletInstance(ProgramCounter pc) throws WorkflowException;
69
70 /**
jaegonkim6a7b5242018-09-12 23:09:42 +090071 * Builds workflow context.
m.rahil09251882019-04-15 22:58:33 +053072 *
jaegonkim6a7b5242018-09-12 23:09:42 +090073 * @param workplace workplace of system workflow
m.rahil09251882019-04-15 22:58:33 +053074 * @param data data model of system workflow context
jaegonkim6a7b5242018-09-12 23:09:42 +090075 * @return workflow context
76 * @throws WorkflowException workflow exception
77 */
78 WorkflowContext buildContext(Workplace workplace, DataModelTree data) throws WorkflowException;
79
80 /**
81 * Builds system workflow context.
m.rahil09251882019-04-15 22:58:33 +053082 *
jaegonkim6a7b5242018-09-12 23:09:42 +090083 * @param workplace workplace of system workflow
m.rahil09251882019-04-15 22:58:33 +053084 * @param data data model of system workflow context
jaegonkim6a7b5242018-09-12 23:09:42 +090085 * @return system workflow context
86 * @throws WorkflowException workflow exception
87 */
88 WorkflowContext buildSystemContext(Workplace workplace, DataModelTree data) throws WorkflowException;
89
90 /**
91 * Returns workflow attributes.
m.rahil09251882019-04-15 22:58:33 +053092 *
jaegonkim6a7b5242018-09-12 23:09:42 +090093 * @return attributes
94 */
95 Set<WorkflowAttribute> attributes();
mohamedrahilr63a921c2019-02-27 19:48:25 +053096
97 /**
jaegonkim4064ed12019-05-18 11:34:45 +090098 * Build the list of ProgramCounters, and returns.
m.rahil09251882019-04-15 22:58:33 +053099 *
jaegonkim4064ed12019-05-18 11:34:45 +0900100 * @return program counter list
mohamedrahilr63a921c2019-02-27 19:48:25 +0530101 */
jaegonkim4064ed12019-05-18 11:34:45 +0900102 List<ProgramCounter> getProgram();
m.rahil09251882019-04-15 22:58:33 +0530103
104 /**
105 * Returns worklet description.
106 * @param pc program counter
107 * @return worklet description list
108 */
109 WorkletDescription getWorkletDesc(ProgramCounter pc);
110
jaegonkimce75d3c2020-03-22 00:44:29 +0900111}