use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class IsSetNillableOptionalWithDefaultTestCases method registerTypes.
@Override
public void registerTypes() {
Type stringType = typeHelper.getType("commonj.sdo", "String");
Type intType = typeHelper.getType("commonj.sdo", "Int");
SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
// create employee type
DataObject employeeTypeDO = dataFactory.create("commonj.sdo", "Type");
employeeTypeDO.set("uri", getControlRootURI());
employeeTypeDO.set("name", getRootInterfaceName());
// add id property
DataObject employeeIDProperty = addProperty(employeeTypeDO, ID_NAME, intType, false, false, true);
employeeIDProperty.set("nullable", true);
employeeIDProperty.set("default", 10);
// add firstname property
DataObject employeeFirstnameProperty = addProperty(employeeTypeDO, FIRSTNAME_NAME, stringType, false, false, true);
employeeFirstnameProperty.set("nullable", true);
employeeFirstnameProperty.set("default", "default-first");
// add task property
DataObject employeeTaskProperty = addProperty(employeeTypeDO, TASK_NAME, stringType, false, true, true);
// employeeTaskProperty.set("nullable", false);
// employeeTaskProperty.set("default", new ArrayList());
employeeTaskProperty.setBoolean("many", true);
// add lastname property
DataObject employeeLastnameProperty = addProperty(employeeTypeDO, LASTNAME_NAME, stringType, false, false, true);
// employeeLastnameProperty.set("nullable", false);
// employeeLastnameProperty.set("default", "default-last");
// define type
Type employeeSDOType = typeHelper.define(employeeTypeDO);
// create a property of type employee - and associate the discriptor by QName
DataObject propDO = dataFactory.create(propertyType);
propDO.set("name", getControlRootName());
propDO.set("type", employeeSDOType);
typeHelper.defineOpenContentProperty(getControlRootURI(), propDO);
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class IsSetNillableWithDefaultTestCases method registerTypes.
@Override
public void registerTypes() {
Type stringType = typeHelper.getType("commonj.sdo", "String");
Type intType = typeHelper.getType("commonj.sdo", "Int");
SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
// create employee type
DataObject employeeTypeDO = dataFactory.create("commonj.sdo", "Type");
employeeTypeDO.set("uri", getControlRootURI());
employeeTypeDO.set("name", getRootInterfaceName());
// add id property
DataObject employeeIDProperty = addProperty(employeeTypeDO, ID_NAME, intType, false, false, true);
employeeIDProperty.set("nullable", true);
employeeIDProperty.set("default", 10);
// add firstname property
DataObject employeeFirstnameProperty = addProperty(employeeTypeDO, FIRSTNAME_NAME, stringType, false, false, true);
employeeFirstnameProperty.set("nullable", true);
employeeFirstnameProperty.set("default", "default-first");
// add task property
DataObject employeeTaskProperty = addProperty(employeeTypeDO, TASK_NAME, stringType, false, true, true);
// employeeTaskProperty.set("nullable", false);
// employeeTaskProperty.set("default", new ArrayList());
employeeTaskProperty.setBoolean("many", true);
// add lastname property
DataObject employeeLastnameProperty = addProperty(employeeTypeDO, LASTNAME_NAME, stringType, false, false, true);
// employeeLastnameProperty.set("nullable", false);
// employeeLastnameProperty.set("default", "default-last");
// define type
Type employeeSDOType = typeHelper.define(employeeTypeDO);
// create a property of type employee - and associate the discriptor by QName
DataObject propDO = dataFactory.create(propertyType);
propDO.set("name", getControlRootName());
propDO.set("type", employeeSDOType);
typeHelper.defineOpenContentProperty(getControlRootURI(), propDO);
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class XSDHelperSimpleTypeTestCases method testSimpleTypeWithSDO_Java_InstanceClass.
// commonj.sdo/java
public void testSimpleTypeWithSDO_Java_InstanceClass() {
String f = "org/eclipse/persistence/testing/sdo/helper/xsdhelper/define/simpletypes/SimpleTypeWithSDOJavaInstanceClass.xsd";
String xmlSchema = getSchema(f);
List types = xsdHelper.define(xmlSchema);
assertEquals(types.size(), 1);
Type type = (Type) types.get(0);
// Name
assertEquals("my-int", type.getName());
// abstract
assertFalse(type.isAbstract());
// Base
assertEquals(type.getBaseTypes().size(), 0);
// dataType
assertTrue(type.isDataType());
// Uri
assertEquals(type.getURI(), "http://www.example.org");
assertEquals("INSTANCE_CLASS", ((SDOType) type).getInstanceClassName());
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class XSDHelperSimpleTypeTestCases method testSimpleTypeWithSDO_JAVA_ExtendedInstanceClass.
public void testSimpleTypeWithSDO_JAVA_ExtendedInstanceClass() {
String f = "org/eclipse/persistence/testing/sdo/helper/xsdhelper/define/simpletypes/SimpleTypeWithSDOJavaExtendedInstanceClass.xsd";
String xmlSchema = getSchema(f);
List types = xsdHelper.define(xmlSchema);
assertEquals(types.size(), 1);
Type type = (Type) types.get(0);
// Name
assertEquals("my-int", type.getName());
// abstract
assertFalse(type.isAbstract());
// Base
assertEquals(type.getBaseTypes().size(), 1);
Type baseType = (Type) type.getBaseTypes().get(0);
assertEquals(baseType, SDOConstants.SDO_INT);
assertEquals(((SDOType) baseType).getSubTypes().size(), 0);
// this.assertEquals(baseType.getName(), "int");
// this.assertEquals(baseType.getURI(), "commonj.sdo");
// dataType
assertTrue(type.isDataType());
// Uri
assertEquals(type.getURI(), "http://www.example.org");
assertEquals("EXTENDED_INSTANCE_CLASS", ((SDOType) type).getInstanceClassName());
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class DefineAndGenerateAppInfoTNSTestCases method getControlTypes.
@Override
public List getControlTypes() {
List types = new ArrayList();
String uri = "theTNS";
Type stringType = typeHelper.getType("commonj.sdo", "String");
Type intType = typeHelper.getType("commonj.sdo", "Int");
Type dateType = typeHelper.getType("commonj.sdo", "Date");
Type yearMonthDayType = SDOConstants.SDO_YEARMONTHDAY;
Type decimalType = typeHelper.getType("commonj.sdo", "Decimal");
/**
**ADDRESS TYPE****
*/
// ADDRESS TYPE
SDOType USaddrType = new SDOType(uri, "USAddress");
USaddrType.setDataType(false);
USaddrType.setInstanceClassName("abc.USAddress");
SDOProperty addrNameProp = new SDOProperty(aHelperContext);
addrNameProp.setName("name");
addrNameProp.setXsd(true);
addrNameProp.setXsdLocalName("name");
addrNameProp.setType(stringType);
USaddrType.addDeclaredProperty(addrNameProp);
SDOProperty streetProp = new SDOProperty(aHelperContext);
streetProp.setName("street");
streetProp.setXsd(true);
streetProp.setXsdLocalName("street");
streetProp.setType(stringType);
USaddrType.addDeclaredProperty(streetProp);
SDOProperty cityProp = new SDOProperty(aHelperContext);
cityProp.setName("city");
cityProp.setXsd(true);
cityProp.setXsdLocalName("city");
cityProp.setType(stringType);
USaddrType.addDeclaredProperty(cityProp);
SDOProperty stateProp = new SDOProperty(aHelperContext);
stateProp.setName("state");
stateProp.setXsd(true);
stateProp.setXsdLocalName("state");
stateProp.setType(stringType);
USaddrType.addDeclaredProperty(stateProp);
SDOProperty zipProp = new SDOProperty(aHelperContext);
zipProp.setName("zip");
zipProp.setXsd(true);
zipProp.setXsdLocalName("zip");
zipProp.setType(decimalType);
USaddrType.addDeclaredProperty(zipProp);
SDOProperty countryProp = new SDOProperty(aHelperContext);
countryProp.setName("country");
countryProp.setXsd(true);
countryProp.setXsdLocalName("country");
countryProp.setType(stringType);
countryProp.setDefault("US");
USaddrType.addDeclaredProperty(countryProp);
/**
**QUANTITY TYPE****
*/
SDOType quantityType = new SDOType(uri, "quantityType");
quantityType.setDataType(true);
quantityType.setInstanceClass(ClassConstants.PINT);
quantityType.getBaseTypes().add(intType);
/**
**SKU TYPE****
*/
SDOType SKUType = new SDOType(uri, "SKU");
SKUType.setInstanceClassName("java.lang.String");
SKUType.setDataType(true);
SKUType.getBaseTypes().add(stringType);
/**
**ITEM TYPE****
*/
SDOType itemType = new SDOType(uri, "Item");
itemType.setInstanceClassName("abc.Item");
itemType.setDataType(false);
SDOProperty productNameProp = new SDOProperty(aHelperContext);
productNameProp.setName("productName");
productNameProp.setXsd(true);
productNameProp.setXsdLocalName("productName");
productNameProp.setType(stringType);
itemType.addDeclaredProperty(productNameProp);
SDOProperty quantityProp = new SDOProperty(aHelperContext);
quantityProp.setName("quantity");
quantityProp.setXsd(true);
quantityProp.setXsdLocalName("quantity");
quantityProp.setType(quantityType);
itemType.addDeclaredProperty(quantityProp);
SDOProperty partNumProp = new SDOProperty(aHelperContext);
partNumProp.setName("partNum");
partNumProp.setXsd(true);
partNumProp.setXsdLocalName("partNum");
partNumProp.setType(SKUType);
itemType.addDeclaredProperty(partNumProp);
SDOProperty USPriceProp = new SDOProperty(aHelperContext);
USPriceProp.setName("USPrice");
USPriceProp.setXsd(true);
USPriceProp.setXsdLocalName("USPrice");
USPriceProp.setType(decimalType);
itemType.addDeclaredProperty(USPriceProp);
SDOProperty itemCommentProp = new SDOProperty(aHelperContext);
itemCommentProp.setName("comment");
itemCommentProp.setXsd(true);
itemCommentProp.setXsdLocalName("comment");
itemCommentProp.setType(stringType);
itemCommentProp.setContainment(false);
itemType.addDeclaredProperty(itemCommentProp);
SDOProperty shipDateProp = new SDOProperty(aHelperContext);
shipDateProp.setName("shipDate");
shipDateProp.setXsd(true);
shipDateProp.setXsdLocalName("shipDate");
shipDateProp.setType(yearMonthDayType);
shipDateProp.setContainment(false);
itemType.addDeclaredProperty(shipDateProp);
/**
**ITEMS TYPE****
*/
SDOType itemsType = new SDOType(uri, "Items");
itemsType.setDataType(false);
itemsType.setInstanceClassName("abc.Items");
SDOProperty itemProp = new SDOProperty(aHelperContext);
itemProp.setName("item");
itemProp.setContainment(true);
itemProp.setMany(true);
itemProp.setXsd(true);
itemProp.setXsdLocalName("item");
itemProp.setType(itemType);
itemsType.addDeclaredProperty(itemProp);
/**
**PURCHASEORDER TYPE****
*/
SDOProperty shipToProp = new SDOProperty(aHelperContext);
shipToProp.setName("shipTo");
shipToProp.setXsd(true);
shipToProp.setXsdLocalName("shipTo");
shipToProp.setContainment(true);
shipToProp.setType(USaddrType);
SDOProperty billToProp = new SDOProperty(aHelperContext);
billToProp.setName("billTo");
billToProp.setXsd(true);
billToProp.setXsdLocalName("billTo");
billToProp.setContainment(true);
billToProp.setType(USaddrType);
SDOProperty itemsProp = new SDOProperty(aHelperContext);
itemsProp.setName("items");
itemsProp.setXsd(true);
itemsProp.setXsdLocalName("items");
itemsProp.setContainment(true);
itemsProp.setType(itemsType);
SDOProperty commentProp = new SDOProperty(aHelperContext);
commentProp.setName("comment");
commentProp.setXsd(true);
commentProp.setXsdLocalName("comment");
commentProp.setType(stringType);
commentProp.setContainment(false);
SDOProperty orderDateProp = new SDOProperty(aHelperContext);
orderDateProp.setName("orderDate");
orderDateProp.setXsd(true);
orderDateProp.setXsdLocalName("orderDate");
orderDateProp.setType(yearMonthDayType);
orderDateProp.setContainment(false);
SDOType POtype = new SDOType(uri, "PurchaseOrder");
POtype.setInstanceClassName("abc.PurchaseOrder");
POtype.setDataType(false);
POtype.addDeclaredProperty(shipToProp);
POtype.addDeclaredProperty(billToProp);
POtype.addDeclaredProperty(itemsProp);
POtype.addDeclaredProperty(commentProp);
POtype.addDeclaredProperty(orderDateProp);
types.add(USaddrType);
types.add(POtype);
types.add(itemType);
types.add(itemsType);
types.add(SKUType);
types.add(quantityType);
return types;
}
Aggregations