return true;
}
String subFlowId = subFlowElem.getAttributeValue("Id");
// check if this subflow is defined.
if (!processMap.keySet().contains(subFlowId)) {
eh.add (new PrioritizedMessage
(PrioritizedMessage.Priority.ERROR,
bundleBase + "#procdef.activity.subflow.notfound",
new Object[] {activityId, subFlowId, processId}));
return false;
}
// check if the formal params of the called process in the type of
// OUT and INOUT reference the datafields or formal params in the
// calling process.
// find out all the actual parameters of the calling process.
List actualParams = new ArrayList();
Iterator actualParamsIt
= actualParamsPath.selectNodes(subFlowElem).iterator();
while(actualParamsIt.hasNext()) {
String apm = ((Element)actualParamsIt.next()).getText();
actualParams.add(apm);
}
// Map of id and its mode
Map callerFpMap = new HashMap();
List formalParamsList = formalParamsPath.selectNodes(process);
Iterator formalParamsIt = formalParamsList.iterator();
while (formalParamsIt.hasNext()) {
Element fm = (Element)formalParamsIt.next();
String fmId = fm.getAttributeValue("Id");
callerFpMap.put(fmId, fm.getAttributeValue("Mode"));
}
// find out all the formal parameters of the called process.
Element subFlowProc = (Element)processMap.get(subFlowId);
List subFlowFormalParams = formalParamsPath.selectNodes(subFlowProc);
if (subFlowFormalParams.size() != actualParams.size()){
eh.add (new PrioritizedMessage
(PrioritizedMessage.Priority.ERROR, bundleBase
+ "#procdef.activity.subflow.params.notmatched",
new Object[] {activityId, subFlowId, processId}));
return false;
}
int index = 0;
for (Iterator formParamIter = subFlowFormalParams.iterator();
formParamIter.hasNext(); index ++) {
Element fpElem = (Element)formParamIter.next();
FormalParameter fp = new FormalParameter
(fpElem.getAttributeValue("Id"), Integer.toString(index),
FormalParameter.Mode.fromString
(fpElem.getAttributeValue("Mode")),
XPDLUtil.extractDataType
(fpElem.getChild("DataType", xpdlns)));
String actParam = ((String)actualParams.get(index)).trim();
if (callerFpMap.containsKey(actParam)) {
// check the mode of the formal parameter of the calling
// process
String callerParamMode = (String)callerFpMap.get(actParam);
if (callerParamMode.indexOf(fp.mode().toString()) == -1){
eh.add (new PrioritizedMessage
(PrioritizedMessage.Priority.ERROR, bundleBase
+ "#procdef.activity.subflow.parammode.notmatched",
new Object [] {
subFlowId, actParam, callerParamMode,
fp.mode().toString(), activityId,
processId}));
return false;
}
}
if (procdataMap.containsKey(actParam)) {
boolean compat = true;
if (fp.mode().equals(FormalParameter.Mode.IN)
|| fp.mode().equals(FormalParameter.Mode.INOUT)) {
compat = typeCompatible
(fp.type(), XPDLUtil.extractDataType
(((ProcData)procdataMap.get(actParam)).dataType));
}
if (fp.mode().equals(FormalParameter.Mode.OUT)
|| fp.mode().equals(FormalParameter.Mode.INOUT)) {
compat = compat && typeCompatible
(XPDLUtil.extractDataType
(((ProcData)procdataMap.get(actParam)).dataType),
fp.type());
}
if (!compat) {
String[] errDatas = {subFlowId, activityId, processId};
eh.add (new PrioritizedMessage
(PrioritizedMessage.Priority.ERROR, bundleBase
+ "#procdef.activity.subflow"
+ ".paramdatatype.notmatched", errDatas));
return false;
}
} else {
if (fp.mode() != FormalParameter.Mode.IN) {
eh.add
(new PrioritizedMessage
(PrioritizedMessage.Priority.ERROR, bundleBase
+ "#procdef.activity.subflow.datanotfound",
new Object[] {subFlowId, actParam, activityId,
processId}));
return false;
}
if (XPDLUtil.isXMLType (fp.type())) {
String res = notXMLOrValid (actParam);
if (res != null) {
eh.add
(new PrioritizedMessage
(PrioritizedMessage.Priority.ERROR, bundleBase
+ "#procdef.subflow.params.invalidXML",
new Object[]{subFlowId, actParam, activityId,
processId, res}));
return false;