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