/** * @param sourceExtent not null extent */ public Collection<RefObject> execute(RefPackage sourceExtent) throws JmiException { Collection<RefObject> result; // locate the meta class (in metaClass) within the metamodel result = Navigator.getMetaClass( sourceExtent, metaclass ).refAllOfClass(); return result; } }
public RefPackage execute(RefPackage refPackage) throws RuntimeException, IllegalArgumentException { for (RefClass metaClass : (Collection<RefClass>) refPackage.refAllClasses()) { result.addAll( metaClass.refAllOfClass() ); } return null; } });
/** * This method registers in the cache all instances of that class * @param classProxy not null */ public final void load(RefClass classProxy) { Iterator iterator; RefObject refObject; iterator = classProxy.refAllOfClass().iterator(); while ( iterator.hasNext() ) { refObject = (RefObject) iterator.next(); register(refObject); } }
/** * @param modelElement is a non-null model element. * @return a non-null collection of tagged values bound to that model element */ private Collection<TaggedValue> allTaggedValues(ModelElement modelElement) { Collection<TaggedValue> result; TaggedValue tag; Iterator sourceIterator; result = new ArrayList<TaggedValue>(); sourceIterator = taggedValue.getMetaClass( extent ).refAllOfClass().iterator(); while ( sourceIterator.hasNext() ) { tag = (TaggedValue) sourceIterator.next(); if ( tag.getModelElement() == modelElement ) { result.add( tag ); } } return result; }
/** * Copy the values of the attributes of the instances of refClass as corresponding values of corresponding attributes in * the corresponding instances * * @param targetExtent not null extent where to copy the instances of refClass * @param originalMetaClass not null source model class * @param objectsMap not null correspondence between an original and copy objects */ private void copyAttributes(RefPackage targetExtent, RefClass originalMetaClass, Map<RefObject, RefObject> objectsMap) { Collection<Procedure<RefObject>> copyAttributesOperations; copyAttributesOperations = collectCopyAttributeOperations(originalMetaClass, targetExtent, objectsMap); // TODO: Let A extends B, check if A.allOfClass() subclass of B.allOfClass() // TODO: If so, then DO NOT collect superclasses of A to collect their attributes, as this would // TODO: repeat copying the parent attributes for all its subclasses, which is slow for (RefObject source : (Collection<RefObject>) originalMetaClass.refAllOfClass()) { for (Procedure<RefObject> copy : copyAttributesOperations) { try { copy.execute(source); } catch (Exception ex) { LOGGER.log(Level.SEVERE, copy+" on "+new PrintModelElement().execute( source )+" caused: ", ex); } } } }
/** * Copy the instances of refClass to the targetExtent with the stated metamodel transformation, * collect the correspondence of original to copy objects in objectsMap * * @param targetExtent not null extent where to copy the instances of refClass * @param originalMetaClass not null source model class * @param objectsMap not null correspondence between an original and copy objects */ private void copyObjects(RefPackage targetExtent, RefClass originalMetaClass, Map<RefObject, RefObject> objectsMap) { Procedure<RefObject> construct; ClassName className; className = new ClassNameImpl((Classifier) originalMetaClass.refMetaObject()); construct = nameMapping.mapMetaClass( className, sourceExtent, targetExtent, objectsMap ); for (RefObject source : (Collection<RefObject>) originalMetaClass.refAllOfClass()) { try { construct.execute(source); // objectsMap is updated to bind the source to the produced object(s) if any } catch (Exception ex) { LOGGER.log(Level.SEVERE, "Copy object "+new PrintModelElement().execute( source )+" caused: ",ex); } } }