Re: [mdr-users] Clustering the UML for Traceability

Pieter Van Gorp <[email protected]> Wed, 20 Jul 2005 16:53:58 +0200
Newsgroups gmane.comp.java.netbeans.modules.mdr.user
Message-ID <[email protected]>
Hi Martin and others,
I've managed to generate the JMI interfaces for a tracing metamodel
that clusters the UML metamodel.  I've attached the MOF-XMI (see
traceMMmof.xml).

I have a test in which I create a trace between two UML attributes. 
I'm not sure if I'm using the NB/JMI API right when creating the
clustering extent: I create a new extent and pass an array of size one
in which the UML application model is stored.  When serializing the
trace extent to XMI, no problems are reported but the references to
the UML attributes are in fact dangling IDREFs instead of HREFs to the
original UML-XMI file.

Even worse, I get a classcastexception when trying to create a new
trace extent to test whether the XMI for the traceability model
contains the required information:
org.netbeans.api.mdr.CreationFailedException: Cannot instantiate
package because of unexpected exception: java.lang.ClassCastException
        at org.netbeans.mdr.NBMDRepositoryImpl.createExtent(NBMDRepositoryImpl.java:472)
        at org.netbeans.mdr.NBMDRepositoryImpl.createExtent(NBMDRepositoryImpl.java:292)
        at be.ac.ua.fots.motmot.prototypes.crossreferences.TestMDR.testReadTraceBetweenUmlAttributes(TestMDR.java:176)

I've attached the source of my test and the output of its execution by Maven.

I hope I've simply used the API "a little bit" wrong... by the way,
I'm setting up some documentation about MOF clustering that I'll
publish on my website once I've get this prototype right...

Looking forward to hear from you,
Pieter Van Gorp.

On 7/19/05, Martin Matula <[email protected]> wrote:
> You can see the clustered import e.g. in extension file for UML 1.3:
> http://mdr.netbeans.org/source/browse/~checkout~/mdr/xmidiffs/01-12-02_Diff.xml
> 
> There is a new package UML that clusters the top-level packages from the
> UML 1.3 metamodel and adds JMI tags to them.
> Regards,
> Martin
> 
> Pieter Van Gorp wrote:
> 
> >Hi Martin, since the tracing metamodel is so small (only one reference
> >to ModelElement) this sounds feasible.  However, I have no idea how
> >the clustered import and the references should look like in XMI.
> >
> >Does anybody have an example of this?  It doesn't need to be minimal.
> >Attachment size is not an issue if you mail me personally.  Perhaps
> >there's even an online example that I don't know of?
> >
> >Thanks a lot in advance,
> >Pieter.
> >
> >On 7/19/05, Martin Matula <[email protected]> wrote:
> >
> >
> >>Hm. This will be difficult. The simplest way to model this is probably
> >>to add ModelElement to your metamodel, create it in UML profile for MOF
> >>(without the UML definition), trasform it to MOF and then add the
> >>clustered import and replace references from your ModelElement to UML
> >>Model Element manually.
> >>Martin
> >>
> >>Pieter Van Gorp wrote:
> >>
> >>
> >>
> >>>Hi,
> >>>I want to use a minimal metamodel for storing traceability
> >>>information.  Right now, I only use two MOF classes: Trace and Node.
> >>>The node class has an attribute "role" of type String and an attribute
> >>>"content" whose type is the superclass of the metamodel of the
> >>>language for modeling applications.  In the case of UML, this is
> >>>ModelElement.
> >>>
> >>>The UML models need to be stored in plain UML-XMI.  Therefore, I think
> >>>my "Tracing" metamodel needs to cluster the UML metamodel.  Hence my
> >>>question: how do I represent the UML 1.4 metamodel in the UML profile
> >>>for MOF?  On the NetBeans MM site, I could not find the UML-XMI
> >>>defining the UML metamodel but only the MOF-XMI.  Then again, I don't
> >>>know if the UML profile for MOF actually requires the UML definition
> >>>of all clustered metamodels... perhaps I can use an empty package with
> >>>the proper tags on it as a stub for "the" actual UML metapackage?
> >>>
> >>>Are there any examples of clustering the UML?  If not, could you
> >>>please help me creating such an example?
> >>>
> >>>Thanks a lot in advance,
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> 
>
traceMMmof.xml (text/xml, 10.3 KB)
<?xml version = '1.0' encoding = 'ISO-8859-1' ?>
<XMI xmi.version = '1.2' xmlns:Model = 'org.omg.xmi.namespace.Model' timestamp = 'Tue Jul 19 20:49:52 CEST 2005'>
  <XMI.header>
    <XMI.documentation>
      <XMI.exporter>Netbeans XMI Writer</XMI.exporter>
      <XMI.exporterVersion>1.0</XMI.exporterVersion>
    </XMI.documentation>
  </XMI.header>
  <XMI.content>
    <Model:Package xmi.id = 'a1' name = 'PrimitiveTypes' annotation = '' isRoot = 'true'
      isLeaf = 'true' isAbstract = 'false' visibility = 'public_vis'>
      <Model:Namespace.contents>
        <Model:PrimitiveType xmi.id = 'a2' name = 'Integer' annotation = '' isRoot = 'true'
          isLeaf = 'true' isAbstract = 'false' visibility = 'public_vis'/>
        <Model:PrimitiveType xmi.id = 'a3' name = 'Long' annotation = '' isRoot = 'true'
          isLeaf = 'true' isAbstract = 'false' visibility = 'public_vis'/>
        <Model:PrimitiveType xmi.id = 'a4' name = 'Float' annotation = '' isRoot = 'true'
          isLeaf = 'true' isAbstract = 'false' visibility = 'public_vis'/>
        <Model:PrimitiveType xmi.id = 'a5' name = 'Double' annotation = '' isRoot = 'true'
          isLeaf = 'true' isAbstract = 'false' visibility = 'public_vis'/>
        <Model:PrimitiveType xmi.id = 'a6' name = 'Boolean' annotation = '' isRoot = 'true'
          isLeaf = 'true' isAbstract = 'false' visibility = 'public_vis'/>
        <Model:PrimitiveType xmi.id = 'a7' name = 'String' annotation = '' isRoot = 'true'
          isLeaf = 'true' isAbstract = 'false' visibility = 'public_vis'/>
        <Model:PrimitiveType xmi.id = 'a8' name = 'Object' annotation = '' isRoot = 'true'
          isLeaf = 'true' isAbstract = 'false' visibility = 'public_vis'/>
      </Model:Namespace.contents>
    </Model:Package>
    <Model:Package xmi.id = 'a9' name = 'tracing' annotation = '' isRoot = 'false'
      isLeaf = 'false' isAbstract = 'false' visibility = 'public_vis'>
      <Model:Namespace.contents>
        <Model:Tag xmi.id = 'a10' name = 'javax.jmi.packagePrefix' annotation = ''
          tagId = 'javax.jmi.packagePrefix'>
          <Model:Tag.values>be.ac.ua.fots.metamodels</Model:Tag.values>
          <Model:Tag.elements>
            <Model:Package xmi.idref = 'a9'/>
          </Model:Tag.elements>
        </Model:Tag>
        <Model:Association xmi.id = 'a11' name = 'nodecontent' annotation = '' isRoot = 'false'
          isLeaf = 'false' isAbstract = 'false' visibility = 'public_vis' isDerived = 'false'>
          <Model:Namespace.contents>
            <Model:AssociationEnd xmi.id = 'a12' annotation = '' isNavigable = 'false'
              aggregation = 'none' isChangeable = 'true' name='node'>
              <Model:AssociationEnd.multiplicity>
                <XMI.field>1</XMI.field>
                <XMI.field>1</XMI.field>
                <XMI.field>false</XMI.field>
                <XMI.field>true</XMI.field>
              </Model:AssociationEnd.multiplicity>
              <Model:TypedElement.type>
                <Model:Class xmi.idref = 'a13'/>
              </Model:TypedElement.type>
            </Model:AssociationEnd>
            <Model:AssociationEnd xmi.id = 'a14' name = 'content' annotation = '' isNavigable = 'true'
              aggregation = 'none' isChangeable = 'true'>
              <Model:AssociationEnd.multiplicity>
                <XMI.field>1</XMI.field>
                <XMI.field>1</XMI.field>
                <XMI.field>false</XMI.field>
                <XMI.field>true</XMI.field>
              </Model:AssociationEnd.multiplicity>
              <Model:TypedElement.type>
				  <Model:Class href= 'M2_DiagramInterchangeModel.xml|a141' /> <!-- was: xmi.idref = 'a15' --> <!-- perhaps href should be idref without mentioning XMI file because import works really good? -->
              </Model:TypedElement.type>
            </Model:AssociationEnd>
          </Model:Namespace.contents>
        </Model:Association>
        <Model:Class xmi.id = 'a16' name = 'Trace' annotation = '' isRoot = 'false'
          isLeaf = 'false' isAbstract = 'false' visibility = 'public_vis' isSingleton = 'false'>
          <Model:Namespace.contents>
            <Model:Reference xmi.id = 'a17' name = 'node' annotation = '' scope = 'instance_level'
              visibility = 'public_vis' isChangeable = 'true'>
              <Model:StructuralFeature.multiplicity>
                <XMI.field>-1</XMI.field>
                <XMI.field>-1</XMI.field>
                <XMI.field>false</XMI.field>
                <XMI.field>true</XMI.field>
              </Model:StructuralFeature.multiplicity>
              <Model:TypedElement.type>
                <Model:Class xmi.idref = 'a13'/>
              </Model:TypedElement.type>
              <Model:Reference.referencedEnd>
                <Model:AssociationEnd xmi.idref = 'a18'/>
              </Model:Reference.referencedEnd>
            </Model:Reference>
          </Model:Namespace.contents>
        </Model:Class>
        <Model:Class xmi.id = 'a13' name = 'Node' annotation = '' isRoot = 'false'
          isLeaf = 'false' isAbstract = 'false' visibility = 'public_vis' isSingleton = 'false'>
          <Model:Namespace.contents>
            <Model:Attribute xmi.id = 'a19' name = 'role' annotation = '' scope = 'instance_level'
              visibility = 'public_vis' isChangeable = 'true' isDerived = 'false'>
              <Model:StructuralFeature.multiplicity>
                <XMI.field>1</XMI.field>
                <XMI.field>1</XMI.field>
                <XMI.field>false</XMI.field>
                <XMI.field>false</XMI.field>
              </Model:StructuralFeature.multiplicity>
              <Model:TypedElement.type>
                <Model:PrimitiveType xmi.idref = 'a7'/>
              </Model:TypedElement.type>
            </Model:Attribute>
            <Model:Reference xmi.id = 'a20' name = 'trace' annotation = '' scope = 'instance_level'
              visibility = 'public_vis' isChangeable = 'true'>
              <Model:StructuralFeature.multiplicity>
                <XMI.field>1</XMI.field>
                <XMI.field>1</XMI.field>
                <XMI.field>false</XMI.field>
                <XMI.field>true</XMI.field>
              </Model:StructuralFeature.multiplicity>
              <Model:TypedElement.type>
                <Model:Class xmi.idref = 'a16'/>
              </Model:TypedElement.type>
              <Model:Reference.referencedEnd>
                <Model:AssociationEnd xmi.idref = 'a21'/>
              </Model:Reference.referencedEnd>
            </Model:Reference>
            <Model:Reference xmi.id = 'a22' name = 'content' annotation = '' scope = 'instance_level'
              visibility = 'public_vis' isChangeable = 'true'>
              <Model:StructuralFeature.multiplicity>
                <XMI.field>1</XMI.field>
                <XMI.field>1</XMI.field>
                <XMI.field>false</XMI.field>
                <XMI.field>true</XMI.field>
              </Model:StructuralFeature.multiplicity>
              <Model:TypedElement.type>
                <Model:Class href= 'M2_DiagramInterchangeModel.xml|a141' />
              </Model:TypedElement.type>
              <Model:Reference.referencedEnd>
                <Model:AssociationEnd xmi.idref = 'a14'/>
              </Model:Reference.referencedEnd>
            </Model:Reference>
          </Model:Namespace.contents>
        </Model:Class>
        <Model:Association xmi.id = 'a23' name = 'tracenodes' annotation = '' isRoot = 'false'
          isLeaf = 'false' isAbstract = 'false' visibility = 'public_vis' isDerived = 'false'>
          <Model:Namespace.contents>
            <Model:AssociationEnd xmi.id = 'a21' name = 'trace' annotation = '' isNavigable = 'true'
              aggregation = 'none' isChangeable = 'true'>
              <Model:AssociationEnd.multiplicity>
                <XMI.field>1</XMI.field>
                <XMI.field>1</XMI.field>
                <XMI.field>false</XMI.field>
                <XMI.field>true</XMI.field>
              </Model:AssociationEnd.multiplicity>
              <Model:TypedElement.type>
                <Model:Class xmi.idref = 'a16'/>
              </Model:TypedElement.type>
            </Model:AssociationEnd>
            <Model:AssociationEnd xmi.id = 'a18' name = 'node' annotation = '' isNavigable = 'true'
              aggregation = 'none' isChangeable = 'true'>
              <Model:AssociationEnd.multiplicity>
                <XMI.field>-1</XMI.field>
                <XMI.field>-1</XMI.field>
                <XMI.field>false</XMI.field>
                <XMI.field>true</XMI.field>
              </Model:AssociationEnd.multiplicity>
              <Model:TypedElement.type>
                <Model:Class xmi.idref = 'a13'/>
              </Model:TypedElement.type>
            </Model:AssociationEnd>
          </Model:Namespace.contents>
        </Model:Association>
        <Model:Import xmi.id = 'a24' name = 'PrimitiveTypes' annotation = '' visibility = 'public_vis'
          isClustered = 'false'>
          <Model:Import.importedNamespace>
            <Model:Package xmi.idref = 'a1'/>
          </Model:Import.importedNamespace>
        </Model:Import>
        <Model:Import xmi.id = 'a25' name = 'UML' annotation = '' visibility = 'public_vis' isClustered = 'true'>
          <Model:Import.importedNamespace>
			  <Model:Package href= 'M2_DiagramInterchangeModel.xml|a940' /> <!-- was: xmi.idref = 'a26' -->
          </Model:Import.importedNamespace>
        </Model:Import>
      </Model:Namespace.contents>
  </Model:Package>
  <!--
    <Model:Package xmi.id = 'a26' name = 'core' annotation = '' isRoot = 'false'
      isLeaf = 'false' isAbstract = 'false' visibility = 'public_vis'>
      <Model:Namespace.contents>
        <Model:Tag xmi.id = 'a27' name = 'javax.jmi.packagePrefix' annotation = ''
          tagId = 'javax.jmi.packagePrefix'>
          <Model:Tag.values>org.omg.uml</Model:Tag.values>
          <Model:Tag.elements>
            <Model:Package xmi.idref = 'a26'/>
          </Model:Tag.elements>
        </Model:Tag>
        <Model:Class xmi.id = 'a15' name = 'ModelElement' annotation = '' isRoot = 'false'
          isLeaf = 'false' isAbstract = 'false' visibility = 'public_vis' isSingleton = 'false'/>
      </Model:Namespace.contents>
  </Model:Package>
  -->
	</XMI.content>
</XMI>
TestMDR.java (text/x-java, 9.9 KB)
package be.ac.ua.fots.motmot.prototypes.crossreferences;

import java.util.Iterator;
import java.util.List;
import java.util.LinkedList;
import java.util.Collection;

import javax.jmi.model.ModelPackage;
import javax.jmi.model.MofClass;
import javax.jmi.model.MofPackage;
import javax.jmi.reflect.RefPackage;
import javax.jmi.reflect.RefClass;
import javax.jmi.reflect.InvalidNameException;

import org.omg.uml.foundation.core.*;
import org.omg.uml.foundation.datatypes.*;
import org.omg.uml.modelmanagement.*;

import org.netbeans.api.mdr.*;
import org.netbeans.api.xmi.*;

import java.net.URL;
import java.io.*;

import junit.framework.*;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;

import be.ac.ua.fots.metamodels.tracing.*;

/**
 * Test MDR support for references across extents
 */
public class TestMDR extends TestCase {
  private static Model model= null; // made static because it should be initialized with the calls from the maven plugin
  private static Logger logger= Logger.getLogger(TestMDR.class);
  
	static {
	    // configure MDR to use an in-memory storage implementation
		System.setProperty(
				"org.netbeans.mdr.storagemodel.StorageFactoryClassName",
				"org.netbeans.mdr.persistence.btreeimpl.btreestorage.BtreeFactory");
//			"org.netbeans.mdr.persistence.memoryimpl.StorageFactoryImpl");// in-mem

		// set the JMI logging so output does not go to standard out
		System.setProperty("org.netbeans.lib.jmi.Logger.fileName", "mdr.log");
	};  
  /*
   * user properties
   */
  private final URL     appMMurl= TestMDR.class.getResource("../../../../../../../metamodel.xml"); // MM for applications
  private final URL     appMurl= TestMDR.class.getResource("../../../../../../../model.xml"); // application model
  private final URL     traceMMurl= TestMDR.class.getResource("../../../../../../../traceMMmof.xml"); // MM for traces
  // note: no URL for trace model since it is save as BTX only
  private final String  traceMextentName= "tracesFor_"+appMurl.toExternalForm();
  private File          umlAttrsTraceXMIfile= new File("tracebetweenUmlAttrsTest.xml");
  /*
   * lifecycle fields (set by setup())
   */ 
 
	private MDRepository  repo= null;
  // for models
	private RefPackage    appMextent= null;
  // for traces
  private RefPackage    traceMextent= null;
  private MofPackage    traceMainMP= null;

  /**
   * Constructor for respecting junit lifecycle only...
   */
  public TestMDR(String name) {
    super(name);
    Thread.currentThread().setContextClassLoader(TestMDR.class.getClassLoader());
		repo = MDRManager.getDefault().getDefaultRepository();
	  // enable assertions (since '-ea' cannot easily be passed to the java command of the maven plugin)
	  Thread.currentThread().getContextClassLoader().setDefaultAssertionStatus(true);
    URL url = TestMDR.class.getResource("log4j.xml");
	  DOMConfigurator.configure(url);
  }
  
 protected void setUp() throws Exception {
    logger.debug("setUp");
		repo.beginTrans(true);
    initMDR();
  }

  protected void tearDown() throws Exception {
    logger.debug("tearDown");
    logger.debug("Shutting down MDR...");
		repo.endTrans(false);
		MDRManager.getDefault().shutdownAll();
  }
  
  /**
   * Write the UML loaded from initMDR() back to XMI 
   */
  public void testWriteAppModel() {
    try {
			logger.info("Writing loaded appMextent to XMI...");
      String modelRelPath= (new File(appMurl.getFile())).getName();
      logger.debug("modelRelPath: "+modelRelPath);
			XMIWriterFactory.getDefault().createXMIWriter().write(new FileOutputStream(
						new File(modelRelPath.substring(0,modelRelPath.lastIndexOf('.'))
							+"_trans"+
							modelRelPath.substring( // extension
								modelRelPath.lastIndexOf('.'),
								modelRelPath.length()
							)
						)
					), 
					appMextent, "1.2");
      logger.info("'appMextent' written to XMI");
    } catch (Exception e) {
      logger.error("Test failed");
      e.printStackTrace();
      Assert.fail();
    }	
  }

  /**
   * Create a trace to a UML class.
   *
   * We're loading the UML extent into the trace extent when doing createExtent in initMDR.
   * Alternatively, one could explicitly read the UML XMI into the proper package of the trace extent.
   */

  public void testCreateTraceBetweenUmlAttributes() {
    try {
      Assert.assertTrue("Typing problem with UML application model", appMextent instanceof org.omg.uml.UmlPackage);
      org.omg.uml.UmlPackage umlPackage= (org.omg.uml.UmlPackage)appMextent;
      org.omg.uml.foundation.core.CorePackage corePackage= umlPackage.getCore();
      Collection attributes= corePackage.getAttribute().refAllOfClass();
      logger.debug("number of attributes: "+attributes.size());
      Iterator attributeIt= attributes.iterator();
      Attribute a1= (Attribute)attributeIt.next();
      Attribute a2= (Attribute)attributeIt.next();
      logger.info("creating trace from attribute '"+a1.getName()+"' to attribute '"+a2.getName()+"'.");
      TracingPackage handleToTraceModel= (TracingPackage)traceMextent; 
      Trace trace= handleToTraceModel.getTrace().createTrace();
      // add node1
      logger.debug("adding node1");
      be.ac.ua.fots.metamodels.tracing.Node node1= handleToTraceModel.getNode().createNode("reference to a1");
      logger.debug("adding association from trace to node1");
      handleToTraceModel.getTracenodes().add(trace, node1);
      logger.debug("adding association from node1 to a1");
      handleToTraceModel.getNodecontent().add(node1, a1);
      // add node2
      logger.debug("adding node2");
      be.ac.ua.fots.metamodels.tracing.Node node2= handleToTraceModel.getNode().createNode("reference to a2");
      handleToTraceModel.getTracenodes().add(trace, node2);
      logger.debug("adding association from node2 to a2");
      handleToTraceModel.getNodecontent().add(node2, a2);

      logger.info("Writing traceMextent to XMI");
      XMIWriterFactory.getDefault().createXMIWriter().write(
        new FileOutputStream(umlAttrsTraceXMIfile),
        traceMextent, 
        "1.2"
      );
		} catch (Exception e) {
      logger.error("Test failed");
      e.printStackTrace();
      Assert.fail(e.getMessage());
    } 
	}

  
  /**
   * Read the trace model created by 'testCreateTraceBetweenUmlAttributes' from XMI
   */
  public void testReadTraceBetweenUmlAttributes() {
    try {
      logger.info("Trying to read trace between UML attributes from XMI again");
      XMIReader xmiReader = XMIReaderFactory.getDefault().createXMIReader();
      RefPackage loadedTraceExtent=  (RefPackage) repo.createExtent("testTracesFor_"+appMurl.toExternalForm(), traceMainMP, new RefPackage[]{appMextent});
      logger.info("Start reading...");
      xmiReader.read(umlAttrsTraceXMIfile.toURI().toString(), loadedTraceExtent);
      logger.debug("class of loadedTraceExtent: "+loadedTraceExtent.getClass());
      TracingPackage handleToTraceModel= (TracingPackage)loadedTraceExtent;
      logger.debug("Number of nodes in traceMextent: "+Integer.toString(handleToTraceModel.getNode().refAllOfClass().size()));
      Assert.assertTrue("Two nodes were created in other test but they are not read here...", handleToTraceModel.getNode().refAllOfClass().size()==2);
    } catch (Exception e) {
      logger.error("Test failed");
      e.printStackTrace();
      Assert.fail(e.getMessage());
    }
  }
 
  /**
   * Initialize model repository: read models from XMI
   */
  private void initMDR() throws Exception {
    logger.debug("Initializing MDR");
    XMIReader xmiReader = XMIReaderFactory.getDefault().createXMIReader();
    try {
      logger.debug("get extent - try ("+appMurl+")");
      // initialize application extent
      appMextent= (RefPackage) repo.createExtent(appMurl.toExternalForm(), getMainMP(appMMurl, "UML", xmiReader));
      logger.info("Reading 'appMextent' from XMI ("+appMurl.toExternalForm()+")");
	  	Collection col= xmiReader.read(appMurl.toExternalForm(), appMextent);
      logger.debug("col.size for model.xml: "+col.size());
    } catch (Exception e) {
      logger.debug("create extent error: "+e.getMessage());
      logger.debug("get extent - retry ("+appMurl+")");
      // try again by opening existing extent (BTX)
      appMextent= (RefPackage) repo.getExtent(appMurl.toExternalForm());
    }
    logger.debug("get extent - done");
    // initialize tracing extent 
    traceMainMP= getMainMP(traceMMurl, "tracing", xmiReader);
    try {
      logger.debug("get extent - try ("+traceMextentName+")");
      logger.info("Using cluster of appMextent ("+new RefPackage[]{appMextent}+")");
      traceMextent= (RefPackage) repo.createExtent(traceMextentName, traceMainMP, new RefPackage[]{appMextent});
    } catch (Exception e) {
      logger.debug("create extent error: "+e.getMessage());
      logger.debug("get extent - retry ("+traceMextentName+")");
      traceMextent= (RefPackage) repo.getExtent(traceMextentName);
   }
    logger.debug("get extent - done ("+traceMextentName+")");
 }

 /**
  * Get the main metapackage of the given metamodel
  * @throws Exception thrown when main meta package not found in metamodel extent
  */
  private MofPackage getMainMP(URL mmURL, String mainMPname, XMIReader xmiReader) throws Exception {
    ModelPackage mmExtent= null;
    try {
      mmExtent = (ModelPackage) repo.createExtent(mmURL.toExternalForm());
  		xmiReader.read(mmURL.toExternalForm(), mmExtent);
    } catch (Exception e) {
      // try again by opening existing extent (BTX)
      mmExtent= (ModelPackage) repo.getExtent(mmURL.toExternalForm());
    }
		Collection metaPkgs = mmExtent.getMofPackage().refAllOfClass();
		Iterator it = metaPkgs.iterator();
	  MofPackage mainMP= null;
		while ((mainMP == null) && it.hasNext()) {
			Object obj = it.next();
			// check necessary because there are tags here as well, not just packages
			if (obj instanceof MofPackage) {
				MofPackage pkg = (MofPackage) obj;
				if (mainMPname.equals(pkg.getName())) {
					mainMP = pkg;
				}
			}
		}
		if (mainMP == null)
			throw new Exception("Main meta package not found");
    return mainMP;
  }
}
maven.log (text/x-log, 6.6 KB)
 __  __
|  \/  |__ _Apache__ ___
| |\/| / _` \ V / -_) ' \  ~ intelligent projects ~
|_|  |_\__,_|\_/\___|_||_|  v. 1.0.2

build:start:

java:prepare-filesystem:

java:compile:
    [echo] Compiling to /home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes
    [echo] 
==========================================================

  NOTE: Targetting JVM 1.4, classes
  will not run on earlier JVMs

==========================================================
          

java:jar-resources:

test:prepare-filesystem:

test:test-resources:

test:compile:

test:test:
    [junit] Running be.ac.ua.fots.motmot.prototypes.crossreferences.TestMDR
DEBUG [TestMDR] setUp
DEBUG [TestMDR] Initializing MDR
DEBUG [TestMDR] get extent - try (file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
DEBUG [TestMDR] create extent error: Package extent named 'file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml' already exists.
DEBUG [TestMDR] get extent - retry (file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
DEBUG [TestMDR] get extent - done
DEBUG [TestMDR] get extent - try (tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
INFO  [TestMDR] Using cluster of appMextent ([Ljavax.jmi.reflect.RefPackage;@898540)
DEBUG [TestMDR] create extent error: Package extent named 'tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml' already exists.
DEBUG [TestMDR] get extent - retry (tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
DEBUG [TestMDR] get extent - done (tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
INFO  [TestMDR] Writing loaded appMextent to XMI...
DEBUG [TestMDR] modelRelPath: model.xml
INFO  [TestMDR] 'appMextent' written to XMI
DEBUG [TestMDR] tearDown
DEBUG [TestMDR] Shutting down MDR...
DEBUG [TestMDR] setUp
DEBUG [TestMDR] Initializing MDR
DEBUG [TestMDR] get extent - try (file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
DEBUG [TestMDR] create extent error: Package extent named 'file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml' already exists.
DEBUG [TestMDR] get extent - retry (file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
DEBUG [TestMDR] get extent - done
DEBUG [TestMDR] get extent - try (tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
INFO  [TestMDR] Using cluster of appMextent ([Ljavax.jmi.reflect.RefPackage;@1123eb0)
DEBUG [TestMDR] create extent error: Package extent named 'tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml' already exists.
DEBUG [TestMDR] get extent - retry (tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
DEBUG [TestMDR] get extent - done (tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
DEBUG [TestMDR] number of attributes: 89
INFO  [TestMDR] creating trace from attribute 'second' to attribute 'minute'.
DEBUG [TestMDR] adding node1
DEBUG [TestMDR] adding association from trace to node1
DEBUG [TestMDR] adding association from node1 to a1
DEBUG [TestMDR] adding node2
DEBUG [TestMDR] adding association from node2 to a2
INFO  [TestMDR] Writing traceMextent to XMI
DEBUG [TestMDR] tearDown
DEBUG [TestMDR] Shutting down MDR...
DEBUG [TestMDR] setUp
DEBUG [TestMDR] Initializing MDR
DEBUG [TestMDR] get extent - try (file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
DEBUG [TestMDR] create extent error: Package extent named 'file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml' already exists.
DEBUG [TestMDR] get extent - retry (file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
DEBUG [TestMDR] get extent - done
DEBUG [TestMDR] get extent - try (tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
INFO  [TestMDR] Using cluster of appMextent ([Ljavax.jmi.reflect.RefPackage;@1422384)
DEBUG [TestMDR] create extent error: Package extent named 'tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml' already exists.
DEBUG [TestMDR] get extent - retry (tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
DEBUG [TestMDR] get extent - done (tracesFor_file:/home/pvgorp/connected/cvswork/MoTMoT/prototypes/crossreferences/target/classes/be/ac/ua/fots/motmot/prototypes/crossreferences/../../../../../../../model.xml)
INFO  [TestMDR] Trying to read trace between UML attributes from XMI again
ERROR [TestMDR] Test failed
DEBUG [TestMDR] tearDown
DEBUG [TestMDR] Shutting down MDR...
    [junit] Tests run: 3, Failures: 1, Errors: 0, Time elapsed: 8.653 sec
    [junit] [ERROR] TEST be.ac.ua.fots.motmot.prototypes.crossreferences.TestMDR FAILED
Total time: 16 seconds
Finished at: Wed Jul 20 16:37:04 CEST 2005