use of org.eclipse.persistence.sdo.helper.SDOTypeHelper in project eclipselink by eclipse-ee4j.
the class SDOTestCase method setUp.
@Override
public void setUp() {
xmlComparer = new SDOXMLComparer();
if (customContext) {
// default to instance of a HelperContext
aHelperContext = new SDOHelperContext();
} else {
// default to static context (Global)
aHelperContext = HelperProvider.getDefaultContext();
}
typeHelper = aHelperContext.getTypeHelper();
xmlHelper = aHelperContext.getXMLHelper();
xsdHelper = aHelperContext.getXSDHelper();
equalityHelper = aHelperContext.getEqualityHelper();
copyHelper = aHelperContext.getCopyHelper();
dataFactory = aHelperContext.getDataFactory();
// TODO: we should be using the DataHelper interface
dataHelper = (SDODataHelper) aHelperContext.getDataHelper();
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(true);
builderFactory.setIgnoringElementContentWhitespace(true);
try {
parser = builderFactory.newDocumentBuilder();
} catch (Exception e) {
fail("Could not create parser.");
e.printStackTrace();
}
((SDOTypeHelper) typeHelper).reset();
((SDOXMLHelper) xmlHelper).reset();
((SDOXSDHelper) xsdHelper).reset();
}
use of org.eclipse.persistence.sdo.helper.SDOTypeHelper in project eclipselink by eclipse-ee4j.
the class DefineAndGenerateSequencesPurchaseOrderTestCases method getControlTypes.
@Override
public List getControlTypes() {
SDOType changeSummaryType = (SDOType) aHelperContext.getTypeHelper().getType(SDOConstants.SDO_URL, SDOConstants.CHANGESUMMARY);
List<Type> types = new ArrayList<Type>();
((SDOTypeHelper) typeHelper).reset();
// String xsdSchema = getSchema("org/eclipse/persistence/testing/sdo/schemas/PurchaseOrderComplexSequenced.xsd");
// List types = xsdHelper.define(xsdSchema);
DataObject addressTypeDO = dataFactory.create("commonj.sdo", "Type");
addressTypeDO.set("uri", NON_DEFAULT_URI);
addressTypeDO.set("name", "AddressType");
addressTypeDO.set("sequenced", true);
addProperty(addressTypeDO, "name", SDOConstants.SDO_STRING, false, false, true);
addProperty(addressTypeDO, "street", SDOConstants.SDO_STRING, false, true, true);
addProperty(addressTypeDO, "city", SDOConstants.SDO_STRING, false, false, true);
Type addressType = typeHelper.define(addressTypeDO);
((SDOProperty) addressType.getProperty("name")).setXsd(true);
((SDOProperty) addressType.getProperty("name")).setXsdLocalName("name");
((SDOProperty) addressType.getProperty("street")).setXsd(true);
((SDOProperty) addressType.getProperty("street")).setXsdLocalName("street");
((SDOProperty) addressType.getProperty("city")).setXsd(true);
((SDOProperty) addressType.getProperty("city")).setXsdLocalName("city");
// -----------------
DataObject usAddressTypeDO = dataFactory.create("commonj.sdo", "Type");
usAddressTypeDO.set("uri", NON_DEFAULT_URI);
usAddressTypeDO.set("name", "usAddressType");
usAddressTypeDO.set("sequenced", true);
List<Type> baseTypes = new ArrayList<Type>();
baseTypes.add(addressType);
usAddressTypeDO.set("baseType", baseTypes);
DataObject stateProp = addProperty(usAddressTypeDO, "state", SDOConstants.SDO_STRING);
stateProp.set(SDOConstants.XMLELEMENT_PROPERTY, true);
Type usAddressType = typeHelper.define(usAddressTypeDO);
((SDOProperty) usAddressType.getProperty("state")).setXsd(true);
((SDOProperty) usAddressType.getProperty("state")).setXsdLocalName("state");
// -----------------
DataObject cdnAddressTypeDO = dataFactory.create("commonj.sdo", "Type");
cdnAddressTypeDO.set("uri", NON_DEFAULT_URI);
cdnAddressTypeDO.set("name", "cdnAddressType");
cdnAddressTypeDO.set("sequenced", true);
// reset
baseTypes = new ArrayList<Type>();
baseTypes.add(addressType);
cdnAddressTypeDO.set("baseType", baseTypes);
addProperty(cdnAddressTypeDO, "province", SDOConstants.SDO_STRING, false, false, true);
addProperty(cdnAddressTypeDO, "postalcode", SDOConstants.SDO_STRING, false, false, true);
Type cdnAddressType = typeHelper.define(cdnAddressTypeDO);
((SDOProperty) cdnAddressType.getProperty("province")).setXsd(true);
((SDOProperty) cdnAddressType.getProperty("province")).setXsdLocalName("province");
((SDOProperty) cdnAddressType.getProperty("postalcode")).setXsd(true);
((SDOProperty) cdnAddressType.getProperty("postalcode")).setXsdLocalName("postalcode");
// -----------------
DataObject cdnAddressMailingTypeDO = dataFactory.create("commonj.sdo", "Type");
cdnAddressMailingTypeDO.set("uri", NON_DEFAULT_URI);
cdnAddressMailingTypeDO.set("name", "cdnAddressMailingType");
cdnAddressMailingTypeDO.set("sequenced", true);
// reset
baseTypes = new ArrayList<Type>();
baseTypes.add(cdnAddressType);
cdnAddressMailingTypeDO.set("baseType", baseTypes);
DataObject deliveryInfoProp = addProperty(cdnAddressMailingTypeDO, "deliveryInfo", SDOConstants.SDO_STRING);
deliveryInfoProp.set(SDOConstants.XMLELEMENT_PROPERTY, true);
Type cdnAddressMailingType = typeHelper.define(cdnAddressMailingTypeDO);
((SDOProperty) cdnAddressMailingType.getProperty("deliveryInfo")).setXsd(true);
((SDOProperty) cdnAddressMailingType.getProperty("deliveryInfo")).setXsdLocalName("deliveryInfo");
// -----------------
DataObject itemTypeDO = dataFactory.create("commonj.sdo", "Type");
itemTypeDO.set("uri", NON_DEFAULT_URI);
itemTypeDO.set("name", "LineItemType");
DataObject prodcutNameProp = addProperty(itemTypeDO, "productName", SDOConstants.SDO_STRING);
prodcutNameProp.set(SDOConstants.XMLELEMENT_PROPERTY, true);
DataObject priceProp = addProperty(itemTypeDO, "price", SDOConstants.SDO_FLOAT);
priceProp.set(SDOConstants.XMLELEMENT_PROPERTY, true);
DataObject shipDateProp = addProperty(itemTypeDO, "shipDate", SDOConstants.SDO_STRING);
shipDateProp.set(SDOConstants.XMLELEMENT_PROPERTY, true);
DataObject commentProp = addProperty(itemTypeDO, "comment", SDOConstants.SDO_STRING);
commentProp.set(SDOConstants.XMLELEMENT_PROPERTY, true);
Type itemType = typeHelper.define(itemTypeDO);
((SDOProperty) itemType.getProperty("productName")).setXsd(true);
((SDOProperty) itemType.getProperty("productName")).setXsdLocalName("productName");
((SDOProperty) itemType.getProperty("price")).setXsd(true);
((SDOProperty) itemType.getProperty("price")).setXsdLocalName("price");
((SDOProperty) itemType.getProperty("shipDate")).setXsd(true);
((SDOProperty) itemType.getProperty("shipDate")).setXsdLocalName("shipDate");
((SDOProperty) itemType.getProperty("comment")).setXsd(true);
((SDOProperty) itemType.getProperty("comment")).setXsdLocalName("comment");
// -----------------
DataObject itemsTypeDO = dataFactory.create("commonj.sdo", "Type");
itemsTypeDO.set("uri", NON_DEFAULT_URI);
itemsTypeDO.set("name", "Items");
itemsTypeDO.set("sequenced", true);
addProperty(itemsTypeDO, "item", itemType, true, true, true);
Type itemsType = typeHelper.define(itemsTypeDO);
((SDOProperty) itemsType.getProperty("item")).setXsd(true);
((SDOProperty) itemsType.getProperty("item")).setXsdLocalName("item");
// -----------------
DataObject poTypeDO = dataFactory.create("commonj.sdo", "Type");
poTypeDO.set("uri", NON_DEFAULT_URI);
poTypeDO.set("name", "PurchaseOrderType");
addProperty(poTypeDO, "address", addressType, true, true, true);
addProperty(poTypeDO, "comment", SDOConstants.SDO_STRING, false, false, true);
addProperty(poTypeDO, "items", itemsType, true, false, true);
Type poType = typeHelper.define(poTypeDO);
((SDOProperty) poType.getProperty("address")).setXsd(true);
((SDOProperty) poType.getProperty("address")).setXsdLocalName("address");
((SDOProperty) poType.getProperty("comment")).setXsd(true);
((SDOProperty) poType.getProperty("comment")).setXsdLocalName("comment");
((SDOProperty) poType.getProperty("items")).setXsd(true);
((SDOProperty) poType.getProperty("items")).setXsdLocalName("items");
// ((SDOProperty)poType.getProperty("myCS")).setXsd(true);
// ((SDOProperty)poType.getProperty("myCS")).setXsdLocalName("myCS");
// -----------------
DataObject companyTypeDO = dataFactory.create("commonj.sdo", "Type");
companyTypeDO.set("uri", NON_DEFAULT_URI);
companyTypeDO.set("name", "CompanyType");
DataObject csProp = addProperty(companyTypeDO, "myCS", changeSummaryType, true, false, true);
csProp.set("readOnly", true);
addProperty(companyTypeDO, "order", poType, true, false, true);
Type companyType = typeHelper.define(companyTypeDO);
((SDOProperty) companyType.getProperty("myCS")).setXsd(true);
((SDOProperty) companyType.getProperty("myCS")).setXsdLocalName("myCS");
((SDOProperty) companyType.getProperty("order")).setXsd(true);
((SDOProperty) companyType.getProperty("order")).setXsdLocalName("order");
// ------------------
types.add(companyType);
types.add(cdnAddressType);
types.add(usAddressType);
types.add(itemsType);
types.add(poType);
types.add(cdnAddressMailingType);
types.add(itemType);
types.add(addressType);
return types;
}
use of org.eclipse.persistence.sdo.helper.SDOTypeHelper in project eclipselink by eclipse-ee4j.
the class DefineAndGenerateSequencesTestCases method getControlTypes.
@Override
public List<Type> getControlTypes() {
List<Type> types = new ArrayList<Type>();
((SDOTypeHelper) typeHelper).reset();
// String xsdSchema = getSchema("org/eclipse/persistence/testing/sdo/helper/xsdhelper/define/complextypes/ComplexTypeWithMultipleOpenContent.xsd");
// List types = xsdHelper.define(xsdSchema);
DataObject myTestType2DO = dataFactory.create("commonj.sdo", "Type");
myTestType2DO.set("uri", NON_DEFAULT_URI);
myTestType2DO.set("name", "myTestType2");
myTestType2DO.set("open", true);
myTestType2DO.set("sequenced", true);
Type myTestType2 = typeHelper.define(myTestType2DO);
((SDOType) myTestType2).setXsd(true);
((SDOType) myTestType2).setXsdLocalName("myTestType2");
DataObject myTestType5DO = dataFactory.create("commonj.sdo", "Type");
myTestType5DO.set("uri", NON_DEFAULT_URI);
myTestType5DO.set("name", "myTestType5");
myTestType5DO.set("sequenced", true);
myTestType5DO.set("open", true);
DataObject prop = addProperty(myTestType5DO, "test", SDOConstants.SDO_STRING);
prop.set("many", true);
prop = addProperty(myTestType5DO, "test2", SDOConstants.SDO_STRING);
prop.set("many", true);
Type myTestType5 = typeHelper.define(myTestType5DO);
((SDOType) myTestType5).setXsd(true);
((SDOType) myTestType5).setXsdLocalName("myTestType5");
((SDOProperty) myTestType5.getProperty("test")).setXsd(true);
((SDOProperty) myTestType5.getProperty("test")).setXsdLocalName("test");
((SDOProperty) myTestType5.getProperty("test2")).setXsd(true);
((SDOProperty) myTestType5.getProperty("test2")).setXsdLocalName("test2");
DataObject myTestType3DO = dataFactory.create("commonj.sdo", "Type");
myTestType3DO.set("uri", NON_DEFAULT_URI);
myTestType3DO.set("name", "myTestType3");
myTestType3DO.set("open", true);
myTestType3DO.set("sequenced", true);
Type myTestType3 = typeHelper.define(myTestType3DO);
((SDOType) myTestType3).setXsd(true);
((SDOType) myTestType3).setXsdLocalName("myTestType3");
DataObject myTestTypeDO = dataFactory.create("commonj.sdo", "Type");
myTestTypeDO.set("uri", NON_DEFAULT_URI);
myTestTypeDO.set("name", "myTestType");
myTestTypeDO.set("open", true);
myTestTypeDO.set("sequenced", true);
Type myTestType = typeHelper.define(myTestTypeDO);
((SDOType) myTestType).setXsd(true);
((SDOType) myTestType).setXsdLocalName("myTestType");
DataObject myTestType4DO = dataFactory.create("commonj.sdo", "Type");
myTestType4DO.set("uri", NON_DEFAULT_URI);
myTestType4DO.set("name", "myTestType4");
myTestType4DO.set("sequenced", true);
myTestType4DO.set("open", true);
myTestType4DO.set("sequenced", true);
prop = addProperty(myTestType4DO, "test", SDOConstants.SDO_STRING);
prop.set("many", true);
prop = addProperty(myTestType4DO, "test2", SDOConstants.SDO_STRING);
prop.set("many", true);
Type myTestType4 = typeHelper.define(myTestType4DO);
((SDOType) myTestType4).setXsd(true);
((SDOType) myTestType4).setXsdLocalName("myTestType4");
((SDOProperty) myTestType4.getProperty("test")).setXsd(true);
((SDOProperty) myTestType4.getProperty("test")).setXsdLocalName("test");
((SDOProperty) myTestType4.getProperty("test2")).setXsd(true);
((SDOProperty) myTestType4.getProperty("test2")).setXsdLocalName("test2");
types.add(myTestType2);
types.add(myTestType4);
types.add(myTestType);
types.add(myTestType5);
types.add(myTestType3);
return types;
}
use of org.eclipse.persistence.sdo.helper.SDOTypeHelper in project eclipselink by eclipse-ee4j.
the class DefineAndGenerateWrapperTypeTestCases method getTypesToGenerateFrom.
@Override
public List getTypesToGenerateFrom() {
// public List getControlTypes() {
List types = new ArrayList();
((SDOTypeHelper) typeHelper).reset();
SDOType dataObjectType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATAOBJECT);
SDOProperty xmlDataTypeProperty = (SDOProperty) typeHelper.getOpenContentProperty(SDOConstants.SDOXML_URL, SDOConstants.SDOXML_DATATYPE);
SDOProperty xmlSchemaTypeProperty = (SDOProperty) typeHelper.getOpenContentProperty(SDOConstants.ORACLE_SDO_URL, SDOConstants.XML_SCHEMA_TYPE_NAME);
DataObject myChildTypeDO = dataFactory.create("commonj.sdo", "Type");
myChildTypeDO.set("uri", "http://www.example.org");
myChildTypeDO.set("name", "childType");
addProperty(myChildTypeDO, "name", SDOConstants.SDO_STRING, false, false, true);
Type childType = typeHelper.define(myChildTypeDO);
((SDOProperty) childType.getProperty("name")).setXsd(true);
((SDOProperty) childType.getProperty("name")).setXsdLocalName("name");
DataObject myRootTypeDO = dataFactory.create("commonj.sdo", "Type");
myRootTypeDO.set("uri", "http://www.example.org");
myRootTypeDO.set("name", "rootType");
DataObject test1Prop = addProperty(myRootTypeDO, "test1", SDOConstants.SDO_INTOBJECT, false, false, true);
DataObject test2Prop = addProperty(myRootTypeDO, "test2", SDOConstants.SDO_BOOLEANOBJECT, false, false, true);
test2Prop.set(xmlDataTypeProperty, SDOConstants.SDO_BOOLEANOBJECT);
DataObject test3Prop = addProperty(myRootTypeDO, "test3", SDOConstants.SDO_DATE, false, false, true);
DataObject test4Prop = addProperty(myRootTypeDO, "test4", SDOConstants.SDO_DATETIME, false, false, true);
DataObject test5Prop = addProperty(myRootTypeDO, "test5", SDOConstants.SDO_SHORT, false, false, true);
test5Prop.set(xmlDataTypeProperty, SDOConstants.SDO_SHORTOBJECT);
DataObject test6Prop = addProperty(myRootTypeDO, "test6", dataObjectType, true, false, true);
test6Prop.set(xmlDataTypeProperty, dataObjectType);
DataObject test7Prop = addProperty(myRootTypeDO, "test7", childType, true, false, true);
test7Prop.set(xmlSchemaTypeProperty, childType);
test7Prop.set(xmlDataTypeProperty, dataObjectType);
Type myRootType = typeHelper.define(myRootTypeDO);
((SDOType) myRootType).setXsd(true);
((SDOType) myRootType).setXsdLocalName("rootType");
((SDOProperty) myRootType.getProperty("test1")).setXsd(true);
((SDOProperty) myRootType.getProperty("test1")).setXsdLocalName("test1");
((SDOProperty) myRootType.getProperty("test2")).setXsd(true);
((SDOProperty) myRootType.getProperty("test2")).setXsdLocalName("test2");
((SDOProperty) myRootType.getProperty("test3")).setXsd(true);
((SDOProperty) myRootType.getProperty("test3")).setXsdLocalName("test3");
((SDOProperty) myRootType.getProperty("test4")).setXsd(true);
((SDOProperty) myRootType.getProperty("test4")).setXsdLocalName("test4");
((SDOProperty) myRootType.getProperty("test5")).setXsd(true);
((SDOProperty) myRootType.getProperty("test5")).setXsdLocalName("test5");
((SDOProperty) myRootType.getProperty("test6")).setXsd(true);
((SDOProperty) myRootType.getProperty("test6")).setXsdLocalName("test6");
((SDOProperty) myRootType.getProperty("test7")).setXsd(true);
((SDOProperty) myRootType.getProperty("test7")).setXsdLocalName("test7");
types.add(childType);
types.add(myRootType);
return types;
}
use of org.eclipse.persistence.sdo.helper.SDOTypeHelper in project eclipselink by eclipse-ee4j.
the class DefineAndGenerateWrapperTypeTestCases method getTypesToGenerateFromForSchemaTypeTest.
public List getTypesToGenerateFromForSchemaTypeTest() {
// public List getControlTypes() {
List types = new ArrayList();
((SDOTypeHelper) typeHelper).reset();
SDOType dataObjectType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATAOBJECT);
SDOProperty xmlDataTypeProperty = (SDOProperty) typeHelper.getOpenContentProperty(SDOConstants.SDOXML_URL, SDOConstants.SDOXML_DATATYPE);
SDOProperty xmlSchemaTypeProperty = (SDOProperty) typeHelper.getOpenContentProperty(SDOConstants.ORACLE_SDO_URL, SDOConstants.XML_SCHEMA_TYPE_NAME);
DataObject myChildTypeDO = dataFactory.create("commonj.sdo", "Type");
myChildTypeDO.set("uri", "http://www.example.org");
myChildTypeDO.set("name", "childType");
addProperty(myChildTypeDO, "name", SDOConstants.SDO_STRING, false, false, true);
DataObject myRootTypeDO = dataFactory.create("commonj.sdo", "Type");
myRootTypeDO.set("uri", "http://www.example.org");
myRootTypeDO.set("name", "rootType");
DataObject test1Prop = addProperty(myRootTypeDO, "test1", SDOConstants.SDO_INTOBJECT, false, false, true);
DataObject test2Prop = addProperty(myRootTypeDO, "test2", SDOConstants.SDO_BOOLEANOBJECT, false, false, true);
test2Prop.set(xmlDataTypeProperty, SDOConstants.SDO_BOOLEANOBJECT);
DataObject test3Prop = addProperty(myRootTypeDO, "test3", SDOConstants.SDO_DATE, false, false, true);
DataObject test4Prop = addProperty(myRootTypeDO, "test4", SDOConstants.SDO_DATETIME, false, false, true);
DataObject test5Prop = addProperty(myRootTypeDO, "test5", SDOConstants.SDO_SHORT, false, false, true);
test5Prop.set(xmlDataTypeProperty, SDOConstants.SDO_SHORTOBJECT);
DataObject test6Prop = addProperty(myRootTypeDO, "test6", dataObjectType, true, false, true);
test6Prop.set(xmlDataTypeProperty, dataObjectType);
DataObject test7Prop = addProperty(myRootTypeDO, "test7", myChildTypeDO, true, false, true);
test7Prop.set(xmlSchemaTypeProperty, myChildTypeDO);
test7Prop.set(xmlDataTypeProperty, dataObjectType);
Type myRootType = typeHelper.define(myRootTypeDO);
((SDOType) myRootType).setXsd(true);
((SDOType) myRootType).setXsdLocalName("rootType");
((SDOProperty) myRootType.getProperty("test1")).setXsd(true);
((SDOProperty) myRootType.getProperty("test1")).setXsdLocalName("test1");
((SDOProperty) myRootType.getProperty("test2")).setXsd(true);
((SDOProperty) myRootType.getProperty("test2")).setXsdLocalName("test2");
((SDOProperty) myRootType.getProperty("test3")).setXsd(true);
((SDOProperty) myRootType.getProperty("test3")).setXsdLocalName("test3");
((SDOProperty) myRootType.getProperty("test4")).setXsd(true);
((SDOProperty) myRootType.getProperty("test4")).setXsdLocalName("test4");
((SDOProperty) myRootType.getProperty("test5")).setXsd(true);
((SDOProperty) myRootType.getProperty("test5")).setXsdLocalName("test5");
((SDOProperty) myRootType.getProperty("test6")).setXsd(true);
((SDOProperty) myRootType.getProperty("test6")).setXsdLocalName("test6");
((SDOProperty) myRootType.getProperty("test7")).setXsd(true);
((SDOProperty) myRootType.getProperty("test7")).setXsdLocalName("test7");
Type childType = typeHelper.define(myChildTypeDO);
((SDOProperty) childType.getProperty("name")).setXsd(true);
((SDOProperty) childType.getProperty("name")).setXsdLocalName("name");
types.add(childType);
types.add(myRootType);
return types;
}
Aggregations