use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class QueryUtils method getPotentialAssigneesForUser.
private static List<PrismReferenceValue> getPotentialAssigneesForUser(MidPointPrincipal principal, QName limitationItemName) throws SchemaException {
List<PrismReferenceValue> rv = new ArrayList<>();
rv.add(new PrismReferenceValue(principal.getOid(), UserType.COMPLEX_TYPE));
for (DelegatorWithOtherPrivilegesLimitations delegator : principal.getDelegatorWithOtherPrivilegesLimitationsCollection()) {
if (DeputyUtils.limitationsAllow(delegator.getLimitations(), limitationItemName)) {
rv.add(ObjectTypeUtil.createObjectRef(delegator.getDelegator()).asReferenceValue());
}
}
return rv;
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class ReportUtils method getItemRealValue.
public static Object getItemRealValue(PrismContainerValue containerValue, String itemName) {
Item item = containerValue.findItem(new QName(itemName));
if (item == null || item.size() == 0) {
return null;
}
if (item.size() > 1) {
throw new IllegalStateException("More than one value in item " + item);
}
PrismValue value = item.getValue(0);
if (value == null) {
return null;
}
if (value instanceof PrismPropertyValue) {
return ((PrismPropertyValue) value).getValue();
} else if (value instanceof PrismReferenceValue) {
ObjectReferenceType ort = new ObjectReferenceType();
ort.setupReferenceValue((PrismReferenceValue) value);
return ort;
} else if (value instanceof PrismContainerValue) {
// questionable
return ((PrismContainerValue) value).asContainerable();
} else {
throw new IllegalStateException("Unknown PrismValue: " + value);
}
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class RoleGovernanceRelationsPanel method initLoadableModels.
private void initLoadableModels() {
approverRelationObjects = new LoadableModel<List<String>>(false) {
@Override
protected List<String> load() {
OperationResult result = new OperationResult(OPERATION_LOAD_APPROVER_RELATION_OBJECTS);
PrismReferenceValue rv = new PrismReferenceValue(getModelObject().getOid());
rv.setRelation(RelationTypes.APPROVER.getRelation());
ObjectQuery query = QueryBuilder.queryFor(FocusType.class, getPageBase().getPrismContext()).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(rv).build();
List<PrismObject<FocusType>> approverRelationObjects = WebModelServiceUtils.searchObjects(FocusType.class, query, result, getPageBase());
return getObjectOidsList(approverRelationObjects);
}
};
ownerRelationObjects = new LoadableModel<List<String>>(false) {
@Override
protected List<String> load() {
OperationResult result = new OperationResult(OPERATION_LOAD_OWNER_RELATION_OBJECTS);
PrismReferenceValue rv = new PrismReferenceValue(getModelObject().getOid());
rv.setRelation(RelationTypes.OWNER.getRelation());
ObjectQuery query = QueryBuilder.queryFor(FocusType.class, getPageBase().getPrismContext()).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(rv).build();
List<PrismObject<FocusType>> ownerRelationObjects = WebModelServiceUtils.searchObjects(FocusType.class, query, result, getPageBase());
return getObjectOidsList(ownerRelationObjects);
}
};
managerRelationObjects = new LoadableModel<List<String>>(false) {
@Override
protected List<String> load() {
OperationResult result = new OperationResult(OPERATION_LOAD_MANAGER_RELATION_OBJECTS);
PrismReferenceValue rv = new PrismReferenceValue(getModelObject().getOid());
rv.setRelation(RelationTypes.MANAGER.getRelation());
ObjectQuery query = QueryBuilder.queryFor(FocusType.class, getPageBase().getPrismContext()).item(FocusType.F_ASSIGNMENT, AssignmentType.F_TARGET_REF).ref(rv).build();
List<PrismObject<FocusType>> managerRelationObjects = WebModelServiceUtils.searchObjects(FocusType.class, query, result, getPageBase());
return getObjectOidsList(managerRelationObjects);
}
};
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class PageSelfDashboard method createAssignmentItem.
private AssignmentItemDto createAssignmentItem(PrismObject<UserType> user, PrismContainerValue<AssignmentType> assignment, Task task, OperationResult result) {
ActivationType activation = assignment.asContainerable().getActivation();
if (activation != null && activation.getAdministrativeStatus() != null && !activation.getAdministrativeStatus().equals(ActivationStatusType.ENABLED)) {
return null;
}
PrismReference targetRef = assignment.findReference(AssignmentType.F_TARGET_REF);
if (targetRef == null || targetRef.isEmpty()) {
// account construction
PrismContainer construction = assignment.findContainer(AssignmentType.F_CONSTRUCTION);
String name = null;
String description = "";
if (construction.getValue().asContainerable() != null && !construction.isEmpty()) {
ConstructionType constr = (ConstructionType) construction.getValue().asContainerable();
if (constr.getResourceRef() != null) {
ObjectReferenceType resourceRef = constr.getResourceRef();
PrismObject resource = WebModelServiceUtils.loadObject(ResourceType.class, resourceRef.getOid(), this, task, result);
name = WebComponentUtil.getName(resource);
description = constr.getDescription();
}
}
return new AssignmentItemDto(AssignmentEditorDtoType.CONSTRUCTION, name, description, null);
}
PrismReferenceValue refValue = targetRef.getValue();
PrismObject value = refValue.getObject();
if (value == null) {
// resolve reference
value = WebModelServiceUtils.loadObject(ObjectType.class, refValue.getOid(), this, task, result);
}
if (value == null) {
// we couldn't resolve assignment details
return new AssignmentItemDto(null, null, null, null);
}
String name = WebComponentUtil.getDisplayNameOrName(value);
AssignmentEditorDtoType type = AssignmentEditorDtoType.getType(value.getCompileTimeClass());
String relation = refValue.getRelation() != null ? refValue.getRelation().getLocalPart() : null;
return new AssignmentItemDto(type, name, getAssignmentDescription(value), relation);
}
use of com.evolveum.midpoint.prism.PrismReferenceValue in project midpoint by Evolveum.
the class SearchItemPanel method findLookupTable.
private PrismObject<LookupTableType> findLookupTable(ItemDefinition definition) {
PrismReferenceValue valueEnumerationRef = definition.getValueEnumerationRef();
if (valueEnumerationRef == null) {
return null;
}
PageBase page = getPageBase();
String lookupTableUid = valueEnumerationRef.getOid();
Task task = page.createSimpleTask("loadLookupTable");
OperationResult result = task.getResult();
Collection<SelectorOptions<GetOperationOptions>> options = WebModelServiceUtils.createLookupTableRetrieveOptions();
return WebModelServiceUtils.loadObject(LookupTableType.class, lookupTableUid, options, page, task, result);
}
Aggregations