use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class AssignExecutor method resolve.
private Collection<ObjectReferenceType> resolve(ObjectReferenceType ref, QName relationOverride, Task task, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ExpressionEvaluationException {
if (ref.getFilter() != null) {
Class<? extends ObjectType> clazz = prismContext.getSchemaRegistry().determineCompileTimeClass(ref.getType());
if (clazz == null) {
throw new SchemaException("No compile time class for " + ref.getType() + " in " + ref);
}
ObjectQuery query = prismContext.getQueryConverter().createObjectQuery(clazz, ref.getFilter());
QName effectiveRelation = getEffectiveRelation(ref, relationOverride);
return modelService.searchObjects(clazz, query, createReadOnlyCollection(), task, result).stream().map(object -> ObjectTypeUtil.createObjectRef(object, effectiveRelation)).collect(Collectors.toList());
} else if (relationOverride != null) {
return singletonList(ref.clone().relation(relationOverride));
} else {
return singletonList(ref);
}
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class AssignExecutor method parseParameters.
@Override
AssignParameters parseParameters(ActionExpressionType action, PipelineData input, ExecutionContext context, OperationResult result) throws SchemaException, ScriptExecutionException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
AssignParameters parameters = new AssignParameters();
// Dynamic parameters
Collection<ObjectReferenceType> dynamicRoleRefs = getRolesParameter(action, input, context, result);
Collection<ObjectReferenceType> dynamicResourceRefs = getResourcesParameter(action, input, context, result);
Collection<QName> relationSpecifications = getRelationsParameter(action, input, context, result);
QName relationSpecification = MiscUtil.extractSingleton(relationSpecifications, () -> new IllegalArgumentException("Using 'relation' as a multivalued parameter is not allowed"));
if (PrismConstants.Q_ANY.matches(relationSpecification)) {
throw new IllegalArgumentException("Using 'q:any' as relation specification is not allowed");
}
QName relationOverride;
if (relationSpecification != null) {
List<RelationDefinitionType> relationDefinitions = relationRegistry.getRelationDefinitions();
relationOverride = relationDefinitions.stream().filter(definition -> prismContext.relationMatches(relationSpecification, definition.getRef())).findFirst().orElseThrow(() -> new IllegalArgumentException("Relation matching '" + relationSpecification + "' not found")).getRef();
} else {
relationOverride = null;
}
// Static parameters
Collection<ObjectReferenceType> staticTargetRefs;
Collection<ObjectReferenceType> staticResourceRefs;
Collection<ConstructionType> staticConstructions;
if (action instanceof AssignActionExpressionType) {
staticTargetRefs = ((AssignActionExpressionType) action).getTargetRef();
staticResourceRefs = ((AssignActionExpressionType) action).getResourceRef();
staticConstructions = ((AssignActionExpressionType) action).getConstruction();
} else {
staticTargetRefs = emptyList();
staticResourceRefs = emptyList();
staticConstructions = emptyList();
}
// Consolidation
Task task = context.getTask();
parameters.targetRefs.addAll(resolve(staticTargetRefs, relationOverride, task, result));
parameters.targetRefs.addAll(resolve(dynamicRoleRefs, relationOverride, task, result));
QName defaultRelation = relationRegistry.getDefaultRelation();
parameters.constructions.addAll(staticConstructions);
parameters.constructions.addAll(resourceRefsToConstructions(resolve(staticResourceRefs, defaultRelation, task, result)));
parameters.constructions.addAll(resourceRefsToConstructions(resolve(dynamicResourceRefs, defaultRelation, task, result)));
return parameters;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class PipelineData method getDataAsReferences.
/**
* Returns the pipeline content as a list of references. Objects, PRVs, OIDs are converted directly
* to references. Search filters and queries are evaluated first.
*
* This is a legacy method and its use should be avoided.
*/
@NotNull
public List<ObjectReferenceType> getDataAsReferences(QName defaultTargetType, Class<? extends ObjectType> typeForQuery, ExecutionContext context, OperationResult result) throws ScriptExecutionException, CommunicationException, ObjectNotFoundException, SchemaException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException {
List<ObjectReferenceType> retval = new ArrayList<>(data.size());
for (PipelineItem item : data) {
PrismValue value = item.getValue();
if (value instanceof PrismObjectValue) {
PrismObjectValue<?> objectValue = (PrismObjectValue<?>) value;
ObjectReferenceType ref = new ObjectReferenceType();
ref.setType(objectValue.asPrismObject().getDefinition().getTypeName());
ref.setOid(objectValue.getOid());
retval.add(ref);
} else if (value instanceof PrismPropertyValue) {
Object realValue = value.getRealValue();
if (realValue instanceof SearchFilterType) {
retval.addAll(resolveQuery(typeForQuery, new QueryType().filter((SearchFilterType) realValue), context, result));
} else if (realValue instanceof QueryType) {
retval.addAll(resolveQuery(typeForQuery, (QueryType) realValue, context, result));
} else if (realValue instanceof String) {
ObjectReferenceType ref = new ObjectReferenceType();
ref.setType(defaultTargetType);
ref.setOid((String) realValue);
retval.add(ref);
} else if (realValue instanceof ObjectReferenceType) {
retval.add((ObjectReferenceType) realValue);
} else {
throw new ScriptExecutionException("Unsupported reference type: " + value.getClass());
}
} else if (value instanceof PrismReferenceValue) {
PrismReferenceValue referenceValue = (PrismReferenceValue) value;
ObjectReferenceType ref = new ObjectReferenceType();
ref.setupReferenceValue(referenceValue);
retval.add(ref);
}
}
return retval;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class PipelineData method prepareXmlData.
public static PipelineDataType prepareXmlData(List<PipelineItem> output, ScriptingExpressionEvaluationOptionsType options) {
boolean hideResults = options != null && Boolean.TRUE.equals(options.isHideOperationResults());
PipelineDataType rv = new PipelineDataType();
if (output != null) {
for (PipelineItem item : output) {
PipelineItemType itemType = new PipelineItemType();
PrismValue value = item.getValue();
if (value instanceof PrismReferenceValue) {
// This is a bit of hack: value.getRealValue() would return unserializable object (PRV$1 - does not have type QName)
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue((PrismReferenceValue) value);
itemType.setValue(ort);
} else {
itemType.setValue(value.getRealValue());
}
if (!hideResults) {
itemType.setResult(item.getResult().createOperationResultType());
}
rv.getItem().add(itemType);
}
}
return rv;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType in project midpoint by Evolveum.
the class ModelInteractionServiceImpl method getDeputyAssignees.
private void getDeputyAssignees(List<ObjectReferenceType> deputies, AbstractWorkItemType workItem, Set<String> oidsToSkip, Task task, OperationResult result) throws SchemaException {
List<PrismReferenceValue> assigneeReferencesToQuery = workItem.getAssigneeRef().stream().map(assigneeRef -> assigneeRef.clone().relation(PrismConstants.Q_ANY).asReferenceValue()).collect(Collectors.toList());
ObjectQuery query = prismContext.queryFor(UserType.class).item(UserType.F_DELEGATED_REF).ref(assigneeReferencesToQuery).build();
SearchResultList<PrismObject<UserType>> potentialDeputies = cacheRepositoryService.searchObjects(UserType.class, query, null, // TODO consider read-only here
result);
for (PrismObject<UserType> potentialDeputy : potentialDeputies) {
if (oidsToSkip.contains(potentialDeputy.getOid())) {
continue;
}
if (determineDeputyValidity(potentialDeputy, workItem.getAssigneeRef(), workItem, OtherPrivilegesLimitationType.F_APPROVAL_WORK_ITEMS, task, result)) {
deputies.add(ObjectTypeUtil.createObjectRefWithFullObject(potentialDeputy, prismContext));
oidsToSkip.add(potentialDeputy.getOid());
}
}
}
Aggregations