public RefPackage execute(RefPackage refPackage) throws RuntimeException, IllegalArgumentException { result.addAll( refPackage.refAllAssociations() ); return null; } });
public RefPackage execute(RefPackage refPackage) throws RuntimeException, IllegalArgumentException { result.addAll( refPackage.refAllClasses() ); return null; } });
/** * The task's execution method. This method filters the model classes associated with metapackage and * executes the nested <template> tasks for the filtered classes collection. This * methods invokes the internal formatting tasks with the metapackage itself. */ public RefStruct execute(RefPackage sourceExtent) throws IllegalArgumentException { RefStruct result; RefPackage refPackage; if ( sourceExtent == null ) { throw new IllegalArgumentException("Expected non-null extent"); } refPackage = Navigator.getMetaPackage( sourceExtent, metapackage ); // non-null result = refPackage.refCreateStruct( type, parameters ); return result; } }
rootPackage = rootPackage.refPackage( itemName ); result = rootPackage.refClass( itemName );
structClassPackage = structClassNamespacePackage.refPackage( structClassNamespace.getName() ); result = structClassPackage.refCreateStruct(getName(), fieldValues ); structClassClass = structClassNamespacePackage.refClass( structClassNamespace.getName() ); result = structClassClass.refCreateStruct(getName(), fieldValues );
enumClassPackage = enumClassNamespacePackage.refPackage( enumClassNamespace.getName() ); result = enumClassPackage.refGetEnum( enumClassName.getName(), getName() ); enumClassClass = enumClassNamespacePackage.refClass( enumClassNamespace.getName() ); result = enumClassClass.refGetEnum( enumClassName.getName(), getName() );
default RefAssociation locateAssociation(RefPackage targetExtent) { RefAssociation result; RefPackage newMetaPackage; if ( getOwner() instanceof PackageName ) { newMetaPackage = ((PackageName) getOwner()).getMetaPackage( targetExtent ); result = newMetaPackage.refAssociation( getName() ); } else { throw new IllegalArgumentException(this + " should be a class name in order to lookup the corresponding *AssociationClass instance"); } return result; } }
/** * This method requires an M1 object object and a StringBuilder where to describe the object. * * @param result is the buffer where to add the obect's description * @param object is the M1 object to investigate */ private void append(StringBuilder result, RefPackage object, Set visited) { result.append( "RefPackage ") .append( object.refMetaObject().refGetValue( "name" ) ); }
/** * This method finds the metapackage with the name provided * * @param rootPackage is the top-most package / the model's extent * @param metaPackageName a meta package name with syntax [<package>{::<package>}] * @return the non-null meta package * @throws JmiException if the meta package name is not a valid one */ public static RefPackage getMetaPackage(RefPackage rootPackage, String metaPackageName) throws JmiException { RefPackage result; String[] parsedPath; String itemName; assert rootPackage != null : "Expected a non-null package"; result = rootPackage; // parse syntax [<package>{::<package>}] parsedPath = Name.parseQualifiedName( metaPackageName ); for (int i = 0; i < parsedPath.length; i++) { itemName = parsedPath[i]; try { result = result.refPackage( itemName ); } catch (JmiException ex) { throw new IllegalArgumentException("Looking up the package "+ metaPackageName + " down the path: " + Arrays.asList( Arrays.copyOf( parsedPath, i ) ) + " reached " + PRINT_MODEL_ELEMENT.execute( result ) + " for which retrieving the nested package '"+itemName+"'" + " caused ", ex); } } return result; }
/** * The task's execution method. This method filters the model classes associated with metaPackage and * executes the nested <template> tasks for the filtered classes collection. This * methods invokes the internal formatting tasks with the metaPackage itself. */ public RefEnum execute(RefPackage sourceExtent) throws IllegalArgumentException { RefEnum result; RefPackage refPackage; if ( sourceExtent == null ) { throw new IllegalArgumentException("Expected a non-null extent"); } refPackage = Navigator.getMetaPackage( sourceExtent, metaPackage ); // non-null result = refPackage.refGetEnum( type, literal ); return result; } }
/** * This method adds all model objects found in the meta classes in the package provided * or in its subpackages * @param thisPackage is the meta-package to collect objects in * @param result is a non-null list of all model objects */ private static void process(RefPackage thisPackage, ProcessPackage processPackage) { processPackage.execute(thisPackage); for (RefPackage nested : (Collection<RefPackage>) thisPackage.refAllPackages()) { process( nested, processPackage); } }
/** * Remove the domain by removing the extent. */ public synchronized void removeDomain() throws CWMException { repository.beginTrans( true ); repository.endTrans( false ); // just to make sure, this forces a commit on the database RefPackage refPackage = repository.getExtent( domainName ); if ( refPackage != null ) { // Delete the root package... refPackage.refDelete(); removeFromList(); } }
/** * @param rootPackage not null extent */ public RefClass getMetaClass(RefPackage rootPackage) throws JmiException { RefClass result; RefPackage ownerPackage; assert rootPackage != null : "Expected a non-null package"; if ( getOwner() == null ) { ownerPackage = rootPackage; } else if ( getOwner() instanceof PackageName ) { ownerPackage = ((PackageName) getOwner()).getMetaPackage( rootPackage ); } else { throw new IllegalArgumentException(this + " should be a class name in order to lookup the corresponding *Class instance"); } try { result = ownerPackage.refClass( getName() ); } catch (JmiException ex) { throw new IllegalArgumentException("Looking up the class "+ this + " reached " + PRINT_MODEL_ELEMENT.execute( ownerPackage ) + " for which retrieving the nested class '"+getName()+"'" + " caused ",ex); } return result; }
/** * @param qualifiedName not null, not empty qualified name of the Enum Class * @param targetExtent not null * @return the class name of that Enum */ private static Name<?> constructOwnerClassName(List<String> qualifiedName, RefPackage targetExtent) { Name<?> result; String name; RefBaseObject namespace; namespace = targetExtent; result = null; for (int i=0; i<qualifiedName.size()-1; i++) { name = qualifiedName.get( i ); if ( namespace instanceof RefPackage ) { // the current name is a name of a package or class, packageName is a name of a package so far try { namespace = ((RefPackage) namespace).refPackage( name ); result = new PackageNameImpl((PackageName) result, name); } catch (InvalidNameException ex) { // name is not a package, it could be only a class namespace = ((RefPackage) namespace).refClass( name ); result = new ClassNameImpl((PackageName) result, name); } } else { // namespace is a Class owning at most an enumeration throw new IllegalArgumentException("Resolving "+qualifiedName +" struct name, reached "+PRINT_MODEL_ELEMENT.execute( namespace ) +" which cannot contain nested "+name); } } return result; }
/** * @param rootPackage not null extent */ public RefAssociation getMetaAssociation(RefPackage rootPackage) throws JmiException { RefAssociation result; RefPackage ownerPackage; assert rootPackage != null : "Expected a non-null package"; if ( getOwner() == null ) { ownerPackage = rootPackage; } else { ownerPackage = getOwner().getMetaPackage( rootPackage ); } try { result = ownerPackage.refAssociation( getName() ); } catch (JmiException ex) { throw new IllegalArgumentException("Looking up the association "+ this + " reached " + PRINT_MODEL_ELEMENT.execute( ownerPackage ) + " for which retrieving the nested class '"+getName()+"'" + " caused ",ex); } return result; }
/** * @param sourceExtent not null * @return non-null list of one element - the metaobject, describing the metapackage */ public Collection<RefObject> execute(RefPackage sourceExtent) throws JmiException { Collection<RefObject> result; // locate the meta class (in metaClass) within the metamodel result = new ArrayList<>(); result.add(Navigator.getMetaPackage( sourceExtent, qualifiedName ).refMetaObject()); return result; } }
/** * @param rootPackage the extent or another instance of a package proxy (class) to start navigating form * @return the metamodel package this describes, starting from the rootPackage extent * @throws JmiException * @see net.mdatools.modelant.core.api.name.PackageName#getMetaPackage(javax.jmi.reflect.RefPackage) */ public RefPackage getMetaPackage(RefPackage rootPackage) throws JmiException { RefPackage result; assert rootPackage != null : "Expected a non-null package"; if ( getOwner() == null ) { result = rootPackage; } else { result = getOwner().getMetaPackage( rootPackage ); } try { result = result.refPackage( getName() ); } catch (JmiException ex) { throw new IllegalArgumentException("Looking up the package "+ this + " reached " + PRINT_MODEL_ELEMENT.execute( result ) + " for which retrieving the nested package '"+getName()+"'" + " caused ",ex); } return result; }
namespace = ((RefPackage) namespace).refPackage( name ); packageName = new PackageNameImpl((PackageName) packageName, name); namespace = ((RefPackage) namespace).refClass( name ); packageName = new ClassNameImpl((PackageName) packageName, name);
public RefPackage execute(RefPackage refPackage) throws RuntimeException, IllegalArgumentException { for (RefClass metaClass : (Collection<RefClass>) refPackage.refAllClasses()) { result.addAll( metaClass.refAllOfClass() ); } return null; } });