summaryrefslogtreecommitdiffstats
path: root/java/sdo/tools
diff options
context:
space:
mode:
authorkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2008-07-28 14:30:12 +0000
committerkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2008-07-28 14:30:12 +0000
commitf1e99ea09209f97d2c2081e6f9a25900a38c8c90 (patch)
tree248882ce689ccb786cc79e31ac33f5cee4c5969f /java/sdo/tools
parentae0049c24386c0a2e2c276a41f23bc17c5408e7c (diff)
merge of commit 643011 from 1.1 branch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@680370 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sdo/tools')
-rw-r--r--java/sdo/tools/pom.xml13
-rw-r--r--java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/adapter/SDOGenModelGeneratorAdapter.java76
-rw-r--r--java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java652
-rw-r--r--java/sdo/tools/src/main/resources/META-INF/NOTICE1
-rw-r--r--java/sdo/tools/src/main/resources/META-INF/README.txt4
-rw-r--r--java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java140
-rw-r--r--java/sdo/tools/src/test/resources/sdoModel.xsd56
7 files changed, 477 insertions, 465 deletions
diff --git a/java/sdo/tools/pom.xml b/java/sdo/tools/pom.xml
index 0a61744cb6..e40a8c55d9 100644
--- a/java/sdo/tools/pom.xml
+++ b/java/sdo/tools/pom.xml
@@ -95,6 +95,19 @@
<build>
<plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Implementation-Vendor-Id>org.apache</Implementation-Vendor-Id>
+ <Implementation-Version>1.1-incubating</Implementation-Version>
+ <X-Compile-Source-JDK>1.4</X-Compile-Source-JDK>
+ <X-Compile-Target-JDK>1.4</X-Compile-Target-JDK>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
diff --git a/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/adapter/SDOGenModelGeneratorAdapter.java b/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/adapter/SDOGenModelGeneratorAdapter.java
index c557d18431..16678e001b 100644
--- a/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/adapter/SDOGenModelGeneratorAdapter.java
+++ b/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/adapter/SDOGenModelGeneratorAdapter.java
@@ -1,38 +1,38 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.generate.adapter;
-
-import org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory;
-import org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapter;
-import org.eclipse.emf.common.util.Monitor;
-
-public class SDOGenModelGeneratorAdapter extends GenModelGeneratorAdapter {
-
- public SDOGenModelGeneratorAdapter(
- GeneratorAdapterFactory generatorAdapterFactory) {
- super(generatorAdapterFactory);
- }
-
- protected void ensureProjectExists(String workspacePath, Object object,
- Object projectType, boolean force, Monitor monitor) {
- // Do nothing -- this avoids differential behaviour according to whether we
- // are running in Eclipse or not
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.generate.adapter;
+
+import org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory;
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapter;
+import org.eclipse.emf.common.util.Monitor;
+
+public class SDOGenModelGeneratorAdapter extends GenModelGeneratorAdapter {
+
+ public SDOGenModelGeneratorAdapter(
+ GeneratorAdapterFactory generatorAdapterFactory) {
+ super(generatorAdapterFactory);
+ }
+
+ protected void ensureProjectExists(String workspacePath, Object object,
+ Object projectType, boolean force, Monitor monitor) {
+ // Do nothing -- this avoids differential behaviour according to whether we
+ // are running in Eclipse or not
+ }
+}
diff --git a/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java b/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java
index 6c4293f514..062580f4b8 100644
--- a/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java
+++ b/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java
@@ -1,326 +1,326 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.generate.util;
-
-import java.util.Iterator;
-
-import org.apache.tuscany.sdo.model.ModelFactory;
-import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl;
-import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
-import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
-import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
-import org.eclipse.emf.codegen.ecore.genmodel.GenDelegationKind;
-import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
-import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
-import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
-import org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl;
-import org.eclipse.emf.codegen.ecore.genmodel.impl.Literals;
-import org.eclipse.emf.codegen.util.CodeGenUtil;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EcorePackage;
-
-import commonj.sdo.Type;
-
-public class SDOGenUtil {
-
- public static String getQualifiedTypeAccessor(GenClassifier genClassifier)
- {
- GenPackage genPackage = genClassifier.getGenPackage();
- return getFactoryImpl(genPackage) + ".get" + genClassifier.getClassifierAccessorName() + "()";
- }
-
- public static String getDependentFactoryArgumentList(GenPackage genPackage, boolean isFormalArguments)
- {
- StringBuffer result = new StringBuffer();
- for (Iterator iter = genPackage.getPackageInitializationDependencies().iterator(); iter.hasNext(); )
- {
- GenPackage dep = (GenPackage)iter.next();
- if (isFormalArguments)
- {
- result.append(dep.getImportedFactoryClassName());
- result.append(" ");
- }
- result.append(genPackage.getPackageInstanceVariable(dep));
- if (iter.hasNext()) result.append(", ");
- }
- return result.toString();
- }
-
- public static String getFactoryImpl(GenPackage genPackage)
- {
- return "((" + genPackage.getImportedFactoryClassName() + ")"
- + genPackage.getImportedFactoryInterfaceName() + ".INSTANCE)";
- }
-
- public static String getListKind(GenFeature genFeature, boolean suppressNotification )
- {
- boolean unsettable = genFeature.isUnsettable();
-
- if (suppressNotification)
- {
- return "ListKind.BASIC";
- }
- else if (genFeature.isEffectiveContains())
- {
- if (genFeature.isBidirectional())
- {
- if (genFeature.isResolveProxies())
- {
- if( unsettable )
- return "ListKind.CONTAINMENT_INVERSE_RESOLVING_UNSETTABLE";
- else
- return "ListKind.CONTAINMENT_INVERSE_RESOLVING";
- }
- else
- {
- if( unsettable )
- return "ListKind.CONTAINMENT_INVERSE_UNSETTABLE";
- else
- return "ListKind.CONTAINMENT_INVERSE";
- }
- }
- else
- {
- if (genFeature.isResolveProxies())
- {
- if( unsettable )
- return "ListKind.CONTAINMENT_RESOLVING_UNSETTABLE";
- else
- return "ListKind.CONTAINMENT_RESOLVING";
- }
- else
- {
- if( unsettable )
- return "ListKind.CONTAINMENT_UNSETTABLE";
- else
- return "ListKind.CONTAINMENT";
- }
- }
- }
- else if (genFeature.isReferenceType())
- {
- if (genFeature.isBidirectional())
- {
- GenFeature reverseFeature = genFeature.getReverse();
- if (genFeature.isResolveProxies())
- {
- if (reverseFeature.isListType())
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING";
- }
- else
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_INVERSE_RESOLVING_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT_INVERSE_RESOLVING";
- }
- }
- else
- {
- if (reverseFeature.isListType())
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_MANYINVERSE_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT_MANYINVERSE";
- }
- else
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_INVERSE_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT_INVERSE";
- }
- }
- }
- else
- {
- if (genFeature.isResolveProxies())
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_RESOLVING_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT_RESOLVING";
- }
- else
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT";
- }
- }
- }
- else
- { //datatype
- if (genFeature.isUnique())
- {
- if( unsettable )
- return "ListKind.DATATYPE_UNIQUE_UNSETTABLE";
- else
- return "ListKind.DATATYPE_UNIQUE";
- }
- else
- {
- if( unsettable )
- return "ListKind.DATATYPE_UNSETTABLE";
- else
- return "ListKind.DATATYPE";
- }
- }
- }
-
- public static boolean hasChangeSummaryProperty(GenClass genClass)
- {
- return getChangeSummaryProperty(genClass) != null;
- }
-
- public static String getQualifiedInternalPropertyID(GenFeature genFeature)
- {
- return genFeature.getGenClass().getImportedClassName() + ".INTERNAL_" + genFeature.getUpperName();
- }
-
- public static String getChangeSummaryProperty(GenClass genClass)
- {
- Type csType = ((ModelFactoryImpl)ModelFactory.INSTANCE).getChangeSummaryType();
- for (Iterator i = genClass.getGenFeatures().iterator(); i.hasNext(); )
- {
- GenFeature genFeature = (GenFeature)i.next();
- EClassifier eClassifier = genFeature.getEcoreFeature().getEType();
- if (eClassifier instanceof Type)
- {
- Type type = (Type)eClassifier;
- //if (csType == type)// this doesn't work when generating sdoModel.xsd
- if (csType.getName().equals(type.getName()) && csType.getURI().equals(type.getURI()))
- {
- return genFeature.getUpperName();
- }
- }
- }
- return null;
- }
-
- public static String printArguments(GenPackage genPackage, GenModel genModel) {
- StringBuffer result = new StringBuffer();
- if(!CodeGenUtil.capName(genPackage.getNSName()).equals(genPackage.getPrefix())) {
- result.append(" -prefix " + genPackage.getPrefix());
- }
- if (genModel.isSuppressInterfaces()) {
- result.append(" -noInterfaces");
- }
- if ( genModel.getFeatureDelegation() == GenDelegationKind.VIRTUAL_LITERAL) {
- result.append(" -sparsePattern");
- }
- if ("org.apache.tuscany.sdo.impl.StoreDataObjectImpl".equals(genModel.getRootExtendsClass())) {
- result.append(" -storePattern");
- }
- if (genModel.isSuppressNotification()) {
- result.append(" -noNotification");
- }
- if (genModel.isSuppressContainment()) {
- result.append(" -noContainment");
- }
- if (genModel.isArrayAccessors()) {
- result.append(" -arrayAccessors");
- }
- if (genModel.isSuppressUnsettable()) {
- result.append(" -noUnsettable");
- }
-
- return result.toString();
- }
-
- /*
- * EMF doesn't do what we want in all cases, so filter the cases we need to handle
- * and drop through to EMF for all others.
- */
- public static String getStaticDefaultValue(GenFeature genFeature) {
- String result = "null";
- boolean defaultFound = false;
-
- String defaultString = genFeature.getEcoreFeature()
- .getDefaultValueLiteral();
- EClassifier eType = genFeature.getEcoreFeature().getEType();
- if (eType instanceof EDataType) {
- GenPackage genPackage = ((GenFeatureImpl) genFeature)
- .findGenPackage(genFeature.getEcoreFeature().getEType().getEPackage());
- GenDataType gdt = null;
- if (genPackage != null) {
- for (Iterator iter = genPackage.getGenDataTypes().iterator(); iter
- .hasNext()
- && gdt == null;) {
- GenDataType genDataType = (GenDataType) iter.next();
- if (eType.getName().equals(genDataType.getEcoreDataType().getName())) {
- gdt = genDataType;
- }
- }
- }
- EClassifier eDataType = gdt.getEcoreDataType();
- if (eDataType.getEPackage() != EcorePackage.eINSTANCE
- && defaultString != null) {
- boolean replaced = false;
- for (Iterator i = EcorePackage.eINSTANCE.getEClassifiers().iterator(); i
- .hasNext();) {
- EClassifier eClassifier = (EClassifier) i.next();
- if (eClassifier instanceof EDataType
- && eClassifier.getInstanceClassName().equals(
- eDataType.getInstanceClassName())
- && ((EDataType) eClassifier).isSerializable()
- && eClassifier != EcorePackage.eINSTANCE.getEDate()) {
- replaced = true;
- eDataType = eClassifier;
- break;
- }
- }
- if (!replaced) {
- result = "((" + genPackage.getFactoryClassName() + ")"
- + genPackage.getFactoryInterfaceName() + "."
- + genPackage.getFactoryInstanceName() + ")." + "create"
- + gdt.getName() + "FromString("
- + Literals.toLiteral(defaultString) + ")";
-
-
- if (gdt.isPrimitiveType())
- {
- result = "((" + gdt.getObjectInstanceClassName() + ")" + result
- + ")." + gdt.getPrimitiveValueFunction() + "()";
- } else if (!gdt.isObjectType()) {
- result = "(" + gdt.getImportedInstanceClassName() + ")" + result;
- }
-
- defaultFound = true;
- }
- }
- }
-
- if (!defaultFound) {
- // the input didn't match any special case that we want to handle differently
- // from EMF's default approach, so go ahead and get EMF to do it
- result = genFeature.getStaticDefaultValue();
- }
-
- return result;
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.generate.util;
+
+import java.util.Iterator;
+
+import org.apache.tuscany.sdo.model.ModelFactory;
+import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
+import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
+import org.eclipse.emf.codegen.ecore.genmodel.GenDelegationKind;
+import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+import org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl;
+import org.eclipse.emf.codegen.ecore.genmodel.impl.Literals;
+import org.eclipse.emf.codegen.util.CodeGenUtil;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EcorePackage;
+
+import commonj.sdo.Type;
+
+public class SDOGenUtil {
+
+ public static String getQualifiedTypeAccessor(GenClassifier genClassifier)
+ {
+ GenPackage genPackage = genClassifier.getGenPackage();
+ return getFactoryImpl(genPackage) + ".get" + genClassifier.getClassifierAccessorName() + "()";
+ }
+
+ public static String getDependentFactoryArgumentList(GenPackage genPackage, boolean isFormalArguments)
+ {
+ StringBuffer result = new StringBuffer();
+ for (Iterator iter = genPackage.getPackageInitializationDependencies().iterator(); iter.hasNext(); )
+ {
+ GenPackage dep = (GenPackage)iter.next();
+ if (isFormalArguments)
+ {
+ result.append(dep.getImportedFactoryClassName());
+ result.append(" ");
+ }
+ result.append(genPackage.getPackageInstanceVariable(dep));
+ if (iter.hasNext()) result.append(", ");
+ }
+ return result.toString();
+ }
+
+ public static String getFactoryImpl(GenPackage genPackage)
+ {
+ return "((" + genPackage.getImportedFactoryClassName() + ")"
+ + genPackage.getImportedFactoryInterfaceName() + ".INSTANCE)";
+ }
+
+ public static String getListKind(GenFeature genFeature, boolean suppressNotification )
+ {
+ boolean unsettable = genFeature.isUnsettable();
+
+ if (suppressNotification)
+ {
+ return "ListKind.BASIC";
+ }
+ else if (genFeature.isEffectiveContains())
+ {
+ if (genFeature.isBidirectional())
+ {
+ if (genFeature.isResolveProxies())
+ {
+ if( unsettable )
+ return "ListKind.CONTAINMENT_INVERSE_RESOLVING_UNSETTABLE";
+ else
+ return "ListKind.CONTAINMENT_INVERSE_RESOLVING";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.CONTAINMENT_INVERSE_UNSETTABLE";
+ else
+ return "ListKind.CONTAINMENT_INVERSE";
+ }
+ }
+ else
+ {
+ if (genFeature.isResolveProxies())
+ {
+ if( unsettable )
+ return "ListKind.CONTAINMENT_RESOLVING_UNSETTABLE";
+ else
+ return "ListKind.CONTAINMENT_RESOLVING";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.CONTAINMENT_UNSETTABLE";
+ else
+ return "ListKind.CONTAINMENT";
+ }
+ }
+ }
+ else if (genFeature.isReferenceType())
+ {
+ if (genFeature.isBidirectional())
+ {
+ GenFeature reverseFeature = genFeature.getReverse();
+ if (genFeature.isResolveProxies())
+ {
+ if (reverseFeature.isListType())
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_INVERSE_RESOLVING_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT_INVERSE_RESOLVING";
+ }
+ }
+ else
+ {
+ if (reverseFeature.isListType())
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_MANYINVERSE_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT_MANYINVERSE";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_INVERSE_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT_INVERSE";
+ }
+ }
+ }
+ else
+ {
+ if (genFeature.isResolveProxies())
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_RESOLVING_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT_RESOLVING";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT";
+ }
+ }
+ }
+ else
+ { //datatype
+ if (genFeature.isUnique())
+ {
+ if( unsettable )
+ return "ListKind.DATATYPE_UNIQUE_UNSETTABLE";
+ else
+ return "ListKind.DATATYPE_UNIQUE";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.DATATYPE_UNSETTABLE";
+ else
+ return "ListKind.DATATYPE";
+ }
+ }
+ }
+
+ public static boolean hasChangeSummaryProperty(GenClass genClass)
+ {
+ return getChangeSummaryProperty(genClass) != null;
+ }
+
+ public static String getQualifiedInternalPropertyID(GenFeature genFeature)
+ {
+ return genFeature.getGenClass().getImportedClassName() + ".INTERNAL_" + genFeature.getUpperName();
+ }
+
+ public static String getChangeSummaryProperty(GenClass genClass)
+ {
+ Type csType = ((ModelFactoryImpl)ModelFactory.INSTANCE).getChangeSummaryType();
+ for (Iterator i = genClass.getGenFeatures().iterator(); i.hasNext(); )
+ {
+ GenFeature genFeature = (GenFeature)i.next();
+ EClassifier eClassifier = genFeature.getEcoreFeature().getEType();
+ if (eClassifier instanceof Type)
+ {
+ Type type = (Type)eClassifier;
+ //if (csType == type)// this doesn't work when generating sdoModel.xsd
+ if (csType.getName().equals(type.getName()) && csType.getURI().equals(type.getURI()))
+ {
+ return genFeature.getUpperName();
+ }
+ }
+ }
+ return null;
+ }
+
+ public static String printArguments(GenPackage genPackage, GenModel genModel) {
+ StringBuffer result = new StringBuffer();
+ if(!CodeGenUtil.capName(genPackage.getNSName()).equals(genPackage.getPrefix())) {
+ result.append(" -prefix " + genPackage.getPrefix());
+ }
+ if (genModel.isSuppressInterfaces()) {
+ result.append(" -noInterfaces");
+ }
+ if ( genModel.getFeatureDelegation() == GenDelegationKind.VIRTUAL_LITERAL) {
+ result.append(" -sparsePattern");
+ }
+ if ("org.apache.tuscany.sdo.impl.StoreDataObjectImpl".equals(genModel.getRootExtendsClass())) {
+ result.append(" -storePattern");
+ }
+ if (genModel.isSuppressNotification()) {
+ result.append(" -noNotification");
+ }
+ if (genModel.isSuppressContainment()) {
+ result.append(" -noContainment");
+ }
+ if (genModel.isArrayAccessors()) {
+ result.append(" -arrayAccessors");
+ }
+ if (genModel.isSuppressUnsettable()) {
+ result.append(" -noUnsettable");
+ }
+
+ return result.toString();
+ }
+
+ /*
+ * EMF doesn't do what we want in all cases, so filter the cases we need to handle
+ * and drop through to EMF for all others.
+ */
+ public static String getStaticDefaultValue(GenFeature genFeature) {
+ String result = "null";
+ boolean defaultFound = false;
+
+ String defaultString = genFeature.getEcoreFeature()
+ .getDefaultValueLiteral();
+ EClassifier eType = genFeature.getEcoreFeature().getEType();
+ if (eType instanceof EDataType) {
+ GenPackage genPackage = ((GenFeatureImpl) genFeature)
+ .findGenPackage(genFeature.getEcoreFeature().getEType().getEPackage());
+ GenDataType gdt = null;
+ if (genPackage != null) {
+ for (Iterator iter = genPackage.getGenDataTypes().iterator(); iter
+ .hasNext()
+ && gdt == null;) {
+ GenDataType genDataType = (GenDataType) iter.next();
+ if (eType.getName().equals(genDataType.getEcoreDataType().getName())) {
+ gdt = genDataType;
+ }
+ }
+ }
+ EClassifier eDataType = gdt.getEcoreDataType();
+ if (eDataType.getEPackage() != EcorePackage.eINSTANCE
+ && defaultString != null) {
+ boolean replaced = false;
+ for (Iterator i = EcorePackage.eINSTANCE.getEClassifiers().iterator(); i
+ .hasNext();) {
+ EClassifier eClassifier = (EClassifier) i.next();
+ if (eClassifier instanceof EDataType
+ && eClassifier.getInstanceClassName().equals(
+ eDataType.getInstanceClassName())
+ && ((EDataType) eClassifier).isSerializable()
+ && eClassifier != EcorePackage.eINSTANCE.getEDate()) {
+ replaced = true;
+ eDataType = eClassifier;
+ break;
+ }
+ }
+ if (!replaced) {
+ result = "((" + genPackage.getFactoryClassName() + ")"
+ + genPackage.getFactoryInterfaceName() + "."
+ + genPackage.getFactoryInstanceName() + ")." + "create"
+ + gdt.getName() + "FromString("
+ + Literals.toLiteral(defaultString) + ")";
+
+
+ if (gdt.isPrimitiveType())
+ {
+ result = "((" + gdt.getObjectInstanceClassName() + ")" + result
+ + ")." + gdt.getPrimitiveValueFunction() + "()";
+ } else if (!gdt.isObjectType()) {
+ result = "(" + gdt.getImportedInstanceClassName() + ")" + result;
+ }
+
+ defaultFound = true;
+ }
+ }
+ }
+
+ if (!defaultFound) {
+ // the input didn't match any special case that we want to handle differently
+ // from EMF's default approach, so go ahead and get EMF to do it
+ result = genFeature.getStaticDefaultValue();
+ }
+
+ return result;
+ }
+}
diff --git a/java/sdo/tools/src/main/resources/META-INF/NOTICE b/java/sdo/tools/src/main/resources/META-INF/NOTICE
index 6901a96038..9f9572a167 100644
--- a/java/sdo/tools/src/main/resources/META-INF/NOTICE
+++ b/java/sdo/tools/src/main/resources/META-INF/NOTICE
@@ -4,5 +4,4 @@ Copyright (c) 2005 - 2008 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
-Please see the LICENSE file present in the META-INF directory of this archive.
diff --git a/java/sdo/tools/src/main/resources/META-INF/README.txt b/java/sdo/tools/src/main/resources/META-INF/README.txt
index 687f357105..1b8144f7c5 100644
--- a/java/sdo/tools/src/main/resources/META-INF/README.txt
+++ b/java/sdo/tools/src/main/resources/META-INF/README.txt
@@ -1,5 +1,5 @@
-Apache Tuscany 1.1-incubating build (February 2008)
-===============================================
+Apache Tuscany 1.1-incubating build (April 2008)
+================================================
http://incubator.apache.org/tuscany/
diff --git a/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java b/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java
index 47be663e49..290f27338a 100644
--- a/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java
+++ b/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java
@@ -1,70 +1,70 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sdo.test;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.tuscany.sdo.generate.XSD2JavaGenerator;
-
-import junit.framework.TestCase;
-
-
-public class GeneratedPackagesTestCase extends TestCase
-{
- static String expectedNamespace = "http://www.example.com/sequences";
-
- public void testPackageValidity()
- {
- XSD2JavaGenerator codeGen = new XSD2JavaGenerator();
- String [] genArgs = { "-schemaNamespace", "all", "-noGenerate", "src/test/resources/sequences.xsd" };
- codeGen.generateFromXMLSchema( genArgs );
- List packages = codeGen.getGeneratedPackageInfo();
-
- for (Iterator iter = packages.iterator(); iter.hasNext();)
- {
- XSD2JavaGenerator.GeneratedPackage packageInfo = (XSD2JavaGenerator.GeneratedPackage)iter.next();
- assertTrue(expectedNamespace.equals(packageInfo.getNamespace()));
-
- String name;
- boolean validatedMixedQuote = false;
- boolean validatedRC = false;
- for (Iterator iterClass = packageInfo.getClasses().iterator(); iterClass.hasNext();)
- {
- XSD2JavaGenerator.GeneratedPackage.PackageClassInfo classInfo = (XSD2JavaGenerator.GeneratedPackage.PackageClassInfo)iterClass.next();
- name = classInfo.getName();
-
- if( "mixedStockQuote".equals(name))
- {
- assertTrue("com.example.sequences.MixedQuote".equals(classInfo.getClassName()));
- validatedMixedQuote = true;
- }
-
- if( "rc".equals(name))
- {
- assertTrue("com.example.sequences.RepeatingChoice".equals(classInfo.getClassName()));
- validatedRC = true;
- }
- }
- assertTrue(validatedMixedQuote);
- assertTrue(validatedRC);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sdo.test;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.tuscany.sdo.generate.XSD2JavaGenerator;
+
+import junit.framework.TestCase;
+
+
+public class GeneratedPackagesTestCase extends TestCase
+{
+ static String expectedNamespace = "http://www.example.com/sequences";
+
+ public void testPackageValidity()
+ {
+ XSD2JavaGenerator codeGen = new XSD2JavaGenerator();
+ String [] genArgs = { "-schemaNamespace", "all", "-noGenerate", "src/test/resources/sequences.xsd" };
+ codeGen.generateFromXMLSchema( genArgs );
+ List packages = codeGen.getGeneratedPackageInfo();
+
+ for (Iterator iter = packages.iterator(); iter.hasNext();)
+ {
+ XSD2JavaGenerator.GeneratedPackage packageInfo = (XSD2JavaGenerator.GeneratedPackage)iter.next();
+ assertTrue(expectedNamespace.equals(packageInfo.getNamespace()));
+
+ String name;
+ boolean validatedMixedQuote = false;
+ boolean validatedRC = false;
+ for (Iterator iterClass = packageInfo.getClasses().iterator(); iterClass.hasNext();)
+ {
+ XSD2JavaGenerator.GeneratedPackage.PackageClassInfo classInfo = (XSD2JavaGenerator.GeneratedPackage.PackageClassInfo)iterClass.next();
+ name = classInfo.getName();
+
+ if( "mixedStockQuote".equals(name))
+ {
+ assertTrue("com.example.sequences.MixedQuote".equals(classInfo.getClassName()));
+ validatedMixedQuote = true;
+ }
+
+ if( "rc".equals(name))
+ {
+ assertTrue("com.example.sequences.RepeatingChoice".equals(classInfo.getClassName()));
+ validatedRC = true;
+ }
+ }
+ assertTrue(validatedMixedQuote);
+ assertTrue(validatedRC);
+ }
+ }
+}
diff --git a/java/sdo/tools/src/test/resources/sdoModel.xsd b/java/sdo/tools/src/test/resources/sdoModel.xsd
index 645b7b700a..6b596c5b36 100644
--- a/java/sdo/tools/src/test/resources/sdoModel.xsd
+++ b/java/sdo/tools/src/test/resources/sdoModel.xsd
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- -->
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:sdoJava="commonj.sdo/java" targetNamespace="commonj.sdo">
-
- <!-- Dummy XSD definition of special SDO ChangeSummaryType -->
- <xsd:simpleType name="ChangeSummaryType" sdoJava:instanceClass="commonj.sdo.ChangeSummary">
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
-
-</xsd:schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:sdoJava="commonj.sdo/java" targetNamespace="commonj.sdo">
+
+ <!-- Dummy XSD definition of special SDO ChangeSummaryType -->
+ <xsd:simpleType name="ChangeSummaryType" sdoJava:instanceClass="commonj.sdo.ChangeSummary">
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+
+
+</xsd:schema>