tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fra...@apache.org
Subject svn commit: r416472 - in /incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo: helper/DataHelperImpl.java model/impl/ModelFactoryImpl.java util/DataObjectUtil.java util/SDOUtil.java
Date Thu, 22 Jun 2006 21:01:54 GMT
Author: frankb
Date: Thu Jun 22 14:01:53 2006
New Revision: 416472

URL: http://svn.apache.org/viewvc?rev=416472&view=rev
Log:
Fix broken get/set of various date-type properties

Modified:
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
    incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java?rev=416472&r1=416471&r2=416472&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java
(original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java
Thu Jun 22 14:01:53 2006
@@ -49,7 +49,14 @@
       new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS"),
       new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"),
       new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"),
-      new SimpleDateFormat("yyyy-MM-dd")
+      new SimpleDateFormat("'P'yyyy'Y' MM'M' dd'D' 'T' HH'H' mm'M' ss'S.'SSS"),
+      new SimpleDateFormat("--MM zz"),
+      new SimpleDateFormat("--MM-dd zz"),
+      new SimpleDateFormat("---dd zz"),
+      new SimpleDateFormat("HH:mm:ss'.'SSS"),
+      new SimpleDateFormat("yyyy-MM-dd"),
+      new SimpleDateFormat("yyyy-MM"),
+      new SimpleDateFormat("yyyy")
     };
     
     for (int i = 0; i < DATE_PATTERNS.length; ++i)

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java?rev=416472&r1=416471&r2=416472&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java
(original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java
Thu Jun 22 14:01:53 2006
@@ -537,8 +537,7 @@
    */
   public String createDateTimeFromString(EDataType eDataType, String initialValue)
   {
-    Object obj = XMLTypeFactory.eINSTANCE.createDateTime(initialValue);
-    return (obj != null) ? obj.toString() : null;
+      return initialValue;
   }
 
   /**
@@ -548,7 +547,7 @@
    */
   public String convertDateTimeToString(EDataType eDataType, Object instanceValue)
   {
-    return XMLTypeFactory.eINSTANCE.convertDateTime(instanceValue);
+      return (String)instanceValue;
   }
 
   /**
@@ -558,8 +557,7 @@
    */
   public String createDayFromString(EDataType eDataType, String initialValue)
   {
-    Object obj = XMLTypeFactory.eINSTANCE.createGDay(initialValue);
-    return (obj != null) ? obj.toString() : null;
+      return initialValue;
   }
 
   /**
@@ -569,7 +567,7 @@
    */
   public String convertDayToString(EDataType eDataType, Object instanceValue)
   {
-    return XMLTypeFactory.eINSTANCE.convertGDay(instanceValue);
+      return (String)instanceValue;
   }
 
   /**
@@ -639,8 +637,7 @@
    */
   public String createDurationFromString(EDataType eDataType, String initialValue)
   {
-    Object obj = XMLTypeFactory.eINSTANCE.createDuration(initialValue);
-    return (obj != null) ? obj.toString() : null;
+      return initialValue;
   }
 
   /**
@@ -650,7 +647,7 @@
    */
   public String convertDurationToString(EDataType eDataType, Object instanceValue)
   {
-    return XMLTypeFactory.eINSTANCE.convertDuration(instanceValue);
+      return (String)instanceValue;
   }
 
   /**
@@ -800,8 +797,7 @@
    */
   public String createMonthFromString(EDataType eDataType, String initialValue)
   {
-    Object obj = XMLTypeFactory.eINSTANCE.createGMonth(initialValue);
-    return (obj != null) ? obj.toString() : null;
+      return initialValue;
   }
 
   /**
@@ -811,7 +807,7 @@
    */
   public String convertMonthToString(EDataType eDataType, Object instanceValue)
   {
-    return XMLTypeFactory.eINSTANCE.convertGMonth(instanceValue);
+      return (String)instanceValue;
   }
 
   /**
@@ -821,8 +817,7 @@
    */
   public String createMonthDayFromString(EDataType eDataType, String initialValue)
   {
-    Object obj = XMLTypeFactory.eINSTANCE.createGMonthDay(initialValue);
-    return (obj != null) ? obj.toString() : null;
+      return initialValue;
   }
 
   /**
@@ -832,7 +827,7 @@
    */
   public String convertMonthDayToString(EDataType eDataType, Object instanceValue)
   {
-    return XMLTypeFactory.eINSTANCE.convertGMonthDay(instanceValue);
+      return (String)instanceValue;
   }
 
   /**
@@ -942,8 +937,7 @@
    */
   public String createTimeFromString(EDataType eDataType, String initialValue)
   {
-    Object obj = XMLTypeFactory.eINSTANCE.createTime(initialValue);
-    return (obj != null) ? obj.toString() : null;
+      return initialValue;
   }
 
   /**
@@ -953,7 +947,7 @@
    */
   public String convertTimeToString(EDataType eDataType, Object instanceValue)
   {
-    return XMLTypeFactory.eINSTANCE.convertTime(instanceValue);
+      return (String)instanceValue;
   }
 
   /**
@@ -983,8 +977,7 @@
    */
   public String createYearFromString(EDataType eDataType, String initialValue)
   {
-    Object obj = XMLTypeFactory.eINSTANCE.createGYear(initialValue);
-    return (obj != null) ? obj.toString() : null;
+      return initialValue;
   }
 
   /**
@@ -994,7 +987,7 @@
    */
   public String convertYearToString(EDataType eDataType, Object instanceValue)
   {
-    return XMLTypeFactory.eINSTANCE.convertGYear(instanceValue);
+      return (String)instanceValue;
   }
 
   /**
@@ -1004,8 +997,7 @@
    */
   public String createYearMonthFromString(EDataType eDataType, String initialValue)
   {
-    Object obj = XMLTypeFactory.eINSTANCE.createGYearMonth(initialValue);
-    return (obj != null) ? obj.toString() : null;
+      return initialValue;
   }
 
   /**
@@ -1015,7 +1007,7 @@
    */
   public String convertYearMonthToString(EDataType eDataType, Object instanceValue)
   {
-    return XMLTypeFactory.eINSTANCE.convertGYearMonth(instanceValue);
+      return (String)instanceValue;
   }
 
   /**
@@ -1025,8 +1017,7 @@
    */
   public String createYearMonthDayFromString(EDataType eDataType, String initialValue)
   {
-    Object obj = XMLTypeFactory.eINSTANCE.createDate(initialValue);
-    return (obj != null) ? obj.toString() : null;
+      return initialValue;
   }
 
   /**
@@ -1036,7 +1027,7 @@
    */
   public String convertYearMonthDayToString(EDataType eDataType, Object instanceValue)
   {
-    return XMLTypeFactory.eINSTANCE.convertDate(instanceValue);
+      return (String)instanceValue;
   }
 
   /**

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java?rev=416472&r1=416471&r2=416472&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
(original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java
Thu Jun 22 14:01:53 2006
@@ -70,6 +70,7 @@
 import commonj.sdo.Property;
 import commonj.sdo.Sequence;
 import commonj.sdo.Type;
+import commonj.sdo.helper.DataHelper;
 import commonj.sdo.helper.TypeHelper;
 
 
@@ -1123,6 +1124,10 @@
 
   public static Date getDate(Object value)
   {
+    if (value instanceof String) {
+      return DataHelper.INSTANCE.toDate((String)value);
+    }
+
     if (value instanceof XMLCalendar)
     {
       return ((XMLCalendar)value).getDate();
@@ -1156,28 +1161,54 @@
     }
 
     String name = eType.getInstanceClassName();
-    if (name == "java.lang.Object")
+        
+    if (name == "java.lang.String")
     {
       String typeName = getDateTypeName((EDataType)eType);
-      if ("Date".equals(typeName))
-      {
-        return new XMLCalendar(value, XMLCalendar.DATE);
+      if ("DateTime".equals(typeName)) {
+          return DataHelper.INSTANCE.toDateTime(value);
+      }
+      else if ("Day".equals(typeName)) {
+          return DataHelper.INSTANCE.toDay(value);
+      }
+      else if ("Duration".equals(typeName)) {
+          return DataHelper.INSTANCE.toDuration(value);
+      }
+      else if ("Month".equals(typeName)) {
+          return DataHelper.INSTANCE.toMonth(value);
+      }
+      else if ("MonthDay".equals(typeName)) {
+          return DataHelper.INSTANCE.toMonthDay(value);
+      }
+      else if ("Time".equals(typeName)) {
+          return DataHelper.INSTANCE.toTime(value);
+      }
+      else if ("Year".equals(typeName)) {
+          return DataHelper.INSTANCE.toYear(value);
       }
-      if ("DateTime".equals(typeName))
+      else if ("YearMonth".equals(typeName)) {
+          return DataHelper.INSTANCE.toYearMonth(value);
+      }
+      else if ("YearMonthDay".equals(typeName)) {
+          return DataHelper.INSTANCE.toYearMonthDay(value);
+      }
+      else if ("String".equals(typeName))
       {
-        return new XMLCalendar(value, XMLCalendar.DATETIME);
+        return DataHelper.INSTANCE.toDateTime(value);
       }
+      
       // Instead of throwing an IllegalArgumentException we will pass the value to the property
       return value;
     }
 
-    if (name == "java.lang.Long" || name == "long")
+    if (name == "java.util.Date")
     {
-      return new Long(value.getTime());
+      return new XMLCalendar(value, XMLCalendar.DATE);
     }
-    if (name == "java.lang.String")
+    
+    if (name == "java.lang.Long" || name == "long")
     {
-      return value.toString();
+      return new Long(value.getTime());
     }
 
     // Instead of throwing an IllegalArgumentException we will pass the value to the property
@@ -1187,7 +1218,16 @@
   protected static String getDateTypeName(EDataType eDataType)
   {
     String name = eDataType.getName();
-    if (("DateTime".equals(name)) || ("Date".equals(name)))
+    if (("DateTime".equals(name)) ||
+            ("Day".equals(name)) ||
+            ("Duration".equals(name)) ||
+            ("Month".equals(name)) ||
+            ("MonthDay".equals(name)) ||
+            ("Time".equals(name)) ||
+            ("Year".equals(name)) ||
+            ("YearMonth".equals(name)) ||
+            ("YearMonthDay".equals(name)) ||
+            ("String".equals(name)))
     {
       return name;
     }
@@ -1205,7 +1245,16 @@
       {
         EDataType memberType = (EDataType)memberTypes.get(i);
         String memberTypeName = getDateTypeName(memberType);
-        if (("DateTime".equals(memberTypeName)) || ("Date".equals(memberTypeName)))
+        if (("DateTime".equals(memberTypeName)) ||
+                ("Day".equals(memberTypeName)) ||
+                ("Duration".equals(memberTypeName)) ||
+                ("Month".equals(memberTypeName)) ||
+                ("MonthDay".equals(memberTypeName)) ||
+                ("Time".equals(memberTypeName)) ||
+                ("Year".equals(memberTypeName)) ||
+                ("YearMonth".equals(memberTypeName)) ||
+                ("YearMonthDay".equals(memberTypeName)) ||
+                ("String".equals(memberTypeName)))
         {
           return memberTypeName;
         }
@@ -2100,6 +2149,10 @@
       {
         EObject eObject = (EObject)eObjects.get(i);
         EStructuralFeature feature = (EStructuralFeature)((Type)eObject.eClass()).getProperty(attributeName);
+        // If feature is null, that means it could be an open feature.
+        if(feature == null){
+        	feature = (EStructuralFeature)DataObjectUtil.getOpenFeature(eObject, attributeName);
+        }
         if (feature != null)
         {
           Object test = eObject.eGet(feature, true);
@@ -2353,19 +2406,17 @@
         result.put("emof", new EMOFResourceFactoryImpl());
       }
 
-      if (Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.xsd")) == null)
+      if (!(Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.xsd")) instanceof
XSDResourceFactoryImpl))
       {
         result.put("xsd", new XSDResourceFactoryImpl());
       }
 
-      //FIXME ClassCastException in XSDHelper.define() if you give it a WSDL file
-      // Patch for JIRA TUSCANY-42
-      if (Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.wsdl")) == null)
+      if (!(Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.wsdl")) instanceof
XSDResourceFactoryImpl))
       {
         result.put("wsdl", new XSDResourceFactoryImpl());
       }
 
-      if (Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.*")) == null)
+      if (!(Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.*")) instanceof
SDOXMLResourceFactoryImpl))
       {
         result.put("*", new SDOXMLResourceFactoryImpl());
       }

Modified: incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java?rev=416472&r1=416471&r2=416472&view=diff
==============================================================================
--- incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java
(original)
+++ incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java
Thu Jun 22 14:01:53 2006
@@ -224,16 +224,6 @@
   }
   
   /**
-   * Create a new XMLStreamHelper, with visibility to types in the specified TypeHelper scope.
-   * @param scope the TypeHelper to use for locating types.
-   * @return the new XMLStreamHelper.
-   */
-  public static XMLStreamHelper createXMLStreamHelper(TypeHelper scope)
-  {
-    return new XMLStreamHelperImpl(scope);
-  }
-  
-  /**
    * Create a new XSDHelper, with visibility to types in the specified TypeHelper scope.
    * @param scope the TypeHelper to use for locating and populating types.
    * @return the new XSDHelper.
@@ -243,6 +233,16 @@
     return new XSDHelperImpl(scope);
   }
   
+  /**
+   * Create a new XMLStreamHelper, with visibility to types in the specified TypeHelper scope.
+   * @param scope the TypeHelper to use for locating types.
+   * @return the new XMLStreamHelper.
+   */
+  public static XMLStreamHelper createXMLStreamHelper(TypeHelper scope)
+  {
+    return new XMLStreamHelperImpl(scope);
+  }
+  
   public static Type createType(TypeHelper scope, String uri, String name, boolean isDataType)
   {
     ExtendedMetaData extendedMetaData = ((TypeHelperImpl)scope).getExtendedMetaData();
@@ -365,7 +365,8 @@
     EStructuralFeature eStructuralFeature = propertyType.isDataType() ? (EStructuralFeature)SDOFactory.eINSTANCE.createAttribute()
: (EStructuralFeature)SDOFactory.eINSTANCE.createReference();
     eStructuralFeature.setName(name);
     eStructuralFeature.setEType((EClassifier)propertyType);
-    if (containingType.getName() == null)
+    //if (containingType.getName() == null)
+    if ("".equals(ExtendedMetaData.INSTANCE.getName((EClass)containingType)))
     {
       ExtendedMetaData.INSTANCE.setFeatureKind(eStructuralFeature, ExtendedMetaData.ELEMENT_FEATURE);
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message