EProxy URI does not resolve in ecore model

2019-04-22 20:50发布

问题:

In my Ecore model all types that come from outside the current model are not resolved by their proxies. All fields of the object returned by getType() are null and only the storage type URI is filled in at runtime.

Here is an extract of my model:

<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="model" nsURI="http:///model.ecore" nsPrefix="model">
  <eSubpackages name="general" nsURI="http:///model/general.ecore" nsPrefix="model.general">
    <eClassifiers xsi:type="ecore:EClass" name="Address">
      <eStructuralFeatures xsi:type="ecore:EAttribute" name="street" ordered="false" lowerBound="1"
      eType="ecore:EDataType platform:/plugin/org.eclipse.uml2.types/model/Types.ecore#//String"/>
    </eClassifiers>
  </eSubpackages>
</ecore:EPackage>

Currently if I make an

Address a = <address item from model>
Type t = a.getType();

all fields of t will be null and the toString() returns something like:

org.eclipse.uml2.uml.internal.impl.PrimitiveTypeImpl@6e315086 (eProxyURI:
 platform:/plugin/org.eclipse.uml2.types/model/Types.ecore#//String)

回答1:

Change the proxy URIs from platform:/plugin/org.eclipse.uml2.types/model/Types.ecore#//String to contain the NS URI of the package that contains the data type: http://www.eclipse.org/uml2/4.0.0/Types#//String.

Note that this change can only be done in a textual editor.