jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.workflow.api; |
| 17 | |
| 18 | import java.net.URI; |
mohamedrahilr | 63a921c | 2019-02-27 19:48:25 +0530 | [diff] [blame] | 19 | import java.util.List; |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 20 | import java.util.Set; |
| 21 | |
| 22 | /** |
| 23 | * An interface representing workflow. |
| 24 | */ |
| 25 | public 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 | /** |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 42 | * Returns next program counter. |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 43 | * @param context workflow context |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 44 | * @return next program counter |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 45 | * @throws WorkflowException workflow exception |
| 46 | */ |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 47 | 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; |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * Returns instance of worklet. |
jaegonkim | f85ee3c | 2019-04-21 11:10:25 +0900 | [diff] [blame] | 59 | * @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. |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 67 | * @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(); |
mohamedrahilr | 63a921c | 2019-02-27 19:48:25 +0530 | [diff] [blame] | 96 | |
| 97 | /** |
| 98 | * Returns worklet type list. |
| 99 | * @return worklet type |
| 100 | */ |
| 101 | List<String> getWorkletTypeList(); |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 102 | } |