Search in sources :

Example 6 with MetaDataType

use of org.jboss.drools.MetaDataType 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);
        }
    }
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) MetaDataType(org.jboss.drools.MetaDataType) FlowElement(org.eclipse.bpmn2.FlowElement) UserTask(org.eclipse.bpmn2.UserTask) FlowElementsContainer(org.eclipse.bpmn2.FlowElementsContainer) ArrayList(java.util.ArrayList) List(java.util.List) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue)

Example 7 with MetaDataType

use of org.jboss.drools.MetaDataType in project kie-wb-common by kiegroup.

the class Utils method getMetaDataValue.

public static String getMetaDataValue(List<ExtensionAttributeValue> extensionValues, String metaDataName) {
    if (extensionValues != null && extensionValues.size() > 0) {
        for (ExtensionAttributeValue extattrval : extensionValues) {
            FeatureMap extensionElements = extattrval.getValue();
            List<MetaDataType> metadataExtensions = (List<MetaDataType>) extensionElements.get(DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, true);
            for (MetaDataType metaType : metadataExtensions) {
                if (metaType.getName() != null && metaType.getName().equals(metaDataName) && metaType.getMetaValue() != null && metaType.getMetaValue().length() > 0) {
                    return metaType.getMetaValue();
                }
            }
        }
    }
    return null;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) MetaDataType(org.jboss.drools.MetaDataType) List(java.util.List) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue)

Example 8 with MetaDataType

use of org.jboss.drools.MetaDataType in project kie-wb-common by kiegroup.

the class StringElement method setStringValue.

void setStringValue(BaseElement element, String value) {
    if (element != null) {
        MetaDataType eleMetadata = DroolsFactory.eINSTANCE.createMetaDataType();
        eleMetadata.setName(name);
        eleMetadata.setMetaValue(asCData(value));
        if (element.getExtensionValues() == null || element.getExtensionValues().isEmpty()) {
            ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
            element.getExtensionValues().add(extensionElement);
        }
        FeatureMap.Entry eleExtensionElementEntry = new EStructuralFeatureImpl.SimpleFeatureMapEntry((EStructuralFeature.Internal) DroolsPackage.Literals.DOCUMENT_ROOT__META_DATA, eleMetadata);
        element.getExtensionValues().get(0).getValue().add(eleExtensionElementEntry);
    }
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) MetaDataType(org.jboss.drools.MetaDataType) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) ExtensionAttributeValue(org.eclipse.bpmn2.ExtensionAttributeValue)

Aggregations

MetaDataType (org.jboss.drools.MetaDataType)8 ExtensionAttributeValue (org.eclipse.bpmn2.ExtensionAttributeValue)7 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)7 List (java.util.List)3 ArrayList (java.util.ArrayList)2 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)2 EStructuralFeatureImpl (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 StringWriter (java.io.StringWriter)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 Entry (java.util.Map.Entry)1 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)1 Collaboration (org.eclipse.bpmn2.Collaboration)1 DataObject (org.eclipse.bpmn2.DataObject)1 Error (org.eclipse.bpmn2.Error)1 Escalation (org.eclipse.bpmn2.Escalation)1 FlowElement (org.eclipse.bpmn2.FlowElement)1 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)1