/** * Copies the content of the sourceUMLPath to the umlFile * The referenced Profile files will be also copied * @param sourceUMLPath - The path of the source .uml File */ private void setUpUMLFile(String sourceUMLPath){ copyFile(sourceUMLPath, umlFile); Model m = getUmlModel(); EList<Profile> profiles = m.getAllAppliedProfiles(); for(Profile profile : profiles){ String filestring = ((BasicEObjectImpl) profile).eProxyURI().toPlatformString(false); Path profileFilepath = new Path(filestring); String oldFolder = new Path(new Path(sourceUMLPath).toFile().getParent().toString()).toString(); String oldFileName = oldFolder+Path.SEPARATOR+profileFilepath.toFile().getName(); int index = umlFilePath.lastIndexOf(Path.SEPARATOR); String newFileName = umlFilePath.substring(0, index)+Path.SEPARATOR+profileFilepath.toFile().getName(); IFile newFile = fileFromPath(newFileName); copyFile(oldFileName, newFile); } }
/** * Add a reference to a named AD * @param element * @param referenceURI * @param referenceID * @param attribute */ @SuppressWarnings("unchecked") public static void addReference(EPlanElement element, URI referenceURI, String referenceID, String attribute) { if (referenceURI != null) { EObject data = element.getData(); EStructuralFeature feature = data.eClass().getEStructuralFeature(attribute); EClass referenceClass = (EClass) feature.getEType(); List groupReferences = (List)data.eGet(data.eClass().getEStructuralFeature(attribute)); URI uri = referenceURI.appendFragment(referenceID); EObject groupObject = ActivityDictionary.getInstance().getEFactoryInstance().create(referenceClass); ((BasicEObjectImpl)groupObject).eSetProxyURI(uri); if (!groupReferences.contains(groupObject)) { groupReferences.add(groupObject); } } }
public static BaseElement getBaseElement(DefinitionsBehavior definitions,BaseElement baseElement){ if(baseElement==null){ return null; } if(baseElement.getId()==null){ BasicEObjectImpl basicEObjectImpl=(BasicEObjectImpl)baseElement; if(basicEObjectImpl!=null&&basicEObjectImpl.eProxyURI()!=null){ String elementId=basicEObjectImpl.eProxyURI().fragment(); BaseElement bpmnElement=definitions.getElement(elementId); return bpmnElement; } else{ return null; } }else{ return baseElement; } }
private BaseElement getBaseElement(BaseElement baseElement){ if(baseElement==null){ return null; } if(baseElement.getId()==null){ BasicEObjectImpl basicEObjectImpl=(BasicEObjectImpl)baseElement; if(basicEObjectImpl!=null&&basicEObjectImpl.eProxyURI()!=null){ String elementId=basicEObjectImpl.eProxyURI().fragment(); BaseElement bpmnElement=definitions.getElement(elementId); return bpmnElement; } else{ return null; } }else{ return baseElement; } }
/** * Returns an URI that identifies the given object. */ protected String getObjectURI(EObject object) { if (object == null) { return null; } if (object.eIsProxy() && object instanceof BasicEObjectImpl) { return ((BasicEObjectImpl) object).eProxyURI().toString(); } Resource eResource = object.eResource(); if (eResource == null) { return null; } return eResource.getURI().toString() + "#" + eResource.getURIFragment(object); }
private EObject copy(EStructuralFeature feature, EObject eObject) { if (eObject.eContainer() != null || eObject.eResource() != null) { if (feature instanceof EReference) { EReference reference = (EReference) feature; URI uri = (reference.isContainment() ? null : EcoreUtil.getURI(eObject)); if (reference.isContainment()) { eObject = copy(eObject); } ((BasicEObjectImpl)eObject).eSetProxyURI(uri); } } return eObject; }
public static void unresolveProxies(EObject object) { for (EReference r : object.eClass().getEReferences()) { if (object.eContainmentFeature() == r) { continue; } for (EObject referencedObject : eGetAsList(object, r)) { if (r.isContainment() && referencedObject instanceof BasicEObjectImpl) { unresolveProxies(referencedObject); } else { unresolveProxy(referencedObject); } } } }
/** * Will be called by super class once for each proxy. Super class will ensure that * <code>crossReferencedEObject</code> is a proxy. */ @Override protected void add(InternalEObject eObject, EReference eReference, EObject crossReferencedEObject) { handler.handle(eObject, eReference, (BasicEObjectImpl) crossReferencedEObject); }
public static void unresolveProxy(EObject referencedObject) { ((BasicEObjectImpl)referencedObject).eSetProxyURI(EcoreUtil.getURI(referencedObject)); }
private BaseElement getBaseElement(BaseElement baseElement) { if(baseElement==null){ return null; } if(baseElement.getId()==null){ BasicEObjectImpl basicEObjectImpl=(BasicEObjectImpl)baseElement; if(basicEObjectImpl!=null&&basicEObjectImpl.eProxyURI()!=null){ String elementId=basicEObjectImpl.eProxyURI().fragment(); BaseElement bpmnElement=definitions.getElement(elementId); return bpmnElement; } else{ return null; } }else{ return baseElement; } }
/** * Will be invoked for each proxy. */ public void handle(InternalEObject source, EReference eReference, BasicEObjectImpl targetProxy);