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; |
nitinanand | c8b7025 | 2019-04-17 15:35:43 +0530 | [diff] [blame] | 20 | import java.util.Optional; |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 21 | import java.util.Set; |
| 22 | |
| 23 | /** |
| 24 | * An interface representing workflow. |
| 25 | */ |
| 26 | public interface Workflow { |
| 27 | |
| 28 | /** |
| 29 | * Id of workflow. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 30 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 31 | * @return id |
| 32 | */ |
| 33 | URI id(); |
| 34 | |
| 35 | /** |
| 36 | * Returns init worklet. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 37 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 38 | * @param context workflow context |
| 39 | * @return init worklet |
| 40 | * @throws WorkflowException workflow exception |
| 41 | */ |
| 42 | Worklet init(WorkflowContext context) throws WorkflowException; |
| 43 | |
| 44 | /** |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 45 | * Returns next program counter. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 46 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 47 | * @param context workflow context |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 48 | * @return next program counter |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 49 | * @throws WorkflowException workflow exception |
| 50 | */ |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 51 | ProgramCounter next(WorkflowContext context) throws WorkflowException; |
| 52 | |
| 53 | /** |
| 54 | * Gets increased program coounter. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 55 | * |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 56 | * @param pc program counter |
| 57 | * @return increased program counter |
| 58 | * @throws WorkflowException workflow exception |
| 59 | */ |
| 60 | ProgramCounter increased(ProgramCounter pc) throws WorkflowException; |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 61 | |
| 62 | /** |
| 63 | * Returns instance of worklet. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 64 | * |
jaegonkim | f85ee3c | 2019-04-21 11:10:25 +0900 | [diff] [blame] | 65 | * @param pc program counter |
| 66 | * @return instance of worklet |
| 67 | * @throws WorkflowException workflow exception |
| 68 | */ |
| 69 | Worklet getWorkletInstance(ProgramCounter pc) throws WorkflowException; |
| 70 | |
| 71 | /** |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 72 | * Builds workflow context. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 73 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 74 | * @param workplace workplace of system workflow |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 75 | * @param data data model of system workflow context |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 76 | * @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.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 83 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 84 | * @param workplace workplace of system workflow |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 85 | * @param data data model of system workflow context |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 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. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 93 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 94 | * @return attributes |
| 95 | */ |
| 96 | Set<WorkflowAttribute> attributes(); |
mohamedrahilr | 63a921c | 2019-02-27 19:48:25 +0530 | [diff] [blame] | 97 | |
| 98 | /** |
jaegonkim | 4064ed1 | 2019-05-18 11:34:45 +0900 | [diff] [blame] | 99 | * Build the list of ProgramCounters, and returns. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 100 | * |
jaegonkim | 4064ed1 | 2019-05-18 11:34:45 +0900 | [diff] [blame] | 101 | * @return program counter list |
mohamedrahilr | 63a921c | 2019-02-27 19:48:25 +0530 | [diff] [blame] | 102 | */ |
jaegonkim | 4064ed1 | 2019-05-18 11:34:45 +0900 | [diff] [blame] | 103 | List<ProgramCounter> getProgram(); |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 104 | |
| 105 | /** |
nitinanand | c8b7025 | 2019-04-17 15:35:43 +0530 | [diff] [blame] | 106 | * 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.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 115 | * Returns worklet description. |
| 116 | * @param pc program counter |
| 117 | * @return worklet description list |
| 118 | */ |
| 119 | WorkletDescription getWorkletDesc(ProgramCounter pc); |
| 120 | |
nitinanand | c8b7025 | 2019-04-17 15:35:43 +0530 | [diff] [blame] | 121 | /** |
| 122 | * Returns trigger worklet class name if any. |
| 123 | * @return trigger worklet class name |
| 124 | */ |
| 125 | Optional<String> getTriggerWorkletClassName(); |
| 126 | |
| 127 | } |