Return-Path: Delivered-To: apmail-ws-tuscany-dev-archive@locus.apache.org Received: (qmail 85513 invoked from network); 14 Dec 2007 10:52:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Dec 2007 10:52:23 -0000 Received: (qmail 89156 invoked by uid 500); 14 Dec 2007 10:52:11 -0000 Delivered-To: apmail-ws-tuscany-dev-archive@ws.apache.org Received: (qmail 89138 invoked by uid 500); 14 Dec 2007 10:52:11 -0000 Mailing-List: contact tuscany-dev-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: tuscany-dev@ws.apache.org Delivered-To: mailing list tuscany-dev@ws.apache.org Received: (qmail 89129 invoked by uid 99); 14 Dec 2007 10:52:11 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Dec 2007 02:52:11 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of amita.vadhavkar@gmail.com designates 64.233.162.226 as permitted sender) Received: from [64.233.162.226] (HELO nz-out-0506.google.com) (64.233.162.226) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Dec 2007 10:51:50 +0000 Received: by nz-out-0506.google.com with SMTP id l1so613013nzf.43 for ; Fri, 14 Dec 2007 02:51:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=CeQGLWeWfKyiOvq56jjweTi8MaZfJ8v/SRAT+GT6PNg=; b=vPLakKhRWxr1O2oUxxzMMprBMbATnU9Nv1NqOx4PdQlLis9nh2TFLYtW/++3v0u4mlY/bQYTbeVbliQcsd8sEuN7fVRa37aQVMuALRXaFWyJX9SyFmphQcvI/AjQZXR6CS63nCwR17/Yvwrdx7kldjVOgDpSlE0wHIHfM+Usok0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=qPAO7dkL9fqUUEblQpk+DB+mnkB+86Rbwa70fN6utAh7Ogofk3X2wcg1uqhQbOtdPeOnX7p6jiw3MAR+B0lB/xXdQGhMCZ8IVk/JmHaD19ukiOm992WD20X/hmfSI8DuTpqfRYJtNWTIoxegVNbRlih1/WRMnCD68F4/DdNgBO4= Received: by 10.142.178.13 with SMTP id a13mr1344148wff.17.1197629512768; Fri, 14 Dec 2007 02:51:52 -0800 (PST) Received: by 10.142.52.13 with HTTP; Fri, 14 Dec 2007 02:51:52 -0800 (PST) Message-ID: <62dd6b650712140251j465404d3ua6e3ed780134f67e@mail.gmail.com> Date: Fri, 14 Dec 2007 16:21:52 +0530 From: "Amita Vadhavkar" To: tuscany-dev@ws.apache.org Subject: Re: [SDO] questions about support for Enumeration facet In-Reply-To: <9deac9fd0712120210q5e5e5fb0x9ec47e7b802a18b8@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_395_20064689.1197629512724" References: <62dd6b650712110159g359fcafaj47022d3b7f9b99d5@mail.gmail.com> <9deac9fd0712110826k439c8713xd678ab765b30468@mail.gmail.com> <9deac9fd0712120209y3a293742qa35db479cfe59fef@mail.gmail.com> <9deac9fd0712120210q5e5e5fb0x9ec47e7b802a18b8@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_395_20064689.1197629512724 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Tried to do little more analysis to see what is the way to reach ExtendedMetadata from DataObjectUtil. Please see the findings below. DataObjectUtil.getMetaObjectInstanceProperty(EModelElement, Property) can be reached from AttributeImpl(EAttributeImpl), ClassImpl(EClassImpl), DataTypeImpl(EDataTypeImpl), ReferenceImpl(EReferenceImpl). Below is the inheritance for EAttributeImpl - java.lang.Object extended by org.eclipse.emf.common.notify.impl.BasicNotifierImpl extended by org.eclipse.emf.ecore.impl.BasicEObjectImpl extended by org.eclipse.emf.ecore.impl.EObjectImpl extended by org.eclipse.emf.ecore.impl.FlatEObjectImpl extended by org.eclipse.emf.ecore.impl.EModelElementImpl** extended by org.eclipse.emf.ecore.impl.ENamedElementImpl extended by org.eclipse.emf.ecore.impl.ETypedElementImpl extended by org.eclipse.emf.ecore.impl.EStructuralFeatureImpl extended by org.eclipse.emf.ecore.impl.EAttributeImpl Below is the inheritance for EClassImpl - java.lang.Object extended by org.eclipse.emf.common.notify.impl.BasicNotifierImpl extended by org.eclipse.emf.ecore.impl.BasicEObjectImpl extended by org.eclipse.emf.ecore.impl.EObjectImpl extended by org.eclipse.emf.ecore.impl.FlatEObjectImpl extended by org.eclipse.emf.ecore.impl.EModelElementImpl** extended by org.eclipse.emf.ecore.impl.ENamedElementImpl extended by org.eclipse.emf.ecore.impl.EClassifierImpl extended by org.eclipse.emf.ecore.impl.EClassImpl Below is the inheritance for EDataTypeImpl - java.lang.Object extended by org.eclipse.emf.common.notify.impl.BasicNotifierImpl extended by org.eclipse.emf.ecore.impl.BasicEObjectImpl extended by org.eclipse.emf.ecore.impl.EObjectImpl extended by org.eclipse.emf.ecore.impl.FlatEObjectImpl extended by org.eclipse.emf.ecore.impl.EModelElementImpl** extended by org.eclipse.emf.ecore.impl.ENamedElementImpl extended by org.eclipse.emf.ecore.impl.EClassifierImpl**** extended by org.eclipse.emf.ecore.impl.EDataTypeImpl**** Below is the inheritance for EReferenceImpl - java.lang.Object extended by org.eclipse.emf.common.notify.impl.BasicNotifierImpl extended by org.eclipse.emf.ecore.impl.BasicEObjectImpl extended by org.eclipse.emf.ecore.impl.EObjectImpl extended by org.eclipse.emf.ecore.impl.FlatEObjectImpl extended by org.eclipse.emf.ecore.impl.EModelElementImpl** extended by org.eclipse.emf.ecore.impl.ENamedElementImpl extended by org.eclipse.emf.ecore.impl.ETypedElementImpl extended by org.eclipse.emf.ecore.impl.EStructuralFeatureImpl extended by org.eclipse.emf.ecore.impl.EReferenceImpl In this heirarchy, DataObjectUtil.getMetaObjectInstanceProperty() sticks to EModelElementImpl as is it common in all these 4 cases. But in case of EDataTypeImpl there is further hierarchy which is useful when it comes to facets - which is EClassifierImpl. EClassifierImpl has getExtendedMetaData() returning BasicExtendedMetaData.EClassifierExtendedMetaData. This one has all the methods for getting different facet informations like - java.util.List< java.lang.String> getEnumerationFacet() , int getMinLengthFacet() and so on. So a way out to get the enum facet value as a list can be - in DataObjectUtil.getMetaObjectInstanceProperty() - do as below - if(metaObject instanceof EDataTypeImpl/EClassifierImpl){ if(property.getName().equals("enumeration")) { List enumVals = ((EDataTypeImpl)metaObject).getExtendedMetaData().getEnumerationFacet(); return enumVals; } } Same can be the way to get value of "getPatternFacet() as this is the only other facet which returns a list" (ref emfBasicExtendedMetaData.EClassifierExtendedMetaData). For all other facets as they return a single value, the current SDO code may be enough {OR for all facets on EDataTypeImpl, we can reach ((EDataTypeImpl)metaObject).getExtendedMetaData() and call patricular getFacet methods, not sure if this is required - suggestions?} DataObjectUtil.getMetaObjectInstanceProperties() can remain unchanged. With the above change in DataObjectUtil.getMetaObjectInstanceProperty(), we can add a new method in SDOUtil - public static List getEnumerationFacet(Type type) { Property enumProperty = getInstanceProperty(type, "enumeration"); return DataObjectUtil.getMetaObjectInstanceProperty(type, enumProperty); } This way for a DataTypeImpl enum facet values will come out as a List. Please give suggestions. I can open another JIRA and fix patternFacet too in same way. Regards, Amita On Dec 12, 2007 3:40 PM, kelvin goodson wrote: > By the way, until the wiki has been used to update the websitre then the > FAQ > can be seen at > > http://cwiki.apache.org/confluence/display/TUSCANY/Tuscany+SDO+Java+-+FAQ > > Kelvin. > > On 12/12/2007, kelvin goodson wrote: > > > > It occurred to me that there's a bit of a knack to debugging into EMF > > code, so I just wrote an FAQ to describe how to do this. Comments are > > welcome on its clarity or accuracy. > > > > Regards, Kelvin. > > > > On 11/12/2007, kelvin goodson wrote: > > > > > > Amita, > > > > > > It feels like option 1 is the easy way to do things, and option 2 is > the > > > right way given the introduction of instance properties on metadata > provided > > > for this purpose (but doesn't currently work). > > > > > > Here's the results of my digging around. Let's start with what I > found > > > last since it might prove to be the answer. It seems highly likely to > be > > > so, but there is more thinking to be done. So after quite a bit of > digging > > > to see how things are handled in EMF I saw the TODO in DataObjectUtil > .... > > > > > > public static Object getMetaObjectInstanceProperty(EModelElement > > > metaObject, Property property) > > > { > > > String value = EcoreUtil.getAnnotation(metaObject, > > > property.getContainingType().getURI(), property.getName ()); > > > //TODO if (property.isMany()) ... // create list of values from > from > > > string > > > return SDOUtil.createFromString(property.getType(), value); > > > } > > > > > > So there's a couple of things I haven't got my head round yet that > > > perhaps you could take a look at since I must divert my attention for > a > > > while. The first is that the instance Property for the Type's > enumeration > > > is isMany = false. So even if we handled the TODO we wouldn't get the > > > desired result. The second is that we must ensure a generic string > > > tokenizer here, but I'm not yet confident that the tokenizing that we > want > > > to satisfy the current issue would be the same for all Properties. > What I > > > mean by this is that for the example you give, it starts with the > separator > > > "space" indicating that the first literal that should be returned from > > > tokenizing is the empty string. Would this be true for all Property > values, > > > or is it the case that sometimes we would consider trimming leading > white > > > space? > > > > > > I had been going down a track of investigating storage and retrieval > of > > > the enumeration facets inside EMF, which may yet prove to be the way > to fix > > > this issue. The facets seem to be stored in two ways. Once as an > > > annotation on the metadata artifact directly, in concatenated string > form, > > > and once as a vector on the extended metadata associated with the > eDataType > > > (See setEnumerationFacet(EDataType,List) of BasicExtendedMetaData. > The bulk > > > of code in setEnumerationFacet is devoted to concatenating the string > > > literals and hanging the annotation on the eDataType (Type), but the > last > > > line then squirrels the original input vector of enumerations away on > the > > > extended metadata. > > > > > > Now there is a basicGetEnumerationFacet method on the nested class > > > EDataTypeExtendedMetaDataImpl, which is contained in > BasicExtendedMetaData > > > which has all the reverse logic for unpacking the vector of > enumerations > > > from the concatenated string, but it never gets called in the > scenario you > > > described. Given the piece of code I included above, that wouldn't > work > > > anyway, given the EcoreUtil .getAnnotation returns a single String. > > > > > > I don't have a solution yet, but I'll think on it. Any suggestions > you > > > may have are welcome. > > > > > > Regards, Kelvin. > > > > > > > > > > > > > > > > > > On 11/12/2007, Amita Vadhavkar wrote: > > > > > > > > Hi, > > > > I tried TUSCANY-1360 related to enumeration facet. Below is the > > > > summary of > > > > what was > > > > discussed so far and a few questions. > > > > > ------------------------------------------------------------------------------------------------------------------------------------- > > > > > > > > 1) One way to do this is - > > > > public static List getEnumerationFacet(Type type) { > > > > return ExtendedMetaData.INSTANCE.getEnumerationFacet > > > > ((EDataType)type); > > > > } > > > > > > > > which works very straight forward and gives a list of enums. > > > > > > > > > ------------------------------------------------------------------------------------------------------------------------------------- > > > > 2) Another way is - > > > > Do type.getInstanceProperties() and find the Property called > > > > "enumeration". > > > > > > > > Where, getInstanceProperties() calls > > > > DataObjectUtil.getMetaObjectInstanceProperties(EModelElement > > > > metaObject) > > > > in which for the given metaObject its annotations and details of > each > > > > annotations are traversed. Each > > > > Annotation Detail is mapped to EStringToStringMapEntryImpl entry > like > > > > below > > > > - > > > > > > > > EStringToStringMapEntryImpl entry = > > > > (EStringToStringMapEntryImpl)iter.next(); //iter is Iterator over > > > > current > > > > Annotation's Details > > > > String propertyName = entry.getTypedKey(); > > > > > > > > Property globalProperty = getGlobalProperty(hc, propertyURI, > > > > propertyName); > > > > if (globalProperty != null) > > > > { > > > > result.add(globalProperty); > > > > } > > > > > > > > Result is a UniqueEList which is returned at the end. > > > > > > > > Here, when entry.getTypedKey() is "enumeration", entry.getTypedValue > () > > > > gives > > > > a String having space separated enums > > > > > > > > e.g. for > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > it gives," Good Bad" > > > > > > > > As we see in Property globalProperty = getGlobalProperty(hc, > > > > propertyURI, > > > > propertyName); the TypedKey information is > > > > used when forming Property with name "enumeration", but the > TypedValue > > > > information is not stored in the Property. > > > > Same thing will be applicable for other facets like MinLenght, > > > > MaxExclusive.... > > > > > ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > > > > > > > Questions: > > > > > > > > Thus, the question I have is, in case of following 2), what will be > > > > the way > > > > to preserve the mapping (key-value) > > > > information available about facets from EMF in the formed Property? > > > > And what > > > > will be better approach for TUSCANY-1360 > > > > and as such for any other facets? > > > > > > > > Regards, > > > > Amita > > > > > > > > > > > > > ------=_Part_395_20064689.1197629512724--