Author: frankb
Date: Wed Jul 26 16:55:42 2006
New Revision: 425913
URL: http://svn.apache.org/viewvc?rev=425913&view=rev
Log:
-noEMF codegen improvements
Modified:
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java
incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/templates/model/SDOClass.java
incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/templates/model/SDOFactoryClass.java
incubator/tuscany/java/sdo/tools/templates/models/SDOClass.javajet
incubator/tuscany/java/sdo/tools/templates/models/SDOFactoryClass.javajet
Modified:
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java?rev=425913&r1=425912&r2=425913&view=diff
==============================================================================
---
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java
(original)
+++
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java
Wed Jul 26 16:55:42 2006
@@ -42,6 +42,8 @@
*/
public abstract class DataObjectBase extends DataObjectImpl
{
+
+ protected int OPPOSITE_FEATURE_BASE = EOPPOSITE_FEATURE_BASE;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Following methods should be proposed SPI for generated subclasses to use
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -62,12 +64,22 @@
{
eNotify(new ENotificationImpl(this, Notification.SET, property, oldValue,
newValue));
}
+
+ protected void notify(int changeKind, int property, Object oldValue, Object
newValue, boolean isSetChange)
+ {
+ eNotify(new ENotificationImpl(this, Notification.SET, property, oldValue,
newValue, isSetChange));
+ }
protected void notify(int changeKind, int property, double oldDoubleValue,
double newDoubleValue, boolean isSetChange)
{
eNotify(new ENotificationImpl(this, Notification.SET, property,
oldDoubleValue, newDoubleValue, isSetChange));
}
+ protected void notify(int changeKind, int property, boolean oldBooleanValue,
boolean newBooleanValue, boolean isSetChange)
+ {
+ eNotify(new ENotificationImpl(this, Notification.SET, property,
oldBooleanValue, newBooleanValue, isSetChange));
+ }
+
protected interface ListKind
{
int CONTAINMENT = 0;
@@ -84,7 +96,7 @@
}
protected BasicSequence createSequence(int property) {
- return new BasicSequence(new BasicFeatureMap(this, property));
+ return new BasicSequence(new BasicFeatureMap(this, property));
}
protected Sequence createSequence(Sequence sequence, Type type, int
propertyIndex) {
@@ -129,32 +141,92 @@
protected void unsetSequence(Sequence seq) {
((FeatureMap.Internal.Wrapper)seq).featureMap().clear();
}
+
+ protected ChangeContext basicAdd(Sequence seq, Type type, int propertyIndex,
Object newValue, ChangeContext changeContext) {
+ ChangeContextImpl changeContextImpl = (ChangeContextImpl)changeContext;
+ changeContextImpl.notificationChain =
((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).basicAdd(((EClass)type).getEStructuralFeature(propertyIndex),
newValue, changeContextImpl.notificationChain);
+ return changeContextImpl;
+ }
protected Object get(int featureID, boolean resolve)
{
return null;
}
+ private ChangeContextImpl initializeChangeContext(ChangeContext
changeContext)
+ {
+ ChangeContextImpl changeContextImpl;
+ if (changeContext == null)
+ {
+ changeContextImpl = new ChangeContextImpl(null);
+ } else
+ {
+ changeContextImpl = (ChangeContextImpl)changeContext;
+ }
+ return changeContextImpl;
+ }
+
protected interface ChangeContext {}
protected ChangeContext inverseRemove(Object otherEnd, int propertyIndex,
ChangeContext changeContext)
{
- ChangeContextImpl changeContextImpl = (ChangeContextImpl)changeContext;
+ ChangeContextImpl changeContextImpl =
initializeChangeContext(changeContext);
changeContextImpl.notificationChain =
super.eInverseRemove((InternalEObject)otherEnd, propertyIndex,
changeContextImpl.notificationChain);
return changeContextImpl;
}
+ protected ChangeContext inverseAdd(Object otherEnd, int propertyIndex,
ChangeContext changeContext)
+ {
+ ChangeContextImpl changeContextImpl =
initializeChangeContext(changeContext);
+ changeContextImpl = (ChangeContextImpl)changeContext;
+ changeContextImpl.notificationChain =
super.eInverseAdd((InternalEObject)otherEnd, propertyIndex,
changeContextImpl.notificationChain);
+ return changeContextImpl;
+ }
+
+ protected ChangeContext inverseRemove(Object thisEnd, Object otherEnd, int
propertyIndex, Class baseClass, ChangeContext changeContext)
+ {
+ ChangeContextImpl changeContextImpl =
initializeChangeContext(changeContext);
+ changeContextImpl = (ChangeContextImpl)changeContext;
+ changeContextImpl.notificationChain =
((InternalEObject)thisEnd).eInverseRemove((InternalEObject)otherEnd,
propertyIndex, baseClass, changeContextImpl.notificationChain);
+ return changeContextImpl;
+ }
+
+ protected ChangeContext inverseAdd(Object thisEnd, Object otherEnd, int
propertyIndex, Class baseClass, ChangeContext changeContext)
+ {
+ ChangeContextImpl changeContextImpl =
initializeChangeContext(changeContext);
+ changeContextImpl.notificationChain =
((InternalEObject)thisEnd).eInverseAdd((InternalEObject)otherEnd,
propertyIndex, baseClass, changeContextImpl.notificationChain);
+ return changeContextImpl;
+ }
+
+ protected ChangeContext addNotification(Object notifier, int eventType, int
featureID, Object oldValue, Object newValue, ChangeContext changeContext)
+ {
+ ENotificationImpl notification = new
ENotificationImpl((InternalEObject)notifier, eventType, featureID, oldValue,
newValue);
+ ChangeContextImpl changeContextImpl =
initializeChangeContext(changeContext);
+ if (changeContextImpl.notificationChain == null)
changeContextImpl.notificationChain = notification; else
changeContextImpl.notificationChain.add(notification);
+ return changeContextImpl;
+ }
+
protected ChangeContext removeFromList(List propertyList, Object
objectToRemove, ChangeContext changeContext)
{
- ChangeContextImpl changeContextImpl = (ChangeContextImpl)changeContext;
+ ChangeContextImpl changeContextImpl =
initializeChangeContext(changeContext);
changeContextImpl.notificationChain =
((InternalEList)propertyList).basicRemove(objectToRemove,
changeContextImpl.notificationChain);
return changeContextImpl;
}
- protected ChangeContext removeFromSequence(Sequence sequence, Object
otherEnd, ChangeContext changeContext) {
- ChangeContextImpl changeContextImpl = (ChangeContextImpl)changeContext;
+ protected ChangeContext removeFromSequence(Sequence sequence, Object
otherEnd, ChangeContext changeContext)
+ {
+ ChangeContextImpl changeContextImpl =
initializeChangeContext(changeContext);
changeContextImpl.notificationChain =
((InternalEList)((FeatureMap.Internal.Wrapper)sequence).featureMap()).basicRemove(otherEnd,
changeContextImpl.notificationChain);
return changeContextImpl;
+ }
+
+ protected void dispatch(ChangeContext changeContext)
+ {
+ ChangeContextImpl changeContextImpl =
initializeChangeContext(changeContext);
+ if (changeContextImpl.notificationChain != null)
+ {
+ changeContextImpl.notificationChain.dispatch();
+ }
}
protected boolean isProxy()
Modified:
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java?rev=425913&r1=425912&r2=425913&view=diff
==============================================================================
---
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java
(original)
+++
incubator/tuscany/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java
Wed Jul 26 16:55:42 2006
@@ -16,14 +16,19 @@
*/
package org.apache.tuscany.sdo.impl;
+import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl;
+import org.apache.tuscany.sdo.model.impl.ModelPackageImpl;
import org.apache.tuscany.sdo.util.DataObjectUtil;
+import org.eclipse.emf.ecore.EAnnotation;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.ENamedElement;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.impl.EClassImpl;
import org.eclipse.emf.ecore.impl.EFactoryImpl;
import org.eclipse.emf.ecore.impl.EPackageImpl;
@@ -36,6 +41,9 @@
*/
public class FactoryBase extends EPackageImpl
{
+
+ public static final boolean IS_ATTRIBUTE = true;
+
protected FactoryBase(String namespaceURI, String namespacePrefix)
{
super(new SDOEFactoryImpl());
@@ -78,6 +86,11 @@
initEClass((EClass)type, instanceClass, name, !IS_ABSTRACT, !IS_INTERFACE,
IS_GENERATED_INSTANCE_CLASS);
}
+ protected void initializeType(Type type, Class instanceClass, String name,
boolean isSerializable, boolean isGenerated)
+ {
+ initEDataType((EDataType)type, instanceClass, name, isSerializable,
isGenerated);
+ }
+
protected void initializeProperty(Property property, Type type, String name,
String defaultValue, int lower, int upper, Class containerClass, boolean
isReadonly, boolean isUnsettable, boolean isDerived)
{
initEAttribute((EAttribute)property, (EClassifier)type, name,
defaultValue, lower, upper, containerClass, isDerived, isDerived, !isReadonly,
isUnsettable, !IS_ID, !IS_UNIQUE, isDerived, IS_ORDERED);
@@ -88,13 +101,16 @@
initEReference((EReference)property, (EClassifier)type,
(EReference)oppositeProperty, name, defaultValue, lower, upper, containerClass,
isDerived, isDerived, !isReadonly, isComposite, !isComposite /*resolve*/,
isUnsettable, IS_UNIQUE, isDerived, IS_ORDERED);
}
-
-
protected void createXSDMetaData()
{
createDocumentRoot();
}
-
+
+ protected void addXSDMapping(String[] xsdMappings, String annotationSource)
+ {
+ addAnnotation((ENamedElement)this, annotationSource, xsdMappings);
+ }
+
protected void addXSDMapping(Type type, String[] xsdMappings)
{
addAnnotation((ENamedElement)type, ANNOTATION_SOURCE, xsdMappings);
@@ -105,19 +121,63 @@
addAnnotation((ENamedElement)property, ANNOTATION_SOURCE, xsdMappings);
}
- protected void createGlobalProperty(String name, Type type, String[]
xsdMappings)
+ protected void setInstanceProperty(Type type, String namespaceURI, String
propertyName, String propertyValue)
{
- int propertyNumber = documentRootEClass.getEStructuralFeatures().size();
- createEReference(documentRootEClass, propertyNumber);
- EReference globalProperty =
(EReference)documentRootEClass.getEStructuralFeatures().get(propertyNumber);
- initEReference(globalProperty, (EClass)type, null, name, null, 0, -2,
null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE,
!IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
- addAnnotation((ENamedElement)globalProperty, ANNOTATION_SOURCE,
xsdMappings);
+ setInstanceProperty((ENamedElement)type, namespaceURI, propertyName,
propertyValue);
+ }
+
+ protected void setInstanceProperty(Property property, String namespaceURI,
String propertyName, String propertyValue)
+ {
+ setInstanceProperty((ENamedElement)property, namespaceURI, propertyName,
propertyValue);
}
- protected Type getSequence() {
- return (Type)ecorePackage.getEFeatureMapEntry();
+ private void setInstanceProperty(ENamedElement eNamedElement, String
namespaceURI, String propertyName, String propertyValue)
+ {
+ EAnnotation annotation = eNamedElement.getEAnnotation(namespaceURI);
+ if (annotation == null)
+ {
+ addAnnotation(eNamedElement, namespaceURI, new String[]{propertyName,
propertyValue});
+ } else
+ {
+ annotation.getDetails().put(propertyName, propertyValue);
+ }
+ }
+
+ protected Property createGlobalProperty(String name, Type type, String[]
xsdMappings)
+ {
+ return createGlobalProperty(name, type, xsdMappings, false);
+ }
+
+ protected Property createGlobalProperty(String name, Type type, String[]
xsdMappings, boolean asAttribute)
+ {
+ return createGlobalProperty(name, type, xsdMappings, asAttribute,
ANNOTATION_SOURCE);
+ }
+
+ protected Property createGlobalProperty(String name, Type type, String[]
xsdMappings, boolean asAttribute, String annotationSource)
+ {
+ int propertyNumber = documentRootEClass.getEStructuralFeatures().size();
+
+ EStructuralFeature globalProperty;
+ if(asAttribute) {
+ createEAttribute(documentRootEClass, propertyNumber);
+ EAttribute gatt =
(EAttribute)documentRootEClass.getEStructuralFeatures().get(propertyNumber);
+ initEAttribute(gatt, (EDataType)type, name, null, 0, -2, IS_TRANSIENT,
IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED,
IS_ORDERED);
+ globalProperty = gatt;
+ } else {
+ createEReference(documentRootEClass, propertyNumber);
+ EReference gref =
(EReference)documentRootEClass.getEStructuralFeatures().get(propertyNumber);
+ initEReference(gref, (EClass)type, null, name, null, 0, -2, null,
IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES,
!IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
+ globalProperty = gref;
+ }
+ addAnnotation((ENamedElement)globalProperty, annotationSource,
xsdMappings);
+ return (Property) globalProperty;
}
+ protected Type getSequence()
+ {
+ return (Type)ecorePackage.getEFeatureMapEntry();
+ }
+
//public static FactoryBase getStaticFactory(String namespaceURI)
// temporarily return Object - until everything is gen'd with new codegen
pattern
public static Object getStaticFactory(String namespaceURI)
@@ -127,6 +187,18 @@
return ePackage instanceof FactoryBase ? (Object)ePackage :
(Object)ePackage.getEFactoryInstance();
}
+ // default implementation of createFromString
+ public Object createFromString(Type type, String stringValue, int
propertyValue)
+ {
+ return
(String)ModelFactoryImpl.eINSTANCE.createFromString(ModelPackageImpl.Literals.STRING,
stringValue);
+ }
+
+ // default implementation of convertToString
+ public String convertToString(Type type, Object objectValue, int
propertyValue)
+ {
+ return
ModelFactoryImpl.eINSTANCE.convertToString(ModelPackageImpl.Literals.STRING,
objectValue);
+ }
+
// private EMF-specific methods
private static class SDOEFactoryImpl extends EFactoryImpl
@@ -146,6 +218,16 @@
}
return (EObject)result;
}
+
+ public Object createFromString(EDataType eDataType, String stringValue)
+ {
+ return sdoFactory.createFromString((Type)eDataType, stringValue,
eDataType.getClassifierID());
+ }
+
+ public String convertToString(EDataType eDataType, Object objectValue)
+ {
+ return sdoFactory.convertToString((Type)eDataType, objectValue,
eDataType.getClassifierID());
+ }
}
private static final int DOCUMENT_ROOT = 0;
@@ -154,7 +236,7 @@
private static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2;
private static final String ANNOTATION_SOURCE =
"http:///org/eclipse/emf/ecore/util/ExtendedMetaData";
private EClass documentRootEClass = null;
-
+
private void createDocumentRoot()
{
documentRootEClass = ecoreFactory.createEClass();
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=425913&r1=425912&r2=425913&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
Wed Jul 26 16:55:42 2006
@@ -1100,5 +1100,6 @@
public commonj.sdo.Type getYear() { return
(commonj.sdo.Type)getModelPackageImpl().getYear(); }
public commonj.sdo.Type getYearMonth() { return
(commonj.sdo.Type)getModelPackageImpl().getYearMonth(); }
public commonj.sdo.Type getYearMonthDay() { return
(commonj.sdo.Type)getModelPackageImpl().getYearMonthDay(); }
+ public commonj.sdo.Type getDataObject() { return
(commonj.sdo.Type)getModelPackageImpl().getDataObject(); }
} //ModelFactoryImpl
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]