public ConstructionType resourceRef(ObjectReferenceType value) { setResourceRef(value); return this; }
@NotNull public static <T extends ObjectType> AssignmentType createAssignmentTo(@NotNull ObjectReferenceType ref, @Nullable PrismContext prismContext) { AssignmentType assignment = new AssignmentType(prismContext); if (QNameUtil.match(ref.getType(), ResourceType.COMPLEX_TYPE)) { ConstructionType construction = new ConstructionType(); construction.setResourceRef(ref); assignment.setConstruction(construction); } else { assignment.setTargetRef(ref); } return assignment; }
@NotNull public static AssignmentType createAssignmentWithConstruction(@NotNull PrismObject<ResourceType> object, ShadowKindType kind, String intent, PrismContext prismContext) { AssignmentType assignment = new AssignmentType(prismContext); ConstructionType construction = new ConstructionType(prismContext); construction.setResourceRef(createObjectRef(object, prismContext)); construction.setKind(kind); construction.setIntent(intent); assignment.setConstruction(construction); return assignment; }
protected ConstructionType createAccountConstruction(String resourceOid, String intent) throws SchemaException { ConstructionType accountConstructionType = new ConstructionType(); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resourceOid); accountConstructionType.setResourceRef(resourceRef); accountConstructionType.setIntent(intent); return accountConstructionType; }
@NotNull public static <T extends ObjectType> AssignmentType createAssignmentTo(@NotNull PrismObject<T> object, QName relation) { AssignmentType assignment = new AssignmentType(object.getPrismContext()); if (object.asObjectable() instanceof ResourceType) { ConstructionType construction = new ConstructionType(object.getPrismContext()); construction.setResourceRef(createObjectRef(object, relation)); assignment.setConstruction(construction); } else { assignment.setTargetRef(createObjectRef(object, relation)); } return assignment; }
AssignmentType assignmentType = new AssignmentType(); ConstructionType constructionType = new ConstructionType(); constructionType.setResourceRef(resourceRef); assignmentType.setConstruction(constructionType); assignments.add(assignmentType);
protected void fillinUserAssignmentAccountConstruction(PrismObject<UserType> user, String resourceOid) { AssignmentType assignmentType = new AssignmentType(); ConstructionType accountConstruntion = new ConstructionType(); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resourceOid); resourceRef.setType(ResourceType.COMPLEX_TYPE); accountConstruntion.setResourceRef(resourceRef); accountConstruntion.setKind(ShadowKindType.ACCOUNT); assignmentType.setConstruction(accountConstruntion); user.asObjectable().getAssignment().add(assignmentType); }
protected AssignmentType createConstructionAssignment(String resourceOid, ShadowKindType kind, String intent) { AssignmentType assignmentType = new AssignmentType(); ConstructionType constructionType = new ConstructionType(); constructionType.setKind(kind); assignmentType.setConstruction(constructionType); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resourceOid); resourceRef.setType(ResourceType.COMPLEX_TYPE); constructionType.setResourceRef(resourceRef); constructionType.setIntent(intent); return assignmentType; }
public static AssignmentType createConstructionAssignment(String resourceOid, ShadowKindType kind, String intent) { AssignmentType assignment = new AssignmentType(); ConstructionType construction = new ConstructionType(); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(resourceOid); construction.setResourceRef(resourceRef); if (kind != null) { construction.setKind(kind); } if (intent != null) { construction.setIntent(intent); } assignment.setConstruction(construction); return assignment; }
protected void modifyRoleAddConstruction(String roleOid, long inducementId, String resourceOid) throws SchemaException, ObjectAlreadyExistsException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { Task task = createTask(AbstractModelIntegrationTest.class.getName() + ".modifyRoleAddConstruction"); OperationResult result = task.getResult(); ConstructionType construction = new ConstructionType(); ObjectReferenceType resourceRedRef = new ObjectReferenceType(); resourceRedRef.setOid(resourceOid); construction.setResourceRef(resourceRedRef); ObjectDelta<RoleType> roleDelta = prismContext.deltaFactory().object() .createModificationAddContainer(RoleType.class, roleOid, ItemPath.create(RoleType.F_INDUCEMENT, inducementId, AssignmentType.F_CONSTRUCTION), construction); modelService.executeChanges(MiscSchemaUtil.createCollection(roleDelta), null, task, result); result.computeStatus(); TestUtil.assertSuccess(result); }
private <F extends AssignmentHolderType> void createAssignmentDelta(LensContext<F> context, LensProjectionContext accountContext) throws SchemaException{ Class<F> focusClass = context.getFocusClass(); ContainerDelta<AssignmentType> assignmentDelta = prismContext.deltaFactory().container() .createDelta(AssignmentHolderType.F_ASSIGNMENT, focusClass); AssignmentType assignment = new AssignmentType(); ConstructionType constructionType = new ConstructionType(); constructionType.setResourceRef(ObjectTypeUtil.createObjectRef(accountContext.getResource(), prismContext)); assignment.setConstruction(constructionType); assignmentDelta.addValueToAdd(assignment.asPrismContainerValue()); PrismContainerDefinition<AssignmentType> containerDefinition = prismContext.getSchemaRegistry().findObjectDefinitionByCompileTimeClass(focusClass).findContainerDefinition(AssignmentHolderType.F_ASSIGNMENT); assignmentDelta.applyDefinition(containerDefinition); context.getFocusContext().swallowToProjectionWaveSecondaryDelta(assignmentDelta); }
private void createCustomConstruction(RoleType role, String name, int order) { ConstructionType c = new ConstructionType(prismContext); c.setDescription(name); c.setResourceRef(ObjectTypeUtil.createObjectRef(RESOURCE_DUMMY_EMPTY_OID, ObjectTypes.RESOURCE)); ResourceAttributeDefinitionType nameDef = new ResourceAttributeDefinitionType(); nameDef.setRef(new ItemPathType(ItemPath.create(new QName(SchemaConstants.NS_ICF_SCHEMA, "name")))); MappingType outbound = new MappingType(); outbound.setName(name); ExpressionType expression = new ExpressionType(); ScriptExpressionEvaluatorType script = new ScriptExpressionEvaluatorType(); script.setCode( "import com.evolveum.midpoint.model.impl.lens.TestAssignmentProcessor2\n\n" + "TestAssignmentProcessor2.startCallback('" + name + "')\n" + "this.binding.variables.each {k,v -> TestAssignmentProcessor2.variableCallback(k, v, '" + name + "')}\n" + "TestAssignmentProcessor2.finishCallback('" + name + "')\n" + "return null"); expression.getExpressionEvaluator().add(new ObjectFactory().createScript(script)); outbound.setExpression(expression); nameDef.setOutbound(outbound); c.getAttribute().add(nameDef); AssignmentType a = new AssignmentType(prismContext); a.setDescription("Assignment for " + c.getDescription()); a.setConstruction(c); addAssignmentOrInducement(role, order, a); }
@Test public void testDeleteInducementValidIdSameValueApplyToObject() throws Exception { final String TEST_NAME = "testDeleteInducementValidIdSameValueApplyToObject"; displayTestTile(TEST_NAME); // GIVEN PrismObject<RoleType> role = PrismTestUtil.parseObject(ROLE_CONSTRUCTION_FILE); //Delta ConstructionType construction = new ConstructionType(); ObjectReferenceType resourceRef = new ObjectReferenceType(); resourceRef.setOid(ROLE_CONSTRUCTION_RESOURCE_OID); construction.setResourceRef(resourceRef); AssignmentType inducement = new AssignmentType(); inducement.setConstruction(construction); inducement.setId(ROLE_CONSTRUCTION_INDUCEMENT_ID); ObjectDelta<RoleType> roleDelta = getPrismContext().deltaFactory().object() .createModificationDeleteContainer(RoleType.class, ROLE_CONSTRUCTION_OID, RoleType.F_INDUCEMENT, inducement); // WHEN roleDelta.applyTo(role); // THEN System.out.println("Role after delta application:"); System.out.println(role.debugDump()); assertEquals("Wrong OID", ROLE_CONSTRUCTION_OID, role.getOid()); PrismAsserts.assertPropertyValue(role, UserType.F_NAME, PrismTestUtil.createPolyString("Construction")); PrismContainer<AssignmentType> assignment = role.findContainer(RoleType.F_INDUCEMENT); assertNull("Unexpected inducement", assignment); }
resourceRef.setOid(ROLE_CONSTRUCTION_RESOURCE_OID); resourceRef.setType(ObjectTypes.RESOURCE.getTypeQName()); construction.setResourceRef(resourceRef);
@Test public void test300UserAssignmentPreview() throws Exception { final String TEST_NAME = "test300UserAssignmentPreview"; Task task = createTask(TEST_NAME); PrismObject<UserType> jack = getUser(USER_JACK_OID); display("jack", jack); AssignmentType ass1 = new AssignmentType(prismContext); ass1.setConstruction(new ConstructionType(prismContext)); ass1.getConstruction().setResourceRef(createObjectRef(RESOURCE_DUMMY_OID, RESOURCE)); ObjectDelta<UserType> delta = deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add(ass1) .asObjectDelta(USER_JACK_OID); delta.applyDefinitionIfPresent(jack.getDefinition(), false); /// WHEN displayWhen(TEST_NAME); ModelContext<UserType> modelContext = modelInteractionService.previewChanges(Collections.<ObjectDelta<? extends ObjectType>>singletonList(delta), null, task, task.getResult()); List<ObjectDelta<? extends ObjectType>> primaryDeltas = new ArrayList<>(); List<ObjectDelta<? extends ObjectType>> secondaryDeltas = new ArrayList<>(); fillDeltas(modelContext, primaryDeltas, secondaryDeltas); List<? extends Scene> primaryScenes = modelInteractionService.visualizeDeltas(primaryDeltas, task, task.getResult()); List<? extends Scene> secondaryScenes = modelInteractionService.visualizeDeltas(secondaryDeltas, task, task.getResult()); // THEN displayThen(TEST_NAME); display("primary scenes", primaryScenes); display("secondary scenes", secondaryScenes); // TODO some asserts }
@Test public void test305UserAssignmentAdd() throws Exception { final String TEST_NAME = "test305UserAssignmentAdd"; Task task = createTask(TEST_NAME); display("jack", getUser(USER_JACK_OID)); AssignmentType ass1 = new AssignmentType(); ass1.setConstruction(new ConstructionType()); ass1.getConstruction().setResourceRef(createObjectRef(RESOURCE_DUMMY_OID, RESOURCE)); ObjectDelta<UserType> delta = deltaFor(UserType.class) .item(UserType.F_ASSIGNMENT).add(ass1) .asObjectDelta(USER_JACK_OID); /// WHEN displayWhen(TEST_NAME); final Scene scene = visualizer.visualizeDelta(delta, task, task.getResult()); modelService.executeChanges(Collections.<ObjectDelta<? extends ObjectType>>singletonList(delta), null, task, task.getResult()); // THEN displayThen(TEST_NAME); display("scene", scene); display("jack with assignment", getUser(USER_JACK_OID)); // TODO some asserts }
AssignmentType ass3 = new AssignmentType(prismContext); ass3.setConstruction(new ConstructionType(prismContext)); ass3.getConstruction().setResourceRef(createObjectRef(RESOURCE_DUMMY_OID, RESOURCE)); ut.getAssignment().add(ass3);
ConstructionType c = new ConstructionType(prismContext); c.setDescription(name + "-" + i); c.setResourceRef(ObjectTypeUtil.createObjectRef(RESOURCE_DUMMY_EMPTY_OID, ObjectTypes.RESOURCE)); AssignmentType a = new AssignmentType(prismContext); a.setDescription("Assignment for " + c.getDescription());
ObjectReferenceType resourceRedRef = new ObjectReferenceType(); resourceRedRef.setOid(RESOURCE_DUMMY_RED_OID); constructionType.setResourceRef(resourceRedRef);