You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Andrey Utkin (JIRA)" <de...@tuscany.apache.org> on 2008/12/05 05:42:44 UTC
[jira] Created: (TUSCANY-2719) Wrong serialization DataObject in
XML if DataObject is defined by means of dynamic type
Wrong serialization DataObject in XML if DataObject is defined by means of dynamic type
---------------------------------------------------------------------------------------
Key: TUSCANY-2719
URL: https://issues.apache.org/jira/browse/TUSCANY-2719
Project: Tuscany
Issue Type: Bug
Components: Java SDO Implementation
Reporter: Andrey Utkin
SDO 2.1.0 Specification define rules for XML generation of DataObject`s property defined by dynamic types (without XSD) that (part "10 Generation of XSD from SDO Type and Property" page 107):
===
An element is generated if property.many,
property.containment, or property.nullable is true, or if property.get(xmlElement) is
present and set to true, where xmlElement is an open content property in
commonj.sdo/xml. If the property is bidirectional and the opposite property has
containment=true, nothing is generated. Otherwise, an attribute is generated.
===
But Tuscany generates element by default. Attributes generated only for properties with corresponding xmlElement - the "many" and "nullable" properties dont checked.
XML documents generated for such DataObjects is not corresponds to XSD generated for their Types (XSDHelper.generate()). So, it is not possible to deserialize XML back to DataObject.
I have changed /org/apache/tuscany/sdo/helper/TypeHelperImpl.java method "void initializeProperty()" as follow:
====
--- tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-07-10 16:53:42.000000000 +0400
+++ /patch/apache-tuscany-sdo-1.1.1/tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-12-05 06:54:56.000000000 +0300
@@ -271,6 +271,12 @@
}
}
}
+
+ // Check for many and nullable
+ if (!newProperty.isMany() && !newProperty.isNullable()) {
+ isXmlElement = Boolean.FALSE;
+ }
+
if (!isXmlElement.booleanValue()) {
SDOUtil.setPropertyXMLKind(newProperty, false);
}
====
May be it is not very correct, but works for me ^)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (TUSCANY-2719) Wrong serialization DataObject in
XML if DataObject is defined by means of dynamic type
Posted by "Frank Budinsky (JIRA)" <de...@tuscany.apache.org>.
[ https://issues.apache.org/jira/browse/TUSCANY-2719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12654249#action_12654249 ]
Frank Budinsky commented on TUSCANY-2719:
-----------------------------------------
Andrey, I think you can check for open content more easily. Instead of:
newProperty.getContainingType().getName().equals("DocumentRoot")
you should be able to just call:
newProperty.isOpenContent()
Frank.
> Wrong serialization DataObject in XML if DataObject is defined by means of dynamic type
> ---------------------------------------------------------------------------------------
>
> Key: TUSCANY-2719
> URL: https://issues.apache.org/jira/browse/TUSCANY-2719
> Project: Tuscany
> Issue Type: Bug
> Components: Java SDO Implementation
> Reporter: Andrey Utkin
> Attachments: TUSCANY-2719-2.patch
>
>
> SDO 2.1.0 Specification define rules for XML generation of DataObject`s property defined by dynamic types (without XSD) that (part "10 Generation of XSD from SDO Type and Property" page 107):
> ===
> An element is generated if property.many,
> property.containment, or property.nullable is true, or if property.get(xmlElement) is
> present and set to true, where xmlElement is an open content property in
> commonj.sdo/xml. If the property is bidirectional and the opposite property has
> containment=true, nothing is generated. Otherwise, an attribute is generated.
> ===
> But Tuscany generates element by default. Attributes generated only for properties with corresponding xmlElement - the "many" and "nullable" properties dont checked.
> XML documents generated for such DataObjects is not corresponds to XSD generated for their Types (XSDHelper.generate()). So, it is not possible to deserialize XML back to DataObject.
> I have changed /org/apache/tuscany/sdo/helper/TypeHelperImpl.java method "void initializeProperty()" as follow:
> ====
> --- tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-07-10 16:53:42.000000000 +0400
> +++ /patch/apache-tuscany-sdo-1.1.1/tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-12-05 06:54:56.000000000 +0300
> @@ -271,6 +271,12 @@
> }
> }
> }
> +
> + // Check for many and nullable
> + if (!newProperty.isMany() && !newProperty.isNullable()) {
> + isXmlElement = Boolean.FALSE;
> + }
> +
> if (!isXmlElement.booleanValue()) {
> SDOUtil.setPropertyXMLKind(newProperty, false);
> }
> ====
> May be it is not very correct, but works for me ^)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (TUSCANY-2719) Wrong serialization DataObject in
XML if DataObject is defined by means of dynamic type
Posted by "Andrey Utkin (JIRA)" <de...@tuscany.apache.org>.
[ https://issues.apache.org/jira/browse/TUSCANY-2719?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrey Utkin updated TUSCANY-2719:
----------------------------------
Attachment: TUSCANY-2719-3.patch
Thank you , Frank,
I have attached new patch TUSCANY-2719-3.patch
> Wrong serialization DataObject in XML if DataObject is defined by means of dynamic type
> ---------------------------------------------------------------------------------------
>
> Key: TUSCANY-2719
> URL: https://issues.apache.org/jira/browse/TUSCANY-2719
> Project: Tuscany
> Issue Type: Bug
> Components: Java SDO Implementation
> Reporter: Andrey Utkin
> Attachments: TUSCANY-2719-2.patch, TUSCANY-2719-3.patch
>
>
> SDO 2.1.0 Specification define rules for XML generation of DataObject`s property defined by dynamic types (without XSD) that (part "10 Generation of XSD from SDO Type and Property" page 107):
> ===
> An element is generated if property.many,
> property.containment, or property.nullable is true, or if property.get(xmlElement) is
> present and set to true, where xmlElement is an open content property in
> commonj.sdo/xml. If the property is bidirectional and the opposite property has
> containment=true, nothing is generated. Otherwise, an attribute is generated.
> ===
> But Tuscany generates element by default. Attributes generated only for properties with corresponding xmlElement - the "many" and "nullable" properties dont checked.
> XML documents generated for such DataObjects is not corresponds to XSD generated for their Types (XSDHelper.generate()). So, it is not possible to deserialize XML back to DataObject.
> I have changed /org/apache/tuscany/sdo/helper/TypeHelperImpl.java method "void initializeProperty()" as follow:
> ====
> --- tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-07-10 16:53:42.000000000 +0400
> +++ /patch/apache-tuscany-sdo-1.1.1/tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-12-05 06:54:56.000000000 +0300
> @@ -271,6 +271,12 @@
> }
> }
> }
> +
> + // Check for many and nullable
> + if (!newProperty.isMany() && !newProperty.isNullable()) {
> + isXmlElement = Boolean.FALSE;
> + }
> +
> if (!isXmlElement.booleanValue()) {
> SDOUtil.setPropertyXMLKind(newProperty, false);
> }
> ====
> May be it is not very correct, but works for me ^)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (TUSCANY-2719) Wrong serialization DataObject in
XML if DataObject is defined by means of dynamic type
Posted by "Frank Budinsky (JIRA)" <de...@tuscany.apache.org>.
[ https://issues.apache.org/jira/browse/TUSCANY-2719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12653848#action_12653848 ]
Frank Budinsky commented on TUSCANY-2719:
-----------------------------------------
Thanks Andrey. The only problem I see with your fix is that it can wipe out the users choice (set by the xmlElement property/annotation).
A better fix would be to change the initialization of the isXmlElement variable to this:
Boolean isXmlElement = newProperty.isMany() || newProperty.isNullable();
> Wrong serialization DataObject in XML if DataObject is defined by means of dynamic type
> ---------------------------------------------------------------------------------------
>
> Key: TUSCANY-2719
> URL: https://issues.apache.org/jira/browse/TUSCANY-2719
> Project: Tuscany
> Issue Type: Bug
> Components: Java SDO Implementation
> Reporter: Andrey Utkin
>
> SDO 2.1.0 Specification define rules for XML generation of DataObject`s property defined by dynamic types (without XSD) that (part "10 Generation of XSD from SDO Type and Property" page 107):
> ===
> An element is generated if property.many,
> property.containment, or property.nullable is true, or if property.get(xmlElement) is
> present and set to true, where xmlElement is an open content property in
> commonj.sdo/xml. If the property is bidirectional and the opposite property has
> containment=true, nothing is generated. Otherwise, an attribute is generated.
> ===
> But Tuscany generates element by default. Attributes generated only for properties with corresponding xmlElement - the "many" and "nullable" properties dont checked.
> XML documents generated for such DataObjects is not corresponds to XSD generated for their Types (XSDHelper.generate()). So, it is not possible to deserialize XML back to DataObject.
> I have changed /org/apache/tuscany/sdo/helper/TypeHelperImpl.java method "void initializeProperty()" as follow:
> ====
> --- tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-07-10 16:53:42.000000000 +0400
> +++ /patch/apache-tuscany-sdo-1.1.1/tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-12-05 06:54:56.000000000 +0300
> @@ -271,6 +271,12 @@
> }
> }
> }
> +
> + // Check for many and nullable
> + if (!newProperty.isMany() && !newProperty.isNullable()) {
> + isXmlElement = Boolean.FALSE;
> + }
> +
> if (!isXmlElement.booleanValue()) {
> SDOUtil.setPropertyXMLKind(newProperty, false);
> }
> ====
> May be it is not very correct, but works for me ^)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
Re: [jira] Commented: (TUSCANY-2719) Wrong serialization DataObject in XML
if DataObject is defined by means of dynamic type
Posted by Frank Budinsky <fr...@ca.ibm.com>.
Hi Andrey,
I think you should be able to identify an open content property (in the
initializeProperty method) by calling:
if (newProperty.isOpenContent()) ...
Frank.
"Andrey Utkin (JIRA)" <de...@tuscany.apache.org> wrote on 12/05/2008
11:34:44 AM:
>
> [ https://issues.apache.org/jira/browse/TUSCANY-2719?page=com.
> atlassian.jira.plugin.system.issuetabpanels:comment-
> tabpanel&focusedCommentId=12653857#action_12653857 ]
>
> Andrey Utkin commented on TUSCANY-2719:
> ---------------------------------------
>
> Yes, I agree with you - it is better.
> Frank, I found yet another problem with my fix: it introduce
> problems with Open Content and Sequence Properties...
> As I understand, Open Content properties must be represented as
> elements. It seems to me that such property may be "identified" by
> containing type - its name is "DocumentRoot".
> Currently I have no ideas how to deal with Sequence property... I
> will try to solve it.
>
>
> > Wrong serialization DataObject in XML if DataObject is defined by
> means of dynamic type
> >
>
---------------------------------------------------------------------------------------
> >
> > Key: TUSCANY-2719
> > URL:
https://issues.apache.org/jira/browse/TUSCANY-2719
> > Project: Tuscany
> > Issue Type: Bug
> > Components: Java SDO Implementation
> > Reporter: Andrey Utkin
> >
> > SDO 2.1.0 Specification define rules for XML generation of
> DataObject`s property defined by dynamic types (without XSD) that
> (part "10 Generation of XSD from SDO Type and Property" page 107):
> > ===
> > An element is generated if property.many,
> > property.containment, or property.nullable is true, or if
> property.get(xmlElement) is
> > present and set to true, where xmlElement is an open content property
in
> > commonj.sdo/xml. If the property is bidirectional and the opposite
> property has
> > containment=true, nothing is generated. Otherwise, an attribute
isgenerated.
> > ===
> > But Tuscany generates element by default. Attributes generated
> only for properties with corresponding xmlElement - the "many" and
> "nullable" properties dont checked.
> > XML documents generated for such DataObjects is not corresponds to
> XSD generated for their Types (XSDHelper.generate()). So, it is not
> possible to deserialize XML back to DataObject.
> > I have changed /org/apache/tuscany/sdo/helper/TypeHelperImpl.java
> method "void initializeProperty()" as follow:
> > ====
> > --- tuscany-sdo-1.1.1-
> src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.
> java 2008-07-10 16:53:42.000000000 +0400
> > +++ /patch/apache-tuscany-sdo-1.1.1/tuscany-sdo-1.1.1-
> src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.
> java 2008-12-05 06:54:56.000000000 +0300
> > @@ -271,6 +271,12 @@
> > }
> > }
> > }
> > +
> > + // Check for many and nullable
> > + if (!newProperty.isMany() && !newProperty.isNullable()) {
> > + isXmlElement = Boolean.FALSE;
> > + }
> > +
> > if (!isXmlElement.booleanValue()) {
> > SDOUtil.setPropertyXMLKind(newProperty, false);
> > }
> > ====
> > May be it is not very correct, but works for me ^)
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
[jira] Commented: (TUSCANY-2719) Wrong serialization DataObject in
XML if DataObject is defined by means of dynamic type
Posted by "Andrey Utkin (JIRA)" <de...@tuscany.apache.org>.
[ https://issues.apache.org/jira/browse/TUSCANY-2719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12653857#action_12653857 ]
Andrey Utkin commented on TUSCANY-2719:
---------------------------------------
Yes, I agree with you - it is better.
Frank, I found yet another problem with my fix: it introduce problems with Open Content and Sequence Properties...
As I understand, Open Content properties must be represented as elements. It seems to me that such property may be "identified" by containing type - its name is "DocumentRoot".
Currently I have no ideas how to deal with Sequence property... I will try to solve it.
> Wrong serialization DataObject in XML if DataObject is defined by means of dynamic type
> ---------------------------------------------------------------------------------------
>
> Key: TUSCANY-2719
> URL: https://issues.apache.org/jira/browse/TUSCANY-2719
> Project: Tuscany
> Issue Type: Bug
> Components: Java SDO Implementation
> Reporter: Andrey Utkin
>
> SDO 2.1.0 Specification define rules for XML generation of DataObject`s property defined by dynamic types (without XSD) that (part "10 Generation of XSD from SDO Type and Property" page 107):
> ===
> An element is generated if property.many,
> property.containment, or property.nullable is true, or if property.get(xmlElement) is
> present and set to true, where xmlElement is an open content property in
> commonj.sdo/xml. If the property is bidirectional and the opposite property has
> containment=true, nothing is generated. Otherwise, an attribute is generated.
> ===
> But Tuscany generates element by default. Attributes generated only for properties with corresponding xmlElement - the "many" and "nullable" properties dont checked.
> XML documents generated for such DataObjects is not corresponds to XSD generated for their Types (XSDHelper.generate()). So, it is not possible to deserialize XML back to DataObject.
> I have changed /org/apache/tuscany/sdo/helper/TypeHelperImpl.java method "void initializeProperty()" as follow:
> ====
> --- tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-07-10 16:53:42.000000000 +0400
> +++ /patch/apache-tuscany-sdo-1.1.1/tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-12-05 06:54:56.000000000 +0300
> @@ -271,6 +271,12 @@
> }
> }
> }
> +
> + // Check for many and nullable
> + if (!newProperty.isMany() && !newProperty.isNullable()) {
> + isXmlElement = Boolean.FALSE;
> + }
> +
> if (!isXmlElement.booleanValue()) {
> SDOUtil.setPropertyXMLKind(newProperty, false);
> }
> ====
> May be it is not very correct, but works for me ^)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (TUSCANY-2719) Wrong serialization DataObject in
XML if DataObject is defined by means of dynamic type
Posted by "Andrey Utkin (JIRA)" <de...@tuscany.apache.org>.
[ https://issues.apache.org/jira/browse/TUSCANY-2719?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrey Utkin updated TUSCANY-2719:
----------------------------------
Attachment: TUSCANY-2719-2.patch
Frank, I attach new patch (TUSCANY-2719-2.patch).
1) isMany, isNullable, Open Content Properties and properties of Sequence Types use element. Other - attribute. I hope isXmlElement is not wiped now :)
2) I have to change test case XMLHelperTestCase.java because XSD for dynamic types are changed.
3) I am not sure about correctness of checking for Open content properties and Sequence types.
> Wrong serialization DataObject in XML if DataObject is defined by means of dynamic type
> ---------------------------------------------------------------------------------------
>
> Key: TUSCANY-2719
> URL: https://issues.apache.org/jira/browse/TUSCANY-2719
> Project: Tuscany
> Issue Type: Bug
> Components: Java SDO Implementation
> Reporter: Andrey Utkin
> Attachments: TUSCANY-2719-2.patch
>
>
> SDO 2.1.0 Specification define rules for XML generation of DataObject`s property defined by dynamic types (without XSD) that (part "10 Generation of XSD from SDO Type and Property" page 107):
> ===
> An element is generated if property.many,
> property.containment, or property.nullable is true, or if property.get(xmlElement) is
> present and set to true, where xmlElement is an open content property in
> commonj.sdo/xml. If the property is bidirectional and the opposite property has
> containment=true, nothing is generated. Otherwise, an attribute is generated.
> ===
> But Tuscany generates element by default. Attributes generated only for properties with corresponding xmlElement - the "many" and "nullable" properties dont checked.
> XML documents generated for such DataObjects is not corresponds to XSD generated for their Types (XSDHelper.generate()). So, it is not possible to deserialize XML back to DataObject.
> I have changed /org/apache/tuscany/sdo/helper/TypeHelperImpl.java method "void initializeProperty()" as follow:
> ====
> --- tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-07-10 16:53:42.000000000 +0400
> +++ /patch/apache-tuscany-sdo-1.1.1/tuscany-sdo-1.1.1-src/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java 2008-12-05 06:54:56.000000000 +0300
> @@ -271,6 +271,12 @@
> }
> }
> }
> +
> + // Check for many and nullable
> + if (!newProperty.isMany() && !newProperty.isNullable()) {
> + isXmlElement = Boolean.FALSE;
> + }
> +
> if (!isXmlElement.booleanValue()) {
> SDOUtil.setPropertyXMLKind(newProperty, false);
> }
> ====
> May be it is not very correct, but works for me ^)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.