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. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 29 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 30 | * @return id |
| 31 | */ |
| 32 | URI id(); |
| 33 | |
| 34 | /** |
| 35 | * Returns init worklet. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 36 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 37 | * @param context workflow context |
| 38 | * @return init worklet |
| 39 | * @throws WorkflowException workflow exception |
| 40 | */ |
| 41 | Worklet init(WorkflowContext context) throws WorkflowException; |
| 42 | |
| 43 | /** |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 44 | * Returns next program counter. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 45 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 46 | * @param context workflow context |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 47 | * @return next program counter |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 48 | * @throws WorkflowException workflow exception |
| 49 | */ |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 50 | ProgramCounter next(WorkflowContext context) throws WorkflowException; |
| 51 | |
| 52 | /** |
| 53 | * Gets increased program coounter. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 54 | * |
jaegonkim | e0f45b5 | 2018-10-09 20:23:26 +0900 | [diff] [blame] | 55 | * @param pc program counter |
| 56 | * @return increased program counter |
| 57 | * @throws WorkflowException workflow exception |
| 58 | */ |
| 59 | ProgramCounter increased(ProgramCounter pc) throws WorkflowException; |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 60 | |
| 61 | /** |
| 62 | * Returns instance of worklet. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 63 | * |
jaegonkim | f85ee3c | 2019-04-21 11:10:25 +0900 | [diff] [blame] | 64 | * @param pc program counter |
| 65 | * @return instance of worklet |
| 66 | * @throws WorkflowException workflow exception |
| 67 | */ |
| 68 | Worklet getWorkletInstance(ProgramCounter pc) throws WorkflowException; |
| 69 | |
| 70 | /** |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 71 | * Builds workflow context. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 72 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 73 | * @param workplace workplace of system workflow |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 74 | * @param data data model of system workflow context |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 75 | * @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.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 82 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 83 | * @param workplace workplace of system workflow |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 84 | * @param data data model of system workflow context |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 85 | * @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.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 92 | * |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 93 | * @return attributes |
| 94 | */ |
| 95 | Set<WorkflowAttribute> attributes(); |
mohamedrahilr | 63a921c | 2019-02-27 19:48:25 +0530 | [diff] [blame] | 96 | |
| 97 | /** |
jaegonkim | 4064ed1 | 2019-05-18 11:34:45 +0900 | [diff] [blame] | 98 | * Build the list of ProgramCounters, and returns. |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 99 | * |
jaegonkim | 4064ed1 | 2019-05-18 11:34:45 +0900 | [diff] [blame] | 100 | * @return program counter list |
mohamedrahilr | 63a921c | 2019-02-27 19:48:25 +0530 | [diff] [blame] | 101 | */ |
jaegonkim | 4064ed1 | 2019-05-18 11:34:45 +0900 | [diff] [blame] | 102 | List<ProgramCounter> getProgram(); |
m.rahil | 0925188 | 2019-04-15 22:58:33 +0530 | [diff] [blame] | 103 | |
| 104 | /** |
| 105 | * Returns worklet description. |
| 106 | * @param pc program counter |
| 107 | * @return worklet description list |
| 108 | */ |
| 109 | WorkletDescription getWorkletDesc(ProgramCounter pc); |
| 110 | |
jaegonkim | 6a7b524 | 2018-09-12 23:09:42 +0900 | [diff] [blame] | 111 | } |