@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; }
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(); }
@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; }
public ConstructionType clone() { ConstructionType object = new ConstructionType(); PrismContainerValue value = asPrismContainerValue().clone(); object.setupContainerValue(value); return object; }
public List<ResourceAttributeDefinitionType> createAttributeList() { PrismForJAXBUtil.createContainer(asPrismContainerValue(), F_ATTRIBUTE); return getAttribute(); }
public List<ResourceObjectAssociationType> createAssociationList() { PrismForJAXBUtil.createContainer(asPrismContainerValue(), F_ASSOCIATION); return getAssociation(); }
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); }
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); }
public ResourceType resolveResourceRef(AssignmentType a, OperationResult result) { if (a == null) { return null; } if (a.getConstruction() == null) { return null; } if (a.getConstruction().getResourceRef() == null) { return null; } try { return repositoryService.getObject(ResourceType.class, a.getConstruction().getResourceRef().getOid(), null, result).asObjectable(); } catch (ObjectNotFoundException|SchemaException e) { throw new SystemException(e); } }
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; }
if (refinedObjectClassDefinition == null) { sb.append(" (no object class definition)"); if (getConstructionType() != null && getConstructionType().getResourceRef() != null) { // should DebugUtil.debugDumpLabel(sb, "resourceRef / kind / intent", indent + 1); sb.append(" "); sb.append(ObjectTypeUtil.toShortString(getConstructionType().getResourceRef())); sb.append(" / "); sb.append(getConstructionType().getKind()); sb.append(" / "); sb.append(getConstructionType().getIntent()); if (getConstructionType() != null && getConstructionType().getStrength() == ConstructionStrengthType.WEAK) { sb.append(" weak"); if (getConstructionType() != null && getConstructionType().getDescription() != null) { sb.append("\n"); DebugUtil.debugDumpLabel(sb, "description", indent + 1); sb.append(" ").append(getConstructionType().getDescription());
public static String determineConstructionResource(AssignmentType assignmentType) { ConstructionType construction = assignmentType.getConstruction(); if (construction != null){ if (construction.getResource() != null){ return construction.getResource().getOid(); } else if (construction.getResourceRef() != null){ return construction.getResourceRef().getOid(); } return null; } return null; }
private void evaluateKindIntentObjectClass(Task task, OperationResult result) throws SchemaException, ObjectNotFoundException { String resourceOid = null; if (getConstructionType().getResourceRef() != null) { resourceOid = getConstructionType().getResourceRef().getOid(); if (getConstructionType().getResource() != null) { resourceOid = getConstructionType().getResource().getOid(); ShadowKindType kind = getConstructionType().getKind(); if (kind == null) { kind = ShadowKindType.ACCOUNT; refinedObjectClassDefinition = refinedSchema.getRefinedDefinition(kind, getConstructionType().getIntent()); if (getConstructionType().getIntent() != null) { throw new SchemaException( "No " + kind + " type '" + getConstructionType().getIntent() + "' found in " + getResource(task, result) + " as specified in construction in " + getSource()); } else { auxiliaryObjectClassDefinitions = new ArrayList<>(getConstructionType().getAuxiliaryObjectClass().size()); for (QName auxiliaryObjectClassName : getConstructionType().getAuxiliaryObjectClass()) { RefinedObjectClassDefinition auxOcDef = refinedSchema .getRefinedDefinition(auxiliaryObjectClassName); ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(resourceOid, kind, getConstructionType().getIntent()); projectionContext = getLensContext().findProjectionContext(rat);
ConstructionType act = new ConstructionType(); act.setDescription(dataWritten); delta2.setValueToReplace(act.asPrismContainerValue()); } else { delta2.setValueToReplace(prismContext.itemFactory().createPropertyValue(dataWritten)); dataRead = ((ConstructionType)user.findContainer(attribute2).getValue().getValue()).getDescription(); } else { dataRead = user.findProperty(attribute2).getRealValue(String.class);
} else if (value instanceof ConstructionType) { ConstructionType ct = (ConstructionType) value; Object resource = (ct.getResource() != null ? ct.getResource().getName() : (ct.getResourceRef() != null ? ct.getResourceRef().getOid() : null)); return "resource object" + (resource != null ? " on " + resource : "") + (ct.getDescription() != null ? ": " + ct.getDescription() : ""); } else if (value instanceof Enum) { return value.toString();
/** * Create an instance of {@link ConstructionType } * */ public ConstructionType createConstructionType() { return new ConstructionType(); }
protected void assertAssignedNoAccount(PrismObject<UserType> user, String resourceOid) throws ObjectNotFoundException, SchemaException { UserType userType = user.asObjectable(); for (AssignmentType assignmentType: userType.getAssignment()) { ConstructionType construction = assignmentType.getConstruction(); if (construction != null) { if (construction.getKind() != null && construction.getKind() != ShadowKindType.ACCOUNT) { continue; } if (resourceOid.equals(construction.getResourceRef().getOid())) { AssertJUnit.fail(user.toString()+" has account assignment for resource "+resourceOid+" while expecting no such assignment"); } } } }
public ConstructionType attribute(ResourceAttributeDefinitionType value) { getAttribute().add(value); return this; }
@Override public boolean equals(Object object) { if (!(object instanceof ConstructionType)) { return false; } ConstructionType other = ((ConstructionType) object); return asPrismContainerValue().equivalent(other.asPrismContainerValue()); }
public static String dumpAssignment(AssignmentType assignmentType) { StringBuilder sb = new StringBuilder(); if (assignmentType.getConstruction() != null) { sb.append("Constr(").append(assignmentType.getConstruction().getDescription()).append(") "); } if (assignmentType.getTargetRef() != null) { sb.append("-["); if (assignmentType.getTargetRef().getRelation() != null) { sb.append(assignmentType.getTargetRef().getRelation().getLocalPart()); } sb.append("]-> ").append(assignmentType.getTargetRef().getOid()); } return sb.toString(); }