📄 xpdlreader.java
字号:
Element applicationsElement = UtilXml.firstChildElement(workflowProcessElement, "Applications");
List applications = UtilXml.childElementList(applicationsElement, "Application");
readApplications(applications, packageId, packageVersion, processId, processVersion);
// Activities
Element activitiesElement = UtilXml.firstChildElement(workflowProcessElement, "Activities");
List activities = UtilXml.childElementList(activitiesElement, "Activity");
readActivities(activities, packageId, packageVersion, processId, processVersion, workflowProcessValue);
// Transitions
Element transitionsElement = UtilXml.firstChildElement(workflowProcessElement, "Transitions");
List transitions = UtilXml.childElementList(transitionsElement, "Transition");
readTransitions(transitions, packageId, packageVersion, processId, processVersion);
// ExtendedAttributes?
workflowProcessValue.set("defaultStartActivityId", getExtendedAttributeValue(workflowProcessElement, "defaultStartActivityId", workflowProcessValue.getString("defaultStartActivityId")));
workflowProcessValue.set("sourceReferenceField", getExtendedAttributeValue(workflowProcessElement, "sourceReferenceField", "sourceReferenceId"));
}
// ----------------------------------------------------------------
// Activity
// ----------------------------------------------------------------
protected void readActivities(List activities, String packageId, String packageVersion, String processId,
String processVersion, GenericValue processValue) throws DefinitionParserException {
if (activities == null || activities.size() == 0)
return;
Iterator activitiesIter = activities.iterator();
// do the first one differently because it will be the defaultStart activity
if (activitiesIter.hasNext()) {
Element activityElement = (Element) activitiesIter.next();
String activityId = activityElement.getAttribute("Id");
processValue.set("defaultStartActivityId", activityId);
readActivity(activityElement, packageId, packageVersion, processId, processVersion);
}
while (activitiesIter.hasNext()) {
Element activityElement = (Element) activitiesIter.next();
readActivity(activityElement, packageId, packageVersion, processId, processVersion);
}
}
protected void readActivity(Element activityElement, String packageId, String packageVersion, String processId,
String processVersion) throws DefinitionParserException {
if (activityElement == null)
return;
GenericValue activityValue = delegator.makeValue("WorkflowActivity", null);
values.add(activityValue);
String activityId = activityElement.getAttribute("Id");
activityValue.set("packageId", packageId);
activityValue.set("packageVersion", packageVersion);
activityValue.set("processId", processId);
activityValue.set("processVersion", processVersion);
activityValue.set("activityId", activityId);
activityValue.set("objectName", activityElement.getAttribute("Name"));
activityValue.set("description", UtilXml.childElementValue(activityElement, "Description"));
String limitStr = UtilXml.childElementValue(activityElement, "Limit");
if (limitStr != null) {
try {
activityValue.set("timeLimit", Double.valueOf(limitStr));
} catch (NumberFormatException e) {
throw new DefinitionParserException("Invalid decimal number format in Activity->Limit: " + limitStr, e);
}
}
// (Route | Implementation)
Element routeElement = UtilXml.firstChildElement(activityElement, "Route");
Element implementationElement = UtilXml.firstChildElement(activityElement, "Implementation");
if (routeElement != null) {
activityValue.set("activityTypeEnumId", "WAT_ROUTE");
} else if (implementationElement != null) {
Element noElement = UtilXml.firstChildElement(implementationElement, "No");
Element subFlowElement = UtilXml.firstChildElement(implementationElement, "SubFlow");
Element loopElement = UtilXml.firstChildElement(implementationElement, "Loop");
List tools = UtilXml.childElementList(implementationElement, "Tool");
if (noElement != null) {
activityValue.set("activityTypeEnumId", "WAT_NO");
} else if (subFlowElement != null) {
activityValue.set("activityTypeEnumId", "WAT_SUBFLOW");
readSubFlow(subFlowElement, packageId, packageVersion, processId, processVersion, activityId);
} else if (loopElement != null) {
activityValue.set("activityTypeEnumId", "WAT_LOOP");
readLoop(loopElement, packageId, packageVersion, processId, processVersion, activityId);
} else if (tools != null && tools.size() > 0) {
activityValue.set("activityTypeEnumId", "WAT_TOOL");
readTools(tools, packageId, packageVersion, processId, processVersion, activityId);
} else {
throw new DefinitionParserException(
"No, SubFlow, Loop or one or more Tool elements must exist under the Implementation element of Activity with ID " + activityId +
" in Process with ID " + processId);
}
} else {
throw new DefinitionParserException("Route or Implementation must exist for Activity with ID " + activityId + " in Process with ID " + processId);
}
// Performer?
activityValue.set("performerParticipantId", UtilXml.childElementValue(activityElement, "Performer"));
// StartMode?
Element startModeElement = UtilXml.firstChildElement(activityElement, "StartMode");
if (startModeElement != null) {
if (UtilXml.firstChildElement(startModeElement, "Automatic") != null)
activityValue.set("startModeEnumId", "WAM_AUTOMATIC");
else if (UtilXml.firstChildElement(startModeElement, "Manual") != null)
activityValue.set("startModeEnumId", "WAM_MANUAL");
else
throw new DefinitionParserException("Could not find Mode under StartMode");
}
// FinishMode?
Element finishModeElement = UtilXml.firstChildElement(activityElement, "FinishMode");
if (finishModeElement != null) {
if (UtilXml.firstChildElement(finishModeElement, "Automatic") != null)
activityValue.set("finishModeEnumId", "WAM_AUTOMATIC");
else if (UtilXml.firstChildElement(finishModeElement, "Manual") != null)
activityValue.set("finishModeEnumId", "WAM_MANUAL");
else
throw new DefinitionParserException("Could not find Mode under FinishMode");
}
// Priority?
String priorityStr = UtilXml.childElementValue(activityElement, "Priority");
if (priorityStr != null) {
try {
activityValue.set("objectPriority", Long.valueOf(priorityStr));
} catch (NumberFormatException e) {
throw new DefinitionParserException("Invalid whole number format in Activity->Priority: " + priorityStr, e);
}
}
// SimulationInformation?
Element simulationInformationElement = UtilXml.firstChildElement(activityElement, "SimulationInformation");
if (simulationInformationElement != null) {
if (simulationInformationElement.getAttribute("Instantiation") != null)
activityValue.set("instantiationLimitEnumId", "WFI_" + simulationInformationElement.getAttribute("Instantiation"));
String costStr = UtilXml.childElementValue(simulationInformationElement, "Cost");
if (costStr != null) {
try {
activityValue.set("cost", Double.valueOf(costStr));
} catch (NumberFormatException e) {
throw new DefinitionParserException("Invalid decimal number format in Activity->SimulationInformation->Cost: " + costStr, e);
}
}
// TimeEstimation
Element timeEstimationElement = UtilXml.firstChildElement(simulationInformationElement, "TimeEstimation");
if (timeEstimationElement != null) {
String waitingTimeStr = UtilXml.childElementValue(timeEstimationElement, "WaitingTime");
if (waitingTimeStr != null) {
try {
activityValue.set("waitingTime", Double.valueOf(waitingTimeStr));
} catch (NumberFormatException e) {
throw new DefinitionParserException("Invalid decimal number format in Activity->SimulationInformation->TimeEstimation->WaitingTime: " + waitingTimeStr, e);
}
}
String workingTimeStr = UtilXml.childElementValue(timeEstimationElement, "WorkingTime");
if (workingTimeStr != null) {
try {
activityValue.set("waitingTime", Double.valueOf(workingTimeStr));
} catch (NumberFormatException e) {
throw new DefinitionParserException("Invalid decimal number format in Activity->SimulationInformation->TimeEstimation->WorkingTime: " + workingTimeStr, e);
}
}
String durationStr = UtilXml.childElementValue(timeEstimationElement, "Duration");
if (durationStr != null) {
try {
activityValue.set("duration", Double.valueOf(durationStr));
} catch (NumberFormatException e) {
throw new DefinitionParserException("Invalid decimal number format in Activity->SimulationInformation->TimeEstimation->Duration: " + durationStr, e);
}
}
}
}
activityValue.set("iconUrl", UtilXml.childElementValue(activityElement, "Icon"));
activityValue.set("documentationUrl", UtilXml.childElementValue(activityElement, "Documentation"));
// TransitionRestrictions?
Element transitionRestrictionsElement = UtilXml.firstChildElement(activityElement, "TransitionRestrictions");
List transitionRestrictions = UtilXml.childElementList(transitionRestrictionsElement, "TransitionRestriction");
readTransitionRestrictions(transitionRestrictions, activityValue);
// ExtendedAttributes?
activityValue.set("acceptAllAssignments", getExtendedAttributeValue(activityElement, "acceptAllAssignments", "N"));
activityValue.set("completeAllAssignments", getExtendedAttributeValue(activityElement, "completeAllAssignments", "N"));
activityValue.set("limitService", getExtendedAttributeValue(activityElement, "limitService", null), false);
activityValue.set("limitAfterStart", getExtendedAttributeValue(activityElement, "limitAfterStart", "Y"));
activityValue.set("restartOnDelegate", getExtendedAttributeValue(activityElement, "restartOnDelegate", "N"));
activityValue.set("delegateAfterStart", getExtendedAttributeValue(activityElement, "delegateAfterStart", "Y"));
activityValue.set("inheritPriority", getExtendedAttributeValue(activityElement, "inheritPriority", "N"));
activityValue.set("canStart", getExtendedAttributeValue(activityElement, "canStart", "Y"));
}
protected void readSubFlow(Element subFlowElement, String packageId, String packageVersion, String processId,
String processVersion, String activityId) throws DefinitionParserException {
if (subFlowElement == null)
return;
GenericValue subFlowValue = delegator.makeValue("WorkflowActivitySubFlow", null);
values.add(subFlowValue);
subFlowValue.set("packageId", packageId);
subFlowValue.set("packageVersion", packageVersion);
subFlowValue.set("processId", processId);
subFlowValue.set("processVersion", processVersion);
subFlowValue.set("activityId", activityId);
subFlowValue.set("subFlowProcessId", subFlowElement.getAttribute("Id"));
if (subFlowElement.getAttribute("Execution") != null)
subFlowValue.set("executionEnumId", "WSE_" + subFlowElement.getAttribute("Execution"));
else
subFlowValue.set("executionEnumId", "WSE_ASYNCHR");
// ActualParameters?
Element actualParametersElement = UtilXml.firstChildElement(subFlowElement, "ActualParameters");
List actualParameters = UtilXml.childElementList(actualParametersElement, "ActualParameter");
subFlowValue.set("actualParameters", readActualParameters(actualParameters), false);
}
protected void readLoop(Element loopElement, String packageId, String packageVersion, String processId,
String processVersion, String activityId) throws DefinitionParserException {
if (loopElement == null)
return;
GenericValue loopValue = delegator.makeValue("WorkflowActivityLoop", null);
values.add(loopValue);
loopValue.set("packageId", packageId);
loopValue.set("packageVersion", packageVersion);
loopValue.set("processId", processId);
loopValue.set("processVersion", processVersion);
loopValue.set("activityId", activityId);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -