use of com.sjh.thinkinginjava.classTest.proxy1.Interface in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method marshallTask.
protected void marshallTask(Task task, BPMNPlane plane, JsonGenerator generator, float xOffset, float yOffset, String preProcessingData, Definitions def, Map<String, Object> flowElementProperties) throws JsonGenerationException, IOException {
Map<String, Object> properties = new LinkedHashMap<String, Object>(flowElementProperties);
String taskType = "None";
if (task instanceof BusinessRuleTask) {
taskType = "Business Rule";
Iterator<FeatureMap.Entry> iter = task.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("ruleFlowGroup")) {
properties.put("ruleflowgroup", entry.getValue());
}
}
} else if (task instanceof ScriptTask) {
setScriptProperties((ScriptTask) task, properties);
taskType = "Script";
} else if (task instanceof ServiceTask) {
taskType = "Service";
ServiceTask serviceTask = (ServiceTask) task;
if (serviceTask.getOperationRef() != null && serviceTask.getImplementation() != null) {
properties.put("serviceimplementation", serviceTask.getImplementation());
properties.put("serviceoperation", serviceTask.getOperationRef().getName() == null ? serviceTask.getOperationRef().getImplementationRef() : serviceTask.getOperationRef().getName());
if (def != null) {
List<RootElement> roots = def.getRootElements();
for (RootElement root : roots) {
if (root instanceof Interface) {
Interface inter = (Interface) root;
List<Operation> interOperations = inter.getOperations();
for (Operation interOper : interOperations) {
if (interOper.getId().equals(serviceTask.getOperationRef().getId())) {
properties.put("serviceinterface", inter.getName() == null ? inter.getImplementationRef() : inter.getName());
}
}
}
}
}
}
} else if (task instanceof ManualTask) {
taskType = "Manual";
} else if (task instanceof UserTask) {
taskType = "User";
// get the user task actors
List<ResourceRole> roles = task.getResources();
StringBuilder sb = new StringBuilder();
for (ResourceRole role : roles) {
if (role instanceof PotentialOwner) {
FormalExpression fe = (FormalExpression) ((PotentialOwner) role).getResourceAssignmentExpression().getExpression();
if (fe.getBody() != null && fe.getBody().length() > 0) {
sb.append(fe.getBody());
sb.append(",");
}
}
}
if (sb.length() > 0) {
sb.setLength(sb.length() - 1);
}
properties.put("actors", sb.toString());
} else if (task instanceof SendTask) {
taskType = "Send";
SendTask st = (SendTask) task;
if (st.getMessageRef() != null) {
properties.put("messageref", st.getMessageRef().getId());
}
} else if (task instanceof ReceiveTask) {
taskType = "Receive";
ReceiveTask rt = (ReceiveTask) task;
if (rt.getMessageRef() != null) {
properties.put("messageref", rt.getMessageRef().getId());
}
}
// custom async
String customAsyncMetaData = Utils.getMetaDataValue(task.getExtensionValues(), "customAsync");
String customAsync = (customAsyncMetaData != null && customAsyncMetaData.length() > 0) ? customAsyncMetaData : "false";
properties.put("isasync", customAsync);
// custom autostart
String customAutoStartMetaData = Utils.getMetaDataValue(task.getExtensionValues(), "customAutoStart");
String customAutoStart = (customAutoStartMetaData != null && customAutoStartMetaData.length() > 0) ? customAutoStartMetaData : "false";
properties.put("customautostart", customAutoStart);
// backwards compatibility with jbds editor
boolean foundTaskName = false;
if (task instanceof UserTask && task.getIoSpecification() != null && task.getIoSpecification().getDataInputs() != null) {
List<DataInput> taskDataInputs = task.getIoSpecification().getDataInputs();
for (DataInput din : taskDataInputs) {
if (din.getName() != null && din.getName().equals("TaskName")) {
List<DataInputAssociation> taskDataInputAssociations = task.getDataInputAssociations();
for (DataInputAssociation dia : taskDataInputAssociations) {
if (dia.getTargetRef() != null && dia.getTargetRef().getId().equals(din.getId()) && dia.getAssignment() != null && !dia.getAssignment().isEmpty() && dia.getAssignment().get(0).getFrom() != null) {
properties.put("taskname", ((FormalExpression) dia.getAssignment().get(0).getFrom()).getBody());
foundTaskName = true;
}
}
break;
}
}
}
if (!foundTaskName) {
// try the drools specific attribute set on the task
Iterator<FeatureMap.Entry> iter = task.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("taskName")) {
String tname = (String) entry.getValue();
if (tname != null && tname.length() > 0) {
properties.put("taskname", tname);
}
}
}
}
// check if we are dealing with a custom task
boolean isCustomElement = isCustomElement((String) properties.get("taskname"), preProcessingData);
if (isCustomElement) {
properties.put("tasktype", properties.get("taskname"));
} else {
properties.put("tasktype", taskType);
}
// multiple instance
if (task.getLoopCharacteristics() != null) {
properties.put("multipleinstance", "true");
MultiInstanceLoopCharacteristics taskmi = (MultiInstanceLoopCharacteristics) task.getLoopCharacteristics();
if (taskmi.getLoopDataInputRef() != null) {
ItemAwareElement iedatainput = taskmi.getLoopDataInputRef();
List<DataInputAssociation> taskInputAssociations = task.getDataInputAssociations();
for (DataInputAssociation dia : taskInputAssociations) {
if (dia.getTargetRef().equals(iedatainput)) {
properties.put("multipleinstancecollectioninput", dia.getSourceRef().get(0).getId());
break;
}
}
}
if (taskmi.getLoopDataOutputRef() != null) {
ItemAwareElement iedataoutput = taskmi.getLoopDataOutputRef();
List<DataOutputAssociation> taskOutputAssociations = task.getDataOutputAssociations();
for (DataOutputAssociation dout : taskOutputAssociations) {
if (dout.getSourceRef().get(0).equals(iedataoutput)) {
properties.put("multipleinstancecollectionoutput", dout.getTargetRef().getId());
break;
}
}
}
if (taskmi.getInputDataItem() != null && taskmi.getInputDataItem().getItemSubjectRef() != null) {
List<DataInput> taskDataInputs = task.getIoSpecification().getDataInputs();
for (DataInput din : taskDataInputs) {
if (din != null && din.getItemSubjectRef() != null && taskmi.getInputDataItem() != null && taskmi.getInputDataItem().getItemSubjectRef() != null) {
if (din.getItemSubjectRef().getId().equals(taskmi.getInputDataItem().getItemSubjectRef().getId())) {
properties.put("multipleinstancedatainput", din.getName());
}
}
}
}
if (taskmi.getOutputDataItem() != null && taskmi.getOutputDataItem().getItemSubjectRef() != null) {
List<DataOutput> taskDataOutputs = task.getIoSpecification().getDataOutputs();
for (DataOutput dout : taskDataOutputs) {
if (dout != null && dout.getItemSubjectRef() != null && taskmi.getOutputDataItem() != null && taskmi.getOutputDataItem().getItemSubjectRef() != null) {
if (dout.getItemSubjectRef().getId().equals(taskmi.getOutputDataItem().getItemSubjectRef().getId())) {
properties.put("multipleinstancedataoutput", dout.getName());
}
}
}
}
if (taskmi.getCompletionCondition() != null) {
if (taskmi.getCompletionCondition() instanceof FormalExpression) {
properties.put("multipleinstancecompletioncondition", ((FormalExpression) taskmi.getCompletionCondition()).getBody());
}
}
} else {
properties.put("multipleinstance", "false");
}
// data inputs
List<String> disallowedInputs = new ArrayList<String>();
disallowedInputs.add("miinputCollection");
if ((task instanceof UserTask) || isCustomElement) {
disallowedInputs.add("TaskName");
}
String datainputset = marshallDataInputSet(task, properties, disallowedInputs);
DataInput groupDataInput = null;
DataInput skippableDataInput = null;
DataInput commentDataInput = null;
DataInput descriptionDataInput = null;
DataInput contentDataInput = null;
DataInput priorityDataInput = null;
DataInput localeDataInput = null;
DataInput createdByDataInput = null;
DataInput notCompletedReassignInput = null;
DataInput notStartedReassignInput = null;
DataInput notCompletedNotificationInput = null;
DataInput notStartedNotificationInput = null;
if (task.getIoSpecification() != null) {
List<InputSet> inputSetList = task.getIoSpecification().getInputSets();
for (InputSet inset : inputSetList) {
List<DataInput> dataInputList = inset.getDataInputRefs();
for (DataInput dataIn : dataInputList) {
// dont add "TaskName" as that is added manually
String dataInName = dataIn.getName();
if (task instanceof UserTask && dataInName != null) {
if (dataInName.equals("GroupId")) {
groupDataInput = dataIn;
} else if (dataInName.equals("Skippable")) {
skippableDataInput = dataIn;
} else if (dataInName.equals("Comment")) {
commentDataInput = dataIn;
} else if (dataInName.equals("Description")) {
descriptionDataInput = dataIn;
} else if (dataInName.equals("Content")) {
contentDataInput = dataIn;
} else if (dataInName.equals("Priority")) {
priorityDataInput = dataIn;
} else if (dataInName.equals("Locale")) {
localeDataInput = dataIn;
} else if (dataInName.equals("CreatedBy")) {
createdByDataInput = dataIn;
} else if (dataInName.equals("NotCompletedReassign")) {
notCompletedReassignInput = dataIn;
} else if (dataInName.equals("NotStartedReassign")) {
notStartedReassignInput = dataIn;
} else if (dataInName.equals("NotCompletedNotify")) {
notCompletedNotificationInput = dataIn;
} else if (dataInName.equals("NotStartedNotify")) {
notStartedNotificationInput = dataIn;
}
}
}
}
}
// data outputs
String dataoutputset = marshallDataOutputSet(task, properties, Arrays.asList("mioutputCollection"));
// assignments
StringBuilder associationBuff = new StringBuilder();
List<DataInputAssociation> inputAssociations = task.getDataInputAssociations();
List<DataOutputAssociation> outputAssociations = task.getDataOutputAssociations();
List<String> uniDirectionalAssociations = new ArrayList<String>();
// List<String> biDirectionalAssociations = new ArrayList<String>();
for (DataInputAssociation datain : inputAssociations) {
boolean proceed = true;
if (task.getLoopCharacteristics() != null) {
MultiInstanceLoopCharacteristics taskMultiLoop = (MultiInstanceLoopCharacteristics) task.getLoopCharacteristics();
// dont include associations that include mi loop data inputs
if (taskMultiLoop.getInputDataItem() != null && taskMultiLoop.getInputDataItem().getId() != null) {
if (datain.getSourceRef() != null && datain.getSourceRef().size() > 0 && datain.getSourceRef().get(0).getId().equals(taskMultiLoop.getInputDataItem().getId())) {
proceed = false;
}
}
// dont include associations that include loopDataInputRef as target
if (taskMultiLoop.getLoopDataInputRef() != null) {
if (datain.getTargetRef().equals(taskMultiLoop.getLoopDataInputRef())) {
proceed = false;
}
}
}
if (proceed) {
String lhsAssociation = "";
if (datain.getSourceRef() != null && datain.getSourceRef().size() > 0) {
if (datain.getTransformation() != null && datain.getTransformation().getBody() != null) {
lhsAssociation = datain.getTransformation().getBody();
} else {
lhsAssociation = datain.getSourceRef().get(0).getId();
}
}
String rhsAssociation = "";
if (datain.getTargetRef() != null) {
rhsAssociation = ((DataInput) datain.getTargetRef()).getName();
}
// boolean isBiDirectional = false;
boolean isAssignment = false;
if (datain.getAssignment() != null && datain.getAssignment().size() > 0) {
isAssignment = true;
}
// }
if (isAssignment) {
// only know how to deal with formal expressions
if (datain.getAssignment().get(0).getFrom() instanceof FormalExpression) {
String associationValue = ((FormalExpression) datain.getAssignment().get(0).getFrom()).getBody();
if (associationValue == null) {
associationValue = "";
}
// don't include properties that have their independent input editors
if (isCustomElement((String) properties.get("taskname"), preProcessingData)) {
if (!(rhsAssociation.equals("TaskName"))) {
String replacer = encodeAssociationValue(associationValue);
associationBuff.append("[din]" + rhsAssociation).append("=").append(replacer);
associationBuff.append(",");
properties.put(rhsAssociation.toLowerCase(), associationValue);
}
} else {
if (!(task instanceof UserTask) || !(rhsAssociation.equals("GroupId") || rhsAssociation.equals("Skippable") || rhsAssociation.equals("Comment") || rhsAssociation.equals("Description") || rhsAssociation.equals("Priority") || rhsAssociation.equals("Content") || rhsAssociation.equals("TaskName") || rhsAssociation.equals("Locale") || rhsAssociation.equals("CreatedBy") || rhsAssociation.equals("NotCompletedReassign") || rhsAssociation.equals("NotStartedReassign") || rhsAssociation.equals("NotCompletedNotify") || rhsAssociation.equals("NotStartedNotify"))) {
String replacer = encodeAssociationValue(associationValue);
associationBuff.append("[din]" + rhsAssociation).append("=").append(replacer);
associationBuff.append(",");
properties.put(rhsAssociation.toLowerCase(), associationValue);
}
}
if (rhsAssociation.equalsIgnoreCase("TaskName")) {
properties.put("taskname", associationValue);
}
if (task instanceof UserTask && datain.getAssignment().get(0).getTo() != null && ((FormalExpression) datain.getAssignment().get(0).getTo()).getBody() != null && datain.getAssignment().get(0).getFrom() != null) {
String toBody = ((FormalExpression) datain.getAssignment().get(0).getTo()).getBody();
String fromBody = ((FormalExpression) datain.getAssignment().get(0).getFrom()).getBody();
if (toBody != null) {
if (groupDataInput != null && toBody.equals(groupDataInput.getId())) {
properties.put("groupid", fromBody == null ? "" : fromBody);
} else if (skippableDataInput != null && toBody.equals(skippableDataInput.getId())) {
properties.put("skippable", fromBody);
} else if (commentDataInput != null && toBody.equals(commentDataInput.getId())) {
properties.put("subject", fromBody);
} else if (descriptionDataInput != null && toBody.equals(descriptionDataInput.getId())) {
properties.put("description", fromBody);
} else if (priorityDataInput != null && toBody.equals(priorityDataInput.getId())) {
properties.put("priority", fromBody == null ? "" : fromBody);
} else if (contentDataInput != null && toBody.equals(contentDataInput.getId())) {
properties.put("content", fromBody);
} else if (localeDataInput != null && toBody.equals(localeDataInput.getId())) {
properties.put("locale", fromBody);
} else if (createdByDataInput != null && toBody.equals(createdByDataInput.getId())) {
properties.put("createdby", fromBody);
} else if (notCompletedReassignInput != null && toBody.equals(notCompletedReassignInput.getId())) {
properties.put("tmpreassignmentnotcompleted", updateReassignmentAndNotificationInput(fromBody, "not-completed"));
} else if (notStartedReassignInput != null && toBody.equals(notStartedReassignInput.getId())) {
properties.put("tmpreassignmentnotstarted", updateReassignmentAndNotificationInput(fromBody, "not-started"));
} else if (notCompletedNotificationInput != null && toBody.equals(notCompletedNotificationInput.getId())) {
properties.put("tmpnotificationnotcompleted", updateReassignmentAndNotificationInput(fromBody, "not-completed"));
} else if (notStartedNotificationInput != null && toBody.equals(notStartedNotificationInput.getId())) {
properties.put("tmpnotificationnotstarted", updateReassignmentAndNotificationInput(fromBody, "not-started"));
}
}
}
}
} else // else if(isBiDirectional) {
// associationBuff.append(lhsAssociation).append("<->").append(rhsAssociation);
// associationBuff.append(",");
// biDirectionalAssociations.add(lhsAssociation + "," + rhsAssociation);
// }
{
if (lhsAssociation != null && lhsAssociation.length() > 0) {
associationBuff.append("[din]" + lhsAssociation).append("->").append(rhsAssociation);
associationBuff.append(",");
uniDirectionalAssociations.add(lhsAssociation + "," + rhsAssociation);
}
uniDirectionalAssociations.add(lhsAssociation + "," + rhsAssociation);
// if(contentDataInput != null) {
// if(rhsAssociation.equals(contentDataInput.getName())) {
// properties.put("content", lhsAssociation);
// }
// }
}
}
}
if (properties.get("tmpreassignmentnotcompleted") != null && ((String) properties.get("tmpreassignmentnotcompleted")).length() > 0 && properties.get("tmpreassignmentnotstarted") != null && ((String) properties.get("tmpreassignmentnotstarted")).length() > 0) {
properties.put("reassignment", properties.get("tmpreassignmentnotcompleted") + "^" + properties.get("tmpreassignmentnotstarted"));
} else if (properties.get("tmpreassignmentnotcompleted") != null && ((String) properties.get("tmpreassignmentnotcompleted")).length() > 0) {
properties.put("reassignment", properties.get("tmpreassignmentnotcompleted"));
} else if (properties.get("tmpreassignmentnotstarted") != null && ((String) properties.get("tmpreassignmentnotstarted")).length() > 0) {
properties.put("reassignment", properties.get("tmpreassignmentnotstarted"));
}
if (properties.get("tmpnotificationnotcompleted") != null && ((String) properties.get("tmpnotificationnotcompleted")).length() > 0 && properties.get("tmpnotificationnotstarted") != null && ((String) properties.get("tmpnotificationnotstarted")).length() > 0) {
properties.put("notifications", properties.get("tmpnotificationnotcompleted") + "^" + properties.get("tmpnotificationnotstarted"));
} else if (properties.get("tmpnotificationnotcompleted") != null && ((String) properties.get("tmpnotificationnotcompleted")).length() > 0) {
properties.put("notifications", properties.get("tmpnotificationnotcompleted"));
} else if (properties.get("tmpnotificationnotstarted") != null && ((String) properties.get("tmpnotificationnotstarted")).length() > 0) {
properties.put("notifications", properties.get("tmpnotificationnotstarted"));
}
for (DataOutputAssociation dataout : outputAssociations) {
boolean proceed = true;
if (task.getLoopCharacteristics() != null) {
MultiInstanceLoopCharacteristics taskMultiLoop = (MultiInstanceLoopCharacteristics) task.getLoopCharacteristics();
// dont include associations that include mi loop data outputs
if (taskMultiLoop.getOutputDataItem() != null && taskMultiLoop.getOutputDataItem().getId() != null) {
if (dataout.getTargetRef().getId().equals(taskMultiLoop.getOutputDataItem().getId())) {
proceed = false;
}
}
// dont include associations that include loopDataOutputRef as source
if (taskMultiLoop.getLoopDataOutputRef() != null) {
if (dataout.getSourceRef().get(0).equals(taskMultiLoop.getLoopDataOutputRef())) {
proceed = false;
}
}
}
if (proceed) {
if (dataout.getSourceRef().size() > 0) {
String lhsAssociation = ((DataOutput) dataout.getSourceRef().get(0)).getName();
String rhsAssociation = dataout.getTargetRef().getId();
boolean wasBiDirectional = false;
// }
if (dataout.getTransformation() != null && dataout.getTransformation().getBody() != null) {
rhsAssociation = encodeAssociationValue(dataout.getTransformation().getBody());
}
if (!wasBiDirectional) {
if (lhsAssociation != null && lhsAssociation.length() > 0) {
associationBuff.append("[dout]" + lhsAssociation).append("->").append(rhsAssociation);
associationBuff.append(",");
}
}
}
}
}
String assignmentString = associationBuff.toString();
if (assignmentString.endsWith(",")) {
assignmentString = assignmentString.substring(0, assignmentString.length() - 1);
}
properties.put("assignments", assignmentString);
setAssignmentsInfoProperty(null, datainputset, null, dataoutputset, assignmentString, properties);
// on-entry and on-exit actions
ScriptTypeListValue onEntryActions = getOnEntryActions(task.getExtensionValues());
ScriptTypeListValue onExitActions = getOnExitActions(task.getExtensionValues());
if (!onEntryActions.isEmpty()) {
properties.put(ONENTRYACTIONS, new ScriptTypeListTypeSerializer().serialize(onEntryActions));
}
if (!onExitActions.isEmpty()) {
properties.put(ONEXITACTIONS, new ScriptTypeListTypeSerializer().serialize(onExitActions));
}
// simulation properties
setSimulationProperties(task.getId(), properties);
// marshall the node out
if (isCustomElement((String) properties.get("taskname"), preProcessingData)) {
marshallNode(task, properties, (String) properties.get("taskname"), plane, generator, xOffset, yOffset);
} else {
marshallNode(task, properties, "Task", plane, generator, xOffset, yOffset);
}
}
use of com.sjh.thinkinginjava.classTest.proxy1.Interface in project kie-wb-common by kiegroup.
the class Bpmn2JsonMarshaller method marshallDefinitions.
protected void marshallDefinitions(Definitions def, JsonGenerator generator, String preProcessingData) throws JsonGenerationException, IOException {
try {
generator.writeStartObject();
generator.writeObjectField("resourceId", def.getId());
/**
* "properties":{"name":"",
* "documentation":"",
* "auditing":"",
* "monitoring":"",
* "executable":"true",
* "package":"com.sample",
* "vardefs":"a,b,c,d",
* "lanes" : "a,b,c",
* "id":"",
* "version":"",
* "author":"",
* "language":"",
* "namespaces":"",
* "targetnamespace":"",
* "expressionlanguage":"",
* "typelanguage":"",
* "creationdate":"",
* "modificationdate":""
* }
*/
Map<String, Object> props = new LinkedHashMap<String, Object>();
props.put(NAMESPACES, "");
// props.put("targetnamespace", def.getTargetNamespace());
props.put(TARGETNAMESPACE, "http://www.omg.org/bpmn20");
props.put(TYPELANGUAGE, def.getTypeLanguage());
props.put(NAME, StringEscapeUtils.unescapeXml(def.getName()));
props.put(ID, def.getId());
props.put(EXPRESSIONLANGUAGE, def.getExpressionLanguage());
// backwards compat for BZ 1048191
putDocumentationProperty(def, props);
for (RootElement rootElement : def.getRootElements()) {
if (rootElement instanceof Process) {
// have to wait for process node to finish properties and stencil marshalling
props.put(EXECUTABLE, ((Process) rootElement).isIsExecutable() + "");
props.put(ID, rootElement.getId());
if (rootElement.getDocumentation() != null && rootElement.getDocumentation().size() > 0) {
props.put(DOCUMENTATION, rootElement.getDocumentation().get(0).getText());
}
Process pr = (Process) rootElement;
if (pr.getName() != null && pr.getName().length() > 0) {
props.put(PROCESSN, StringEscapeUtils.unescapeXml(((Process) rootElement).getName()));
}
List<Property> processProperties = ((Process) rootElement).getProperties();
if (processProperties != null && processProperties.size() > 0) {
String propVal = "";
for (int i = 0; i < processProperties.size(); i++) {
Property p = processProperties.get(i);
String pKPI = Utils.getMetaDataValue(p.getExtensionValues(), "customKPI");
propVal += p.getId();
// check the structureRef value
if (p.getItemSubjectRef() != null && p.getItemSubjectRef().getStructureRef() != null) {
propVal += ":" + p.getItemSubjectRef().getStructureRef();
}
if (pKPI != null && pKPI.length() > 0) {
propVal += ":" + pKPI;
}
if (i != processProperties.size() - 1) {
propVal += ",";
}
}
props.put("vardefs", propVal);
}
// packageName and version and adHoc are jbpm-specific extension attribute
Iterator<FeatureMap.Entry> iter = ((Process) rootElement).getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("packageName")) {
props.put(PACKAGE, entry.getValue());
}
if (entry.getEStructuralFeature().getName().equals("version")) {
props.put(VERSION, entry.getValue());
}
if (entry.getEStructuralFeature().getName().equals("adHoc")) {
props.put(ADHOCPROCESS, entry.getValue());
}
}
// process imports, custom description and globals extension elements
String allImports = "";
if ((rootElement).getExtensionValues() != null && (rootElement).getExtensionValues().size() > 0) {
String importsStr = "";
String globalsStr = "";
for (ExtensionAttributeValue extattrval : rootElement.getExtensionValues()) {
FeatureMap extensionElements = extattrval.getValue();
@SuppressWarnings("unchecked") List<ImportType> importExtensions = (List<ImportType>) extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__IMPORT, true);
@SuppressWarnings("unchecked") List<GlobalType> globalExtensions = (List<GlobalType>) extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__GLOBAL, true);
List<MetaDataType> metadataExtensions = (List<MetaDataType>) extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, true);
for (ImportType importType : importExtensions) {
importsStr += importType.getName();
importsStr += "|default,";
}
for (GlobalType globalType : globalExtensions) {
globalsStr += (globalType.getIdentifier() + ":" + globalType.getType());
globalsStr += ",";
}
for (MetaDataType metaType : metadataExtensions) {
props.put("customdescription", metaType.getMetaValue());
}
}
allImports += importsStr;
if (globalsStr.length() > 0) {
if (globalsStr.endsWith(",")) {
globalsStr = globalsStr.substring(0, globalsStr.length() - 1);
}
props.put(GLOBALS, globalsStr);
}
}
// definitions imports (wsdl)
List<org.eclipse.bpmn2.Import> wsdlImports = def.getImports();
if (wsdlImports != null) {
for (org.eclipse.bpmn2.Import imp : wsdlImports) {
allImports += imp.getLocation() + "|" + imp.getNamespace() + "|wsdl,";
}
}
if (allImports.endsWith(",")) {
allImports = allImports.substring(0, allImports.length() - 1);
}
props.put(IMPORTS, allImports);
// simulation
if (_simulationScenario != null && _simulationScenario.getScenarioParameters() != null) {
props.put(CURRENCY, _simulationScenario.getScenarioParameters().getBaseCurrencyUnit() == null ? "" : _simulationScenario.getScenarioParameters().getBaseCurrencyUnit());
props.put(TIMEUNIT, _simulationScenario.getScenarioParameters().getBaseTimeUnit().getName());
}
marshallProperties(props, generator);
marshallStencil("BPMNDiagram", generator);
linkSequenceFlows(((Process) rootElement).getFlowElements());
marshallProcess((Process) rootElement, def, generator, preProcessingData);
} else if (rootElement instanceof Interface) {
// TODO
} else if (rootElement instanceof ItemDefinition) {
// TODO
} else if (rootElement instanceof Resource) {
// TODO
} else if (rootElement instanceof Error) {
// TODO
} else if (rootElement instanceof Message) {
// TODO
} else if (rootElement instanceof Signal) {
// TODO
} else if (rootElement instanceof Escalation) {
// TODO
} else if (rootElement instanceof Collaboration) {
} else {
_logger.warn("Unknown root element " + rootElement + ". This element will not be parsed.");
}
}
generator.writeObjectFieldStart("stencilset");
generator.writeObjectField("url", this.profile.getStencilSetURL());
generator.writeObjectField("namespace", this.profile.getStencilSetNamespaceURL());
generator.writeEndObject();
generator.writeArrayFieldStart("ssextensions");
generator.writeObject(this.profile.getStencilSetExtensionURL());
generator.writeEndArray();
generator.writeEndObject();
} finally {
_diagramElements.clear();
}
}
use of com.sjh.thinkinginjava.classTest.proxy1.Interface in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitServiceTasks.
private void revisitServiceTasks(Definitions def) {
List<RootElement> rootElements = def.getRootElements();
List<Interface> toAddInterfaces = new ArrayList<Interface>();
List<Message> toAddMessages = new ArrayList<Message>();
List<ItemDefinition> toAddDefinitions = new ArrayList<ItemDefinition>();
for (RootElement root : rootElements) {
if (root instanceof Process) {
revisitServiceTasksExecute((Process) root, rootElements, toAddInterfaces, toAddMessages, toAddDefinitions);
}
}
for (Lane lane : _lanes) {
revisitServiceTasksExecuteForLanes(lane, def, rootElements, toAddInterfaces, toAddMessages, toAddDefinitions);
}
for (ItemDefinition id : toAddDefinitions) {
def.getRootElements().add(id);
}
for (Message m : toAddMessages) {
def.getRootElements().add(m);
}
for (Interface i : toAddInterfaces) {
def.getRootElements().add(i);
}
}
use of com.sjh.thinkinginjava.classTest.proxy1.Interface in project Java by Everything1sPossible.
the class SimpleDynamicProxy method main.
public static void main(String[] args) {
RealObject realObject = new RealObject();
consumer(realObject);
Interface proxy = (Interface) Proxy.newProxyInstance(Interface.class.getClassLoader(), new Class[] { Interface.class }, new DynamicProxyHandler(realObject));
consumer(proxy);
}
use of com.sjh.thinkinginjava.classTest.proxy1.Interface in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitServiceTasksExecuteForLanes.
private void revisitServiceTasksExecuteForLanes(Lane lane, Definitions def, List<RootElement> rootElements, List<Interface> toAddInterfaces, List<Message> toAddMessages, List<ItemDefinition> toAddDefinitions) {
List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs();
for (FlowElement fe : laneFlowNodes) {
if (fe instanceof ServiceTask) {
Iterator<FeatureMap.Entry> iter = fe.getAnyAttribute().iterator();
String serviceImplementation = null;
String serviceInterface = null;
String serviceOperation = null;
EStructuralFeature serviceInterfaceFeature = null;
EStructuralFeature serviceOperationFeature = null;
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("serviceimplementation")) {
serviceImplementation = (String) entry.getValue();
}
if (entry.getEStructuralFeature().getName().equals("serviceoperation")) {
serviceOperation = (String) entry.getValue();
serviceOperationFeature = entry.getEStructuralFeature();
}
if (entry.getEStructuralFeature().getName().equals("serviceinterface")) {
serviceInterface = (String) entry.getValue();
serviceInterfaceFeature = entry.getEStructuralFeature();
}
}
boolean foundInterface = false;
Interface touseInterface = null;
if (serviceImplementation != null && serviceImplementation.equals("Java")) {
for (RootElement iroot : rootElements) {
if (iroot instanceof Interface && ((Interface) iroot).getName().equals(serviceInterface)) {
foundInterface = true;
touseInterface = (Interface) iroot;
break;
}
}
if (!foundInterface) {
for (Interface toadd : toAddInterfaces) {
if (toadd.getName() != null && toadd.getName().equals(serviceInterface)) {
foundInterface = true;
touseInterface = toadd;
break;
}
}
}
} else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
for (RootElement iroot : rootElements) {
if (iroot instanceof Interface && ((Interface) iroot).getImplementationRef().equals(serviceInterface)) {
foundInterface = true;
touseInterface = (Interface) iroot;
break;
}
}
if (!foundInterface) {
for (Interface toadd : toAddInterfaces) {
if (toadd.getImplementationRef().equals(serviceInterface)) {
foundInterface = true;
touseInterface = toadd;
break;
}
}
}
}
if (!foundInterface) {
touseInterface = Bpmn2Factory.eINSTANCE.createInterface();
if (serviceInterface == null || serviceInterface.length() == 0) {
serviceInterface = fe.getId() + "_ServiceInterface";
if (serviceInterfaceFeature != null) {
fe.getAnyAttribute().set(serviceInterfaceFeature, serviceInterface);
}
}
touseInterface.setName(serviceInterface);
touseInterface.setImplementationRef(serviceInterface);
touseInterface.setId(fe.getId() + "_ServiceInterface");
toAddInterfaces.add(touseInterface);
}
if (serviceOperation != null) {
boolean foundOperation = false;
for (Operation oper : touseInterface.getOperations()) {
if (serviceImplementation != null && serviceImplementation.equals("Java")) {
if (oper.getName().equals(serviceOperation)) {
foundOperation = true;
break;
}
} else if (serviceImplementation != null && serviceImplementation.equals("##WebService")) {
if (oper.getImplementationRef().equals(serviceOperation)) {
foundOperation = true;
break;
}
}
}
if (!foundOperation) {
Operation touseOperation = Bpmn2Factory.eINSTANCE.createOperation();
if (serviceOperation == null || serviceOperation.length() == 0) {
serviceOperation = fe.getId() + "_ServiceOperation";
if (serviceOperationFeature != null) {
fe.getAnyAttribute().set(serviceOperationFeature, serviceOperation);
}
}
touseOperation.setId(fe.getId() + "_ServiceOperation");
touseOperation.setName(serviceOperation);
touseOperation.setImplementationRef(serviceOperation);
Message message = Bpmn2Factory.eINSTANCE.createMessage();
message.setId(fe.getId() + "_InMessage");
ItemDefinition itemdef = Bpmn2Factory.eINSTANCE.createItemDefinition();
itemdef.setId(message.getId() + "Type");
message.setItemRef(itemdef);
toAddDefinitions.add(itemdef);
toAddMessages.add(message);
touseOperation.setInMessageRef(message);
touseInterface.getOperations().add(touseOperation);
((ServiceTask) fe).setOperationRef(touseOperation);
}
}
} else if (fe instanceof FlowElementsContainer) {
revisitServiceTasksExecute((FlowElementsContainer) fe, rootElements, toAddInterfaces, toAddMessages, toAddDefinitions);
}
}
}
Aggregations