blob: 96e623fa9df45db89f791feec1df275a3b17edeb [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;
19import java.util.Set;
20
21/**
22 * An interface representing workflow.
23 */
24public interface Workflow {
25
26 /**
27 * Id of workflow.
28 * @return id
29 */
30 URI id();
31
32 /**
33 * Returns init worklet.
34 * @param context workflow context
35 * @return init worklet
36 * @throws WorkflowException workflow exception
37 */
38 Worklet init(WorkflowContext context) throws WorkflowException;
39
40 /**
jaegonkime0f45b52018-10-09 20:23:26 +090041 * Returns next program counter.
jaegonkim6a7b5242018-09-12 23:09:42 +090042 * @param context workflow context
jaegonkime0f45b52018-10-09 20:23:26 +090043 * @return next program counter
jaegonkim6a7b5242018-09-12 23:09:42 +090044 * @throws WorkflowException workflow exception
45 */
jaegonkime0f45b52018-10-09 20:23:26 +090046 ProgramCounter next(WorkflowContext context) throws WorkflowException;
47
48 /**
49 * Gets increased program coounter.
50 * @param pc program counter
51 * @return increased program counter
52 * @throws WorkflowException workflow exception
53 */
54 ProgramCounter increased(ProgramCounter pc) throws WorkflowException;
jaegonkim6a7b5242018-09-12 23:09:42 +090055
56 /**
57 * Returns instance of worklet.
58 * @param workletType class name of worklet
59 * @return instance of worklet
60 * @throws WorkflowException workflow exception
61 */
62 Worklet getWorkletInstance(String workletType) throws WorkflowException;
63
64 /**
65 * Builds workflow context.
66 * @param workplace workplace of system workflow
67 * @param data data model of system workflow context
68 * @return workflow context
69 * @throws WorkflowException workflow exception
70 */
71 WorkflowContext buildContext(Workplace workplace, DataModelTree data) throws WorkflowException;
72
73 /**
74 * Builds system workflow context.
75 * @param workplace workplace of system workflow
76 * @param data data model of system workflow context
77 * @return system workflow context
78 * @throws WorkflowException workflow exception
79 */
80 WorkflowContext buildSystemContext(Workplace workplace, DataModelTree data) throws WorkflowException;
81
82 /**
83 * Returns workflow attributes.
84 * @return attributes
85 */
86 Set<WorkflowAttribute> attributes();
87}