public ConstructionType attribute(ResourceAttributeDefinitionType value) { getAttribute().add(value); return this; }
public List<ResourceAttributeDefinitionType> createAttributeList() { PrismForJAXBUtil.createContainer(asPrismContainerValue(), F_ATTRIBUTE); return getAttribute(); }
public static String prettyPrint(ConstructionType act) { if (act == null) { return "null"; } StringBuilder sb = new StringBuilder("ConstructionType("); if (act.getResource() != null) { sb.append(prettyPrint(act.getResource())); } if (act.getResourceRef() != null) { sb.append(prettyPrint(act.getResourceRef())); } sb.append(", "); if (act.getIntent() != null) { sb.append("intent="); sb.append(act.getIntent()); sb.append(", "); } if (act.getAttribute() != null) { for (ResourceAttributeDefinitionType attrConstr: act.getAttribute()) { sb.append(prettyPrint(attrConstr)); } } // TODO: Other properties sb.append(")"); return sb.toString(); }
private void evaluateAttributes(Task task, OperationResult result) throws ExpressionEvaluationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, CommunicationException { attributeMappings = new ArrayList<>(); // LOGGER.trace("Assignments used for account construction for {} ({}): // {}", new Object[]{this.resource, // assignments.size(), assignments}); for (ResourceAttributeDefinitionType attribudeDefinitionType : getConstructionType().getAttribute()) { QName attrName = ItemPathTypeUtil.asSingleNameOrFailNullSafe(attribudeDefinitionType.getRef()); if (attrName == null) { throw new SchemaException( "No attribute name (ref) in attribute definition in account construction in " + getSource()); } if (!attribudeDefinitionType.getInbound().isEmpty()) { throw new SchemaException("Cannot process inbound section in definition of attribute " + attrName + " in account construction in " + getSource()); } MappingType outboundMappingType = attribudeDefinitionType.getOutbound(); if (outboundMappingType == null) { throw new SchemaException("No outbound section in definition of attribute " + attrName + " in account construction in " + getSource()); } MappingImpl<? extends PrismPropertyValue<?>, ? extends PrismPropertyDefinition<?>> attributeMapping = evaluateAttribute( attribudeDefinitionType, task, result); if (attributeMapping != null) { attributeMappings.add(attributeMapping); } } }
private void checkNoAssignmentConstruction(UserType jack, String attributeName) { assertEquals("jack's assignments", 1, jack.getAssignment().size()); AssignmentType assignmentType = jack.getAssignment().get(0); ConstructionType constructionType = assignmentType.getConstruction(); assertNotNull("construction is null", constructionType); for (ResourceAttributeDefinitionType attributeDefinitionType : constructionType.getAttribute()) { if (attributeDefinitionType.getRef().equivalent(new ItemPathType(ItemPath.create(new QName(attributeName))))) { fail("Construction attribute " + attributeName + " present, although it shouldn't"); } } }
private void checkAssignmentConstruction(UserType jack, String attributeName, String value) throws SchemaException { assertEquals("jack's assignments", 1, jack.getAssignment().size()); AssignmentType assignmentType = jack.getAssignment().get(0); ConstructionType constructionType = assignmentType.getConstruction(); assertNotNull("construction is null", constructionType); boolean found = false; for (ResourceAttributeDefinitionType attributeDefinitionType : constructionType.getAttribute()) { if (attributeDefinitionType.getRef().equivalent(new ItemPathType(ItemPath.create(new QName(attributeName))))) { ExpressionType expressionType = attributeDefinitionType.getOutbound().getExpression(); assertNotNull("no expression", expressionType); assertEquals("wrong # of expression evaluators", 1, expressionType.getExpressionEvaluator().size()); JAXBElement<?> element = expressionType.getExpressionEvaluator().get(0); PrimitiveXNode valueXNode = (PrimitiveXNode) (((RawType) element.getValue()).serializeToXNode()); assertEquals("wrong outbound value", value, valueXNode.getStringValue()); found = true; } } assertTrue("attribute " + attributeName + " mapping not found", found); }
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); }
role.setOid(getRoleOid(i)); role.asObjectable().setName(createPolyStringType(getRoleName(i))); List<ResourceAttributeDefinitionType> outboundAttributes = role.asObjectable().getInducement().get(0).getConstruction().getAttribute(); if (hasMultivalueInterests()) { ExpressionType outboundExpression = outboundAttributes.get(0).getOutbound().getExpression();
accountConstruction.getAttribute().add(radt);
mappingType.setExpression(expressionType); attributeDefinitionType.setOutbound(mappingType); constructionType.getAttribute().add(attributeDefinitionType); modifications.add(createAssignmentModification(assignmentType, true)); ObjectDelta<UserType> accountAssignmentUserDelta = prismContext.deltaFactory().object()