1 /*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for additional
4 * information regarding copyright ownership.
5 *
6 *
7 * The Apereo Foundation licenses this file to you under the Educational
8 * Community License, Version 2.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of the License
10 * at:
11 *
12 * http://opensource.org/licenses/ecl2.txt
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 *
20 */
21
22 package org.opencastproject.workflow.api;
23
24 import org.opencastproject.mediapackage.MediaPackage;
25
26 import java.util.Map;
27
28 public class WorkflowOperationResultImpl implements WorkflowOperationResult {
29 protected MediaPackage resultingMediaPackage;
30
31 protected Map<String, String> properties;
32
33 protected Action action;
34
35 protected long timeInQueue;
36
37 protected boolean wait;
38
39 protected boolean isContinuable;
40
41 protected boolean isAbortable;
42
43 /**
44 * No arg constructor needed by JAXB
45 */
46 public WorkflowOperationResultImpl() {
47 }
48
49 /**
50 * Constructs a new WorkflowOperationResultImpl from a mediapackage and an action.
51 *
52 * @param resultingMediaPackage
53 * @param action
54 */
55 public WorkflowOperationResultImpl(MediaPackage resultingMediaPackage, Map<String, String> properties, Action action,
56 long timeInQueue) {
57 this.resultingMediaPackage = resultingMediaPackage;
58 this.properties = properties;
59 this.timeInQueue = timeInQueue;
60 this.isAbortable = true;
61 this.isContinuable = true;
62 if (action == null) {
63 throw new IllegalArgumentException("action must not be null.");
64 } else {
65 this.action = action;
66 }
67 }
68
69 /**
70 * {@inheritDoc}
71 *
72 * @see org.opencastproject.workflow.api.WorkflowOperationResult#getMediaPackage()
73 */
74 public MediaPackage getMediaPackage() {
75 return resultingMediaPackage;
76 }
77
78 /**
79 * Sets the resulting media package.
80 *
81 * @param mediaPackage
82 */
83 public void setMediaPackage(MediaPackage mediaPackage) {
84 this.resultingMediaPackage = mediaPackage;
85 }
86
87 /**
88 *
89 * {@inheritDoc}
90 *
91 * @see org.opencastproject.workflow.api.WorkflowOperationResult#getAction()
92 */
93 public Action getAction() {
94 return action;
95 }
96
97 /**
98 * Sets the action that the workflow service should take on the workflow instance
99 *
100 * @param action
101 */
102 public void setAction(Action action) {
103 if (action == null) {
104 throw new IllegalArgumentException("action must not be null.");
105 }
106 this.action = action;
107 }
108
109 /**
110 * {@inheritDoc}
111 *
112 * @see org.opencastproject.workflow.api.WorkflowOperationResult#getProperties()
113 */
114 @Override
115 public Map<String, String> getProperties() {
116 return properties;
117 }
118
119 /**
120 * {@inheritDoc}
121 *
122 * @see org.opencastproject.workflow.api.WorkflowOperationResult#getTimeInQueue()
123 */
124 @Override
125 public long getTimeInQueue() {
126 return timeInQueue;
127 }
128
129 /**
130 * Specifies whether the operation should be abortable by the user.
131 *
132 * @param isAbortable
133 */
134 public void setAllowsAbort(boolean isAbortable) {
135 this.isAbortable = isAbortable;
136 }
137
138 /**
139 * {@inheritDoc}
140 *
141 * @see org.opencastproject.workflow.api.WorkflowOperationResult#allowsAbort()
142 */
143 @Override
144 public boolean allowsAbort() {
145 return isAbortable;
146 }
147
148 /**
149 * Specifies whether the operation should be continuable by the user.
150 *
151 * @param isContinuable
152 */
153 public void setAllowsContinue(boolean isContinuable) {
154 this.isContinuable = isContinuable;
155 }
156
157 /**
158 * {@inheritDoc}
159 *
160 * @see org.opencastproject.workflow.api.WorkflowOperationResult#allowsContinue()
161 */
162 @Override
163 public boolean allowsContinue() {
164 return isContinuable;
165 }
166
167 }