Search in sources :

Example 71 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType 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 72 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class AssignmentTablePanel method addSelectedResourceAssignPerformed.

protected void addSelectedResourceAssignPerformed(ResourceType resource) {
    AssignmentType assignment = new AssignmentType();
    ConstructionType construction = new ConstructionType();
    assignment.setConstruction(construction);
    try {
        getPageBase().getPrismContext().adopt(assignment, UserType.class, new ItemPath(UserType.F_ASSIGNMENT));
    } catch (SchemaException e) {
        error(getString("Could not create assignment", resource.getName(), e.getMessage()));
        LoggingUtils.logUnexpectedException(LOGGER, "Couldn't create assignment", e);
        return;
    }
    construction.setResource(resource);
    List<AssignmentEditorDto> assignments = getAssignmentModel().getObject();
    AssignmentEditorDto dto = new AssignmentEditorDto(UserDtoStatus.ADD, assignment, getPageBase());
    assignments.add(dto);
    dto.setMinimized(true);
    dto.setShowEmpty(true);
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) ConstructionType(com.evolveum.midpoint.xml.ns._public.common.common_3.ConstructionType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) ItemPath(com.evolveum.midpoint.prism.path.ItemPath)

Example 73 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class SimpleParametricRoleSelector method createAddAssignmentDto.

@Override
protected AssignmentEditorDto createAddAssignmentDto(PrismObject<R> role, PageBase pageBase) {
    AssignmentEditorDto dto = super.createAddAssignmentDto(role, pageBase);
    PrismContainerValue<AssignmentType> newValue;
    try {
        newValue = dto.getNewValue(getPageBase().getPrismContext());
        PrismProperty<String> prop = newValue.findOrCreateProperty(parameterPath);
        prop.setRealValue(selectedParam);
    } catch (SchemaException e) {
        throw new SystemException(e.getMessage(), e);
    }
    return dto;
}
Also used : SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SystemException(com.evolveum.midpoint.util.exception.SystemException) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)

Example 74 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class RAbstractRole method copyFromJAXB.

public static <T extends AbstractRoleType> void copyFromJAXB(AbstractRoleType jaxb, RAbstractRole<T> repo, RepositoryContext repositoryContext, IdGeneratorResult generatorResult) throws DtoTranslationException {
    RFocus.copyFromJAXB(jaxb, repo, repositoryContext, generatorResult);
    repo.setRequestable(jaxb.isRequestable());
    repo.setDisplayName(RPolyString.copyFromJAXB(jaxb.getDisplayName()));
    repo.setIdentifier(jaxb.getIdentifier());
    repo.setRiskLevel(jaxb.getRiskLevel());
    for (AssignmentType inducement : jaxb.getInducement()) {
        RAssignment rInducement = new RAssignment(repo, RAssignmentOwner.ABSTRACT_ROLE);
        RAssignment.copyFromJAXB(inducement, rInducement, jaxb, repositoryContext, generatorResult);
        repo.getAssignments().add(rInducement);
    }
    for (ExclusionPolicyConstraintType exclusion : jaxb.getExclusion()) {
        RExclusion rExclusion = new RExclusion(repo);
        RExclusion.copyFromJAXB(exclusion, rExclusion, jaxb, repositoryContext, generatorResult);
        repo.getExclusion().add(rExclusion);
    }
    for (ObjectReferenceType approverRef : jaxb.getApproverRef()) {
        RObjectReference ref = RUtil.jaxbRefToRepo(approverRef, repositoryContext.prismContext, repo, RReferenceOwner.ROLE_APPROVER);
        if (ref != null) {
            repo.getApproverRef().add(ref);
        }
    }
    //PrismObjectDefinition<AbstractRoleType> roleDefinition = jaxb.asPrismObject().getDefinition();
    repo.setApprovalProcess(jaxb.getApprovalProcess());
    repo.setOwnerRef(RUtil.jaxbRefToEmbeddedRepoRef(jaxb.getOwnerRef(), repositoryContext.prismContext));
}
Also used : RAssignment(com.evolveum.midpoint.repo.sql.data.common.container.RAssignment) ExclusionPolicyConstraintType(com.evolveum.midpoint.xml.ns._public.common.common_3.ExclusionPolicyConstraintType) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) RExclusion(com.evolveum.midpoint.repo.sql.data.common.container.RExclusion)

Example 75 with AssignmentType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType in project midpoint by Evolveum.

the class AbstractAdLdapTest method test500AddOrgMeleeIsland.

@Test
public void test500AddOrgMeleeIsland() throws Exception {
    final String TEST_NAME = "test500AddOrgMeleeIsland";
    TestUtil.displayTestTile(this, TEST_NAME);
    // GIVEN
    Task task = taskManager.createTaskInstance(this.getClass().getName() + "." + TEST_NAME);
    OperationResult result = task.getResult();
    PrismObject<OrgType> org = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(OrgType.class).instantiate();
    OrgType orgType = org.asObjectable();
    orgType.setName(new PolyStringType(GROUP_MELEE_ISLAND_NAME));
    AssignmentType metaroleAssignment = new AssignmentType();
    ObjectReferenceType metaroleRef = new ObjectReferenceType();
    metaroleRef.setOid(ROLE_META_ORG_OID);
    metaroleRef.setType(RoleType.COMPLEX_TYPE);
    metaroleAssignment.setTargetRef(metaroleRef);
    orgType.getAssignment().add(metaroleAssignment);
    // WHEN
    TestUtil.displayWhen(TEST_NAME);
    addObject(org, task, result);
    // THEN
    TestUtil.displayThen(TEST_NAME);
    result.computeStatus();
    TestUtil.assertSuccess(result);
    orgMeleeIslandOid = org.getOid();
    Entry entry = assertLdapGroup(GROUP_MELEE_ISLAND_NAME);
    org = getObject(OrgType.class, orgMeleeIslandOid);
    groupMeleeOid = getSingleLinkOid(org);
    PrismObject<ShadowType> shadow = getShadowModel(groupMeleeOid);
    display("Shadow (model)", shadow);
    assertLdapConnectorInstances(2);
}
Also used : PolyStringType(com.evolveum.prism.xml.ns._public.types_3.PolyStringType) Task(com.evolveum.midpoint.task.api.Task) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) DefaultEntry(org.apache.directory.api.ldap.model.entry.DefaultEntry) Entry(org.apache.directory.api.ldap.model.entry.Entry) OrgType(com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) AssignmentType(com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractIntegrationTest(com.evolveum.midpoint.test.AbstractIntegrationTest)

Aggregations

AssignmentType (com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType)121 Test (org.testng.annotations.Test)61 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)55 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)42 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)41 Task (com.evolveum.midpoint.task.api.Task)39 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)33 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)25 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)24 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)21 QName (javax.xml.namespace.QName)20 PrismObject (com.evolveum.midpoint.prism.PrismObject)19 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)17 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)17 com.evolveum.midpoint.xml.ns._public.common.common_3 (com.evolveum.midpoint.xml.ns._public.common.common_3)17 RoleType (com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType)17 PolyStringType (com.evolveum.prism.xml.ns._public.types_3.PolyStringType)17 ArrayList (java.util.ArrayList)17 SchemaConstants (com.evolveum.midpoint.schema.constants.SchemaConstants)15 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)14