| texo webservice support for nested packages [message #999197] |
Fri, 11 January 2013 09:50  |
Donat Mueller Messages: 10 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 #999373 is a reply to message #999357] |
Fri, 11 January 2013 18:41   |
Donat Mueller Messages: 10 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 #999959 is a reply to message #999408] |
Sun, 13 January 2013 10:19  |
Martin Taal Messages: 5080 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
|
|
|
Powered by
FUDForum. Page generated in 0.02213 seconds