Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 333605 - [Typesystem][UML] does not support all Built-In Primitive Types
Summary: [Typesystem][UML] does not support all Built-In Primitive Types
Status: CLOSED FIXED
Alias: None
Product: M2T
Classification: Modeling
Component: Xpand (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: M4   Edit
Assignee: Karsten Thoms CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-05 15:29 EST by Christian Dietrich CLA
Modified: 2017-10-31 10:58 EDT (History)
0 users

See Also:
karsten.thoms: iplog-
karsten.thoms: kepler+


Attachments
Sample Project and Possible Workaround (10.94 KB, application/zip)
2011-01-05 15:32 EST, Christian Dietrich CLA
karsten.thoms: iplog+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Dietrich CLA 2011-01-05 15:29:05 EST
Build Identifier: 

The Xtend UML2MetaModel does not Support (all) Primitive Types that may be necessary to Process a UML Model (Especially with Profiles) e.g. pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml#EString is not supported 

Reproducible: Always

Steps to Reproduce:
1. take a profile like this

<?xml version="1.0" encoding="UTF-8"?>
<uml:Profile xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xmi:id="_YwjAYKrYEd-j_oPJcQlq3g" name="test" metaclassReference="_fchMUKrcEd-gNa9dLIEAfg">
  <eAnnotations xmi:id="_q3EkEKrcEd-gNa9dLIEAfg" source="http://www.eclipse.org/uml2/2.0.0/UML">
    <contents xmi:type="ecore:EPackage" xmi:id="_gUL0gRkDEeC2EYrCLXJCEg" name="test" nsURI="http:///schemas/test/_gUL0gBkDEeC2EYrCLXJCEg/4" nsPrefix="test">
      <eClassifiers xmi:type="ecore:EClass" xmi:id="_gUL0ghkDEeC2EYrCLXJCEg" name="Bean">
        <eAnnotations xmi:id="_gUL0gxkDEeC2EYrCLXJCEg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_oJEpkKrYEd-j_oPJcQlq3g"/>
        <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_gUL0hBkDEeC2EYrCLXJCEg" name="base_Class" ordered="false" lowerBound="1">
          <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
        </eStructuralFeatures>
        <eStructuralFeatures xmi:type="ecore:EAttribute" xmi:id="_gUL0hhkDEeC2EYrCLXJCEg" name="sample" ordered="false" lowerBound="1" defaultValueLiteral="dhd">
          <eType xmi:type="ecore:EDataType" href="http://www.eclipse.org/emf/2002/Ecore#//EString"/>
        </eStructuralFeatures>
      </eClassifiers>
    </contents>
    <contents xmi:type="ecore:EPackage" xmi:id="_Ae3eMBkCEeC2EYrCLXJCEg" name="test" nsURI="http:///schemas/test/_AekjQBkCEeC2EYrCLXJCEg/3" nsPrefix="test">
      <eClassifiers xmi:type="ecore:EClass" xmi:id="_Ae3eMRkCEeC2EYrCLXJCEg" name="Bean">
        <eAnnotations xmi:id="_Ae3eMhkCEeC2EYrCLXJCEg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_oJEpkKrYEd-j_oPJcQlq3g"/>
        <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_Ae3eMxkCEeC2EYrCLXJCEg" name="base_Class" ordered="false" lowerBound="1">
          <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
        </eStructuralFeatures>
        <eStructuralFeatures xmi:type="ecore:EAttribute" xmi:id="_Ae3eNRkCEeC2EYrCLXJCEg" name="sample" ordered="false" lowerBound="1" eType="_Ae3eNxkCEeC2EYrCLXJCEg" defaultValueLiteral="dhd"/>
      </eClassifiers>
      <eClassifiers xmi:type="ecore:EDataType" xmi:id="_Ae3eNxkCEeC2EYrCLXJCEg" name="MyType" instanceClassName="MyType">
        <eAnnotations xmi:id="_Ae3eOBkCEeC2EYrCLXJCEg" source="http://www.eclipse.org/uml2/2.0.0/UML"/>
      </eClassifiers>
    </contents>
    <contents xmi:type="ecore:EPackage" xmi:id="_ydcK0BkBEeC2EYrCLXJCEg" name="test" nsURI="http:///schemas/test/_yc_e4BkBEeC2EYrCLXJCEg/2" nsPrefix="test">
      <eClassifiers xmi:type="ecore:EClass" xmi:id="_ydcK0RkBEeC2EYrCLXJCEg" name="Bean">
        <eAnnotations xmi:id="_ydcK0hkBEeC2EYrCLXJCEg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_oJEpkKrYEd-j_oPJcQlq3g"/>
        <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_ydcK0xkBEeC2EYrCLXJCEg" name="base_Class" ordered="false" lowerBound="1">
          <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
        </eStructuralFeatures>
        <eStructuralFeatures xmi:type="ecore:EAttribute" xmi:id="_ydcK1RkBEeC2EYrCLXJCEg" name="sample" ordered="false" lowerBound="1" eType="_ydcK1xkBEeC2EYrCLXJCEg"/>
      </eClassifiers>
      <eClassifiers xmi:type="ecore:EDataType" xmi:id="_ydcK1xkBEeC2EYrCLXJCEg" name="MyType" instanceClassName="MyType">
        <eAnnotations xmi:id="_ydcK2BkBEeC2EYrCLXJCEg" source="http://www.eclipse.org/uml2/2.0.0/UML"/>
      </eClassifiers>
    </contents>
    <contents xmi:type="ecore:EPackage" xmi:id="_-xyjQBj_EeC2EYrCLXJCEg" name="test" nsURI="http:///schemas/test/_-xWeYBj_EeC2EYrCLXJCEg/1" nsPrefix="test">
      <eClassifiers xmi:type="ecore:EClass" xmi:id="_-xyjQRj_EeC2EYrCLXJCEg" name="Bean">
        <eAnnotations xmi:id="_-xyjQhj_EeC2EYrCLXJCEg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_oJEpkKrYEd-j_oPJcQlq3g"/>
        <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_-xyjQxj_EeC2EYrCLXJCEg" name="base_Class" ordered="false" lowerBound="1">
          <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
        </eStructuralFeatures>
        <eStructuralFeatures xmi:type="ecore:EAttribute" xmi:id="_-xyjRRj_EeC2EYrCLXJCEg" name="sample" ordered="false" lowerBound="1" eType="_-xyjRxj_EeC2EYrCLXJCEg"/>
      </eClassifiers>
      <eClassifiers xmi:type="ecore:EDataType" xmi:id="_-xyjRxj_EeC2EYrCLXJCEg" name="MyType" instanceClassName="MyType">
        <eAnnotations xmi:id="_-xyjSBj_EeC2EYrCLXJCEg" source="http://www.eclipse.org/uml2/2.0.0/UML"/>
      </eClassifiers>
    </contents>
    <contents xmi:type="ecore:EPackage" xmi:id="_q3FLIKrcEd-gNa9dLIEAfg" name="test" nsURI="http:///schemas/test/_q3Cu4KrcEd-gNa9dLIEAfg/0" nsPrefix="test">
      <eClassifiers xmi:type="ecore:EClass" xmi:id="_q3FLIarcEd-gNa9dLIEAfg" name="Bean">
        <eAnnotations xmi:id="_q3FLIqrcEd-gNa9dLIEAfg" source="http://www.eclipse.org/uml2/2.0.0/UML" references="_oJEpkKrYEd-j_oPJcQlq3g"/>
        <eStructuralFeatures xmi:type="ecore:EReference" xmi:id="_q3FLI6rcEd-gNa9dLIEAfg" name="base_Class" ordered="false" lowerBound="1">
          <eType xmi:type="ecore:EClass" href="http://www.eclipse.org/uml2/3.0.0/UML#//Class"/>
        </eStructuralFeatures>
      </eClassifiers>
    </contents>
  </eAnnotations>
  <elementImport xmi:id="_inmlEKrYEd-j_oPJcQlq3g">
    <importedElement xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String"/>
  </elementImport>
  <elementImport xmi:id="_fchMUKrcEd-gNa9dLIEAfg">
    <importedElement xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
  </elementImport>
  <packagedElement xmi:type="uml:Stereotype" xmi:id="_oJEpkKrYEd-j_oPJcQlq3g" name="Bean">
    <ownedAttribute xmi:id="_lUFcoKrcEd-gNa9dLIEAfg" name="base_Class" association="_lUEOgKrcEd-gNa9dLIEAfg">
      <type xmi:type="uml:Class" href="pathmap://UML_METAMODELS/UML.metamodel.uml#Class"/>
    </ownedAttribute>
    <ownedAttribute xmi:id="_ZfiqMBj-EeC2EYrCLXJCEg" name="sample">
      <type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/EcorePrimitiveTypes.library.uml#EString"/>
      <defaultValue xmi:type="uml:LiteralString" xmi:id="_sedq8BkBEeC2EYrCLXJCEg" value="dhd"/>
    </ownedAttribute>
  </packagedElement>
  <packagedElement xmi:type="uml:Extension" xmi:id="_lUEOgKrcEd-gNa9dLIEAfg" name="Class_Bean" memberEnd="_lUE1kKrcEd-gNa9dLIEAfg _lUFcoKrcEd-gNa9dLIEAfg">
    <ownedEnd xmi:type="uml:ExtensionEnd" xmi:id="_lUE1kKrcEd-gNa9dLIEAfg" name="extension_Bean" type="_oJEpkKrYEd-j_oPJcQlq3g" aggregation="composite" association="_lUEOgKrcEd-gNa9dLIEAfg"/>
  </packagedElement>
</uml:Profile>


and a sample model like this

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:test="http:///schemas/test/_gUL0gBkDEeC2EYrCLXJCEg/4" xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" xsi:schemaLocation="http:///schemas/test/_gUL0gBkDEeC2EYrCLXJCEg/4 test.profile.uml#_gUL0gRkDEeC2EYrCLXJCEg">
  <uml:Model xmi:id="_0dbQIBkCEeC2EYrCLXJCEg" name="Test">
    <packagedElement xmi:type="uml:Package" xmi:id="_2XkBkBkCEeC2EYrCLXJCEg" name="test">
      <packagedElement xmi:type="uml:Class" xmi:id="_3wY1sBkCEeC2EYrCLXJCEg" name="A"/>
      <packagedElement xmi:type="uml:Class" xmi:id="_5i8YcBkCEeC2EYrCLXJCEg" name="B"/>
    </packagedElement>
    <profileApplication xmi:id="_um_y0BkDEeC2EYrCLXJCEg">
      <eAnnotations xmi:id="_um_y0RkDEeC2EYrCLXJCEg" source="http://www.eclipse.org/uml2/2.0.0/UML">
        <references xmi:type="ecore:EPackage" href="test.profile.uml#_gUL0gRkDEeC2EYrCLXJCEg"/>
      </eAnnotations>
      <appliedProfile href="test.profile.uml#_YwjAYKrYEd-j_oPJcQlq3g"/>
    </profileApplication>
  </uml:Model>
  <test:Bean xmi:id="_wQUhEBkDEeC2EYrCLXJCEg" base_Class="_5i8YcBkCEeC2EYrCLXJCEg" sample="dhdtreteretr"/>
</xmi:XMI>

2. a template like this

«DEFINE main FOR uml::Model»
	«EXPAND main FOREACH ownedElement»
«ENDDEFINE»

«DEFINE main FOR uml::Package»
	«EXPAND main FOREACH ownedElement»
«ENDDEFINE»

«DEFINE main FOR test::Bean»
«FILE name+".txt"»
//«this.getValue(this.getAppliedStereotype(test::Bean.toString()),"sample")»
«ENDFILE»
«ENDDEFINE»

«DEFINE main FOR uml::Class»
«ENDDEFINE»

«DEFINE main FOR uml::Element»
«ENDDEFINE»


3. and a workflow like this

<workflow>
	
	<bean class="org.eclipse.xtend.typesystem.uml2.Setup" standardUML2Setup="true" />
	
	<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri=".." />
	
	<component class="org.eclipse.emf.mwe.utils.Reader">
		<uri value="platform:/resource/xpand.uml.profile.sample/src/model/test.uml" />
		<modelSlot value="model" />
	</component>
	
	<component class="org.eclipse.emf.mwe.utils.DirectoryCleaner">
		<directory value="src-gen" />
	</component>
	
	
	<component class="org.eclipse.xpand2.Generator">
		<metaModel class="org.eclipse.xtend.typesystem.uml2.profile.ProfileMetaModel">
			<profile value="platform:/resource/xpand.uml.profile.sample/src/model/test.profile.uml" />
		</metaModel>
		<metaModel class="org.eclipse.xtend.typesystem.uml2.UML2MetaModel" />
		<expand value="template::Template::main FOR model" />
		<outlet path="src-gen" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
	</component>
	

</workflow>

4. and you ll get an error message like this

2029 ERROR StereotypeType     - Couldn't find type for EcorePrimitiveTypes::EString
Comment 1 Christian Dietrich CLA 2011-01-05 15:31:04 EST
see http://www.eclipse.org/forums/index.php?t=msg&th=202548
Comment 2 Christian Dietrich CLA 2011-01-05 15:32:23 EST
Created attachment 186123 [details]
Sample Project and Possible Workaround
Comment 3 Christian Dietrich CLA 2011-01-05 15:33:07 EST
Here a Possible Workarround

package model;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.emf.mwe.utils.Mapping;
import org.eclipse.xtend.typesystem.Type;
import org.eclipse.xtend.typesystem.uml2.UML2MetaModel;

public class ExtendedUML2Metamodel extends UML2MetaModel {
	
	private Map<String,String> mappings = new HashMap<String,String>();
	
	public void addMapping(Mapping mapping) {
		mappings.put(mapping.getFrom(), mapping.getTo());
	}
	
	@Override
	public Type getTypeForName(String typeName) {
		Type mappedType = null;
		String mappedTypeName = mappings.get(typeName);
		if (mappedTypeName != null) {
			mappedType = getTypeForName(mappedTypeName);
			if (mappedType != null) {
				return mappedType;
			}
		}
		return super.getTypeForName(typeName);
	}

}


	
	<component class="org.eclipse.xpand2.Generator">
		<metaModel class="org.eclipse.xtend.typesystem.uml2.profile.ProfileMetaModel">
			<profile value="platform:/resource/xpand.uml.profile.sample/src/model/test.profile.uml" />
		</metaModel>
		<metaModel class="model.ExtendedUML2Metamodel">
			<mapping from="EcorePrimitiveTypes::EString" to="ecore::EString" />
		</metaModel>
		<expand value="template::Template::main FOR model" />
		<outlet path="src-gen" >
			<postprocessor class="org.eclipse.xpand2.output.JavaBeautifier" />
		</outlet>
	</component>
Comment 4 Karsten Thoms CLA 2012-09-04 07:49:52 EDT
I prefer to come along without configurable mappings yet. The EcorePrimitiveTypes library is discrete, thus the contained types can be mapped hard coded like the other primitive type mappings in UML2MetaModelBase.

The provided example revealed another issue: The classifier "Class" is contained in the package "UML". This was former "uml" with lower case, like the EPackage name. This leads to fail if getTypeForName("UML::Class") is invoked when trying to resolve the Stereotype's super type. Thus, queried types starting with "UML::" have to be mapped to "uml::<Name>".
Comment 5 Karsten Thoms CLA 2012-09-04 08:06:17 EDT
The mentioned additional issue is reported as bug#388232
Comment 6 Karsten Thoms CLA 2012-09-04 08:11:39 EDT
Pushed to master
Comment 7 Karsten Thoms CLA 2013-02-07 06:12:35 EST
Part of Kepler M4 (Version 1.3.0)
Comment 8 Eclipse Webmaster CLA 2017-10-31 10:46:58 EDT
Requested via bug 522520.

-M.
Comment 9 Eclipse Webmaster CLA 2017-10-31 10:58:11 EDT
Requested via bug 522520.

-M.