package ever.workflowRepresentation; import java.io.Serializable; import java.util.ArrayList; import javax.xml.stream.XMLStreamWriter; import ever.pipeline.Sentence; /** * This abstract class is used to derive Task, XOR and AND Elements for it. * @author Pol Schumacher, Wirtschaftsinformatik, Institut fuer Informatik, Goethe Universitaet Frankfurt * */ public abstract class WorkflowElement implements Serializable{ /** * */ private static final long serialVersionUID = 5; private WorkflowElement next; //Rdf ressource name private String resName; private static ArrayList wfElements = new ArrayList(); // private static int lastId=-1; // private int elementId; public Sentence relatedSentence; private WorkflowElement parentElement; /** * Sets id and adds the Element to the list of elements */ public WorkflowElement(WorkflowElement parent, Sentence s) { parentElement=parent; // lastId++; // this.elementId=lastId; WorkflowElement.wfElements.add(this); relatedSentence=s; } public WorkflowElement() { // lastId++; // this.elementId=lastId; WorkflowElement.wfElements.add(this); } /** * The id is unique WorkflowElements (And, XOR, Sequence and Tasks) Dataobjects use a different id set * @return id of the workflow */ public int getId() { return 1; } /** * Writes the xml representation of the current workflowelement * @param writer to write into */ public abstract void exportWf2Xml(XMLStreamWriter writer); // /** // * Write the xml representation of the current workflowelement for artificially generated workflowelements. // * @param writer // */ // public abstract void exportWf2XmlArti(XMLStreamWriter writer); /** * Add related sentence to workflow element to be able to track the origin of an element * @param sen */ public void addRelSentence(Sentence sen) { relatedSentence=sen; } // public void setNext(WorkflowElement next) // { // this.next=next; // } @Deprecated public String getResName() { return resName; } @Deprecated public void setResName(String resName) { this.resName = resName; } /** * Resets id generator and workflowelement list */ public static void reset() { WorkflowElement.wfElements=new ArrayList(); // lastId=-1; } @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((next == null) ? 0 : next.hashCode()); result = prime * result + ((relatedSentence == null) ? 0 : relatedSentence.hashCode()); result = prime * result + ((resName == null) ? 0 : resName.hashCode()); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; WorkflowElement other = (WorkflowElement) obj; if (next == null) { if (other.next != null) return false; } else if (!next.equals(other.next)) return false; if (relatedSentence == null) { if (other.relatedSentence != null) return false; } else if (!relatedSentence.equals(other.relatedSentence)) return false; if (resName == null) { if (other.resName != null) return false; } else if (!resName.equals(other.resName)) return false; return true; } /** * Returns the parent ELement of the element * @return */ public WorkflowElement getParentElement() { return parentElement; } /** * Sets new parent eLement for the element * @param the new parent element * */ public void setParentElement(WorkflowElement parentSequence) { this.parentElement = parentSequence; } }