public boolean isPredecessorsOR(int id, int id2) { for (LinkedList<SeqCond> linkedList : sequenceCondition) { boolean foundID = false, foundID2 = false; for (SeqCond sc : linkedList) { foundID = (sc.isOperationCheck() && sc.id == id && sc.state == 2) ? true : foundID; foundID2 = (sc.isOperationCheck() && sc.id == id2 && sc.state == 2) ? true : foundID2; } if (foundID && foundID2) { return true; } } return false; }
/** * Checks if this operation is relating to the the state (init=0, exe=1, fin=2) of the operation * with id == id. * * @param id The id of the other operation * @return True if this operation is relating to the execute state of the other op. */ public boolean isRelatingToState(int id, int state) { for (LinkedList<SeqCond> linkedList : sequenceCondition) { for (SeqCond sc : linkedList) { if (sc.isOperationCheck() && sc.id == id && sc.state == state) return true; } } for (LinkedList<SeqCond> linkedList : pSequenceCondition) { for (SeqCond sc : linkedList) { if (sc.isOperationCheck() && sc.id == id && sc.state == state) return true; } } return false; }
public boolean isPredecessor(int id) { for (LinkedList<SeqCond> linkedList : sequenceCondition) { for (SeqCond sc : linkedList) { if (sc.isOperationCheck() && sc.id == id && sc.state == 2) return true; } } return false; }
public Set<Integer> getPreCondOperations() { HashSet<Integer> ids = new HashSet<Integer>(); for (LinkedList<SeqCond> preCond : this.sequenceCondition) { for (SeqCond s : preCond) { if (s.isOperationCheck()) ids.add(s.id); } } return ids; }
public boolean isPredecessorsAND(int id, int id2) { boolean foundID = false, foundID2 = false; for (LinkedList<SeqCond> linkedList : sequenceCondition) { for (SeqCond sc : linkedList) { if (sc.isOperationCheck() && sc.id == id && sc.state == 2) { foundID = true; break; } else if (sc.isOperationCheck() && sc.id == id2 && sc.state == 2) { foundID2 = true; break; } } } if (foundID && foundID2) { return true; } else { return false; } }
public LinkedList<LinkedList<Integer>> getPredecessors() { LinkedList<LinkedList<Integer>> result = new LinkedList<LinkedList<Integer>>(); for (LinkedList<SeqCond> linkedList : sequenceCondition) { LinkedList<Integer> orPred = new LinkedList<Integer>(); for (SeqCond sc : linkedList) { if (sc.isOperationCheck() && sc.state == 2) { orPred.add(sc.id); } } if (!orPred.isEmpty()) result.add(orPred); } return result; }
@Override public boolean equals(Object obj) { if (obj instanceof SeqCond) { SeqCond t = (SeqCond) obj; if (t.id == id && t.state == state) { if ((isVariableCheck() && t.isVariableCheck() && value == t.value) || (isOperationCheck() && t.isOperationCheck())) { return true; } } } return false; }
public String getRawOr(LinkedList<SeqCond> s) { String out = ""; if (s.size() == 1) { SeqCond seqCond = s.getFirst(); if (seqCond.isOperationCheck()) { out += Integer.toString(seqCond.id) + Model.getOperationEnding(seqCond.state); } else if (seqCond.isVariableCheck()) { out += Integer.toString(seqCond.id) + Model.getVariabelCheck(seqCond.state) + Integer.toString(seqCond.value); } } else if (s.size() > 1) { out += "("; for (Iterator<SeqCond> it = s.iterator(); it.hasNext(); ) { SeqCond seqCond = it.next(); if (seqCond.isOperationCheck()) { out += Integer.toString(seqCond.id) + Model.getOperationEnding(seqCond.state); } else if (seqCond.isVariableCheck()) { out += Integer.toString(seqCond.id) + Model.getVariabelCheck(seqCond.state) + Integer.toString(seqCond.value); } out = it.hasNext() ? out + EFAVariables.SP_OR : out; } out += ")"; } return out; }