]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - runtime/org.argeo.slc.specs/src/main/java/org/argeo/slc/process/SlcExecution.java
Remove runtime packages
[gpl/argeo-slc.git] / runtime / org.argeo.slc.specs / src / main / java / org / argeo / slc / process / SlcExecution.java
index cfef480336f4975ea2c8c82741f75cb6c64a0e5e..068c6957725c16c9874ba6d8274ffea2c872b739 100644 (file)
@@ -1,16 +1,34 @@
+/*\r
+ * Copyright (C) 2007-2012 Argeo GmbH\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *         http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
 package org.argeo.slc.process;\r
 \r
+import java.io.Serializable;\r
 import java.util.ArrayList;\r
+import java.util.Date;\r
 import java.util.List;\r
 import java.util.Map;\r
 import java.util.TreeMap;\r
 \r
-public class SlcExecution {\r
-       public final static String STATUS_SCHEDULED = "SCHEDULED";\r
-       public final static String STATUS_RUNNING = "RUNNING";\r
-       public final static String STATUS_FINISHED = "FINISHED";\r
-       public final static String STATUS_ERROR = "ERROR";\r
-       public final static String STATUS_CLEANED = "CLEANED";\r
+import org.argeo.slc.execution.ExecutionProcess;\r
+import org.argeo.slc.execution.ExecutionStep;\r
+import org.argeo.slc.execution.RealizedFlow;\r
+\r
+/** @deprecated use other implementations of {@link ExecutionProcess} */\r
+public class SlcExecution implements ExecutionProcess, Serializable {\r
+       private static final long serialVersionUID = -7607457971382118466L;\r
 \r
        public final static String UNKOWN_HOST = "UNKOWN_HOST";\r
 \r
@@ -18,12 +36,16 @@ public class SlcExecution {
        private String host;\r
        private String user;\r
        private String type;\r
-       private String status;\r
+       private String status = NEW;\r
        private Map<String, String> attributes = new TreeMap<String, String>();\r
 \r
+       /** TODO: Synchronize */\r
        private List<SlcExecutionStep> steps = new ArrayList<SlcExecutionStep>();\r
        private List<RealizedFlow> realizedFlows = new ArrayList<RealizedFlow>();\r
 \r
+       /** Attachment uuid. */\r
+       private String realizedFlowsXml = null;\r
+\r
        public List<RealizedFlow> getRealizedFlows() {\r
                return realizedFlows;\r
        }\r
@@ -40,6 +62,10 @@ public class SlcExecution {
                this.steps = steps;\r
        }\r
 \r
+       public void addSteps(List<ExecutionStep> steps) {\r
+               // not implemented on deprecated\r
+       }\r
+\r
        public String getUuid() {\r
                return uuid;\r
        }\r
@@ -81,10 +107,12 @@ public class SlcExecution {
        }\r
 \r
        public SlcExecutionStep currentStep() {\r
-               if (steps.size() > 0)\r
-                       return steps.get(steps.size() - 1);\r
-               else\r
-                       return null;\r
+               synchronized (steps) {\r
+                       if (steps.size() > 0)\r
+                               return steps.get(steps.size() - 1);\r
+                       else\r
+                               return null;\r
+               }\r
        }\r
 \r
        @Override\r
@@ -115,4 +143,40 @@ public class SlcExecution {
                buf.append(" attributes=").append(attributes);\r
                return buf.toString();\r
        }\r
+\r
+       public Date getStartDate() {\r
+               synchronized (steps) {\r
+                       if (steps.size() == 0)\r
+                               return null;\r
+                       else\r
+                               return steps.get(0).getTimestamp();\r
+               }\r
+       }\r
+\r
+       public Date getEndDate() {\r
+               if (!status.equals(COMPLETED) && !status.equals(ERROR))\r
+                       return null;\r
+\r
+               synchronized (steps) {\r
+                       if (steps.size() == 0)\r
+                               return null;\r
+                       else\r
+                               return steps.get(steps.size() - 1).getTimestamp();\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Not (yet) a stable API, should not be relied upon!\r
+        * \r
+        * @return an id or an url allowing to retrieve the XML, not the XML itself!\r
+        */\r
+       public String getRealizedFlowsXml() {\r
+               return realizedFlowsXml;\r
+       }\r
+\r
+       /** Not (yet) a stable API, should not be relied upon! */\r
+       public void setRealizedFlowsXml(String realizedFlowsXml) {\r
+               this.realizedFlowsXml = realizedFlowsXml;\r
+       }\r
+\r
 }\r