List of usage examples for javax.xml.registry LifeCycleManager EXTRINSIC_OBJECT
String EXTRINSIC_OBJECT
To view the source code for javax.xml.registry LifeCycleManager EXTRINSIC_OBJECT.
Click Source Link
From source file:it.cnr.icar.eric.client.xml.registry.InfomodelFactoryTest.java
/** * Test lcm.create, lcm.save and query of extended Association *//*from www .java 2 s . c o m*/ public void testExtendedAssociationLCM() throws Exception { System.out.println("\ntestExtendedAssociationLCM"); Object o; @SuppressWarnings("unused") InfomodelFactory extUtil = InfomodelFactory.getInstance(); Concept parentConcept = (Concept) bqm.getRegistryObject(BindingUtility.CANONICAL_OBJECT_TYPE_ID_Association, "ClassificationNode"); Concept myAssociationType = lcm.createConcept(parentConcept, "MyAssociation", "MyAssociation"); myAssociationType.setKey(lcm.createKey(ASS_EXT_UUID)); try { BulkResponse br; // Save concept and update it, to get the path br = lcm.saveObjects(Collections.singleton(myAssociationType)); assertResponseSuccess(br); Query q = dqm.createQuery(QueryImpl.QUERY_TYPE_SQL, "select * from ClassificationNode where id = '" + ASS_EXT_UUID + "'"); br = dqm.executeQuery(q); assertResponseSuccess(br); myAssociationType = (Concept) br.getCollection().iterator().next(); // test lcm.createObject(Concept) o = lcm.createObject(myAssociationType); assertNotNull(o); assertTrue("Association extensions must extend AssociationImpl", o instanceof AssociationImpl); assertEquals("Should have been default class", ASS_EXT_CLASSNAME, o.getClass().getName()); assertEquals("Should be of type MyAssociation", myAssociationType, ((Association) o).getAssociationType()); // test lcm.createObject(String) o = lcm.createObject(ASS_NICKNAME); assertNotNull(o); assertTrue("Association extensions must extend AssociationImpl", o instanceof AssociationImpl); assertEquals("Should have been default class", ASS_EXT_CLASSNAME, o.getClass().getName()); assertEquals("Should be of type MyAssociation", myAssociationType, ((Association) o).getAssociationType()); // test lcm.createAssociation o = lcm.createAssociation(myAssociationType); assertNotNull(o); assertTrue("Association extensions must extend AssociationImpl", o instanceof AssociationImpl); assertEquals("Should have been default class", ASS_EXT_CLASSNAME, o.getClass().getName()); assertEquals("Should be of type MyAssociation", myAssociationType, ((Association) o).getAssociationType()); ((RegistryObject) o).setKey(lcm.createKey(ASS_TEST_UUID)); // Association needs a source and a target RegistryObject target = lcm.createExtrinsicObject(); target.setKey(lcm.createKey(EO_TEST_UUID)); assertNotNull(target); ((AssociationImpl) o).setTargetObject(target); ((AssociationImpl) o).setSourceObject(parentConcept); ArrayList<Object> objects = new ArrayList<Object>(); objects.add(o); objects.add(target); br = lcm.saveObjects(objects); assertResponseSuccess(br); q = dqm.createQuery(QueryImpl.QUERY_TYPE_SQL, "select * from Association where id = '" + ASS_TEST_UUID + "'"); br = dqm.executeQuery(q); assertResponseSuccess(br); o = br.getCollection().iterator().next(); assertEquals("Should have been default class", ASS_EXT_CLASSNAME, o.getClass().getName()); } finally { // cleanup deleteIfExist(ASS_EXT_UUID, LifeCycleManager.ASSOCIATION); deleteIfExist(EO_TEST_UUID, LifeCycleManager.EXTRINSIC_OBJECT); deleteIfExist(ASS_TEST_UUID, LifeCycleManager.ASSOCIATION); } }
From source file:it.cnr.icar.eric.client.xml.registry.InfomodelFactoryTest.java
/** * Test lcm.create, lcm.save and query of extended ExtrinsicObject *//*from w ww . jav a 2 s . c o m*/ public void testExtendedExtrinsicObjectLCM() throws Exception { System.out.println("\ntestExtendedExtrinsicObjectLCM"); Object o; @SuppressWarnings("unused") InfomodelFactory extUtil = InfomodelFactory.getInstance(); Concept parentConcept = (Concept) bqm .getRegistryObject(BindingUtility.CANONICAL_OBJECT_TYPE_ID_ExtrinsicObject, "ClassificationNode"); Concept myExtrinsicObjectType = lcm.createConcept(parentConcept, "MyExtrinsicObject", "MyExtrinsicObject"); myExtrinsicObjectType.setKey(lcm.createKey(EO_EXT_UUID)); try { BulkResponse br; // Save concept and update it, to get the path br = lcm.saveObjects(Collections.singleton(myExtrinsicObjectType)); assertResponseSuccess(br); Query q = dqm.createQuery(QueryImpl.QUERY_TYPE_SQL, "select * from ClassificationNode where id = '" + EO_EXT_UUID + "'"); br = dqm.executeQuery(q); assertResponseSuccess(br); myExtrinsicObjectType = (Concept) br.getCollection().iterator().next(); // test lcm.createObject(Concept) o = lcm.createObject(myExtrinsicObjectType); assertNotNull(o); assertTrue("ExtrinsicObject extensions must extend ExtrinsicObjectImpl", o instanceof ExtrinsicObjectImpl); assertEquals("Should have been default class", EO_EXT_CLASSNAME, o.getClass().getName()); assertEquals("Should be of type MyExtrinsicObject", myExtrinsicObjectType, ((ExtrinsicObject) o).getObjectType()); // test lcm.createObject(String) o = lcm.createObject(EO_NICKNAME); assertNotNull(o); assertTrue("ExtrinsicObject extensions must extend ExtrinsicObjectImpl", o instanceof ExtrinsicObjectImpl); assertEquals("Should have been default class", EO_EXT_CLASSNAME, o.getClass().getName()); assertEquals("Should be of type MyExtrinsicObject", myExtrinsicObjectType, ((ExtrinsicObject) o).getObjectType()); // test lcm.createExtrinsicObject o = lcm.createExtrinsicObject(myExtrinsicObjectType); assertNotNull(o); assertTrue("ExtrinsicObject extensions must extend ExtrinsicObjectImpl", o instanceof ExtrinsicObjectImpl); assertEquals("Should have been default class", EO_EXT_CLASSNAME, o.getClass().getName()); assertEquals("Should be of type MyExtrinsicObject", myExtrinsicObjectType, ((ExtrinsicObject) o).getObjectType()); ((RegistryObject) o).setKey(lcm.createKey(EO_TEST_UUID)); br = lcm.saveObjects(Collections.singleton(myExtrinsicObjectType)); assertResponseSuccess(br); br = lcm.saveObjects(Collections.singleton(o)); assertResponseSuccess(br); q = dqm.createQuery(QueryImpl.QUERY_TYPE_SQL, "select * from ExtrinsicObject where id = '" + EO_TEST_UUID + "'"); br = dqm.executeQuery(q); assertResponseSuccess(br); o = br.getCollection().iterator().next(); assertEquals("Should have been default class", EO_EXT_CLASSNAME, o.getClass().getName()); } finally { // cleanup deleteIfExist(EO_EXT_UUID, LifeCycleManager.EXTRINSIC_OBJECT); deleteIfExist(EO_TEST_UUID, LifeCycleManager.EXTRINSIC_OBJECT); } }