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;
}
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);
}
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;
}
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));
}
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);
}
Aggregations