use of org.eclipse.emf.ecore.xml.type.AnyType 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.xml.type.AnyType in project InformationSystem by ObeoNetwork.
the class MigrationResourceHandler method processUnknownData.
protected void processUnknownData(final XMLResource resource) {
final Map<EObject, AnyType> extMap = resource.getEObjectToExtensionMap();
for (final EObject key : extMap.keySet()) {
final AnyType value = extMap.get(key);
handleUnknownData(key, value);
}
}
use of org.eclipse.emf.ecore.xml.type.AnyType in project InformationSystem by ObeoNetwork.
the class ClassDiagramGenerator method removeOptionalElements.
private void removeOptionalElements(Collection<GenerationInfo> generationInfos, Resource vsmFromTemplate) {
// Remove optional elements
if (vsmFromTemplate instanceof XMLResource) {
Map<EObject, AnyType> eObjectToExtensionMap = ((XMLResource) vsmFromTemplate).getEObjectToExtensionMap();
Map<String, Collection<EObject>> optionalNodes = getOptionalNodes(eObjectToExtensionMap);
for (Entry<String, Collection<EObject>> optionalNodeEntry : optionalNodes.entrySet()) {
String optionalNodeId = optionalNodeEntry.getKey();
if (optionalNodeId.startsWith("{")) {
optionalNodeId = optionalNodeId.substring(1);
}
if (optionalNodeId.endsWith("}")) {
optionalNodeId = optionalNodeId.substring(0, optionalNodeId.length() - 1);
}
// Check if we have informations on this node
boolean toBeDeleted = false;
for (GenerationInfo generationInfo : generationInfos) {
Boolean optionalNodeActivated = generationInfo.getBooleanInfos().get(optionalNodeId);
if (optionalNodeActivated == Boolean.FALSE) {
toBeDeleted = true;
break;
}
}
if (toBeDeleted) {
// Remove the node
for (EObject object : optionalNodeEntry.getValue()) {
EcoreUtil.delete(object);
}
}
}
}
}
Aggregations