public SDOType getRootSDOType() { SDOType type = new SDOType("http://testing", "myRoot"); type.setOpen(true); type.setAbstract(false); SDOProperty prop = new SDOProperty(aHelperContext); prop.setName("name"); prop.setType(SDOConstants.SDO_STRING); prop.setContainingType(type); type.addDeclaredProperty(prop); SDOProperty prop2 = new SDOProperty(aHelperContext); prop2.setName("child"); prop2.setType(typeHelper.getType("http://testing", "firstChildType")); prop2.setContainment(true); prop2.setContainingType(type); type.addDeclaredProperty(prop2); SDOProperty prop3 = new SDOProperty(aHelperContext); prop3.setName("child2"); prop3.setType(typeHelper.getType("http://testing", "firstChildType")); prop3.setContainment(true); prop3.setContainingType(type); type.addDeclaredProperty(prop3); SDOProperty prop4 = new SDOProperty(aHelperContext); prop4.setName("nullTypeProp"); // we were omitting setting the Type on purpose here - we don't need it - just add anything prop4.setType(SDOConstants.SDO_BOOLEAN); prop4.setContainingType(type); type.addDeclaredProperty(prop4); ((SDOTypeHelper) typeHelper).addType(type); return type; }
// purpose: detach a dataobject from one tree and set it to another tree, see changesummary doc. // issue number 9 public void testIsModifiedMoveDataObjectFromOneTreeToAnother() { changeSummary.beginLogging(); SDOType changeSummaryType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.CHANGESUMMARY); SDOType dataObjectType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATAOBJECT); SDODataObject o; // = new SDODataObject(); SDOType ty = new SDOType("newTypeUri", "newType"); ty.setOpen(true); SDOProperty p = new SDOProperty(aHelperContext); p.setName("new Property"); p.setContainment(true); p.setType(dataObjectType); ty.addDeclaredProperty(p); SDOProperty p1 = new SDOProperty(aHelperContext); p1.setName("new Property ChangeSummary"); p1.setContainment(false); p1.setType(changeSummaryType); ty.addDeclaredProperty(p1); o = (SDODataObject) dataFactory.create(ty); o.getChangeSummary().beginLogging(); containedDataObject.detach(); assertDetached(containedDataObject, changeSummary, true); // container and cs will not be set o.set(p, containedDataObject); assertCreated(containedDataObject, o.getChangeSummary()); assertModified(o, o.getChangeSummary()); assertDetached(containedDataObject, changeSummary, false); // container and cs will be set assertModified(root, changeSummary); }
public List getControlTypes() { List types = new ArrayList(); String uri = "http://www.example.org"; Type stringType = typeHelper.getType("commonj.sdo", "String"); Type byteType = typeHelper.getType("commonj.sdo", "Bytes"); SDOType employeeSDOType = new SDOType(uri, "EmployeeType"); employeeSDOType.setInstanceClassName("defaultPackage.EmployeeType"); SDOProperty prop = new SDOProperty(aHelperContext); prop.setName("id"); prop.setType(stringType); // prop.setAttribute(false); // prop.setElement(true); prop.setInstanceProperty(SDOConstants.XMLELEMENT_PROPERTY, Boolean.TRUE); prop.setXsd(true); prop.setXsdLocalName("id"); prop.setContainment(true); employeeSDOType.addDeclaredProperty(prop); SDOProperty prop2 = new SDOProperty(aHelperContext); prop2.setName("name"); prop2.setType(stringType); // prop2.setAttribute(false); // prop2.setElement(true); prop2.setInstanceProperty(SDOConstants.XMLELEMENT_PROPERTY, Boolean.TRUE); prop2.setXsd(true); prop2.setXsdLocalName("name"); prop2.setContainment(true); employeeSDOType.addDeclaredProperty(prop2); SDOProperty prop3 = new SDOProperty(aHelperContext); prop3.setName("photo"); prop3.setType(byteType); // prop3.setAttribute(false); // prop3.setElement(true); prop3.setInstanceProperty(SDOConstants.XMLELEMENT_PROPERTY, Boolean.TRUE); prop3.setXsd(true); prop3.setXsdLocalName("photo"); prop3.setContainment(true); prop3.setXsdType(XMLConstants.BASE_64_BINARY_QNAME); prop3.setInstanceProperty(SDOConstants.MIME_TYPE_PROPERTY, "image/jpeg"); employeeSDOType.addDeclaredProperty(prop3); types.add(employeeSDOType); return types; }
// purpose: after logging, dataobject create dataobject public void testIsModifiedFactory() { changeSummary.beginLogging(); SDODataObject o; // = new SDODataObject(); SDOType ty = new SDOType("newTypeUri", "newType"); ty.setOpen(true); SDOProperty p = new SDOProperty(aHelperContext); p.setName("new Property"); p.setContainment(false); p.setType(SDOConstants.SDO_STRING); ty.addDeclaredProperty(p); o = (SDODataObject) root.createDataObject(rootProperty, ty); assertCreated(o, changeSummary); }
public void testSetGetDataObjectWithQueryPath() { SDOProperty property_c1_object = new SDOProperty(aHelperContext); property_c1_object.setName("PName-c1"); property_c1_object.setContainment(true); property_c1_object.setMany(true); property_c1_object.setType(SDOConstants.SDO_INT); type_c0.addDeclaredProperty(property_c1_object); Integer b = new Integer(12); dataObject_a.setInt("PName-a0/PName-b0[number='1']/PName-c1.0", b.intValue()); this.assertEquals( b.intValue(), dataObject_a.getInt("PName-a0/PName-b0[number='1']/PName-c1.0")); }
public SDOType getFirstChildType() { SDOType type = new SDOType("http://testing", "firstChildType"); type.setOpen(true); type.setAbstract(false); SDOProperty prop = new SDOProperty(aHelperContext); prop.setName("name"); prop.setType(SDOConstants.SDO_STRING); prop.setContainingType(type); type.addDeclaredProperty(prop); SDOProperty prop2 = new SDOProperty(aHelperContext); prop2.setName("child"); prop2.setType(typeHelper.getType("http://testing", "secondChildType")); prop2.setContainment(true); prop2.setContainingType(type); type.addDeclaredProperty(prop2); ((SDOTypeHelper) typeHelper).addType(type); return type; }
public void setUp() { // set up as a/b/c super.setUp(); type_a = new SDOType(URINAME, TYPENAME_A); type_b = new SDOType(URINAME, TYPENAME_B); type_c = new SDOType(URINAME, TYPENAME_C); type_c_bNotSDODataOject = new SDOType(URINAME, TYPENAME_C); type_a_bNotSDODataOject = new SDOType(URINAME, TYPENAME_A); type_b_bNotSDODataOject = new SDOType(URINAME, TYPENAME_B); property_a = new SDOProperty(aHelperContext); property_a.setContainment(true); property_a.setName(PROPERTY_NAME_A); property_a.setType(type_b); type_a.addDeclaredProperty(property_a); dataObject_a = (SDODataObject) dataFactory.create(type_a); property_b = new SDOProperty(aHelperContext); property_b.setContainment(true); property_b.setMany(true); property_b.setType(type_c); property_b.setName(PROPERTY_NAME_B); type_b.addDeclaredProperty(property_b); dataObject_b = (SDODataObject) dataFactory.create(type_b); dataObject_c = (SDODataObject) dataFactory.create(type_c); dataObject_a.set(property_a, dataObject_b); // a dataobject's a property has value b dataobject List objects = new ArrayList(); objects.add(dataObject_c); dataObject_b.set(property_b, objects); // b dataobject's b property has value c dataobject property_a_bNotSDODataOject = new SDOProperty(aHelperContext); property_a_bNotSDODataOject.setName(PROPERTY_NAME_A); property_a_bNotSDODataOject.setType(type_b_bNotSDODataOject); type_a_bNotSDODataOject.addDeclaredProperty(property_a_bNotSDODataOject); dataObject_a_bNotSDODataOject = (SDODataObject) dataFactory.create(type_a_bNotSDODataOject); property_b_bNotSDODataOject = new SDOProperty(aHelperContext); property_b_bNotSDODataOject.setName(PROPERTY_NAME_B); property_b_bNotSDODataOject.setType(SDOConstants.SDO_STRING); type_b_bNotSDODataOject.addDeclaredProperty(property_b_bNotSDODataOject); dataObject_b_bNotSDODataOject = (SDODataObject) dataFactory.create(type_b_bNotSDODataOject); dataObject_c_bNotSDODataOject = (SDODataObject) dataFactory.create(type_c_bNotSDODataOject); dataObject_a_bNotSDODataOject.set( property_a_bNotSDODataOject, dataObject_b_bNotSDODataOject); // a dataobject's a property has value b dataobject dataObject_b_bNotSDODataOject.set( property_b_bNotSDODataOject, "test"); // b dataobject's b property has value c dataobject /*List basTypes_a = new ArrayList(); basTypes_a.add(type_b); basTypes_a.add(type_c); List basTypes_b = new ArrayList(); basTypes_b.add(type_c); type_a.setBaseTypes(basTypes_a); type_b.setBaseTypes(basTypes_b);*/ type_a_pathLength_1 = new SDOType(URINAME, TYPENAME_A); property_a_pathLength_1 = new SDOProperty(aHelperContext); property_a_pathLength_1.setName(PROPERTY_NAME_A_LENGTH_1); type_a_pathLength_1.addDeclaredProperty(property_a_pathLength_1); dataObject_a_pathLength_1 = (SDODataObject) dataFactory.create(type_a_pathLength_1); }