Search in sources :

Example 31 with PrismContainerValue

use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.

the class AssignmentTablePanel method handleAssignmentDeltas.

public ContainerDelta handleAssignmentDeltas(ObjectDelta<T> userDelta, PrismContainerDefinition def, QName assignmentPath) throws SchemaException {
    ContainerDelta assDelta = new ContainerDelta(new ItemPath(), assignmentPath, def, // hoping that def contains a prism
    def.getPrismContext());
    // context!
    // PrismObject<OrgType> org =
    // (PrismObject<OrgType>)getModel().getObject().getAssignmentParent();
    // PrismObjectDefinition orgDef = org.getDefinition();
    // PrismContainerDefinition assignmentDef =
    // def.findContainerDefinition(assignmentPath);
    List<AssignmentEditorDto> assignments = getAssignmentModel().getObject();
    for (AssignmentEditorDto assDto : assignments) {
        PrismContainerValue newValue = assDto.getNewValue(getPageBase().getPrismContext());
        switch(assDto.getStatus()) {
            case ADD:
                newValue.applyDefinition(def, false);
                assDelta.addValueToAdd(newValue.clone());
                break;
            case DELETE:
                PrismContainerValue oldValue = assDto.getOldValue();
                oldValue.applyDefinition(def);
                assDelta.addValueToDelete(oldValue.clone());
                break;
            case MODIFY:
                if (!assDto.isModified(getPageBase().getPrismContext())) {
                    LOGGER.trace("Assignment '{}' not modified.", new Object[] { assDto.getName() });
                    continue;
                }
                handleModifyAssignmentDelta(assDto, def, newValue, userDelta);
                break;
            default:
                warn(getString("pageUser.message.illegalAssignmentState", assDto.getStatus()));
        }
    }
    if (!assDelta.isEmpty()) {
        assDelta = userDelta.addModification(assDelta);
    }
    // todo remove this block [lazyman] after model is updated - it has to
    // remove resource from accountConstruction
    Collection<PrismContainerValue> values = assDelta.getValues(PrismContainerValue.class);
    for (PrismContainerValue value : values) {
        AssignmentType ass = new AssignmentType();
        ass.setupContainerValue(value);
        removeResourceFromAccConstruction(ass);
    }
    return assDelta;
}
Also used : PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ContainerDelta(com.evolveum.midpoint.prism.delta.ContainerDelta) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 32 with PrismContainerValue

use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.

the class TestOpenDj method assertEntitlementGroup.

protected void assertEntitlementGroup(PrismObject<ShadowType> account, String entitlementOid) {
    ShadowAssociationType associationType = IntegrationTestTools.assertAssociation(account, ASSOCIATION_GROUP_NAME, entitlementOid);
    PrismContainerValue identifiersCVal = associationType.getIdentifiers().asPrismContainerValue();
    PrismProperty<String> dnProp = identifiersCVal.findProperty(getSecondaryIdentifierQName());
    assertNotNull("No DN identifier in group association in " + account + ", got " + identifiersCVal, dnProp);
}
Also used : PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ShadowAssociationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowAssociationType)

Example 33 with PrismContainerValue

use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.

the class SchemaProcessor method createContainerFieldGetterBody.

private void createContainerFieldGetterBody(JFieldVar field, ClassOutline classOutline, JMethod method) {
    JBlock body = method.body();
    List<JAnnotationUse> existingAnnotations = (List<JAnnotationUse>) getAnnotations(method);
    for (JAnnotationUse annotation : existingAnnotations) {
        if (isAnnotationTypeOf(annotation, XmlElement.class)) {
            Field mfield = getField(JAnnotationUse.class, "memberValues");
            mfield.setAccessible(true);
            Map<String, Object> map;
            try {
                map = (Map<String, Object>) mfield.get(annotation);
            } catch (IllegalArgumentException | IllegalAccessException e) {
                throw new RuntimeException(e.getMessage(), e);
            }
            mfield.setAccessible(false);
            map.remove("name");
            annotation.param("name", normalizeFieldName(field.name()));
        }
    }
    if (isList(field.type())) {
        //JClass list = (JClass) field.type();
        //JClass listType = list.getTypeParameters().get(0);
        // PrismContainerValue pcv = asPrismContainerValue()
        JVar pcvVar = body.decl(CLASS_MAP.get(PrismContainerValue.class), "pcv", JExpr.invoke(METHOD_AS_PRISM_CONTAINER_VALUE));
        // PrismContainer container = PrismForJAXBUtil.getContainer(pcv, F_ASSIGNMENT);
        JInvocation invocation = CLASS_MAP.get(PrismForJAXBUtil.class).staticInvoke(METHOD_PRISM_UTIL_GET_CONTAINER);
        invocation.arg(pcvVar);
        invocation.arg(JExpr.ref(fieldFPrefixUnderscoredUpperCase(field.name())));
        JVar containerVar = body.decl(CLASS_MAP.get(PrismContainer.class), "container", invocation);
        // anonymous class (e.g. FocusType.AnonAssignment and its methods)
        JDefinedClass anonymousClass = createFieldContainerGetterListAnon(field, classOutline);
        createFieldContainerCreateItemBody(field, findMethod(anonymousClass, "createItem"));
        createFieldContainerGetValueFrom(field, findMethod(anonymousClass, "getValueFrom"));
        // return new FocusType.AnonAssignment(container, pcv);
        JInvocation newList = JExpr._new(anonymousClass);
        newList.arg(containerVar);
        newList.arg(pcvVar);
        body._return(newList);
        return;
    }
    JInvocation invocation = CLASS_MAP.get(PrismForJAXBUtil.class).staticInvoke(METHOD_PRISM_UTIL_GET_FIELD_SINGLE_CONTAINERABLE);
    invocation.arg(JExpr.invoke(METHOD_AS_PRISM_CONTAINER_VALUE));
    invocation.arg(JExpr.ref(fieldFPrefixUnderscoredUpperCase(field.name())));
    invocation.arg(JExpr.dotclass((JClass) field.type()));
    body._return(invocation);
}
Also used : PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) Field(java.lang.reflect.Field) PrismForJAXBUtil(com.evolveum.midpoint.prism.xjc.PrismForJAXBUtil) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) PrismReferenceArrayList(com.evolveum.midpoint.prism.xjc.PrismReferenceArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PrismContainerArrayList(com.evolveum.midpoint.prism.xjc.PrismContainerArrayList) PrismObject(com.evolveum.midpoint.prism.PrismObject)

Example 34 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)

Example 35 with PrismContainerValue

use of com.evolveum.midpoint.prism.PrismContainerValue in project midpoint by Evolveum.

the class TaskQuartzImpl method setExtensionContainerValue.

// use this method to avoid cloning the value
@Override
public <T extends Containerable> void setExtensionContainerValue(QName containerName, T value) throws SchemaException {
    PrismContainerDefinition containerDef = getPrismContext().getSchemaRegistry().findContainerDefinitionByElementName(containerName);
    if (containerDef == null) {
        throw new SchemaException("Unknown container item " + containerName);
    }
    ArrayList<PrismContainerValue<T>> values = new ArrayList(1);
    values.add(value.asPrismContainerValue());
    processModificationBatched(setExtensionContainerAndPrepareDelta(containerName, containerDef, values));
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) ArrayList(java.util.ArrayList) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition)

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