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;
}
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);
}
}
}
}
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;
}
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);
}
}
}
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;
}
Aggregations