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 this.action = action;
106 }
107
108 /**
109 * {@inheritDoc}
110 *
111 * @see org.opencastproject.workflow.api.WorkflowOperationResult#getProperties()
112 */
113 @Override
114 public Map<String, String> getProperties() {
115 return properties;
116 }
117
118 /**
119 * {@inheritDoc}
120 *
121 * @see org.opencastproject.workflow.api.WorkflowOperationResult#getTimeInQueue()
122 */
123 @Override
124 public long getTimeInQueue() {
125 return timeInQueue;
126 }
127
128 /**
129 * Specifies whether the operation should be abortable by the user.
130 *
131 * @param isAbortable
132 */
133 public void setAllowsAbort(boolean isAbortable) {
134 this.isAbortable = isAbortable;
135 }
136
137 /**
138 * {@inheritDoc}
139 *
140 * @see org.opencastproject.workflow.api.WorkflowOperationResult#allowsAbort()
141 */
142 @Override
143 public boolean allowsAbort() {
144 return isAbortable;
145 }
146
147 /**
148 * Specifies whether the operation should be continuable by the user.
149 *
150 * @param isContinuable
151 */
152 public void setAllowsContinue(boolean isContinuable) {
153 this.isContinuable = isContinuable;
154 }
155
156 /**
157 * {@inheritDoc}
158 *
159 * @see org.opencastproject.workflow.api.WorkflowOperationResult#allowsContinue()
160 */
161 @Override
162 public boolean allowsContinue() {
163 return isContinuable;
164 }
165
166 }