use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class LoadAndSaveBase64AttachmentTestCases method registerTypes.
@Override
public void registerTypes() {
SDOType stringType = (SDOType) typeHelper.getType("commonj.sdo", "String");
SDOType bytesType = (SDOType) typeHelper.getType("commonj.sdo", "Bytes");
SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
// create a new Type for Customers
DataObject customerType = dataFactory.create("commonj.sdo", "Type");
customerType.set("uri", getControlRootURI());
customerType.set("name", "EmployeeType");
// create an idproperty
addProperty(customerType, "id", stringType, false, false, true);
// create a first name property
addProperty(customerType, "name", stringType, false, false, true);
// create a photo property
DataObject photoProp = addProperty(customerType, "photo", bytesType, true, true, true);
// now define the Customer type so that customers can be made
Type customerSDOType = typeHelper.define(customerType);
DataObject propDO = dataFactory.create(propertyType);
propDO.set("name", getControlRootName());
propDO.set("type", customerSDOType);
typeHelper.defineOpenContentProperty(getControlRootURI(), propDO);
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class LoadAndSaveBug6130541TestCases method registerTypes.
/* protected void generateClasses(String tmpDirName) throws Exception{
URL url = new URL(getSchemaLocation() + getSchemaName());
InputStream is = url.openStream();
SDOClassGenerator classGenerator = new SDOClassGenerator(aHelperContext);
DefaultSchemaResolver schemaResolver = new DefaultSchemaResolver();
schemaResolver.setBaseSchemaLocation(getSchemaLocation());
StreamSource ss = new StreamSource(is);
classGenerator.generate(ss, tmpDirName, schemaResolver);
}*/
@Override
public void registerTypes() {
SDOType stringType = (SDOType) typeHelper.getType("commonj.sdo", "String");
SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
// create a new Type for Employee
DataObject empType = dataFactory.create("commonj.sdo", "Type");
empType.set("uri", "http://theUri");
empType.set("name", "EmployeeType");
// create a first name property
addProperty(empType, "name", stringType, false, false, true);
addProperty(empType, "jobTitle", stringType, false, false, true);
addProperty(empType, "manager", empType, true, false, true);
Type empSDOType = typeHelper.define(empType);
// create a new Type for Company
DataObject compnayType = dataFactory.create("commonj.sdo", "Type");
compnayType.set("uri", "http://theUri");
compnayType.set("name", "CompanyType");
addProperty(compnayType, "companyName", stringType, false, false, true);
addProperty(compnayType, "employee", empSDOType, true, true, true);
Type companySDOType = typeHelper.define(compnayType);
DataObject propDO = dataFactory.create(propertyType);
propDO.set("name", "company");
propDO.set("type", companySDOType);
// typeHelper.defineOpenContentProperty(getControlRootURI(), propDO);
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class LoadAndSaveIDRefTestCases method registerTypes.
@Override
public void registerTypes() {
SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
SDOType stringType = (SDOType) typeHelper.getType("commonj.sdo", "String");
SDOType dateType = (SDOType) typeHelper.getType("commonj.sdo", "YearMonthDay");
SDOType addressType = (SDOType) registerAddressType();
SDOType itemType = (SDOType) registerItemType();
DataObject purchaseOrderTypeType = dataFactory.create("commonj.sdo", "Type");
SDOProperty prop = (SDOProperty) purchaseOrderTypeType.getType().getProperty("uri");
purchaseOrderTypeType.set(prop, getControlRootURI());
prop = (SDOProperty) purchaseOrderTypeType.getType().getProperty("name");
purchaseOrderTypeType.set(prop, "PurchaseOrder");
addProperty(purchaseOrderTypeType, "poID", stringType, false, false, true);
DataObject shipToProp = addProperty(purchaseOrderTypeType, "shipTo", addressType, true, false, true);
DataObject billToProp = addProperty(purchaseOrderTypeType, "billTo", addressType, true, false, true);
DataObject itemProp = addProperty(purchaseOrderTypeType, "item", itemType, false, true, true);
addProperty(purchaseOrderTypeType, "comment", stringType);
addProperty(purchaseOrderTypeType, "orderDate", dateType);
// set unidirectional reference id
setIDPropForReferenceProperties(purchaseOrderTypeType, "poID");
DataObject customerTypeDO = getCustomerTypeDO(purchaseOrderTypeType);
DataObject customerProp = addProperty(purchaseOrderTypeType, "customer", customerTypeDO, false, false, false);
DataObject poProp = addProperty(customerTypeDO, "purchaseOrder", purchaseOrderTypeType, false, false, true);
customerProp.set("opposite", poProp);
poProp.set("opposite", customerProp);
Type POType = typeHelper.define(purchaseOrderTypeType);
Type custType = typeHelper.define(customerTypeDO);
Type companyType = registerCompanyType(POType, custType);
DataObject propDO = dataFactory.create(propertyType);
propDO.set("name", getControlRootName());
// propDO.set("type", POType);
propDO.set("type", companyType);
propDO.set("containment", true);
propDO.set(SDOConstants.XMLELEMENT_PROPERTY, true);
typeHelper.defineOpenContentProperty(getControlRootURI(), propDO);
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class SDOTypeHelperDefineTwiceTestCases method testDefineTwiceName.
public void testDefineTwiceName() {
SDOType typeType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.TYPE);
DataObject theDO = dataFactory.create(typeType);
theDO.set("name", "theName");
theDO.set("uri", "theUri");
addProperty(theDO, "prop1", SDOConstants.SDO_STRING, false, false, true);
Type newType = typeHelper.define(theDO);
assertEquals(1, newType.getDeclaredProperties().size());
DataObject theDO2 = dataFactory.create(typeType);
theDO2.set("name", "theName");
theDO2.set("uri", "theUri");
addProperty(theDO2, "prop2", SDOConstants.SDO_STRING, false, false, true);
Type newType2 = typeHelper.define(theDO2);
assertEquals(1, newType.getDeclaredProperties().size());
assertEquals("prop1", ((SDOProperty) newType.getDeclaredProperties().get(0)).getName());
assertEquals(newType, newType2);
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class OpenContentDefineTestCases method testDefineOpenContentProperty.
public void testDefineOpenContentProperty() {
assertEquals(2, rootType.getDeclaredProperties().size());
SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
DataObject newProperty = dataFactory.create(propertyType);
SDOProperty prop = (SDOProperty) newProperty.getType().getProperty("name");
newProperty.set(prop, "myOpenProp");
prop = (SDOProperty) newProperty.getType().getProperty("type");
newProperty.set(prop, typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.STRING));
Property openProp = typeHelper.defineOpenContentProperty("my.uri", newProperty);
Property lookedUp = typeHelper.getOpenContentProperty("my.uri", "myOpenProp");
assertNotNull(lookedUp);
// verify both properties are the same object
assertTrue(openProp == lookedUp);
assertTrue(lookedUp.isOpenContent());
DataObject rootDataObject = dataFactory.create(rootType);
assertEquals(2, rootDataObject.getInstanceProperties().size());
// set should add the open content property to instance properties
rootDataObject.set(lookedUp, "testing");
assertEquals(3, rootDataObject.getInstanceProperties().size());
assertNull(lookedUp.getContainingType());
// unset should remove the open content property
rootDataObject.unset(lookedUp);
assertEquals(2, rootDataObject.getInstanceProperties().size());
}
Aggregations