use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class WebComponentUtil method createSingleRecurrenceTask.
public static TaskType createSingleRecurrenceTask(String taskName, QName applicableType, ObjectQuery query, ObjectDelta delta, ModelExecuteOptions options, String category, PageBase pageBase) throws SchemaException {
TaskType task = new TaskType();
MidPointPrincipal owner = SecurityUtils.getPrincipalUser();
ObjectReferenceType ownerRef = new ObjectReferenceType();
ownerRef.setOid(owner.getOid());
ownerRef.setType(owner.getUser().COMPLEX_TYPE);
task.setOwnerRef(ownerRef);
task.setBinding(TaskBindingType.LOOSE);
task.setCategory(category);
task.setExecutionStatus(TaskExecutionStatusType.RUNNABLE);
task.setRecurrence(TaskRecurrenceType.SINGLE);
task.setThreadStopAction(ThreadStopActionType.RESTART);
task.setHandlerUri(pageBase.getTaskService().getHandlerUriForCategory(category));
ScheduleType schedule = new ScheduleType();
schedule.setMisfireAction(MisfireActionType.EXECUTE_IMMEDIATELY);
task.setSchedule(schedule);
task.setName(WebComponentUtil.createPolyFromOrigString(taskName));
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_OBJECT_QUERY);
PrismProperty objectQuery = prismTask.findOrCreateProperty(path);
QueryType queryType = QueryJaxbConvertor.createQueryType(query, pageBase.getPrismContext());
objectQuery.addRealValue(queryType);
path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE);
PrismProperty objectType = prismTask.findOrCreateProperty(path);
objectType.setRealValue(applicableType);
if (delta != null) {
path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_OBJECT_DELTA);
PrismProperty objectDelta = prismTask.findOrCreateProperty(path);
objectDelta.setRealValue(DeltaConvertor.toObjectDeltaType(delta));
}
if (options != null) {
prismTask.findOrCreateProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_EXECUTE_OPTIONS)).setRealValue(options.toModelExecutionOptionsType());
}
return task;
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class PageAdminFocus method loadSubwrappers.
private <S extends ObjectType> List<FocusSubwrapperDto<S>> loadSubwrappers(Class<S> type, QName propertyToLoad, boolean noFetch) {
List<FocusSubwrapperDto<S>> list = new ArrayList<>();
ObjectWrapper<F> focusWrapper = getObjectModel().getObject();
PrismObject<F> focus = focusWrapper.getObject();
PrismReference prismReference = focus.findReference(new ItemPath(propertyToLoad));
if (prismReference == null) {
return new ArrayList<>();
}
List<PrismReferenceValue> references = prismReference.getValues();
Task task = createSimpleTask(OPERATION_LOAD_SHADOW);
for (PrismReferenceValue reference : references) {
FocusSubwrapperDto<S> subWrapper = loadSubWrapperDto(type, reference.getOid(), noFetch, task);
if (subWrapper != null) {
list.add(subWrapper);
}
}
return list;
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class PageAdminFocus method handleAssignmentDeltas.
protected ContainerDelta handleAssignmentDeltas(ObjectDelta<F> focusDelta, List<AssignmentEditorDto> assignments, PrismContainerDefinition def, boolean isDelegation) throws SchemaException {
ContainerDelta assDelta = new ContainerDelta(new ItemPath(), def.getName(), def, getPrismContext());
for (AssignmentEditorDto assDto : assignments) {
PrismContainerValue newValue = assDto.getNewValue(getPrismContext());
switch(assDto.getStatus()) {
case ADD:
newValue.applyDefinition(def, false);
assDelta.addValueToAdd(newValue.clone());
break;
case DELETE:
PrismContainerValue oldValue = assDto.getOldValue();
if (isDelegation) {
oldValue.applyDefinition(def, false);
} else {
oldValue.applyDefinition(def);
}
assDelta.addValueToDelete(oldValue.clone());
break;
case MODIFY:
if (!assDto.isModified(getPrismContext())) {
LOGGER.trace("Assignment '{}' not modified.", new Object[] { assDto.getName() });
continue;
}
handleModifyAssignmentDelta(assDto, def, newValue, focusDelta);
break;
default:
warn(getString("pageAdminUser.message.illegalAssignmentState", assDto.getStatus()));
}
}
if (!assDelta.isEmpty()) {
assDelta = focusDelta.addModification(assDelta);
}
// todo remove this block [lazyman] after model is updated - it has to
// remove resource from accountConstruction
Collection<PrismContainerValue> values = assDelta.getValues(PrismContainerValue.class);
for (PrismContainerValue value : values) {
AssignmentType ass = new AssignmentType();
ass.setupContainerValue(value);
removeResourceFromAccConstruction(ass);
}
return assDelta;
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class WorkItemDtoProvider method internalIterator.
@Override
public Iterator<? extends WorkItemDto> internalIterator(long first, long count) {
getAvailableData().clear();
Task task = getTaskManager().createTaskInstance();
OperationResult result = new OperationResult(OPERATION_LIST_ITEMS);
try {
ObjectQuery query = createQuery(first, count, result);
Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.resolveItemsNamed(new ItemPath(F_ASSIGNEE_REF), new ItemPath(T_PARENT, WfContextType.F_OBJECT_REF), new ItemPath(T_PARENT, WfContextType.F_TARGET_REF));
List<WorkItemType> items = getModel().searchContainers(WorkItemType.class, query, options, task, result);
for (WorkItemType item : items) {
try {
getAvailableData().add(new WorkItemDto(item));
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing work item {}", e, item);
result.recordFatalError("Couldn't list work item.", e);
}
}
} catch (SchemaException | ObjectNotFoundException | SecurityViolationException | ConfigurationException | RuntimeException ex) {
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing work items", ex);
result.recordFatalError("Couldn't list work items.", ex);
}
if (result.isUnknown()) {
result.computeStatus();
}
return getAvailableData().iterator();
}
use of com.evolveum.midpoint.prism.path.ItemPath in project midpoint by Evolveum.
the class TestDelta method createDeltaForFindItem.
private ObjectDelta<UserType> createDeltaForFindItem() throws SchemaException {
ObjectDelta<UserType> userDelta = ObjectDelta.createModificationAddProperty(UserType.class, USER_FOO_OID, UserType.F_LOCALITY, PrismTestUtil.getPrismContext(), "Caribbean");
userDelta.addModificationReplaceProperty(UserType.F_GIVEN_NAME, "Guybrush");
ContainerDelta<ActivationType> activationDelta = userDelta.createContainerModification(new ItemPath(UserType.F_ACTIVATION));
PrismContainerValue<ActivationType> activationCVal = new PrismContainerValue();
activationDelta.addValueToAdd(activationCVal);
PrismProperty<Boolean> enabledProperty = activationCVal.createProperty(ActivationType.F_ENABLED);
enabledProperty.setRealValue(Boolean.TRUE);
PrismProperty<XMLGregorianCalendar> validFromProperty = activationCVal.createProperty(ActivationType.F_VALID_FROM);
validFromProperty.setRealValue(XmlTypeConverter.createXMLGregorianCalendar(20016, 5, 16, 19, 8, 33));
userDelta.addModification(activationDelta);
return userDelta;
}
Aggregations