From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../com/example/customer/impl/AccountImpl.java | 256 +++++++++++++ .../example/customer/impl/CustomerFactoryImpl.java | 296 +++++++++++++++ .../com/example/customer/impl/CustomerImpl.java | 419 +++++++++++++++++++++ 3 files changed, 971 insertions(+) create mode 100644 branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/AccountImpl.java create mode 100644 branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/CustomerFactoryImpl.java create mode 100644 branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/CustomerImpl.java (limited to 'branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl') diff --git a/branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/AccountImpl.java b/branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/AccountImpl.java new file mode 100644 index 0000000000..a5d03e0b25 --- /dev/null +++ b/branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/AccountImpl.java @@ -0,0 +1,256 @@ +/** + * + * 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 com.example.customer.impl; + +import com.example.customer.Account; +import com.example.customer.CustomerFactory; + +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +/** + * + * An implementation of the model object 'Account'. + * + *

+ * The following features are implemented: + *

+ *

+ * + * @generated + */ +public class AccountImpl extends DataObjectBase implements Account +{ + + public final static int ACCOUNT_NUM = 0; + + public final static int SDO_PROPERTY_COUNT = 1; + + public final static int EXTENDED_PROPERTY_COUNT = 0; + + + /** + * The internal feature id for the 'Account Num' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ACCOUNT_NUM = 0; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 1; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_ACCOUNT_NUM: return ACCOUNT_NUM; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The default value of the '{@link #getAccountNum() Account Num}' attribute. + * + * + * @see #getAccountNum() + * @generated + * @ordered + */ + protected static final int ACCOUNT_NUM_DEFAULT_ = 0; + + /** + * The cached value of the '{@link #getAccountNum() Account Num}' attribute. + * + * + * @see #getAccountNum() + * @generated + * @ordered + */ + protected int accountNum = ACCOUNT_NUM_DEFAULT_; + + /** + * This is true if the Account Num attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean accountNum_set_ = false; + + /** + * + * + * @generated + */ + public AccountImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((CustomerFactoryImpl)CustomerFactory.INSTANCE).getAccount(); + } + + /** + * + * + * @generated + */ + public int getAccountNum() + { + return accountNum; + } + /** + * + * + * @generated + */ + public void setAccountNum(int newAccountNum) + { + int oldAccountNum = accountNum; + accountNum = newAccountNum; + boolean oldAccountNum_set_ = accountNum_set_; + accountNum_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_ACCOUNT_NUM, oldAccountNum, accountNum, !oldAccountNum_set_); + } + + /** + * + * + * @generated + */ + public void unsetAccountNum() + { + int oldAccountNum = accountNum; + boolean oldAccountNum_set_ = accountNum_set_; + accountNum = ACCOUNT_NUM_DEFAULT_; + accountNum_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_ACCOUNT_NUM, oldAccountNum, ACCOUNT_NUM_DEFAULT_, oldAccountNum_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetAccountNum() + { + return accountNum_set_; + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case ACCOUNT_NUM: + return new Integer(getAccountNum()); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case ACCOUNT_NUM: + setAccountNum(((Integer)newValue).intValue()); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case ACCOUNT_NUM: + unsetAccountNum(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case ACCOUNT_NUM: + return isSetAccountNum(); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (accountNum: "); + if (accountNum_set_) result.append(accountNum); else result.append(""); + result.append(')'); + return result.toString(); + } + +} //AccountImpl diff --git a/branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/CustomerFactoryImpl.java b/branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/CustomerFactoryImpl.java new file mode 100644 index 0000000000..271b273348 --- /dev/null +++ b/branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/CustomerFactoryImpl.java @@ -0,0 +1,296 @@ +/** + * + * 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 com.example.customer.impl; + +import commonj.sdo.helper.HelperContext; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; + +import com.example.customer.*; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.FactoryBase; + +import org.apache.tuscany.sdo.model.ModelFactory; + +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; + +/** + * + * An implementation of the model Factory. + * Generator information: + * patternVersion=1.2; -prefix Customer + * + * @generated + */ +public class CustomerFactoryImpl extends FactoryBase implements CustomerFactory +{ + + /** + * The package namespace URI. + * + * + * @generated + */ + public static final String NAMESPACE_URI = "http://example.com/customer"; + + /** + * The package namespace name. + * + * + * @generated + */ + public static final String NAMESPACE_PREFIX = "stn_1"; + + /** + * The version of the generator pattern used to generate this class. + * + * + * @generated + */ + public static final String PATTERN_VERSION = "1.2"; + + public static final int ACCOUNT = 1; + public static final int CUSTOMER = 2; + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public CustomerFactoryImpl() + { + super(NAMESPACE_URI, NAMESPACE_PREFIX, "com.example.customer"); + } + + /** + * Registers the Factory instance so that it is available within the supplied scope. + * @argument scope a HelperContext instance that will make the types supported by this Factory available. + * + * + * @generated + */ + public void register(HelperContext scope) + { + if(scope == null) { + throw new IllegalArgumentException("Scope can not be null"); + } + + //Register dependent packages with provided scope + ModelFactory.INSTANCE.register(scope); + + // Initialize this package + TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); + th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); + } + + /** + * + * + * @generated + */ + public DataObject create(int typeNumber) + { + switch (typeNumber) + { + case ACCOUNT: return (DataObject)createAccount(); + case CUSTOMER: return (DataObject)createCustomer(); + default: + return super.create(typeNumber); + } + } + + /** + * + * + * @generated + */ + public Account createAccount() + { + AccountImpl account = new AccountImpl(); + return account; + } + /** + * + * + * @generated + */ + public Customer createCustomer() + { + CustomerImpl customer = new CustomerImpl(); + return customer; + } + + // Following creates and initializes SDO metadata for the supported types. + protected Type accountType = null; + + public Type getAccount() + { + return accountType; + } + + protected Type customerType = null; + + public Type getCustomer() + { + return customerType; + } + + + private static CustomerFactoryImpl instance = null; + public static CustomerFactoryImpl init() + { + if (instance != null ) return instance; + instance = new CustomerFactoryImpl(); + + // Initialize dependent packages + ModelFactory ModelFactoryInstance = ModelFactory.INSTANCE; + + // Create package meta-data objects + instance.createMetaData(); + + // Initialize created meta-data + instance.initializeMetaData(); + + // Mark meta-data to indicate it can't be changed + //theCustomerFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ???? + + return instance; + } + + private boolean isCreated = false; + + public void createMetaData() + { + if (isCreated) return; + isCreated = true; + + // Create types and their properties + accountType = createType(false, ACCOUNT); + createProperty(true, accountType,AccountImpl.INTERNAL_ACCOUNT_NUM); + customerType = createType(false, CUSTOMER); + createProperty(false, customerType,CustomerImpl.INTERNAL_ACCOUNT); + createProperty(true, customerType,CustomerImpl.INTERNAL_FIRST_NAME); + } + + private boolean isInitialized = false; + + public void initializeMetaData() + { + if (isInitialized) return; + isInitialized = true; + + // Obtain other dependent packages + ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)ModelFactory.INSTANCE; + Property property = null; + + // Add supertypes to types + + // Initialize types and properties + initializeType(accountType, Account.class, "Account", false); + property = getLocalProperty(accountType, 0); + initializeProperty(property, theModelPackageImpl.getInt(), "accountNum", "0", 0, 1, Account.class, false, true, false); + + initializeType(customerType, Customer.class, "Customer", false); + property = getLocalProperty(customerType, 0); + initializeProperty(property, this.getAccount(), "account", null, 1, 1, Customer.class, false, true, false, true , null); + + property = getLocalProperty(customerType, 1); + initializeProperty(property, theModelPackageImpl.getString(), "firstName", null, 0, 1, Customer.class, false, true, false); + + createXSDMetaData(theModelPackageImpl); + } + + protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl) + { + super.initXSD(); + + Property property = null; + + + addXSDMapping + (accountType, + new String[] + { + "name", "Account", + "kind", "empty" + }); + + addXSDMapping + (getProperty(accountType, AccountImpl.INTERNAL_ACCOUNT_NUM), + new String[] + { + "kind", "attribute", + "name", "accountNum", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (customerType, + new String[] + { + "name", "Customer", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(customerType, CustomerImpl.INTERNAL_ACCOUNT), + new String[] + { + "kind", "element", + "name", "account", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (getProperty(customerType, CustomerImpl.INTERNAL_FIRST_NAME), + new String[] + { + "kind", "attribute", + "name", "firstName", + "namespace", "##targetNamespace" + }); + + property = createGlobalProperty + ("account", + this.getAccount(), + new String[] + { + "kind", "element", + "name", "account", + "namespace", "##targetNamespace" + }); + + property = createGlobalProperty + ("customer", + this.getCustomer(), + new String[] + { + "kind", "element", + "name", "customer", + "namespace", "##targetNamespace" + }); + + } + +} //CustomerFactoryImpl diff --git a/branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/CustomerImpl.java b/branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/CustomerImpl.java new file mode 100644 index 0000000000..c3838b760d --- /dev/null +++ b/branches/sdo-1.0-incubating/tools/src/test/java/com/example/customer/impl/CustomerImpl.java @@ -0,0 +1,419 @@ +/** + * + * 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 com.example.customer.impl; + +import com.example.customer.Account; +import com.example.customer.Customer; +import com.example.customer.CustomerFactory; + +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +/** + * + * An implementation of the model object 'Customer'. + * + *

+ * The following features are implemented: + *

+ *

+ * + * @generated + */ +public class CustomerImpl extends DataObjectBase implements Customer +{ + + public final static int ACCOUNT = 0; + + public final static int FIRST_NAME = 1; + + public final static int SDO_PROPERTY_COUNT = 2; + + public final static int EXTENDED_PROPERTY_COUNT = 0; + + + /** + * The internal feature id for the 'Account' containment reference. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ACCOUNT = 0; + + /** + * The internal feature id for the 'First Name' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_FIRST_NAME = 1; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 2; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_ACCOUNT: return ACCOUNT; + case INTERNAL_FIRST_NAME: return FIRST_NAME; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getAccount() Account}' containment reference. + * + * + * @see #getAccount() + * @generated + * @ordered + */ + + protected Account account = null; + + /** + * This is true if the Account containment reference has been set. + * + * + * @generated + * @ordered + */ + protected boolean account_set_ = false; + + /** + * The default value of the '{@link #getFirstName() First Name}' attribute. + * + * + * @see #getFirstName() + * @generated + * @ordered + */ + protected static final String FIRST_NAME_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getFirstName() First Name}' attribute. + * + * + * @see #getFirstName() + * @generated + * @ordered + */ + protected String firstName = FIRST_NAME_DEFAULT_; + + /** + * This is true if the First Name attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean firstName_set_ = false; + + /** + * + * + * @generated + */ + public CustomerImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((CustomerFactoryImpl)CustomerFactory.INSTANCE).getCustomer(); + } + + /** + * + * + * @generated + */ + public Account getAccount() + { + return account; + } + /** + * + * + * @generated + */ + public ChangeContext basicSetAccount(Account newAccount, ChangeContext changeContext) + { + Account oldAccount = account; + account = newAccount; + boolean oldAccount_set_ = account_set_; + account_set_ = true; + if (isNotifying()) + { + addNotification(this, ChangeKind.SET, INTERNAL_ACCOUNT, oldAccount, newAccount, !oldAccount_set_, changeContext); + } + return changeContext; + } + + /** + * + * + * @generated + */ + public void setAccount(Account newAccount) + { + if (newAccount != account) + { + ChangeContext changeContext = null; + if (account != null) + changeContext = inverseRemove(account, this, OPPOSITE_FEATURE_BASE - INTERNAL_ACCOUNT, null, changeContext); + if (newAccount != null) + changeContext = inverseAdd(newAccount, this, OPPOSITE_FEATURE_BASE - INTERNAL_ACCOUNT, null, changeContext); + changeContext = basicSetAccount(newAccount, changeContext); + if (changeContext != null) dispatch(changeContext); + } + else + { + boolean oldAccount_set_ = account_set_; + account_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_ACCOUNT, newAccount, newAccount, !oldAccount_set_); + } + } + + /** + * + * + * @generated + */ + public ChangeContext basicUnsetAccount(ChangeContext changeContext) + { + Account oldAccount = account; + account = null; + boolean oldAccount_set_ = account_set_; + account_set_ = false; + if (isNotifying()) + { + addNotification(this, ChangeKind.UNSET, INTERNAL_ACCOUNT, oldAccount, null, !oldAccount_set_, changeContext); + } + return changeContext; + } + + /** + * + * + * @generated + */ + public void unsetAccount() + { + if (account != null) + { + ChangeContext changeContext = null; + changeContext = inverseRemove(account, this, EOPPOSITE_FEATURE_BASE - INTERNAL_ACCOUNT, null, changeContext); + changeContext = basicUnsetAccount(changeContext); + if (changeContext != null) dispatch(changeContext); + } + else + { + boolean oldAccount_set_ = account_set_; + account_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_ACCOUNT, null, null, oldAccount_set_); + } + } + + /** + * + * + * @generated + */ + public boolean isSetAccount() + { + return account_set_; + } + + /** + * + * + * @generated + */ + public String getFirstName() + { + return firstName; + } + /** + * + * + * @generated + */ + public void setFirstName(String newFirstName) + { + String oldFirstName = firstName; + firstName = newFirstName; + boolean oldFirstName_set_ = firstName_set_; + firstName_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_FIRST_NAME, oldFirstName, firstName, !oldFirstName_set_); + } + + /** + * + * + * @generated + */ + public void unsetFirstName() + { + String oldFirstName = firstName; + boolean oldFirstName_set_ = firstName_set_; + firstName = FIRST_NAME_DEFAULT_; + firstName_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_FIRST_NAME, oldFirstName, FIRST_NAME_DEFAULT_, oldFirstName_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetFirstName() + { + return firstName_set_; + } + + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case ACCOUNT: + return basicUnsetAccount(changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case ACCOUNT: + return getAccount(); + case FIRST_NAME: + return getFirstName(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case ACCOUNT: + setAccount((Account)newValue); + return; + case FIRST_NAME: + setFirstName((String)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case ACCOUNT: + unsetAccount(); + return; + case FIRST_NAME: + unsetFirstName(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case ACCOUNT: + return isSetAccount(); + case FIRST_NAME: + return isSetFirstName(); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (firstName: "); + if (firstName_set_) result.append(firstName); else result.append(""); + result.append(')'); + return result.toString(); + } + +} //CustomerImpl -- cgit v1.2.3