📄 xpdlutils.java
字号:
if (XMLUtil.getUsingPositions(dcond, dfOrFpId, allVars).size() > 0) { references.add(dl.get("DeadlineCondition")); } } // performer (can be expression containing variable, or direct variable // reference) String perf = act.getPerformer(); if (XMLUtil.getUsingPositions(perf, dfOrFpId, allVars).size() > 0) { references.add(act.get("Performer")); } } // transition condition (can be expression containing variable, or direct variable // reference) it = ((Transitions) wpOrAs.get("Transitions")).toElements().iterator(); while (it.hasNext()) { Transition t = (Transition) it.next(); if (XMLUtil.getUsingPositions(t.getCondition().toValue(), dfOrFpId, allVars) .size() > 0) { references.add(t.getCondition()); } } return references; } public List getReferences(WorkflowProcess wp, ActivitySet referenced) { return getActivitySetReferences(wp, referenced.getId()); } public List getActivitySetReferences(WorkflowProcess wp, String referencedId) { List references = new ArrayList(); if (referencedId.equals("")) { return references; } references.addAll(tGetActivitySetReferences(wp, referencedId)); Iterator it = wp.getActivitySets().toElements().iterator(); while (it.hasNext()) { ActivitySet as = (ActivitySet) it.next(); references.addAll(tGetActivitySetReferences(as, referencedId)); } return references; } public List getReferences(ActivitySet as, ActivitySet referenced) { return tGetActivitySetReferences(as, referenced.getId()); } public List getReferences(ActivitySet as, String referencedId) { return tGetActivitySetReferences(as, referencedId); } public List tGetActivitySetReferences(XMLCollectionElement wpOrAs, String referencedId) { List references = new ArrayList(); if (referencedId.equals("")) { return references; } List types = new ArrayList(); types.add(new Integer(XPDLConstants.ACTIVITY_TYPE_BLOCK)); Iterator it = getActivities((Activities) wpOrAs.get("Activities"), types).iterator(); while (it.hasNext()) { Activity act = (Activity) it.next(); BlockActivity ba = act.getActivityTypes().getBlockActivity(); if (ba.getBlockId().equals(referencedId)) { references.add(ba); } } return references; } public List getReferences(Activity act) { return getActivityReferences((XMLCollectionElement) act.getParent().getParent(), act.getId()); } public List getActivityReferences(XMLCollectionElement wpOrAs, String referencedId) { List refs = new ArrayList(); Transitions tras = ((Transitions) wpOrAs.get("Transitions")); Iterator it = getTransitions(tras, referencedId, true).iterator(); while (it.hasNext()) { refs.add(((Transition) it.next()).get("To")); } it = getTransitions(tras, referencedId, false).iterator(); while (it.hasNext()) { refs.add(((Transition) it.next()).get("From")); } return new ArrayList(refs); } public List getReferences(Transition tra) { Activities acts = (Activities) ((XMLCollectionElement) tra.getParent().getParent()).get("Activities"); Activity from = acts.getActivity(tra.getFrom()); Activity to = acts.getActivity(tra.getTo()); Set refs = new HashSet(); if (from != null) { refs.add(from); } if (to != null) { refs.add(to); } return new ArrayList(refs); } public boolean correctSplitsAndJoins(Package pkg) { boolean changed = false; Iterator it = pkg.getWorkflowProcesses().toElements().iterator(); while (it.hasNext()) { WorkflowProcess wp = (WorkflowProcess) it.next(); changed = correctSplitsAndJoins(wp) || changed; } return changed; } public boolean correctSplitsAndJoins(WorkflowProcess wp) { boolean changed = correctSplitsAndJoins(wp.getActivities().toElements()); Iterator it = wp.getActivitySets().toElements().iterator(); while (it.hasNext()) { ActivitySet as = (ActivitySet) it.next(); changed = correctSplitsAndJoins(as.getActivities().toElements()) || changed; } return changed; } public boolean correctSplitsAndJoins(List acts) { boolean changed = false; Iterator it = acts.iterator(); while (it.hasNext()) { Activity act = (Activity) it.next(); changed = correctSplitAndJoin(act) || changed; } return changed; } public boolean correctSplitAndJoin(Activity act) { Set ogt = XMLUtil.getOutgoingTransitions(act); Set inct = XMLUtil.getIncomingTransitions(act); TransitionRestrictions tres = act.getTransitionRestrictions(); TransitionRestriction tr = null; boolean newTres = false; boolean changed = false; // LoggingManager lm=JaWEManager.getInstance().getLoggingManager(); // lm.debug("Correcting split and join for activity "+act.getId()+", // ogts="+ogt.size()+", incts="+inct.size()); if (tres.size() == 0) { if (ogt.size() > 1 || inct.size() > 1) { tr = JaWEManager.getInstance().getXPDLObjectFactory().createXPDLObject(tres, "", false); newTres = true; } else { return false; } } else { tr = (TransitionRestriction) tres.get(0); } Split s = tr.getSplit(); Join j = tr.getJoin(); TransitionRefs trefs = s.getTransitionRefs(); if (ogt.size() <= 1) { if (trefs.size() > 0) { trefs.clear(); changed = true; } if (!s.getType().equals(XPDLConstants.JOIN_SPLIT_TYPE_NONE)) { s.setTypeNONE(); changed = true; } } if (ogt.size() > 1) { if (s.getType().equals(XPDLConstants.JOIN_SPLIT_TYPE_NONE)) { s.setTypeXOR(); // lm.debug("--------------------- st set to xor"); changed = true; } List trefIds = new ArrayList(); for (int i = 0; i < trefs.size(); i++) { TransitionRef tref = (TransitionRef) trefs.get(i); trefIds.add(tref.getId()); } List transitionIds = new ArrayList(); Iterator it = ogt.iterator(); while (it.hasNext()) { Transition t = (Transition) it.next(); transitionIds.add(t.getId()); } List toRem = new ArrayList(trefIds); toRem.removeAll(transitionIds); List toAdd = new ArrayList(transitionIds); toAdd.removeAll(trefIds); for (int i = 0; i < toRem.size(); i++) { TransitionRef tref = trefs.getTransitionRef((String) toRem.get(i)); trefs.remove(tref); changed = true; } for (int i = 0; i < toAdd.size(); i++) { TransitionRef tref = JaWEManager.getInstance() .getXPDLObjectFactory() .createXPDLObject(trefs, "", false); tref.setId((String) toAdd.get(i)); trefs.add(tref); changed = true; } } if (inct.size() <= 1) { if (!j.getType().equals(XPDLConstants.JOIN_SPLIT_TYPE_NONE)) { j.setTypeNONE(); changed = true; } } else { if (j.getType().equals(XPDLConstants.JOIN_SPLIT_TYPE_NONE)) { j.setTypeXOR(); changed = true; } } // lm.debug("--------------------- st="+s.getType()+", jt="+j.getType()+", // trefss="+trefs.size()); if (s.getType().equals(XPDLConstants.JOIN_SPLIT_TYPE_NONE) && j.getType().equals(XPDLConstants.JOIN_SPLIT_TYPE_NONE)) { if (!newTres) { tres.remove(tr); changed = true; } } else if (newTres) { tres.add(tr); } return changed; } public void updateActivityReferences(List refsTrasToFrom, String oldActId, String newActId) { Iterator it = refsTrasToFrom.iterator(); while (it.hasNext()) { ((XMLElement) it.next()).setValue(newActId); } } public void updateActivityOnTransitionIdChange(Activities acts, String actFromId, String oldTraId, String newTraId) { Activity act = acts.getActivity(actFromId); updateActivityOnTransitionIdChange(act, oldTraId, newTraId); } public void updateActivityOnTransitionIdChange(Activity act, String oldTraId, String newTraId) { if (act != null) { Split s = XMLUtil.getSplit(act); if (s != null) { TransitionRef tref = s.getTransitionRefs().getTransitionRef(oldTraId); if (tref != null) { tref.setId(newTraId); } } } } public void updateActivitiesOnTransitionFromChange(Activities acts, String traId, String traOldFromId, String traNewFromId) { if (traOldFromId != null) { Activity act = acts.getActivity(traOldFromId); if (act != null) { correctSplitAndJoin(act); } } if (traNewFromId != null) { Activity act = acts.getActivity(traNewFromId); if (act != null) { correctSplitAndJoin(act); } } } public void updateActivitiesOnTransitionToChange(Activities acts, String traId, String traOldToId, String traNewToId) { if (traOldToId != null) { Activity act = acts.getActivity(traOldToId); if (act != null) { correctSplitAndJoin(act); } } if (traNewToId != null) { Activity act = acts.getActivity(traNewToId); if (act != null) { correctSplitAndJoin(act); } } } public void removeTransitionsForActivity(Activity act) { Set trasToRemove = getTransitionsForActivity(act); Transitions trs = (Transitions) ((XMLCollectionElement) act.getParent().getParent()).get("Transitions"); Activities acs = (Activities) act.getParent(); if (trasToRemove.size() > 0) { Iterator itt = trasToRemove.iterator(); while (itt.hasNext()) { Transition t = (Transition) itt.next(); Activity from = acs.getActivity(t.getFrom()); Activity to = acs.getActivity(t.getTo()); if (from != act && from != null) { correctSplitAndJoin(from); } if (to != act && to != null) { correctSplitAndJoin(to); } } trs.removeAll(new ArrayList(trasToRemove)); } } public void removeTransitionsForActivities(List acts) { if (acts.size() == 0) return; Activities acs = (Activities) ((Activity) acts.get(0)).getParent(); Set trasToRemove = new HashSet(); Iterator it = acts.iterator(); while (it.hasNext()) { Activity act = (Activity) it.next(); trasToRemove.addAll(getTransitionsForActivity(act)); } if (trasToRemove.size() > 0) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -