📄 xpdlreader.java
字号:
participantValue.set("participantId", participantId);
participantValue.set("participantName", participantElement.getAttribute("Name"));
// ParticipantType
Element participantTypeElement = UtilXml.firstChildElement(participantElement, "ParticipantType");
if (participantTypeElement != null) {
participantValue.set("participantTypeId", participantTypeElement.getAttribute("Type"));
}
// Description?
participantValue.set("description", UtilXml.childElementValue(participantElement, "Description"));
// ExtendedAttributes
participantValue.set("partyId", getExtendedAttributeValue(participantElement, "partyId", null), false);
participantValue.set("roleTypeId", getExtendedAttributeValue(participantElement, "roleTypeId", null), false);
}
}
/*
protected void readParticipants(List participants, String packageId, String packageVersion, String processId, String processVersion, GenericValue valueObject) throws DefinitionParserException {
if (participants == null || participants.size() == 0)
return;
Long nextSeqId = delegator.getNextSeqId("WorkflowParticipantList");
if (nextSeqId == null)
throw new DefinitionParserException("Could not get next sequence id from data source");
String participantListId = nextSeqId.toString();
valueObject.set("participantListId", participantListId);
Iterator participantsIter = participants.iterator();
long index = 1;
while (participantsIter.hasNext()) {
Element participantElement = (Element) participantsIter.next();
String participantId = participantElement.getAttribute("Id");
// if participant doesn't exist, create it; don't do an update because if settings are manually changed it would be annoying as all get out
GenericValue testValue = null;
try {
testValue = delegator.findByPrimaryKey("WorkflowParticipant", UtilMisc.toMap("participantId", participantId));
} catch (GenericEntityException e) {
Debug.logWarning(e, module);
}
if (testValue == null) {
GenericValue participantValue = delegator.makeValue("WorkflowParticipant", null);
values.add(participantValue);
participantValue.set("packageId", packageId);
participantValue.set("packageVersion", packageVersion);
participantValue.set("processId", processId);
participantValue.set("processVersion", processVersion);
participantValue.set("participantId", participantId);
participantValue.set("participantName", participantElement.getAttribute("Name"));
// ParticipantType
Element participantTypeElement = UtilXml.firstChildElement(participantElement, "ParticipantType");
if (participantTypeElement != null) {
participantValue.set("participantTypeId", participantTypeElement.getAttribute("Type"));
}
// Description?
participantValue.set("description", UtilXml.childElementValue(participantElement, "Description"));
// ExtendedAttributes
participantValue.set("partyId", getExtendedAttributeValue(participantElement, "partyId", null), false);
participantValue.set("roleTypeId", getExtendedAttributeValue(participantElement, "roleTypeId", null), false);
}
// regardless of whether the participant was created, create a participant list entry
GenericValue participantListValue = delegator.makeValue("WorkflowParticipantList", null);
values.add(participantListValue);
participantListValue.set("participantListId", participantListId);
participantListValue.set("participantId", participantId);
participantListValue.set("participantIndex", new Long(index));
index++;
}
}
*/
protected void readApplications(List applications, String packageId, String packageVersion, String processId,
String processVersion) throws DefinitionParserException {
if (applications == null || applications.size() == 0)
return;
Iterator applicationsIter = applications.iterator();
while (applicationsIter.hasNext()) {
Element applicationElement = (Element) applicationsIter.next();
GenericValue applicationValue = delegator.makeValue("WorkflowApplication", null);
values.add(applicationValue);
String applicationId = applicationElement.getAttribute("Id");
applicationValue.set("packageId", packageId);
applicationValue.set("packageVersion", packageVersion);
applicationValue.set("processId", processId);
applicationValue.set("processVersion", processVersion);
applicationValue.set("applicationId", applicationId);
applicationValue.set("applicationName", applicationElement.getAttribute("Name"));
// Description?
applicationValue.set("description", UtilXml.childElementValue(applicationElement, "Description"));
// FormalParameters?
Element formalParametersElement = UtilXml.firstChildElement(applicationElement, "FormalParameters");
List formalParameters = UtilXml.childElementList(formalParametersElement, "FormalParameter");
readFormalParameters(formalParameters, packageId, packageVersion, processId, processVersion, applicationId);
}
}
protected void readDataFields(List dataFields, String packageId, String packageVersion, String processId,
String processVersion) throws DefinitionParserException {
if (dataFields == null || dataFields.size() == 0)
return;
Iterator dataFieldsIter = dataFields.iterator();
while (dataFieldsIter.hasNext()) {
Element dataFieldElement = (Element) dataFieldsIter.next();
GenericValue dataFieldValue = delegator.makeValue("WorkflowDataField", null);
values.add(dataFieldValue);
String dataFieldId = dataFieldElement.getAttribute("Id");
String dataFieldName = dataFieldElement.getAttribute("Name");
if (dataFieldName == null || dataFieldName.length() == 0)
dataFieldName = dataFieldId;
dataFieldValue.set("packageId", packageId);
dataFieldValue.set("packageVersion", packageVersion);
dataFieldValue.set("processId", processId);
dataFieldValue.set("processVersion", processVersion);
dataFieldValue.set("dataFieldId", dataFieldId);
dataFieldValue.set("dataFieldName", dataFieldName);
// IsArray attr
dataFieldValue.set("isArray", ("TRUE".equals(dataFieldElement.getAttribute("IsArray")) ? "Y" : "N"));
// DataType
Element dataTypeElement = UtilXml.firstChildElement(dataFieldElement, "DataType");
if (dataTypeElement != null) {
// (%Type;)
readType(dataTypeElement, dataFieldValue);
}
// InitialValue?
dataFieldValue.set("initialValue", UtilXml.childElementValue(dataFieldElement, "InitialValue"));
// Length?
String lengthStr = UtilXml.childElementValue(dataFieldElement, "Length");
if (lengthStr != null && lengthStr.length() > 0) {
try {
dataFieldValue.set("lengthBytes", Long.valueOf(lengthStr));
} catch (NumberFormatException e) {
throw new DefinitionParserException("Invalid whole number format in DataField->Length: " + lengthStr, e);
}
}
// Description?
dataFieldValue.set("description", UtilXml.childElementValue(dataFieldElement, "Description"));
}
}
protected void readFormalParameters(List formalParameters, String packageId, String packageVersion,
String processId, String processVersion, String applicationId) throws DefinitionParserException {
if (formalParameters == null || formalParameters.size() == 0)
return;
Iterator formalParametersIter = formalParameters.iterator();
long index = 1;
while (formalParametersIter.hasNext()) {
Element formalParameterElement = (Element) formalParametersIter.next();
GenericValue formalParameterValue = delegator.makeValue("WorkflowFormalParam", null);
values.add(formalParameterValue);
String formalParamId = formalParameterElement.getAttribute("Id");
formalParameterValue.set("packageId", packageId);
formalParameterValue.set("packageVersion", packageVersion);
formalParameterValue.set("processId", processId);
formalParameterValue.set("processVersion", processVersion);
formalParameterValue.set("applicationId", applicationId);
formalParameterValue.set("formalParamId", formalParamId);
formalParameterValue.set("modeEnumId", "WPM_" + formalParameterElement.getAttribute("Mode"));
String indexStr = formalParameterElement.getAttribute("Index");
if (indexStr != null && indexStr.length() > 0) {
try {
formalParameterValue.set("indexNumber", Long.valueOf(indexStr));
} catch (NumberFormatException e) {
throw new DefinitionParserException("Invalid decimal number format in FormalParameter->Index: " + indexStr, e);
}
} else
formalParameterValue.set("indexNumber", new Long(index));
index++;
// DataType
Element dataTypeElement = UtilXml.firstChildElement(formalParameterElement, "DataType");
if (dataTypeElement != null) {
// (%Type;)
readType(dataTypeElement, formalParameterValue);
}
// Description?
formalParameterValue.set("description", UtilXml.childElementValue(formalParameterElement, "Description"));
}
}
/** Reads information about "Type" entity member sub-elements; the value
* object passed must have two fields to contain Type information:
* <code>dataTypeEnumId</code> and <code>complexTypeInfoId</code>.
*/
protected void readType(Element element, GenericValue value) {
// (%Type;) - (RecordType | UnionType | EnumerationType | ArrayType | ListType | BasicType | PlainType | DeclaredType)
Element typeElement = null;
if ((typeElement = UtilXml.firstChildElement(element, "RecordType")) != null) {// TODO: write code for complex type
} else if ((typeElement = UtilXml.firstChildElement(element, "UnionType")) != null) {// TODO: write code for complex type
} else if ((typeElement = UtilXml.firstChildElement(element, "EnumerationType")) != null) {// TODO: write code for complex type
} else if ((typeElement = UtilXml.firstChildElement(element, "ArrayType")) != null) {// TODO: write code for complex type
} else if ((typeElement = UtilXml.firstChildElement(element, "ListType")) != null) {// TODO: write code for complex type
} else if ((typeElement = UtilXml.firstChildElement(element, "BasicType")) != null) {
value.set("dataTypeEnumId", "WDT_" + typeElement.getAttribute("Type"));
} else if ((typeElement = UtilXml.firstChildElement(element, "PlainType")) != null) {
value.set("dataTypeEnumId", "WDT_" + typeElement.getAttribute("Type"));
} else if ((typeElement = UtilXml.firstChildElement(element, "DeclaredType")) != null) {
// For DeclaredTypes complexTypeInfoId will actually be the type id
value.set("dataTypeEnumId", "WDT_DECLARED");
value.set("complexTypeInfoId", typeElement.getAttribute("Id"));
}
/*
<entity entity-name="WorkflowComplexTypeInfo"
<field name="complexTypeInfoId" type="id-ne"></field>
<field name="memberParentInfoId" type="id"></field>
<field name="dataTypeEnumId" type="id"></field>
<field name="subTypeEnumId" type="id"></field>
<field name="arrayLowerIndex" type="numeric"></field>
<field name="arrayUpperIndex" type="numeric"></field>
*/
}
protected String getExtendedAttributeValue(Element element, String name, String defaultValue) {
if (element == null || name == null)
return defaultValue;
Element extendedAtt
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -