Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Same Model Load method returns different results
Same Model Load method returns different results [message #624747] Wed, 12 September 2007 21:50
Jerry is currently offline JerryFriend
Messages: 32
Registered: July 2009
Member
Dear,

I have a uml model which is defined in Eclipse (let's say mymodel.uml, it
contains a model called "umltry"). There are profiles applied in this
model. Starting a new Eclipse, simply I would like to open that model and
extract information. I used the way given in the "instruction to UML"
profiles" article, but got strange results:

Case1) I use following referenced libararies
(Eclipse32)org.eclipse.osgi_3.2.0.V20060601.jar,
org.eclipse.uml2.common_1.2.3v200702141227.jar,
org.eclipse.uml2.uml.resources_2.0.3v20070214227.jar,
org.eclipse.emf.ecore.xmi_2.2.1v200701181044.jar,
org.eclipse.emf.ecore_2.2.2.v200701181044.jar... etc.

Case2) I use Eclipse 33 instead: org.eclipse.osgi_3.3.0.V20070530.jar,
org.eclipse.uml2.common_1.3.0v200706251652.jar,
org.eclipse.uml2.uml.resources_2.1.0v200706251652.jar,
org.eclipse.emf.ecore.xmi_2.3.0.v200706262000.jar,
org.eclipse.emf.ecore_2.3.0.v200706262000.jar... etc.
<<
public static void main(String[] arg){
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
URI uri = URI.createFileURI("C:\\mymodel.uml");
Model mymodels= (Model) load(uri);

//(**Here it returns null in debug in both Case1 and Case2. Why?**)

ResourceSet resSet=new ResourceSetImpl();
resSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resSet.getResourceFactoryRegistry().getExtensionToFactoryMap ().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
Resource res = resSet.getResource(uri,true);

//(** In Case1:Here the first element of the content of the res
is: org.eclipse.uml2.uml.internal.impl.ModelImpl@18b995c (name: umltry,
visibility: <unset>) (visibility: public) (viewpoint: <unset>). BUT in
Case2, the first element in the content of res is:
org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@e5ddd0 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@145959c (name: Model) **)

Model UMLmodel = (Model)res.getContents().get(0);

//(**if I continue with the above line, in Case1, I get the model
correctly. In Case2 I got Exception in thread "main"
java.lang.ClassCastException:
org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl **)
//** Following is the load method used**
protected static org.eclipse.uml2.uml.Package load(URI uri) {
org.eclipse.uml2.uml.Package package_ = null;
org.eclipse.uml2.uml.Model model =null;
try {
Resource resource = RESOURCE_SET.getResource(uri, true);
package_ = (org.eclipse.uml2.uml.Package) EcoreUtil
.getObjectByType(resource.getContents(), UMLPackage.Literals.PACKAGE);
model = (Model)EcoreUtil.getObjectByType(resource.getContents(),
UMLPackage.Literals.MODEL);
}
catch (WrappedException we) {
err(we.getMessage());
System.exit(1);
}
return package_;
}

>>
Could you please explain this? How could I load the model and extract
information from it in Eclipse3.3?
Thank you very much!
Previous Topic:[Announce] MDT UML2 2.0.4 is available
Next Topic:Editor for profiled UML
Goto Forum:
  


Current Time: Fri Apr 19 11:08:35 GMT 2024

Powered by FUDForum. Page generated in 0.02473 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top