Search in sources :

Example 11 with FeatureMap

use of org.eclipse.emf.ecore.util.FeatureMap in project statecharts by Yakindu.

the class DerivedEObjectEList method isEmpty.

@Override
public boolean isEmpty() {
    if (sourceFeatureIDs != null) {
        for (int i = 0; i < sourceFeatureIDs.length; i++) {
            int sourceFeatureID = sourceFeatureIDs[i];
            if (owner.eIsSet(sourceFeatureID)) {
                EStructuralFeature sourceFeature = getEStructuralFeature(sourceFeatureID);
                Object value = owner.eGet(sourceFeatureID, false, true);
                if (FeatureMapUtil.isFeatureMap(sourceFeature)) {
                    FeatureMap featureMap = (FeatureMap) value;
                    for (int j = 0, size = featureMap.size(); j < size; j++) {
                        if (isIncluded(featureMap.getEStructuralFeature(j)) ? featureMap.getValue(j) != null : isIncluded(featureMap.getValue(j))) {
                            return false;
                        }
                    }
                } else if (isIncluded(sourceFeature)) {
                    if (sourceFeature.isMany() ? ((List<?>) value).size() > 0 : value != null) {
                        return false;
                    }
                } else {
                    if (sourceFeature.isMany()) {
                        InternalEList<?> valuesList = (InternalEList<?>) value;
                        if (valuesList instanceof RandomAccess) {
                            for (int j = 0, size = valuesList.size(); j < size; j++) {
                                if (isIncluded(valuesList.basicGet(j))) {
                                    return false;
                                }
                            }
                        } else {
                            for (Iterator<?> v = valuesList.basicIterator(); v.hasNext(); ) {
                                if (isIncluded(v.next())) {
                                    return false;
                                }
                            }
                        }
                    } else if (isIncluded(value)) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) AbstractSequentialInternalEList(org.eclipse.emf.ecore.util.AbstractSequentialInternalEList) InternalEList(org.eclipse.emf.ecore.util.InternalEList) RandomAccess(java.util.RandomAccess) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 12 with FeatureMap

use of org.eclipse.emf.ecore.util.FeatureMap in project InformationSystem by ObeoNetwork.

the class SoaMigrationHelper method handleUnknownFeaturesAnyAttribute.

@Override
public void handleUnknownFeaturesAnyAttribute(EObject owner, FeatureMap featureMap) {
    if (owner instanceof Parameter) {
        Parameter parameter = (Parameter) owner;
        // Convert "lower + upper" to "multiplicity"
        // Previous default values were lower = 1 and upper = 1
        Iterator<FeatureMap.Entry> iter = featureMap.iterator();
        int lower = 1;
        int upper = 1;
        while (iter.hasNext()) {
            final FeatureMap.Entry entry = iter.next();
            if ("lower".equals(entry.getEStructuralFeature().getName())) {
                lower = Integer.parseInt((String) entry.getValue());
            }
            if ("upper".equals(entry.getEStructuralFeature().getName())) {
                upper = Integer.parseInt((String) entry.getValue());
            }
        }
        // Convert now
        if (lower == 0) {
            // lower == 0
            if (upper < 0 || upper > 1) {
                parameter.setMultiplicity(MultiplicityKind.ZERO_STAR_LITERAL);
            } else {
                parameter.setMultiplicity(MultiplicityKind.ZERO_ONE_LITERAL);
            }
        } else {
            // lower == 1
            if (upper < 0 || upper > 1) {
                parameter.setMultiplicity(MultiplicityKind.ONE_STAR_LITERAL);
            } else {
                parameter.setMultiplicity(MultiplicityKind.ONE_LITERAL);
            }
        }
    }
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) Entry(java.util.Map.Entry) Parameter(org.obeonetwork.dsl.soa.Parameter)

Example 13 with FeatureMap

use of org.eclipse.emf.ecore.util.FeatureMap in project InformationSystem by ObeoNetwork.

the class ClassDiagramGenerator method getOptionalNodes.

private Map<String, Collection<EObject>> getOptionalNodes(Map<EObject, AnyType> eObjectToExtensionMap) {
    Map<String, Collection<EObject>> result = new HashMap<String, Collection<EObject>>();
    for (Entry<EObject, AnyType> entry : eObjectToExtensionMap.entrySet()) {
        AnyType anyType = entry.getValue();
        FeatureMap anyAttribute = anyType.getAnyAttribute();
        for (org.eclipse.emf.ecore.util.FeatureMap.Entry featureMapEntry : anyAttribute) {
            EStructuralFeature feature = featureMapEntry.getEStructuralFeature();
            if (GENERATOR_OPTIONAL_NODE.equals(feature.getName())) {
                String id = (String) featureMapEntry.getValue();
                // Put value into result map
                if (result.get(id) == null) {
                    result.put(id, new ArrayList<EObject>());
                }
                result.get(id).add(entry.getKey());
            }
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) EObject(org.eclipse.emf.ecore.EObject) Collection(java.util.Collection) AnyType(org.eclipse.emf.ecore.xml.type.AnyType)

Example 14 with FeatureMap

use of org.eclipse.emf.ecore.util.FeatureMap 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 15 with FeatureMap

use of org.eclipse.emf.ecore.util.FeatureMap 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)

Aggregations

FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)25 FeatureEList (org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList)10 List (java.util.List)8 ExtensionAttributeValue (org.eclipse.bpmn2.ExtensionAttributeValue)8 ArrayList (java.util.ArrayList)5 EList (org.eclipse.emf.common.util.EList)5 EObject (org.eclipse.emf.ecore.EObject)5 MetaDataType (org.jboss.drools.MetaDataType)5 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)4 Iterator (java.util.Iterator)3 ListIterator (java.util.ListIterator)3 RandomAccess (java.util.RandomAccess)3 InternalEObject (org.eclipse.emf.ecore.InternalEObject)3 AbstractSequentialInternalEList (org.eclipse.emf.ecore.util.AbstractSequentialInternalEList)3 InternalEList (org.eclipse.emf.ecore.util.InternalEList)3 BPSimDataType (bpsim.BPSimDataType)2 HashMap (java.util.HashMap)2 Entry (java.util.Map.Entry)2 Relationship (org.eclipse.bpmn2.Relationship)2 EStructuralFeatureImpl (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl)2