use of org.eclipse.persistence.sdo.SDODataGraph in project eclipselink by eclipse-ee4j.
the class SDODataGraphDataObjectBackPointerTest method setUp.
@Override
public void setUp() {
super.setUp();
dataGraph = new SDODataGraph(aHelperContext);
}
use of org.eclipse.persistence.sdo.SDODataGraph in project eclipselink by eclipse-ee4j.
the class SDODataGraphDataObjectBackPointerTest method testSetDOFromOtherDataGraphWithMixedContainmentNonContainmentWithoutCStoDGwithoutCS.
// This function will exercise the updateDataGraph() function on SDODataObject.updateContainment()
public void testSetDOFromOtherDataGraphWithMixedContainmentNonContainmentWithoutCStoDGwithoutCS() {
DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(new HashMap<QName, String>());
registerTypes();
List<Type> types = getTypesToGenerateFrom();
((SDOXSDHelper) xsdHelper).generate(types, resolver);
// Create target
DataObject aDataObjectTarget = createRootObject(types);
DataGraph aDataGraphTarget = dataGraph;
aDataGraphTarget.createRootObject(aDataObjectTarget.getType());
DataObject targetRoot = aDataGraphTarget.getRootObject();
// Check it
assertNotNull(targetRoot);
assertEquals(targetRoot.getType(), aDataGraphTarget.getType(URINAME, COMPANY_TYPENAME));
ListWrapper pOrdersTarget = (ListWrapper) targetRoot.getList(PO_PATH);
int poSize = pOrdersTarget.size();
assertEquals(0, poSize);
// Create source
DataObject aDataObjectSource = createRootObject(types);
DataGraph aDataGraphSource = new SDODataGraph(aHelperContext);
aDataGraphSource.createRootObject(aDataObjectSource.getType());
DataObject sourceRoot = aDataGraphSource.getRootObject();
// Check it
assertNotNull(sourceRoot);
assertEquals(sourceRoot.getType(), aDataGraphSource.getType(URINAME, COMPANY_TYPENAME));
ListWrapper pOrdersSource = (ListWrapper) aDataObjectSource.getList(PO_PATH);
int poSizeSource = pOrdersSource.size();
assertEquals(1, poSizeSource);
// Clear the target CS so that we enter only the DataGraph recursive loop
((SDODataObject) targetRoot)._setChangeSummary(null);
// Get source DO
DataObject sourcePO = (DataObject) pOrdersSource.get(0);
// DataGraph should be null before set
assertNull(sourcePO.getDataGraph());
// Move the root object from one null data graph to the other
pOrdersTarget.add(sourcePO);
// DataGraph should be not be null before set
assertNotNull(sourcePO.getDataGraph());
// Target dataGraph should be set on all children
assertEquals(aDataGraphTarget, sourcePO.getDataGraph());
DataObject copyPOshipTo = (DataObject) sourcePO.get("shipTo");
DataObject copyPObillTo = (DataObject) sourcePO.get("billTo");
DataObject copyPOitem1 = (DataObject) sourcePO.get("item[1]");
DataObject copyPOitem2 = (DataObject) sourcePO.get("item[2]");
// Check dataGraph back pointers recursively (containment only)
List<DataObject> copyPreOrderList = preOrderTraversalDataObjectList(sourcePO);
assertNotNull(copyPreOrderList);
assertEquals(5, copyPreOrderList.size());
copyPreOrderList.contains(copyPOshipTo);
copyPreOrderList.contains(copyPObillTo);
copyPreOrderList.contains(copyPOitem1);
copyPreOrderList.contains(copyPOitem2);
assertNotNull(copyPOshipTo.getDataGraph());
assertEquals(aDataGraphTarget, copyPOshipTo.getDataGraph());
assertNotNull(copyPObillTo.getDataGraph());
assertEquals(aDataGraphTarget, copyPObillTo.getDataGraph());
// item property is unidirectional or containment=false - still in the dataGraph in this case
assertNotNull(copyPOitem1.getDataGraph());
assertEquals(aDataGraphTarget, copyPOitem1.getDataGraph());
assertNotNull(copyPOitem2.getDataGraph());
assertEquals(aDataGraphTarget, copyPOitem2.getDataGraph());
}
use of org.eclipse.persistence.sdo.SDODataGraph in project eclipselink by eclipse-ee4j.
the class SDODataGraphDataObjectTestCases method setUp.
@Override
public void setUp() {
super.setUp();
dataGraph = new SDODataGraph(aHelperContext);
stringType = typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.STRING);
dateType = typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATE);
yearMonthDayType = typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.YEARMONTHDAY);
decimalType = SDOConstants.SDO_DECIMAL;
idType = typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.ID);
}
use of org.eclipse.persistence.sdo.SDODataGraph in project eclipselink by eclipse-ee4j.
the class SDODataGraphDataObjectBackPointerTest method testSetDOFromOtherDataGraphWithMixedContainmentNonContainmentWithoutCStoDGwithCS.
// This function will exercise the updateChangeSummaryAndDataGraph() function on SDODataObject.updateContainment()
public void testSetDOFromOtherDataGraphWithMixedContainmentNonContainmentWithoutCStoDGwithCS() {
DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(new HashMap<QName, String>());
registerTypes();
List<Type> types = getTypesToGenerateFrom();
((SDOXSDHelper) xsdHelper).generate(types, resolver);
// Create target
DataObject aDataObjectTarget = createRootObject(types);
DataGraph aDataGraphTarget = dataGraph;
aDataGraphTarget.createRootObject(aDataObjectTarget.getType());
DataObject targetRoot = aDataGraphTarget.getRootObject();
// Check it
assertNotNull(targetRoot);
assertEquals(targetRoot.getType(), aDataGraphTarget.getType(URINAME, COMPANY_TYPENAME));
ListWrapper pOrdersTarget = (ListWrapper) targetRoot.getList(PO_PATH);
int poSize = pOrdersTarget.size();
assertEquals(0, poSize);
// Add a porder (null DG source)
// Create source
DataObject aDataObjectSource = createRootObject(types);
DataGraph aDataGraphSource = new SDODataGraph(aHelperContext);
aDataGraphSource.createRootObject(aDataObjectSource.getType());
DataObject sourceRoot = aDataGraphSource.getRootObject();
// Check it
assertNotNull(sourceRoot);
assertEquals(sourceRoot.getType(), aDataGraphSource.getType(URINAME, COMPANY_TYPENAME));
ListWrapper pOrdersSource = (ListWrapper) aDataObjectSource.getList(PO_PATH);
int poSizeSource = pOrdersSource.size();
assertEquals(1, poSizeSource);
// Get source DO
DataObject sourcePO = (DataObject) pOrdersSource.get(0);
// DataGraph should be null before set
assertNull(sourcePO.getDataGraph());
// Move the root object from one null data graph to the other
pOrdersTarget.add(sourcePO);
// DataGraph should be not be null before set
assertNotNull(sourcePO.getDataGraph());
// Target dataGraph should be set on all children
assertEquals(aDataGraphTarget, sourcePO.getDataGraph());
DataObject copyPOshipTo = (DataObject) sourcePO.get("shipTo");
DataObject copyPObillTo = (DataObject) sourcePO.get("billTo");
DataObject copyPOitem1 = (DataObject) sourcePO.get("item[1]");
DataObject copyPOitem2 = (DataObject) sourcePO.get("item[2]");
// Check dataGraph back pointers recursively (containment only)
List<DataObject> copyPreOrderList = preOrderTraversalDataObjectList(sourcePO);
assertNotNull(copyPreOrderList);
assertEquals(5, copyPreOrderList.size());
copyPreOrderList.contains(copyPOshipTo);
copyPreOrderList.contains(copyPObillTo);
copyPreOrderList.contains(copyPOitem1);
copyPreOrderList.contains(copyPOitem2);
assertNotNull(copyPOshipTo.getDataGraph());
assertEquals(aDataGraphTarget, copyPOshipTo.getDataGraph());
assertNotNull(copyPObillTo.getDataGraph());
assertEquals(aDataGraphTarget, copyPObillTo.getDataGraph());
// item property is unidirectional or containment=false - still in the dataGraph in this case
assertNotNull(copyPOitem1.getDataGraph());
assertEquals(aDataGraphTarget, copyPOitem1.getDataGraph());
assertNotNull(copyPOitem2.getDataGraph());
assertEquals(aDataGraphTarget, copyPOitem2.getDataGraph());
}
Aggregations