You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by fr...@apache.org on 2006/12/08 01:31:44 UTC
svn commit: r483757 [3/3] - in /incubator/tuscany/java:
sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/
sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/
sdo/impl/src/main/java/org/apache/tuscany/sdo/model/
sdo/impl/src/main/java/org/apache/tus...
Modified: incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java?view=diff&rev=483757&r1=483756&r2=483757
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java (original)
+++ incubator/tuscany/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java Thu Dec 7 16:31:39 2006
@@ -21,9 +21,15 @@
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.GenFeature;
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+import commonj.sdo.Type;
+
public class SDOGenUtil {
public static String getQualifiedTypeAccessor(GenClassifier genClassifier)
@@ -55,5 +61,25 @@
+ genPackage.getImportedFactoryInterfaceName() + ".INSTANCE)";
}
+ public static boolean hasChangeSummaryProperty(GenClass genClass)
+ {
+ return getChangeSummaryProperty(genClass) != null;
+ }
+
+ 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();
+ Type type = (Type)genFeature.getEcoreFeature().getEType();
+ //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;
+ }
}
Modified: incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java?view=diff&rev=483757&r1=483756&r2=483757
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java (original)
+++ incubator/tuscany/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryGenTestCase.java Thu Dec 7 16:31:39 2006
@@ -35,46 +35,39 @@
public class ChangeSummaryGenTestCase extends TestCase {
public void testMixedQuoteType() throws IOException {
-// TODO T-153 reintroduce once generator special cases the change summary type property
-// QuoteBase quote = CSFactory.INSTANCE.createQuoteBase();
-// DataObject dQuote = (DataObject)quote;
-// // FBCHECK should generated method trigger creation of C/S
-// // also gen method returns Impl class -- change to interface?
-// // ChangeSummary csp = quote.getChanges();
-// ChangeSummary cs = dQuote.getChangeSummary();
-// ChangeSummary csp = quote.getChanges();
-// cs.beginLogging();
-//
-// assertSame(cs, csp);
-//
-// quote.setSymbol("fbnt");
-// quote.setCompanyName("FlyByNightTechnology");
-// quote.setPrice(new BigDecimal("1000.0"));
-// quote.setOpen1(new BigDecimal("1000.0"));
-// quote.setHigh(new BigDecimal("1000.0"));
-// quote.setLow(new BigDecimal("1000.0"));
-// quote.setVolume(1000);
-// quote.setChange1(1000);
-//
-// List quotes = quote.getQuotes();
-// Quote innerQuote = CSFactory.INSTANCE.createQuote();
-//
-// quotes.add(innerQuote);
-// innerQuote.setPrice(new BigDecimal("2000.0"));
-//
-// cs.endLogging();
-//
-// XMLHelper.INSTANCE.save(dQuote, "http://www.example.com/simpleCS", "quoteBase", System.out);
-//
-// cs.undoChanges();
-// System.out.println("\nAfter Undo Changes:");
-// XMLHelper.INSTANCE.save(dQuote, "http://www.example.com/simpleCS", "quoteBase", System.out);
+ QuoteBase quote = CSFactory.INSTANCE.createQuoteBase();
+ DataObject dQuote = (DataObject)quote;
+
+ // ChangeSummary csp = quote.getChanges();
+ ChangeSummary cs = dQuote.getChangeSummary();
+ ChangeSummary csp = quote.getChanges();
+ cs.beginLogging();
+
+ assertSame(cs, csp);
+ quote.setSymbol("fbnt");
+ quote.setCompanyName("FlyByNightTechnology");
+ quote.setPrice(new BigDecimal("1000.0"));
+ quote.setOpen1(new BigDecimal("1000.0"));
+ quote.setHigh(new BigDecimal("1000.0"));
+ quote.setLow(new BigDecimal("1000.0"));
+ quote.setVolume(1000);
+ quote.setChange1(1000);
+ List quotes = quote.getQuotes();
+ Quote innerQuote = CSFactory.INSTANCE.createQuote();
+ quotes.add(innerQuote);
+ innerQuote.setPrice(new BigDecimal("2000.0"));
+
+ cs.endLogging();
+
+ //XMLHelper.INSTANCE.save(dQuote, "http://www.example.com/simpleCS", "quoteBase", System.out);
+
+ cs.undoChanges();
+
+ //System.out.println("\nAfter Undo Changes:");
+ //XMLHelper.INSTANCE.save(dQuote, "http://www.example.com/simpleCS", "quoteBase", System.out);
}
-
-
-
-
+
}
Modified: incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/QuoteBase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/QuoteBase.java?view=diff&rev=483757&r1=483756&r2=483757
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/QuoteBase.java (original)
+++ incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/QuoteBase.java Thu Dec 7 16:31:39 2006
@@ -6,7 +6,7 @@
*/
package org.example.simple.cs;
-import org.apache.tuscany.sdo.model.ChangeSummaryType;
+import commonj.sdo.ChangeSummary;
/**
* <!-- begin-user-doc -->
@@ -25,27 +25,27 @@
public interface QuoteBase extends Quote
{
/**
- * Returns the value of the '<em><b>Changes</b></em>' reference.
+ * Returns the value of the '<em><b>Changes</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
- * If the meaning of the '<em>Changes</em>' reference isn't clear,
+ * If the meaning of the '<em>Changes</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
- * @return the value of the '<em>Changes</em>' reference.
- * @see #setChanges(ChangeSummaryType)
+ * @return the value of the '<em>Changes</em>' attribute.
+ * @see #setChanges(ChangeSummary)
* @generated
*/
- ChangeSummaryType getChanges();
+ ChangeSummary getChanges();
/**
- * Sets the value of the '{@link org.example.simple.cs.QuoteBase#getChanges <em>Changes</em>}' reference.
+ * Sets the value of the '{@link org.example.simple.cs.QuoteBase#getChanges <em>Changes</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @param value the new value of the '<em>Changes</em>' reference.
+ * @param value the new value of the '<em>Changes</em>' attribute.
* @see #getChanges()
* @generated
*/
- void setChanges(ChangeSummaryType value);
+ void setChanges(ChangeSummary value);
} // QuoteBase
Modified: incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/CSFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/CSFactoryImpl.java?view=diff&rev=483757&r1=483756&r2=483757
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/CSFactoryImpl.java (original)
+++ incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/CSFactoryImpl.java Thu Dec 7 16:31:39 2006
@@ -57,7 +57,7 @@
*/
public CSFactoryImpl()
{
- super(NAMESPACE_URI, NAMESPACE_PREFIX);
+ super(NAMESPACE_URI, NAMESPACE_PREFIX, "org.example.simple.cs");
}
/**
@@ -144,7 +144,7 @@
if (isCreated) return;
isCreated = true;
-
+ // Create types and their properties
quoteType = createType(false, QUOTE);
createProperty(true, quoteType, QuoteImpl.SYMBOL);
createProperty(true, quoteType, QuoteImpl.COMPANY_NAME);
@@ -157,7 +157,7 @@
createProperty(false, quoteType, QuoteImpl.QUOTES);
quoteBaseType = createType(false, QUOTE_BASE);
- createProperty(false, quoteBaseType, QuoteBaseImpl.CHANGES);
+ createProperty(true, quoteBaseType, QuoteBaseImpl.CHANGES);
}
private boolean isInitialized = false;
@@ -171,51 +171,40 @@
ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)FactoryBase.getStaticFactory(ModelFactoryImpl.NAMESPACE_URI);
Property property = null;
- // Add supertypes to classes
+ // Add supertypes to types
addSuperType(quoteBaseType, quoteType);
- // Initialize classes and features; add operations and parameters
- initializeType(quoteType, Quote.class, "Quote");
-
+ // Initialize types and properties
+ initializeType(quoteType, Quote.class, "Quote", false);
property = (Property)quoteType.getProperties().get(QuoteImpl.SYMBOL);
initializeProperty(property, theModelPackageImpl.getString(), "symbol", null, 1, 1, Quote.class, false, false, false);
-
property = (Property)quoteType.getProperties().get(QuoteImpl.COMPANY_NAME);
initializeProperty(property, theModelPackageImpl.getString(), "companyName", null, 1, 1, Quote.class, false, false, false);
-
property = (Property)quoteType.getProperties().get(QuoteImpl.PRICE);
initializeProperty(property, theModelPackageImpl.getDecimal(), "price", null, 1, 1, Quote.class, false, false, false);
-
property = (Property)quoteType.getProperties().get(QuoteImpl.OPEN1);
initializeProperty(property, theModelPackageImpl.getDecimal(), "open1", null, 1, 1, Quote.class, false, false, false);
-
property = (Property)quoteType.getProperties().get(QuoteImpl.HIGH);
initializeProperty(property, theModelPackageImpl.getDecimal(), "high", null, 1, 1, Quote.class, false, false, false);
-
property = (Property)quoteType.getProperties().get(QuoteImpl.LOW);
initializeProperty(property, theModelPackageImpl.getDecimal(), "low", null, 1, 1, Quote.class, false, false, false);
-
property = (Property)quoteType.getProperties().get(QuoteImpl.VOLUME);
initializeProperty(property, theModelPackageImpl.getDouble(), "volume", null, 1, 1, Quote.class, false, true, false);
-
property = (Property)quoteType.getProperties().get(QuoteImpl.CHANGE1);
initializeProperty(property, theModelPackageImpl.getDouble(), "change1", null, 1, 1, Quote.class, false, true, false);
-
property = (Property)quoteType.getProperties().get(QuoteImpl.QUOTES);
- initializeProperty(property, this.getQuote(), "quotes", null, 0, -1, Quote.class, false, false, false, true , null);
-
- initializeType(quoteBaseType, QuoteBase.class, "QuoteBase");
+ initializeProperty(property, this.getQuote(), "quotes", null, 0, -1, Quote.class, false, false, false, true, null);
+ initializeType(quoteBaseType, QuoteBase.class, "QuoteBase", false);
property = (Property)quoteBaseType.getProperties().get(QuoteBaseImpl.CHANGES);
- initializeProperty(property, theModelPackageImpl.getChangeSummaryType(), "changes", null, 1, 1, QuoteBase.class, false, false, false, false , null);
+ initializeProperty(property, theModelPackageImpl.getChangeSummaryType(), "changes", null, 1, 1, QuoteBase.class, false, false, false);
createXSDMetaData(theModelPackageImpl);
}
protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl)
{
-// TODO T-153 regenerate this code when issue with isProxy is fixed createXSDMetaData()
-// super.createXSDMetaData();
+ super.initXSD();
Property property = null;
Modified: incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/QuoteBaseImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/QuoteBaseImpl.java?view=diff&rev=483757&r1=483756&r2=483757
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/QuoteBaseImpl.java (original)
+++ incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/QuoteBaseImpl.java Thu Dec 7 16:31:39 2006
@@ -6,13 +6,9 @@
*/
package org.example.simple.cs.impl;
+import commonj.sdo.ChangeSummary;
import commonj.sdo.Type;
-import org.apache.tuscany.sdo.model.ChangeSummaryType;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.InternalEObject;
-
import org.example.simple.cs.CSFactory;
import org.example.simple.cs.QuoteBase;
@@ -113,7 +109,7 @@
public final static int QUOTES = QuoteImpl.QUOTES;
/**
- * The feature id for the '<em><b>Changes</b></em>' reference.
+ * The feature id for the '<em><b>Changes</b></em>' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
@@ -132,34 +128,34 @@
public final static int SDO_PROPERTY_COUNT = QuoteImpl.SDO_PROPERTY_COUNT + 1;
/**
- * The cached value of the '{@link #getChanges() <em>Changes</em>}' reference.
+ * The default value of the '{@link #getChanges() <em>Changes</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getChanges()
* @generated
* @ordered
*/
-
- protected ChangeSummaryType changes = null;
-
+ protected static final ChangeSummary CHANGES_DEFAULT_ = null;
+
/**
+ * The cached value of the '{@link #getChanges() <em>Changes</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
+ * @see #getChanges()
* @generated
+ * @ordered
*/
- protected QuoteBaseImpl()
- {
- super();
- }
+ protected ChangeSummary changes = CHANGES_DEFAULT_;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
- public Type getType()
+ public QuoteBaseImpl()
{
- return ((CSFactoryImpl)CSFactory.INSTANCE).getQuoteBase();
+ super();
+ createChangeSummary(CHANGES);
}
/**
@@ -167,39 +163,28 @@
* <!-- end-user-doc -->
* @generated
*/
- public ChangeSummaryType getChanges()
+ public Type getType()
{
-// TODO T-153 regenerate this code when issue with isProxy is fixed
-// if (changes != null && ((EObject)changes).isProxy())
-// {
-// InternalEObject oldChanges = (InternalEObject)changes;
-// changes = (ChangeSummaryType)eResolveProxy(oldChanges);
-// if (changes != oldChanges)
-// {
-// if (isNotifying())
-// notify(ChangeKind.RESOLVE, CHANGES, oldChanges, changes);
-// }
-// }
- return changes;
+ return ((CSFactoryImpl)CSFactory.INSTANCE).getQuoteBase();
}
+
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
- public ChangeSummaryType basicGetChanges()
+ public ChangeSummary getChanges()
{
return changes;
}
-
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
- public void setChanges(ChangeSummaryType newChanges)
+ public void setChanges(ChangeSummary newChanges)
{
- ChangeSummaryType oldChanges = changes;
+ ChangeSummary oldChanges = changes;
changes = newChanges;
if (isNotifying())
notify(ChangeKind.SET, CHANGES, oldChanges, changes);
@@ -215,8 +200,7 @@
switch (propertyIndex)
{
case CHANGES:
- if (resolve) return getChanges();
- return basicGetChanges();
+ return getChanges();
}
return super.get(propertyIndex, resolve);
}
@@ -231,7 +215,7 @@
switch (propertyIndex)
{
case CHANGES:
- setChanges((ChangeSummaryType)newValue);
+ setChanges((ChangeSummary)newValue);
return;
}
super.set(propertyIndex, newValue);
@@ -247,7 +231,7 @@
switch (propertyIndex)
{
case CHANGES:
- setChanges((ChangeSummaryType)null);
+ setChanges(CHANGES_DEFAULT_);
return;
}
super.unset(propertyIndex);
@@ -263,9 +247,25 @@
switch (propertyIndex)
{
case CHANGES:
- return changes != null;
+ return CHANGES_DEFAULT_ == null ? changes != null : !CHANGES_DEFAULT_.equals(changes);
}
return super.isSet(propertyIndex);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String toString()
+ {
+ if (isProxy(this)) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (changes: ");
+ result.append(changes);
+ result.append(')');
+ return result.toString();
}
} //QuoteBaseImpl
Modified: incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/QuoteImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/QuoteImpl.java?view=diff&rev=483757&r1=483756&r2=483757
==============================================================================
--- incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/QuoteImpl.java (original)
+++ incubator/tuscany/java/sdo/tools/src/test/java/org/example/simple/cs/impl/QuoteImpl.java Thu Dec 7 16:31:39 2006
@@ -326,7 +326,7 @@
* <!-- end-user-doc -->
* @generated
*/
- protected QuoteImpl()
+ public QuoteImpl()
{
super();
}
@@ -749,7 +749,7 @@
*/
public String toString()
{
- if (isProxy()) return super.toString();
+ if (isProxy(this)) return super.toString();
StringBuffer result = new StringBuffer(super.toString());
result.append(" (symbol: ");
Modified: incubator/tuscany/java/sdo/tools/templates/models/SDOClass.javajet
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sdo/tools/templates/models/SDOClass.javajet?view=diff&rev=483757&r1=483756&r2=483757
==============================================================================
--- incubator/tuscany/java/sdo/tools/templates/models/SDOClass.javajet (original)
+++ incubator/tuscany/java/sdo/tools/templates/models/SDOClass.javajet Thu Dec 7 16:31:39 2006
@@ -1,4 +1,4 @@
-<%@ jet package="org.apache.tuscany.sdo.generate.templates.model" skeleton="generator.skeleton" imports="org.eclipse.emf.codegen.util.* java.util.* org.eclipse.emf.codegen.ecore.genmodel.*" class="SDOClass" version="$Id: Class.javajet,v 1.41 2006/02/15 19:58:39 emerks Exp $" %>
+<%@ jet package="org.apache.tuscany.sdo.generate.templates.model" skeleton="generator.skeleton" imports="org.apache.tuscany.sdo.generate.util.* java.util.* org.eclipse.emf.codegen.ecore.genmodel.*" class="SDOClass" version="$Id: Class.javajet,v 1.41 2006/02/15 19:58:39 emerks Exp $" %>
<%
/**
*
@@ -337,6 +337,9 @@
super();
<%for (Iterator i=genClass.getFlagGenFeatures("true").iterator(); i.hasNext();) { GenFeature genFeature = (GenFeature)i.next();%>
<%=genClass.getFlagsField(genFeature)%> |= <%=genFeature.getUpperName()%>_EFLAG;
+ <%}%>
+ <%if (SDOGenUtil.hasChangeSummaryProperty(genClass)) {%>
+ createChangeSummary(<%=SDOGenUtil.getChangeSummaryProperty(genClass)%>);
<%}%>
}
Modified: incubator/tuscany/java/spec/sdo-api/src/main/resources/xml/datagraph.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/spec/sdo-api/src/main/resources/xml/datagraph.xsd?view=diff&rev=483757&r1=483756&r2=483757
==============================================================================
--- incubator/tuscany/java/spec/sdo-api/src/main/resources/xml/datagraph.xsd (original)
+++ incubator/tuscany/java/spec/sdo-api/src/main/resources/xml/datagraph.xsd Thu Dec 7 16:31:39 2006
@@ -21,6 +21,7 @@
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sdo="commonj.sdo"
+ xmlns:sdoJava="commonj.sdo/java"
targetNamespace="commonj.sdo">
<xsd:element name="datagraph" type="sdo:DataGraphType"/>
@@ -66,6 +67,11 @@
</xsd:sequence>
</xsd:complexType>
+<!-- FB TEMP -->
+ <xsd:simpleType name="ChangeSummaryType" sdoJava:instanceClass="commonj.sdo.ChangeSummary">
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+<!--
<xsd:complexType name="ChangeSummaryType">
<xsd:sequence>
<xsd:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="lax"/>
@@ -74,6 +80,7 @@
<xsd:attribute name="delete" type="xsd:string"/>
<xsd:attribute name="logging" type="xsd:boolean"/>
</xsd:complexType>
+-->
<xsd:attribute name="ref" type="xsd:string"/>
<xsd:attribute name="unset" type="xsd:string"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org