Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » texo webservice support for nested packages
texo webservice support for nested packages [message #999197] Fri, 11 January 2013 09:50 Go to next message
Donat Mueller is currently offline Donat Mueller
Messages: 11
Registered: January 2013
Location: switzerland
Junior Member
Hi,

I am using nested model packages with the schema <mandator>.<application>.<version>.
To distinguish class names this is required at ecore model level not only at java package name level.
While decoding the qualified classname in ModelUtils.getEClassFromQualifiedName() the segment splitting with the QUALIFIERSEPARATOR is applied just once. Then ePackage.eNS_PREFIX is checked against the extracted qualifier.
In my case having multiple packages with nsprefix v1 this does not help to make the class name unique.

Suggestion split prefix into qualifier components then walk up the epackage hierarchy and check eNS_PREFIX for each component. Or use nsURI but this would break backward compatibility.

Kind regards,
Donat

[Updated on: Fri, 11 January 2013 17:12]

Report message to a moderator

Re: texo webservice support for nested packages [message #999330 is a reply to message #999197] Fri, 11 January 2013 15:55 Go to previous messageGo to next message
Martin Taal is currently offline Martin Taal
Messages: 5326
Registered: July 2009
Senior Member
Hi Donat,
You mean that some of your epackages have the same prefix (v1) so that this prefix is not unique enough?
If so can't you use more unique prefixes?

Not sure what you mean with this part:
> Suggestion split prefix into qualifier components then walk up the epackage hierarchy and check eNS_PREFIX for each
> component. Or use nsURI but this would break backward compatibility.

gr. Martin

On 01/11/2013 03:50 PM, Donat Mueller wrote:
> Hi,
>
> I am using nested model packages with the schema <mandator>.<application>.<version>.
> To distinguish class names this is required at ecore model level not only at java package name level.
> While decoding the qualified classname in ModelUtils.getEClassFromQualifiedName() the segment splitting with the
> QUALIFIERSEPARATOR is applied just once. Then ePackage.eNS_PREFIX is checked against the extracted qualifier.
> In my case having multiple packages with nsprefix v1 this does not help to make the class name unique.
>
> Suggestion split prefix into qualifier components then walk up the epackage hierarchy and check eNS_PREFIX for each
> component. Or use nsURI but this would break backward compatibility.
>
> Kind regards,
> Donat


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: texo webservice support for nested packages [message #999357 is a reply to message #999330] Fri, 11 January 2013 17:30 Go to previous messageGo to next message
Donat Mueller is currently offline Donat Mueller
Messages: 11
Registered: January 2013
Location: switzerland
Junior Member
Hi Martin,

The model package names are generated. The last segment name is the version of the interface. So often two models will have the same version.
In the library sample there is only one package named library. If the package was org.texo.library then the attribute _eclass for Book should have the value org|texo|library|Book.
To assert the qualified model class each component of the package name org, texo and library should match with nsPrefix of the corresponding ecore class.
Hope could explain my point. If not I will try again with some sample code.

Regards,
Donat


Re: texo webservice support for nested packages [message #999373 is a reply to message #999357] Fri, 11 January 2013 18:41 Go to previous messageGo to next message
Donat Mueller is currently offline Donat Mueller
Messages: 11
Registered: January 2013
Location: switzerland
Junior Member
Here the suggested code

 public static EClass getEClassFromQualifiedName(String name) {
    String[] nameSpacePrefix = null;
    String eClassName = name;
    if (eClassName.contains(QUALIFIERSEPARATOR)) {
      String[] components = name.split("\\" + QUALIFIERSEPARATOR);
      nameSpacePrefix = Arrays.copyOfRange(components, 0, components.length - 1);
      eClassName = components[components.length - 1];
    }
    for (ModelPackage modelPackage : ModelResolver.getInstance().getModelPackages()) {
      final EPackage ePackage = modelPackage.getEPackage();
      if (nameSpacePrefix != null && !ePackage.getNsPrefix().equals(nameSpacePrefix[nameSpacePrefix.length - 1])) {
        continue;
      }
      nextClass: for (EClassifier eClassifier : ePackage.getEClassifiers()) {
        if (eClassifier.getName().equals(eClassName)) {
          if (nameSpacePrefix.length>1)	 {
        	  EPackage eSuperPackage = ePackage.getESuperPackage();
              for (int i=nameSpacePrefix.length-2;i>=0;i--) {
            	  if (!eSuperPackage.getNsPrefix().equals(nameSpacePrefix[i])) {
            		  continue nextClass;
            	  }
            	  eSuperPackage = eSuperPackage.getESuperPackage();
              }
        	  
          }
          return (EClass) eClassifier;
        }
      }
    }

...

[Updated on: Fri, 11 January 2013 18:43]

Report message to a moderator

Re: texo webservice support for nested packages [message #999408 is a reply to message #999373] Fri, 11 January 2013 21:17 Go to previous messageGo to next message
Donat Mueller is currently offline Donat Mueller
Messages: 11
Registered: January 2013
Location: switzerland
Junior Member
Anyway this is not a big issue for me as I have implemented my own ModelOperation subclasses and others probably wont care about model subpackages.
Re: texo webservice support for nested packages [message #999959 is a reply to message #999408] Sun, 13 January 2013 10:19 Go to previous message
Martin Taal is currently offline Martin Taal
Messages: 5326
Registered: July 2009
Senior Member
Hi Donat,
Okay, it seems somewhat less-common imho, it only occurs with epackages with non-unique nsprefixes and the solution only
works for cases with sub model packages. So I prefer to use something else, like a parameter/option somewhere to work
with truly generic qualifiers based on the nsuri.

gr. Martin

On 01/12/2013 03:17 AM, Donat Mueller wrote:
> Anyway this is not a big issue for me as I have implemented my own ModelOperation subclasses and others probably wont
> care about model subpackages.
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:WebServiceHandler does not use template method to create EntityManager
Next Topic:[Texo] texo template files in external plugin
Goto Forum:
  


Current Time: Tue Jul 29 13:04:51 EDT 2014

Powered by FUDForum. Page generated in 0.02528 seconds