Search in sources :

Example 26 with PrismContainerValue

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;
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) PrismContainer(com.evolveum.midpoint.prism.PrismContainer)

Example 27 with PrismContainerValue

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) Test(org.testng.annotations.Test)

Example 28 with PrismContainerValue

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);
}
Also used : Referencable(com.evolveum.midpoint.prism.Referencable) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) JRException(net.sf.jasperreports.engine.JRException) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) Item(com.evolveum.midpoint.prism.Item) PrismProperty(com.evolveum.midpoint.prism.PrismProperty) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismReference(com.evolveum.midpoint.prism.PrismReference) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) ArrayList(java.util.ArrayList) List(java.util.List) Containerable(com.evolveum.midpoint.prism.Containerable) PrismObject(com.evolveum.midpoint.prism.PrismObject)

Example 29 with PrismContainerValue

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);
    }
}
Also used : Item(com.evolveum.midpoint.prism.Item) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) QName(javax.xml.namespace.QName) PrismValue(com.evolveum.midpoint.prism.PrismValue) PrismPropertyValue(com.evolveum.midpoint.prism.PrismPropertyValue)

Example 30 with PrismContainerValue

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);
    }
}
Also used : AccessCertificationCaseType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) RAccessCertificationCase(com.evolveum.midpoint.repo.sql.data.common.container.RAccessCertificationCase)

Aggregations

PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)59 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)22 Task (com.evolveum.midpoint.task.api.Task)22 AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)22 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)21 Test (org.testng.annotations.Test)18 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)17 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)15 ItemDeltaItem (com.evolveum.midpoint.repo.common.expression.ItemDeltaItem)15 ArrayList (java.util.ArrayList)14 ObjectDeltaObject (com.evolveum.midpoint.repo.common.expression.ObjectDeltaObject)13 PrismObject (com.evolveum.midpoint.prism.PrismObject)10 QName (javax.xml.namespace.QName)10 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)9 PrismReference (com.evolveum.midpoint.prism.PrismReference)9 ItemDelta (com.evolveum.midpoint.prism.delta.ItemDelta)9 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)9 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)8 ContainerDelta (com.evolveum.midpoint.prism.delta.ContainerDelta)6 ShadowAssociationType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType)6