use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class SDOTypeHelperAppInfoTestCases method testAppInfoElements.
/**
* Tests setting appinfo elements on a Type and Property via
* dataObject.set(Property, Object) API.
*
* Positive test.
*/
public void testAppInfoElements() {
List<Element> aieList = new ArrayList<Element>();
aieList.add(aiElement);
List<Element> aiePropList = new ArrayList<Element>();
aiePropList.add(aiElementProp);
// create the data object
SDODataObject dataObject = (SDODataObject) dataFactory.create(sdoTypeType);
dataObject.set(NAME, MYDO);
dataObject.set(URI, MYURI);
dataObject.set(SDOConstants.APPINFO_PROPERTY, aieList);
// create a property
SDODataObject prop = (SDODataObject) dataObject.createDataObject(PROPERTY);
prop.set(NAME, MYPROP);
prop.set(TYPE, SDOConstants.SDO_STRING);
prop.set(SDOConstants.APPINFO_PROPERTY, aiePropList);
// create the type
SDOType newType = (SDOType) typeHelper.define(dataObject);
// ======
// DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(new HashMap<QName, String>());
// List<Object> types = new ArrayList<Object>();
// types.add(newType);
// String generatedSchema = ((SDOXSDHelper)xsdHelper).generate(types, resolver);
// System.out.println(generatedSchema);
// ======
// validate that AppInfoElements were handled correctly on Type and Property
// Type
assertNotNull("Type [newType] is null", newType);
assertTrue("Type does not have AppInfoElements set as expected", newType.getAppInfoElements() != null);
assertTrue("Expected AppInfoElements list of size [1] on Type, but was [" + newType.getAppInfoElements().size() + "]", newType.getAppInfoElements().size() == 1);
String val = ((Element) newType.getAppInfoElements().get(0)).getAttribute(SDOConstants.APPINFO_SOURCE_ATTRIBUTE);
assertNotNull("AppInfoElement source on Type is empty/null", val != null && val.length() > 0);
assertTrue("Expected AppInfoElement source [" + TYPE_APP_INFO + "] on Type but was [" + val + "]", val.equals(TYPE_APP_INFO));
String appInfoString = xsdHelper.getAppinfo(newType, TYPE_APP_INFO);
assertEquals("Expected getAppInfo() to return [" + TYPE_APP_INFO_STRING + "] but was [" + appInfoString + "]", TYPE_APP_INFO_STRING, appInfoString);
// Property
SDOProperty myProp = newType.getProperty(MYPROP);
assertNotNull("Property [myProperty] is null", myProp);
assertTrue("Property does not have AppInfoElements set as expected", myProp.getAppInfoElements() != null);
assertTrue("Expected AppInfoElements list of size [1] on Property, but was [" + myProp.getAppInfoElements().size() + "]", myProp.getAppInfoElements().size() == 1);
val = ((Element) myProp.getAppInfoElements().get(0)).getAttribute(SDOConstants.APPINFO_SOURCE_ATTRIBUTE);
assertNotNull("AppInfoElement source on Property is empty/null", val != null && val.length() > 0);
assertTrue("Expected AppInfoElement source [" + PROPERTY_APP_INFO + "] on Property but was [" + val + "]", val.equals(PROPERTY_APP_INFO));
appInfoString = xsdHelper.getAppinfo(myProp, PROPERTY_APP_INFO);
assertEquals("Expected getAppInfo() to return [" + PROPERTY_APP_INFO_STRING + "] but was [" + appInfoString + "]", PROPERTY_APP_INFO_STRING, appInfoString);
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class ChangeSummaryVolumetricsTest method setUp.
@Override
public void setUp() {
super.setUp();
SDOType changeSummaryType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.CHANGESUMMARY);
SDOType dataObjectType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATAOBJECT);
DataObject rootTypeDO = defineType(URINAME, TYPENAME);
rootType = (SDOType) typeHelper.define(rootTypeDO);
rootContainingPropertyB = setUpProperty("propertyA-B", true, dataObjectType, rootType);
rootContainingPropertyC = setUpProperty("propertyA-C", true, dataObjectType, rootType);
rootChangeSummaryProperty = setUpProperty("changeSummaryA", false, changeSummaryType, null);
root = (SDODataObject) dataFactory.create(rootType);
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class ChangeSummaryVolumetricsTest method buildDeepTree.
/*
* root
* -> B
* -> CS-B
* -> D (String)
* -> C
* -> CS-C
*/
protected void buildDeepTree() {
SDOType changeSummaryType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.CHANGESUMMARY);
SDOType dataObjectType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATAOBJECT);
DataObject type_BDO = defineType("B_uri", "B");
DataObject propertyBDO = addProperty(type_BDO, "propertyB", dataObjectType);
propertyBDO.set("containment", true);
type_B = (SDOType) typeHelper.define(type_BDO);
propertyB = (SDOProperty) type_B.getDeclaredPropertiesMap().get("propertyB");
changeSummaryPropertyB = setUpProperty("changeSummaryB", false, changeSummaryType, type_B);
DataObject type_CDO = defineType("C_uri", "C");
DataObject propertyCDO = addProperty(type_CDO, "propertyC", dataObjectType);
propertyBDO.set("containment", true);
type_C = (SDOType) typeHelper.define(type_CDO);
propertyC = (SDOProperty) type_C.getDeclaredPropertiesMap().get("propertyC");
changeSummaryPropertyC = setUpProperty("changeSummaryC", false, changeSummaryType, type_C);
typeB_children = new SDOType[NUM_B_LEVELS];
propertyB_children = new SDOProperty[NUM_B_LEVELS];
dataObjectB_children = new SDODataObject[NUM_B_LEVELS];
dataObjectB = root.createDataObject(rootContainingPropertyB, type_B);
dataObjectC = root.createDataObject(rootContainingPropertyC, type_C);
// setup object array
for (int i = 0; i < NUM_B_LEVELS; i++) {
DataObject typeB_childreniDO = defineType("D_uri" + i, "D" + i);
DataObject propDo = addProperty(typeB_childreniDO, "propertyD" + i, dataObjectType);
propDo.set("containment", true);
typeB_children[i] = (SDOType) typeHelper.define(typeB_childreniDO);
propertyB_children[i] = (SDOProperty) typeB_children[i].getDeclaredPropertiesMap().get("propertyD" + i);
}
dataObjectB_children[0] = dataObjectB.createDataObject(propertyB, typeB_children[0]);
for (int i = 1; i < NUM_B_LEVELS; i++) {
dataObjectB_children[i] = dataObjectB_children[i - 1].createDataObject(propertyB_children[i - 1], typeB_children[i]);
}
// dataObjectD = (SDODataObject)dataObjectB.createDataObject(propertyB, type_D);
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class ChangeSummaryBeginLoggingEndLoggingIsLoggingTest method testOldContainerContainmentPropertyOldSettingListAfterBeginLogging.
/**
* recursively check if old containers and old containment properties are set properly;
* @param o the DataObject to be checked
*/
private void testOldContainerContainmentPropertyOldSettingListAfterBeginLogging(SDODataObject o) {
/*
* 20060710
* This testcase has been modified because the getOld* functions have moved to their
* changeSummary counterparts and may not directly return the actual instance variable
* when not in deleted | modified state
*/
SDODataObject anOldContainer = o.getChangeSummary().getOldContainer(o);
SDODataObject aContainer = o.getContainer();
if (o.getChangeSummary().isModified(o) || o.getChangeSummary().isDeleted(o)) {
assertEquals(anOldContainer, aContainer);
if (aContainer != null) {
Property pp = o.getContainer().getInstanceProperty(o._getContainmentPropertyName());
assertEquals(o.getChangeSummary().getOldContainmentProperty(o), pp);
}
}
assertNotNull(o.getChangeSummary().getOldValues(o));
assertTrue(o.getChangeSummary().getOldValues(o).isEmpty());
List properties = o.getInstanceProperties();
Iterator iterProperties = properties.iterator();
while (iterProperties.hasNext()) {
Property p = (Property) iterProperties.next();
Object v = o.get(p);
if (v instanceof SDODataObject) {
testOldContainerContainmentPropertyOldSettingListAfterBeginLogging(((SDODataObject) v));
}
}
}
use of org.eclipse.persistence.sdo.SDODataObject in project eclipselink by eclipse-ee4j.
the class ChangeSummaryCreatedModifiedDeletedTests method testIsCreatedAfterUseDataFactory.
public void testIsCreatedAfterUseDataFactory() {
rootType.addDeclaredProperty(rootChangeSummaryProperty);
root = (SDODataObject) dataFactory.create(rootType);
changeSummaryA = root.getChangeSummary();
buildTreeWithoutChildChangeSummaries();
changeSummaryA.beginLogging();
assertUnchanged(root, changeSummaryA);
assertUnchanged(dataObjectB, changeSummaryA);
assertUnchanged(dataObjectC, changeSummaryA);
assertUnchanged(dataObjectD, changeSummaryA);
SDOType type_E = new SDOType("EURI", "E");
SDODataObject dataObjectE = (SDODataObject) dataFactory.create(type_E);
dataObjectC.set(propertyC, dataObjectE);
assertUnchanged(root, changeSummaryA);
assertUnchanged(dataObjectB, changeSummaryA);
assertModified(dataObjectC, changeSummaryA);
assertUnchanged(dataObjectD, changeSummaryA);
assertCreated(dataObjectE, changeSummaryA);
}
Aggregations