use of com.evolveum.midpoint.prism.Objectable in project midpoint by Evolveum.
the class DeleteTest method delete001.
@Test
public void delete001() throws Exception {
final File file = new File("./../../samples/dsee/odsee-localhost-advanced-sync.xml");
if (!file.exists()) {
LOGGER.warn("skipping addGetDSEESyncDoubleTest, file {} not found.", new Object[] { file.getPath() });
return;
}
List<PrismObject<? extends Objectable>> elements = prismContext.parserFor(file).parseObjects();
List<String> oids = new ArrayList<String>();
OperationResult result = new OperationResult("Delete Test");
for (int i = 0; i < elements.size(); i++) {
PrismObject object = elements.get(i);
LOGGER.info("Adding object {}, type {}", new Object[] { i, object.getCompileTimeClass().getSimpleName() });
oids.add(repositoryService.addObject(object, null, result));
}
for (int i = 0; i < elements.size(); i++) {
PrismObject object = elements.get(i);
LOGGER.info("Deleting object {}, type {}", new Object[] { i, object.getCompileTimeClass().getSimpleName() });
repositoryService.deleteObject(object.getCompileTimeClass(), oids.get(i), result);
}
}
use of com.evolveum.midpoint.prism.Objectable in project midpoint by Evolveum.
the class SearchTest method beforeClass.
@BeforeClass
public void beforeClass() throws Exception {
super.beforeClass();
PrismTestUtil.resetPrismContext(MidPointPrismContextFactory.FACTORY);
FullTextSearchConfigurationType fullTextConfig = new FullTextSearchConfigurationType();
FullTextSearchIndexedItemsConfigurationType entry = new FullTextSearchIndexedItemsConfigurationType();
entry.getItem().add(new ItemPath(ObjectType.F_NAME).asItemPathType());
entry.getItem().add(new ItemPath(ObjectType.F_DESCRIPTION).asItemPathType());
fullTextConfig.getIndexed().add(entry);
repositoryService.applyFullTextSearchConfiguration(fullTextConfig);
LOGGER.info("Applying full text search configuration: {}", fullTextConfig);
List<PrismObject<? extends Objectable>> objects = prismContext.parserFor(new File(FOLDER_BASIC, "objects.xml")).parseObjects();
objects.addAll(prismContext.parserFor(new File(FOLDER_BASIC, "objects-2.xml")).parseObjects());
OperationResult result = new OperationResult("add objects");
for (PrismObject object : objects) {
repositoryService.addObject(object, null, result);
}
result.recomputeStatus();
assertTrue(result.isSuccess());
}
use of com.evolveum.midpoint.prism.Objectable in project midpoint by Evolveum.
the class SchemaProcessor method updatePrismObject.
private Set<JDefinedClass> updatePrismObject(Outline outline) {
Set<JDefinedClass> containers = new HashSet<JDefinedClass>();
Set<Map.Entry<NClass, CClassInfo>> set = outline.getModel().beans().entrySet();
for (Map.Entry<NClass, CClassInfo> entry : set) {
ClassOutline classOutline = outline.getClazz(entry.getValue());
QName qname = getCClassInfoQName(entry.getValue());
if (qname == null) {
continue;
}
boolean isDirectPrismObject = hasAnnotation(classOutline, A_PRISM_OBJECT);
boolean isIndirectPrismObject = hasParentAnnotation(classOutline, A_PRISM_OBJECT);
if (!isIndirectPrismObject) {
continue;
}
JDefinedClass definedClass = classOutline.implClass;
createDefaultConstructor(definedClass);
createPrismContextObjectableConstructor(definedClass);
createAsPrismObject(definedClass);
if (!isDirectPrismObject) {
continue;
}
definedClass._implements(CLASS_MAP.get(Objectable.class));
containers.add(definedClass);
//inserting PrismObject field into ObjectType class
JVar container = definedClass.field(JMod.PRIVATE, PrismObject.class, CONTAINER_FIELD_NAME);
//create getContainer
// createGetContainerMethod(classOutline, container);
//create setContainer
createSetContainerMethod(definedClass, container);
//create asPrismObject()
createAsPrismContainer(classOutline, container);
// Objectable is also Containerable, we also need these
createAsPrismContainerValueInObject(definedClass);
createSetContainerValueMethodInObject(definedClass, container);
print("Creating toString, equals, hashCode methods.");
//create toString, equals, hashCode
createToStringMethod(definedClass, METHOD_AS_PRISM_CONTAINER);
createEqualsMethod(classOutline, METHOD_AS_PRISM_CONTAINER);
createHashCodeMethod(definedClass, METHOD_AS_PRISM_CONTAINER);
//create toDebugName, toDebugType
createToDebugName(definedClass);
createToDebugType(definedClass);
}
removeCustomGeneratedMethod(outline);
return containers;
}
use of com.evolveum.midpoint.prism.Objectable in project midpoint by Evolveum.
the class OrgStructTest method test001addOrgStructObjectsIncorrect.
@Test
public void test001addOrgStructObjectsIncorrect() throws Exception {
OperationResult opResult = new OperationResult("test001addOrgStructObjectsIncorrect");
List<PrismObject<? extends Objectable>> orgStructIncorrect = prismContext.parserFor(new File(ORG_STRUCT_OBJECTS_INCORRECT)).parseObjects();
for (PrismObject<? extends Objectable> o : orgStructIncorrect) {
repositoryService.addObject((PrismObject<ObjectType>) o, null, opResult);
}
opResult.computeStatusIfUnknown();
AssertJUnit.assertTrue(opResult.isSuccess());
Session session = open();
try {
LOGGER.info("==============CLOSURE TABLE==========");
// descendants of F007 - F007<0>, F009<1>, F008<2>, F0010<2>
Criteria criteria = session.createCriteria(ROrgClosure.class).createCriteria("ancestor", "anc").setFetchMode("ancestor", FetchMode.JOIN).add(Restrictions.eq("anc.oid", ORG_F007_OID));
List<ROrgClosure> orgClosure = criteria.list();
for (ROrgClosure c : orgClosure) {
LOGGER.info("{}", c.getDescendant());
}
AssertJUnit.assertEquals(4, orgClosure.size());
criteria = session.createCriteria(ROrgClosure.class).createCriteria("ancestor", "anc").setFetchMode("ancestor", FetchMode.JOIN).add(Restrictions.eq("anc.oid", ORG_F009_OID));
orgClosure = criteria.list();
AssertJUnit.assertEquals(3, orgClosure.size());
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_NAME).eq(ELAINE_NAME1).build();
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, opResult);
AssertJUnit.assertNotNull(users);
AssertJUnit.assertEquals(1, users.size());
UserType elaine1 = users.get(0).asObjectable();
LOGGER.info("--->elaine1<----");
AssertJUnit.assertEquals("Expected name elaine1, but got " + elaine1.getName().getOrig(), "elaine1", elaine1.getName().getOrig());
AssertJUnit.assertEquals("Expected elaine has one org ref, but got " + elaine1.getParentOrgRef().size(), 2, elaine1.getParentOrgRef().size());
AssertJUnit.assertEquals("Parent org ref oid not equal.", "00000000-8888-6666-0000-100000000011", elaine1.getParentOrgRef().get(0).getOid());
} finally {
close(session);
}
}
use of com.evolveum.midpoint.prism.Objectable in project midpoint by Evolveum.
the class OrgStructTest method test001addOrgStructObjects.
@Test
public void test001addOrgStructObjects() throws Exception {
OperationResult opResult = new OperationResult("test001addOrgStructObjects");
List<PrismObject<? extends Objectable>> orgStruct = prismContext.parserFor(new File(ORG_STRUCT_OBJECTS)).parseObjects();
for (PrismObject<? extends Objectable> o : orgStruct) {
repositoryService.addObject((PrismObject<ObjectType>) o, null, opResult);
}
opResult.computeStatusIfUnknown();
AssertJUnit.assertTrue(opResult.isSuccess());
List<PrismObject<OrgType>> orgTypes = repositoryService.searchObjects(OrgType.class, new ObjectQuery(), null, opResult);
AssertJUnit.assertNotNull(orgTypes);
AssertJUnit.assertEquals(9, orgTypes.size());
OrgType pRoot = repositoryService.getObject(OrgType.class, ORG_PROJECT_ROOT_OID, null, opResult).asObjectable();
AssertJUnit.assertEquals("PRoot", pRoot.getName().getOrig());
PrismObjectDefinition<UserType> userObjectDef = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(UserType.class);
ObjectQuery query = QueryBuilder.queryFor(UserType.class, prismContext).item(UserType.F_NAME).eq(ELAINE_NAME).build();
List<PrismObject<UserType>> users = repositoryService.searchObjects(UserType.class, query, null, opResult);
AssertJUnit.assertEquals(1, users.size());
ELAINE_OID = users.get(0).getOid();
testMonkeySubordinate();
Session session = open();
try {
Query qCount = session.createQuery("select count(*) from ROrgClosure");
assertCount(qCount, 19);
// check descendants for F0001 org unit
qCount = session.createQuery("select count(*) from ROrgClosure where ancestorOid = :ancestorOid");
qCount.setParameter("ancestorOid", ORG_F001_OID);
assertCount(qCount, 6);
qCount = session.createQuery("select count(*) from ROrgClosure where ancestorOid = :ancestorOid and descendantOid = :descendantOid");
qCount.setParameter("ancestorOid", ORG_F001_OID);
qCount.setParameter("descendantOid", ORG_F006_OID);
assertCount(qCount, 1);
} finally {
close(session);
}
}
Aggregations