use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.
the class CertificationTest method getOwningCampaignChecked.
private PrismObject<AccessCertificationCampaignType> getOwningCampaignChecked(AccessCertificationCaseType aCase) {
PrismContainer caseContainer = (PrismContainer) aCase.asPrismContainerValue().getParent();
assertNotNull("campaign is not fetched (case parent is null)", caseContainer);
PrismContainerValue campaignValue = (PrismContainerValue) caseContainer.getParent();
assertNotNull("campaign is not fetched (case container parent is null)", caseContainer);
PrismObject<AccessCertificationCampaignType> campaign = (PrismObject) campaignValue.getParent();
assertNotNull("campaign is not fetched (campaign PCV parent is null)", campaign);
return campaign;
}
use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.
the class AbstractLdapHierarchyTest method test322MoveOrgZblo.
@Test
public void test322MoveOrgZblo() throws Exception {
final String TEST_NAME = "test322MoveOrgZblo";
TestUtil.displayTestTile(this, TEST_NAME);
Task task = taskManager.createTaskInstance(AbstractLdapHierarchyTest.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
PrismObject<OrgType> orgBefore = getOrg(ORG_CORTUV_HRAD_NAME2);
ObjectDelta<OrgType> delta = orgBefore.createModifyDelta();
PrismContainerValue<AssignmentType> oldAssignment = null;
for (PrismContainerValue aval : orgBefore.findContainer(OrgType.F_ASSIGNMENT).getValues()) {
oldAssignment = (PrismContainerValue<AssignmentType>) aval;
if (OrgType.COMPLEX_TYPE.equals(oldAssignment.asContainerable().getTargetRef().getType())) {
break;
}
}
delta.addModificationDeleteContainer(OrgType.F_ASSIGNMENT, oldAssignment.clone());
AssignmentType newAssignmentType = new AssignmentType();
ObjectReferenceType targetRef = new ObjectReferenceType();
targetRef.setOid(orgRolyulaDiabolicaOid);
targetRef.setType(OrgType.COMPLEX_TYPE);
newAssignmentType.setTargetRef(targetRef);
delta.addModificationAddContainer(OrgType.F_ASSIGNMENT, newAssignmentType);
// WHEN
TestUtil.displayWhen(TEST_NAME);
display("Modifying " + orgBefore + "with delta", delta);
modelService.executeChanges(MiscSchemaUtil.createCollection(delta), null, task, result);
// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
dumpOrgTree();
dumpLdap();
PrismObject<OrgType> orgAfter = getAndAssertFunctionalOrg(ORG_CORTUV_HRAD_NAME2, orgRolyulaDiabolicaOid);
assertEquals("Cortuv hrad org OID changed after rename", orgCortuvHradOid, orgAfter.getOid());
recomputeIfNeeded(orgCortuvHradOid);
dumpOrgTree();
dumpLdap();
getAndAssertUser(USER_GORC_USERNAME2, ORG_CORTUV_HRAD_NAME2, ORG_ROYULA_DIABOLICA_NAME);
getAndAssertUser(USER_DEZI_USERNAME, ORG_VYSNE_VLKODLAKY_NAME, ORG_CORTUV_HRAD_NAME2, ORG_ROYULA_DIABOLICA_NAME);
assertSubOrgs(orgAfter, 1);
assertSubOrgs(orgRolyulaCarpathiaOid, 0);
assertSubOrgs(orgRolyulaDiabolicaOid, 1);
assertSubOrgs(ORG_TOP_OID, 2);
assertSubOrgs(orgVysneVlkodlakyOid, 0);
}
use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.
the class MidPointAbstractDataSource method getFieldValue.
@Override
public Object getFieldValue(JRField jrField) throws JRException {
// TODO Auto-generated method stub
String fieldName = jrField.getName();
if (fieldName.equals("oid")) {
return currentObject.getOid();
}
Item i = currentObject.findItem(new QName(fieldName));
if (i == null) {
return null;
}
if (i instanceof PrismProperty) {
if (i.isSingleValue()) {
return ((PrismProperty) i).getRealValue();
}
return ((PrismProperty) i).getRealValues();
} else if (i instanceof PrismReference) {
if (i.isSingleValue()) {
return ((PrismReference) i).getValue().asReferencable();
}
List<Referencable> refs = new ArrayList<Referencable>();
for (PrismReferenceValue refVal : ((PrismReference) i).getValues()) {
refs.add(refVal.asReferencable());
}
return refs;
} else if (i instanceof PrismContainer) {
if (i.isSingleValue()) {
return ((PrismContainer) i).getValue().asContainerable();
}
List<Containerable> containers = new ArrayList<Containerable>();
for (Object pcv : i.getValues()) {
if (pcv instanceof PrismContainerValue) {
containers.add(((PrismContainerValue) pcv).asContainerable());
}
}
return containers;
} else
throw new JRException("Could not get value of the fileld: " + fieldName);
}
use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.
the class ReportUtils method getItemRealValue.
public static Object getItemRealValue(PrismContainerValue containerValue, String itemName) {
Item item = containerValue.findItem(new QName(itemName));
if (item == null || item.size() == 0) {
return null;
}
if (item.size() > 1) {
throw new IllegalStateException("More than one value in item " + item);
}
PrismValue value = item.getValue(0);
if (value == null) {
return null;
}
if (value instanceof PrismPropertyValue) {
return ((PrismPropertyValue) value).getValue();
} else if (value instanceof PrismReferenceValue) {
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue((PrismReferenceValue) value);
return ort;
} else if (value instanceof PrismContainerValue) {
// questionable
return ((PrismContainerValue) value).asContainerable();
} else {
throw new IllegalStateException("Unknown PrismValue: " + value);
}
}
use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.
the class CertificationCaseHelper method addCertificationCampaignCases.
public void addCertificationCampaignCases(Session session, String campaignOid, Collection<PrismContainerValue> values, int currentId, List<Long> affectedIds) throws DtoTranslationException {
for (PrismContainerValue value : values) {
AccessCertificationCaseType caseType = new AccessCertificationCaseType();
caseType.setupContainerValue(value);
if (caseType.getId() == null) {
caseType.setId((long) currentId);
currentId++;
}
// we need to generate IDs but we (currently) do not use that for setting "isTransient" flag
PrismIdentifierGenerator generator = new PrismIdentifierGenerator();
generator.generate(caseType, PrismIdentifierGenerator.Operation.MODIFY);
RAccessCertificationCase row = RAccessCertificationCase.toRepo(campaignOid, caseType, createRepositoryContext());
row.setId(RUtil.toInteger(caseType.getId()));
affectedIds.add(caseType.getId());
session.save(row);
}
}
Aggregations