blob: 1404f9b66258f6f9976aacf0268ed821291dab04 [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.
29 * @return id
30 */
31 URI id();
32
33 /**
34 * Returns init worklet.
35 * @param context workflow context
36 * @return init worklet
37 * @throws WorkflowException workflow exception
38 */
39 Worklet init(WorkflowContext context) throws WorkflowException;
40
41 /**
jaegonkime0f45b52018-10-09 20:23:26 +090042 * Returns next program counter.
jaegonkim6a7b5242018-09-12 23:09:42 +090043 * @param context workflow context
jaegonkime0f45b52018-10-09 20:23:26 +090044 * @return next program counter
jaegonkim6a7b5242018-09-12 23:09:42 +090045 * @throws WorkflowException workflow exception
46 */
jaegonkime0f45b52018-10-09 20:23:26 +090047 ProgramCounter next(WorkflowContext context) throws WorkflowException;
48
49 /**
50 * Gets increased program coounter.
51 * @param pc program counter
52 * @return increased program counter
53 * @throws WorkflowException workflow exception
54 */
55 ProgramCounter increased(ProgramCounter pc) throws WorkflowException;
jaegonkim6a7b5242018-09-12 23:09:42 +090056
57 /**
58 * Returns instance of worklet.
jaegonkimf85ee3c2019-04-21 11:10:25 +090059 * @param pc program counter
60 * @return instance of worklet
61 * @throws WorkflowException workflow exception
62 */
63 Worklet getWorkletInstance(ProgramCounter pc) throws WorkflowException;
64
65 /**
66 * Returns instance of worklet.
jaegonkim6a7b5242018-09-12 23:09:42 +090067 * @param workletType class name of worklet
68 * @return instance of worklet
69 * @throws WorkflowException workflow exception
70 */
71 Worklet getWorkletInstance(String workletType) throws WorkflowException;
72
73 /**
74 * Builds workflow context.
75 * @param workplace workplace of system workflow
76 * @param data data model of system workflow context
77 * @return workflow context
78 * @throws WorkflowException workflow exception
79 */
80 WorkflowContext buildContext(Workplace workplace, DataModelTree data) throws WorkflowException;
81
82 /**
83 * Builds system workflow context.
84 * @param workplace workplace of system workflow
85 * @param data data model of system workflow context
86 * @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.
93 * @return attributes
94 */
95 Set<WorkflowAttribute> attributes();
mohamedrahilr63a921c2019-02-27 19:48:25 +053096
97 /**
98 * Returns worklet type list.
99 * @return worklet type
100 */
101 List<String> getWorkletTypeList();
jaegonkim6a7b5242018-09-12 23:09:42 +0900102}