use of org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver in project eclipselink by eclipse-ee4j.
the class SDODataGraphDataObjectBackPointerTest method testUnsetDOwithMixedContainmentNonContainmentWithoutCStoDGwithCS.
public void testUnsetDOwithMixedContainmentNonContainmentWithoutCStoDGwithCS() {
DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(new HashMap<QName, String>());
registerTypes();
List<Type> types = getTypesToGenerateFrom();
String generatedSchema = ((SDOXSDHelper) xsdHelper).generate(types, resolver);
// log(generatedSchema);
// aDataObject.getType());
dataGraph.createRootObject(URINAME, COMPANY_TYPENAME);
DataObject aWrappedDO = dataGraph.getRootObject();
assertNotNull(aWrappedDO);
// TODO
assertEquals(aWrappedDO.getType(), dataGraph.getType(URINAME, COMPANY_TYPENAME));
DataObject dgDO = populateRootDataGraphDataObject(dataGraph.getRootObject(), types);
ListWrapper pOrders = (ListWrapper) dgDO.getList(PO_PATH);
int poSize = pOrders.size();
assertEquals(1, poSize);
// Delete DO
DataObject detachedDO = (DataObject) pOrders.get(0);
dgDO.unset(PO_PATH + "[1]");
ListWrapper pOrdersDGList = (ListWrapper) dgDO.getList(PO_PATH);
int poSizeDG = pOrdersDGList.size();
assertEquals(poSize - 1, poSizeDG);
assertEquals(null, detachedDO.getDataGraph());
DataObject copyPOshipTo = (DataObject) detachedDO.get("shipTo");
DataObject copyPObillTo = (DataObject) detachedDO.get("billTo");
DataObject copyPOitem1 = (DataObject) detachedDO.get("item[1]");
DataObject copyPOitem2 = (DataObject) detachedDO.get("item[2]");
/*
// Check dataGraph back pointers recursively (containment only)
List<DataObject> copyPreOrderList = preOrderTraversalDataObjectList(detachedDO);
assertNotNull(copyPreOrderList);
assertEquals(5, copyPreOrderList.size());
copyPreOrderList.contains(copyPOshipTo);
copyPreOrderList.contains(copyPObillTo);
copyPreOrderList.contains(copyPOitem1);
copyPreOrderList.contains(copyPOitem2);
*/
assertNull(copyPOshipTo.getDataGraph());
assertNull(copyPObillTo.getDataGraph());
/**
* item property is unidirectional or containment=false - therefore not in the dataGraph.
* However, if the item also has a containment=true reference to itself then it does reference the dataGraph
*/
assertNull(copyPOitem1.getDataGraph());
assertNull(copyPOitem2.getDataGraph());
// Check that the CS is not set on all nodes including non-containment ones
assertNull(copyPOitem1.getChangeSummary());
}
use of org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver in project eclipselink by eclipse-ee4j.
the class SDODataGraphDataObjectBackPointerTest method testDeleteDOwithMixedContainmentNonContainmentWithoutCStoDGwithCS.
public void testDeleteDOwithMixedContainmentNonContainmentWithoutCStoDGwithCS() {
DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(new HashMap<QName, String>());
registerTypes();
List<Type> types = getTypesToGenerateFrom();
((SDOXSDHelper) xsdHelper).generate(types, resolver);
// log(generatedSchema);
// aDataObject.getType());
dataGraph.createRootObject(URINAME, COMPANY_TYPENAME);
DataObject aWrappedDO = dataGraph.getRootObject();
assertNotNull(aWrappedDO);
// TODO
assertEquals(aWrappedDO.getType(), dataGraph.getType(URINAME, COMPANY_TYPENAME));
DataObject dgDO = populateRootDataGraphDataObject(dataGraph.getRootObject(), types);
ListWrapper pOrders = (ListWrapper) dgDO.getList(PO_PATH);
int poSize = pOrders.size();
assertEquals(1, poSize);
// save objects before they are split apart
DataObject detachedDO = (DataObject) pOrders.get(0);
DataObject copyPOshipTo = (DataObject) detachedDO.get("shipTo");
DataObject copyPObillTo = (DataObject) detachedDO.get("billTo");
DataObject copyPOitem1 = (DataObject) detachedDO.get("item[1]");
DataObject copyPOitem2 = (DataObject) detachedDO.get("item[2]");
// Delete DO
detachedDO.delete();
ListWrapper pOrdersDGList = (ListWrapper) dgDO.getList(PO_PATH);
int poSizeDG = pOrdersDGList.size();
assertEquals(poSize - 1, poSizeDG);
assertEquals(null, detachedDO.getDataGraph());
/*
// Check dataGraph back pointers recursively (containment only)
List<DataObject> copyPreOrderList = preOrderTraversalDataObjectList(detachedDO);
assertNotNull(copyPreOrderList);
assertEquals(5, copyPreOrderList.size());
copyPreOrderList.contains(copyPOshipTo);
copyPreOrderList.contains(copyPObillTo);
copyPreOrderList.contains(copyPOitem1);
copyPreOrderList.contains(copyPOitem2);
*/
assertNull(copyPOshipTo.getDataGraph());
assertNull(copyPObillTo.getDataGraph());
/**
* item property is unidirectional or containment=false - therefore not in the dataGraph.
* However, if the item also has a containment=true reference to itself then it does reference the dataGraph
*/
assertNull(copyPOitem1.getDataGraph());
assertNull(copyPOitem2.getDataGraph());
// Check that the CS is not set on all nodes including non-containment ones
assertNull(copyPOitem1.getChangeSummary());
}
use of org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver in project eclipselink by eclipse-ee4j.
the class SDODataGraphDataObjectBackPointerTest method testDetachDOwithMixedContainmentNonContainmentWithoutCStoDGwithCS.
public void testDetachDOwithMixedContainmentNonContainmentWithoutCStoDGwithCS() {
DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(new HashMap<QName, String>());
registerTypes();
List<Type> types = getTypesToGenerateFrom();
String generatedSchema = ((SDOXSDHelper) xsdHelper).generate(types, resolver);
// log(generatedSchema);
// aDataObject.getType());
dataGraph.createRootObject(URINAME, COMPANY_TYPENAME);
DataObject aWrappedDO = dataGraph.getRootObject();
assertNotNull(aWrappedDO);
// TODO
assertEquals(aWrappedDO.getType(), dataGraph.getType(URINAME, COMPANY_TYPENAME));
DataObject dgDO = populateRootDataGraphDataObject(dataGraph.getRootObject(), types);
ListWrapper pOrders = (ListWrapper) dgDO.getList(PO_PATH);
int poSize = pOrders.size();
assertEquals(1, poSize);
// Detach DO
DataObject detachedDO = (DataObject) pOrders.get(0);
detachedDO.detach();
ListWrapper pOrdersDGList = (ListWrapper) dgDO.getList(PO_PATH);
int poSizeDG = pOrdersDGList.size();
assertEquals(poSize - 1, poSizeDG);
assertEquals(null, detachedDO.getDataGraph());
DataObject copyPOshipTo = (DataObject) detachedDO.get("shipTo");
DataObject copyPObillTo = (DataObject) detachedDO.get("billTo");
DataObject copyPOitem1 = (DataObject) detachedDO.get("item[1]");
DataObject copyPOitem2 = (DataObject) detachedDO.get("item[2]");
/*
// Check dataGraph back pointers recursively (containment only)
List<DataObject> copyPreOrderList = preOrderTraversalDataObjectList(detachedDO);
assertNotNull(copyPreOrderList);
assertEquals(5, copyPreOrderList.size());
copyPreOrderList.contains(copyPOshipTo);
copyPreOrderList.contains(copyPObillTo);
copyPreOrderList.contains(copyPOitem1);
copyPreOrderList.contains(copyPOitem2);
*/
assertNull(copyPOshipTo.getDataGraph());
assertNull(copyPObillTo.getDataGraph());
/**
* item property is unidirectional or containment=false - therefore not in the dataGraph.
* However, if the item also has a containment=true reference to itself then it does reference the dataGraph
*/
assertNull(copyPOitem1.getDataGraph());
assertNull(copyPOitem2.getDataGraph());
// Check that the CS is not set on all nodes including non-containment ones
assertNull(copyPOitem1.getChangeSummary());
}
use of org.eclipse.persistence.sdo.helper.DefaultSchemaLocationResolver in project eclipselink by eclipse-ee4j.
the class SDODataGraphDataObjectBackPointerTest method testAddDOwithMixedContainmentNonContainmentWithoutCStoDGwithCS.
public void testAddDOwithMixedContainmentNonContainmentWithoutCStoDGwithCS() {
DefaultSchemaLocationResolver resolver = new DefaultSchemaLocationResolver(new HashMap<QName, String>());
registerTypes();
List<Type> types = getTypesToGenerateFrom();
((SDOXSDHelper) xsdHelper).generate(types, resolver);
// log(generatedSchema);
DataObject aDataObject = createRootObject(types);
dataGraph.createRootObject(aDataObject.getType());
DataObject aWrappedDO = dataGraph.getRootObject();
assertNotNull(aWrappedDO);
assertEquals(aWrappedDO.getType(), dataGraph.getType(URINAME, COMPANY_TYPENAME));
DataObject dgDO = dataGraph.getRootObject();
ListWrapper pOrders = (ListWrapper) aDataObject.getList(PO_PATH);
int poSize = pOrders.size();
assertEquals(1, poSize);
// Create detached DO
DataObject copyPO = (DataObject) pOrders.get(0);
// Create a new ListWrapper and set it on the DG DO
List<DataObject> aList = new ArrayList<DataObject>();
aList.add(copyPO);
// Add DO to DG-DO - there is no existing elements
dgDO.set("porder", aList);
ListWrapper pOrdersDGList = (ListWrapper) dgDO.getList(PO_PATH);
int poSizeDG = pOrdersDGList.size();
// or
// pOrdersDGList.add(copyPO);
assertEquals(poSize, poSizeDG);
assertEquals(dataGraph, copyPO.getDataGraph());
DataObject copyPOshipTo = (DataObject) copyPO.get("shipTo");
DataObject copyPObillTo = (DataObject) copyPO.get("billTo");
DataObject copyPOitem1 = (DataObject) copyPO.get("item[1]");
DataObject copyPOitem2 = (DataObject) copyPO.get("item[2]");
// Check dataGraph back pointers recursively (containment only)
List<DataObject> copyPreOrderList = preOrderTraversalDataObjectList(copyPO);
assertNotNull(copyPreOrderList);
assertEquals(5, copyPreOrderList.size());
copyPreOrderList.contains(copyPOshipTo);
copyPreOrderList.contains(copyPObillTo);
copyPreOrderList.contains(copyPOitem1);
copyPreOrderList.contains(copyPOitem2);
// for(DataObject aDO : copyPreOrderList) {
// assertEquals(dataGraph, aDO.getDataGraph()); // Check containment=true|false nodes
// }
assertNotNull(copyPOshipTo.getDataGraph());
assertNotNull(copyPObillTo.getDataGraph());
// item property is unidirectional or containment=false - still in the dataGraph in this case
assertNotNull(copyPOitem1.getDataGraph());
assertNotNull(copyPOitem2.getDataGraph());
// Check that the CS is set on all nodes including non-containment ones
assertNotNull(copyPOitem1.getChangeSummary());
}
Aggregations