[ http://issues.apache.org/jira/browse/TUSCANY-384?page=all ]
Frank Budinsky resolved TUSCANY-384:
------------------------------------
Resolution: Invalid
The spec doesn't say that an implementation isn't "allowed" to add the getAny()
property, it just says that it isn't "required" to. In Tuscany, we're still
thinking about what we will do about this long term, but for now we do generate
it, so if you don't need/want it, you should just ignore it (you can also
manually delete it from the generated interface if you'd like).
To add open content to an open type you need a global property. In the future
we plan to demand create such properties that don't exist already (as in your
example), but we currently don't do that. Whether or not an implementation will
do that is not clear in the current spec. For now, you need to define the
global property (a global element in some schema):
<schema targetNamespace="some-namespace" ...>
<element name="newProp" type="string">
...
</schema>
You can alternatively (instead of in a schema) use SDOUtil to define the global
property dynamically something like this:
Type globalType = SDOUtil.createType(TypeHelper.INSTANCE, "some-namespace",
null, false); // create a holder type for global properties (name must be null)
SDOUtil.createProperty(globalType, "newProp",
TypeHelper.INSTANCE.getType("commonj.sdo", "String");
In SDO 2.1, there will be an easier way to do this - a new method:
TypeHelper.defineGlobalProperty().
Then you can set the property in your open object like this:
dataObject.set(XSDHelper.INSTANCE.getGlobalProperty("some-namespace",
"newProp", true), "newValue")
Also, like I said above, in the future you will also be able to just do this:
dataObject.set("newProp", "newValue")
and the implementation will do something like this under the covers (if newProp
is not already created):
Type globalType = SDOUtil.createType(TypeHelper.INSTANCE,
dataObject.getType().getURI(), null, false); // if not already created
Property prop = SDOUtil.createProperty(globalType, "newProp",
TypeHelper.INSANCE.getType(newValue.getClass());
dataObject.set(prop, newValue);
> SDOs generated from XSD containing <any /> element in complex type result in
> a getAny() method being created
> ------------------------------------------------------------------------------------------------------------
>
> Key: TUSCANY-384
> URL: http://issues.apache.org/jira/browse/TUSCANY-384
> Project: Tuscany
> Type: Bug
> Components: Java SDO Tools
> Versions: Java-M1
> Environment: Linux (presunme x plaftform)
> Reporter: Dan Murphy
>
> According to spec, one way to generate open content SDOs is to add a <any />
> element to the complex type. For example :
> <complexType name=[NAME]>
> ...
> <any />
> ...
> </complexType>
> Should result in an SDO type:
> Type name=[NAME]
> open=true
> uri=[URI]]
> ? No property required for
> <any>.
> ? Use getInstanceProperties()
> for reflection.
> ? DataObject and generated
> accessors also may be used
> to access the value.
> ? If maxOccurs > 1,
> sequenced=true.
> And not add anything to the Java interface:
> interface [NAME]
> (Taken from p88 of SDO spec 2.0.1, Nov 2005)
> This does result in an SDO which according to the Type.isOpen() method should
> be open, but It also generates a getAny() on the interface which is not in
> line with the specification
> Additionally you still don't appeat to be able to add a property by either :
> dataObject.set("newProp", "newValue") or
> dataObject.getAny().add("newProp", "newValue")
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira