use of org.eclipse.bpmn2.ExtensionAttributeValue in project kie-wb-common by kiegroup.
the class BPMNDirectDiagramMarshallerTest method getProcessExtensionValue.
private String getProcessExtensionValue(Process process, String propertyName) {
List<ExtensionAttributeValue> extensionValues = process.getExtensionValues();
for (ExtensionAttributeValue extensionValue : extensionValues) {
FeatureMap featureMap = extensionValue.getValue();
for (int i = 0; i < featureMap.size(); i++) {
EStructuralFeatureImpl.SimpleFeatureMapEntry featureMapEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) featureMap.get(i);
MetaDataType featureMapValue = (MetaDataType) featureMapEntry.getValue();
if (propertyName.equals(featureMapValue.getName())) {
return featureMapValue.getMetaValue();
}
}
}
return "";
}
use of org.eclipse.bpmn2.ExtensionAttributeValue in project kie-wb-common by kiegroup.
the class BPMNDiagramMarshallerTest method getProcessExtensionValue.
private String getProcessExtensionValue(Process process, String propertyName) {
List<ExtensionAttributeValue> extensionValues = process.getExtensionValues();
for (ExtensionAttributeValue extensionValue : extensionValues) {
FeatureMap featureMap = extensionValue.getValue();
for (int i = 0; i < featureMap.size(); i++) {
EStructuralFeatureImpl.SimpleFeatureMapEntry featureMapEntry = (EStructuralFeatureImpl.SimpleFeatureMapEntry) featureMap.get(i);
MetaDataType featureMapValue = (MetaDataType) featureMapEntry.getValue();
if (propertyName.equals(featureMapValue.getName())) {
return featureMapValue.getMetaValue();
}
}
}
return "";
}
use of org.eclipse.bpmn2.ExtensionAttributeValue in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method applyOnExitActions.
protected void applyOnExitActions(BaseElement element, Map<String, String> properties) {
if (properties.get("onexitactions") != null && properties.get("onexitactions").length() > 0) {
ScriptTypeListValue onExitActions = new ScriptTypeListTypeSerializer().parse(properties.get("onexitactions"));
if (!onExitActions.isEmpty()) {
ScriptTypeValue onExitAction = onExitActions.getValues().get(0);
if (onExitAction.getScript() != null && !onExitAction.getScript().isEmpty()) {
OnExitScriptType onExitScript = DroolsFactory.eINSTANCE.createOnExitScriptType();
onExitScript.setScript(wrapInCDATABlock(onExitAction.getScript()));
String scriptLanguage = Utils.getScriptLanguageFormat(onExitAction.getLanguage());
if (scriptLanguage == null) {
// default to java
scriptLanguage = "http://www.java.com/java";
}
onExitScript.setScriptFormat(scriptLanguage);
if (element.getExtensionValues() == null || element.getExtensionValues().size() < 1) {
ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
element.getExtensionValues().add(extensionElement);
}
FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) DroolsPackage.Literals.DOCUMENT_ROOT__ON_EXIT_SCRIPT, onExitScript);
element.getExtensionValues().get(0).getValue().add(extensionElementEntry);
}
}
}
}
use of org.eclipse.bpmn2.ExtensionAttributeValue in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method addSimulation.
public void addSimulation(Definitions def) {
Relationship relationship = Bpmn2Factory.eINSTANCE.createRelationship();
relationship.getSources().add(def);
relationship.getTargets().add(def);
relationship.setType(defaultRelationshipType);
BPSimDataType simDataType = BpsimFactory.eINSTANCE.createBPSimDataType();
// currently support single scenario
Scenario defaultScenario = BpsimFactory.eINSTANCE.createScenario();
// single scenario suppoert
defaultScenario.setId("default");
// single scenario support
defaultScenario.setName("Simulationscenario");
defaultScenario.setScenarioParameters(_simulationScenarioParameters);
if (_simulationElementParameters.size() > 0) {
Iterator<String> iter = _simulationElementParameters.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
ElementParameters etype = BpsimFactory.eINSTANCE.createElementParameters();
etype.setElementRef(key);
List<EObject> params = _simulationElementParameters.get(key);
for (EObject np : params) {
if (np instanceof ControlParameters) {
etype.setControlParameters((ControlParameters) np);
} else if (np instanceof CostParameters) {
etype.setCostParameters((CostParameters) np);
} else if (np instanceof PriorityParameters) {
etype.setPriorityParameters((PriorityParameters) np);
} else if (np instanceof ResourceParameters) {
etype.setResourceParameters((ResourceParameters) np);
} else if (np instanceof TimeParameters) {
etype.setTimeParameters((TimeParameters) np);
}
}
defaultScenario.getElementParameters().add(etype);
}
}
simDataType.getScenario().add(defaultScenario);
ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
relationship.getExtensionValues().add(extensionElement);
FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((Internal) BpsimPackage.Literals.DOCUMENT_ROOT__BP_SIM_DATA, simDataType);
relationship.getExtensionValues().get(0).getValue().add(extensionElementEntry);
def.getRelationships().add(relationship);
}
use of org.eclipse.bpmn2.ExtensionAttributeValue in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setUserTaskInfo.
private void setUserTaskInfo(FlowElementsContainer container) {
List<FlowElement> flowElements = container.getFlowElements();
for (FlowElement fe : flowElements) {
// Set name and metaData "elementname" to "Task_n" if empty
if (fe instanceof UserTask) {
UserTask task = (UserTask) fe;
String name = task.getName();
if (name == null || name.length() == 0) {
LastUserTaskID++;
String newName = DEFAULT_USERTASK_NAME_PREFIX + LastUserTaskID;
task.setName(newName);
if (task.getExtensionValues() != null && task.getExtensionValues().size() > 0) {
for (ExtensionAttributeValue extattrval : task.getExtensionValues()) {
FeatureMap extensionElements = extattrval.getValue();
List<MetaDataType> metadataExtensions = (List<MetaDataType>) extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, true);
for (MetaDataType eleMetadata : metadataExtensions) {
if (eleMetadata.getName() != null && eleMetadata.getName().equals("elementname")) {
eleMetadata.setMetaValue(wrapInCDATABlock(newName));
}
}
}
}
}
}
if (fe instanceof FlowElementsContainer) {
setUserTaskInfo((FlowElementsContainer) fe);
}
}
}
Aggregations