use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class FocusProjectionsTabPanel method createShadowMenu.
private List<InlineMenuItem> createShadowMenu() {
List<InlineMenuItem> items = new ArrayList<InlineMenuItem>();
PrismObjectDefinition def = getObjectWrapper().getObject().getDefinition();
PrismReferenceDefinition ref = def.findReferenceDefinition(UserType.F_LINK_REF);
InlineMenuItem item;
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.addShadow"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<QName> supportedTypes = new ArrayList<>(1);
supportedTypes.add(ResourceType.COMPLEX_TYPE);
PageBase pageBase = FocusProjectionsTabPanel.this.getPageBase();
ObjectBrowserPanel<ResourceType> resourceSelectionPanel = new ObjectBrowserPanel<ResourceType>(pageBase.getMainPopupBodyId(), ResourceType.class, supportedTypes, true, pageBase) {
@Override
protected void addPerformed(AjaxRequestTarget target, QName type, List<ResourceType> selected) {
// TODO Auto-generated method stub
FocusProjectionsTabPanel.this.addSelectedAccountPerformed(target, selected);
}
};
resourceSelectionPanel.setOutputMarkupId(true);
pageBase.showMainPopup(resourceSelectionPanel, target);
}
});
items.add(item);
items.add(new InlineMenuItem());
}
PrismPropertyDefinition prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (prop.canRead() && prop.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.enable"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getSelectedProjections(projectionModel), true);
}
});
items.add(item);
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.disable"), new InlineMenuItemAction() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateShadowActivation(target, getSelectedProjections(projectionModel), false);
}
});
items.add(item);
}
if (ref.canRead() && ref.canAdd()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlink"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlinkProjectionPerformed(target, projectionModel, getSelectedProjections(projectionModel), ID_SHADOWS);
}
});
items.add(item);
}
prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS);
if (prop.canRead() && prop.canModify()) {
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.unlock"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
unlockShadowPerformed(target, projectionModel, getSelectedProjections(projectionModel));
}
});
items.add(item);
}
prop = def.findPropertyDefinition(SchemaConstants.PATH_ACTIVATION_ADMINISTRATIVE_STATUS);
if (prop.canRead() && prop.canModify()) {
items.add(new InlineMenuItem());
item = new InlineMenuItem(createStringResource("pageAdminFocus.button.delete"), new InlineMenuItemAction() {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
deleteProjectionPerformed(target, projectionModel);
}
});
items.add(item);
}
return items;
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class SearchItem method getAllowedValues.
public List<DisplayableValue> getAllowedValues() {
List<DisplayableValue> list = new ArrayList();
if (!(definition instanceof PrismPropertyDefinition)) {
return list;
}
PrismPropertyDefinition def = (PrismPropertyDefinition) definition;
list.addAll(def.getAllowedValues());
return list;
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class PageTaskAdd method createTask.
private TaskType createTask(TaskAddDto dto) 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.setCategory(dto.getCategory());
String handlerUri = getTaskManager().getHandlerUriForCategory(dto.getCategory());
if (handlerUri == null) {
throw new SystemException("Cannot determine task handler URI for category " + dto.getCategory());
}
task.setHandlerUri(handlerUri);
ObjectReferenceType objectRef;
if (dto.getResource() != null) {
objectRef = new ObjectReferenceType();
objectRef.setOid(dto.getResource().getOid());
objectRef.setType(ResourceType.COMPLEX_TYPE);
task.setObjectRef(objectRef);
}
task.setName(WebComponentUtil.createPolyFromOrigString(dto.getName()));
task.setRecurrence(dto.getReccuring() ? TaskRecurrenceType.RECURRING : TaskRecurrenceType.SINGLE);
task.setBinding(dto.getBound() ? TaskBindingType.TIGHT : TaskBindingType.LOOSE);
ScheduleType schedule = new ScheduleType();
schedule.setInterval(dto.getInterval());
schedule.setCronLikePattern(dto.getCron());
schedule.setEarliestStartTime(MiscUtil.asXMLGregorianCalendar(dto.getNotStartBefore()));
schedule.setLatestStartTime(MiscUtil.asXMLGregorianCalendar(dto.getNotStartAfter()));
schedule.setMisfireAction(dto.getMisfireAction());
task.setSchedule(schedule);
if (dto.getSuspendedState()) {
task.setExecutionStatus(TaskExecutionStatusType.SUSPENDED);
} else {
task.setExecutionStatus(TaskExecutionStatusType.RUNNABLE);
}
if (dto.getThreadStop() != null) {
task.setThreadStopAction(dto.getThreadStop());
} else {
// fill-in default
if (dto.getRunUntilNodeDown() == true) {
task.setThreadStopAction(ThreadStopActionType.CLOSE);
} else {
task.setThreadStopAction(ThreadStopActionType.RESTART);
}
}
if (dto.isDryRun()) {
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_DRY_RUN);
PrismProperty dryRun = prismTask.findOrCreateProperty(path);
SchemaRegistry registry = getPrismContext().getSchemaRegistry();
PrismPropertyDefinition def = registry.findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_DRY_RUN);
dryRun.setDefinition(def);
dryRun.setRealValue(true);
}
if (dto.getFocusType() != null) {
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_OBJECT_TYPE);
PrismProperty focusType = prismTask.findOrCreateProperty(path);
focusType.setRealValue(dto.getFocusType());
}
if (dto.getKind() != null) {
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND);
PrismProperty kind = prismTask.findOrCreateProperty(path);
SchemaRegistry registry = getPrismContext().getSchemaRegistry();
PrismPropertyDefinition def = registry.findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_KIND);
kind.setDefinition(def);
kind.setRealValue(dto.getKind());
}
if (dto.getIntent() != null && StringUtils.isNotEmpty(dto.getIntent())) {
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT);
PrismProperty intent = prismTask.findOrCreateProperty(path);
SchemaRegistry registry = getPrismContext().getSchemaRegistry();
PrismPropertyDefinition def = registry.findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_INTENT);
intent.setDefinition(def);
intent.setRealValue(dto.getIntent());
}
if (dto.getObjectClass() != null && StringUtils.isNotEmpty(dto.getObjectClass())) {
PrismObject<TaskType> prismTask = task.asPrismObject();
ItemPath path = new ItemPath(TaskType.F_EXTENSION, SchemaConstants.OBJECTCLASS_PROPERTY_NAME);
PrismProperty objectClassProperty = prismTask.findOrCreateProperty(path);
QName objectClass = null;
for (QName q : model.getObject().getObjectClassList()) {
if (q.getLocalPart().equals(dto.getObjectClass())) {
objectClass = q;
}
}
SchemaRegistry registry = getPrismContext().getSchemaRegistry();
PrismPropertyDefinition def = registry.findPropertyDefinitionByElementName(SchemaConstants.OBJECTCLASS_PROPERTY_NAME);
objectClassProperty.setDefinition(def);
objectClassProperty.setRealValue(objectClass);
}
return task;
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class PageTaskController method getDeltasToExecute.
private List<ItemDelta<?, ?>> getDeltasToExecute(TaskDto dto) throws SchemaException {
List<ItemDelta<?, ?>> rv = new ArrayList<>();
TaskEditableState orig = dto.getOriginalEditableState();
TaskEditableState curr = dto.getCurrentEditableState();
if (!StringUtils.equals(orig.getName(), curr.getName())) {
String name = curr.getName() != null ? curr.getName() : "";
addDelta(rv, TaskType.F_NAME, new PolyString(name));
}
if (!StringUtils.equals(orig.getDescription(), curr.getDescription())) {
addDelta(rv, TaskType.F_DESCRIPTION, curr.getDescription());
}
ScheduleType origSchedule = orig.getScheduleType();
ScheduleType currSchedule = curr.getScheduleType();
if (!origSchedule.equals(currSchedule)) {
if (dto.getTaskType().getSchedule() != null) {
currSchedule.setLatestFinishTime(dto.getTaskType().getSchedule().getLatestFinishTime());
}
addDelta(rv, TaskType.F_SCHEDULE, currSchedule);
}
if (orig.isRecurring() != curr.isRecurring()) {
addDelta(rv, TaskType.F_RECURRENCE, curr.isRecurring() ? TaskRecurrenceType.RECURRING : TaskRecurrenceType.SINGLE);
}
if (orig.isBound() != curr.isBound()) {
addDelta(rv, TaskType.F_BINDING, curr.isBound() ? TaskBindingType.TIGHT : TaskBindingType.LOOSE);
}
if (orig.getThreadStopActionType() != curr.getThreadStopActionType()) {
addDelta(rv, TaskType.F_THREAD_STOP_ACTION, curr.getThreadStopActionType());
}
if (!ObjectUtils.equals(orig.getWorkerThreads(), curr.getWorkerThreads())) {
SchemaRegistry registry = parentPage.getPrismContext().getSchemaRegistry();
PrismPropertyDefinition def = registry.findPropertyDefinitionByElementName(SchemaConstants.MODEL_EXTENSION_WORKER_THREADS);
rv.add(DeltaBuilder.deltaFor(TaskType.class, parentPage.getPrismContext()).item(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_WORKER_THREADS), def).replace(curr.getWorkerThreads()).asItemDelta());
}
rv.addAll(dto.getHandlerDto().getDeltasToExecute(orig.getHandlerSpecificState(), curr.getHandlerSpecificState(), parentPage.getPrismContext()));
return rv;
}
use of com.evolveum.midpoint.prism.PrismPropertyDefinition in project midpoint by Evolveum.
the class PrismAsserts method assertPropertyDefinition.
public static void assertPropertyDefinition(PrismContainerDefinition<?> containerDef, QName propertyName, QName type, int minOccurs, int maxOccurs, boolean indexed) {
assertPropertyDefinition(containerDef, propertyName, type, minOccurs, maxOccurs);
PrismPropertyDefinition definition = containerDef.findPropertyDefinition(propertyName);
assert equals(indexed, definition.isIndexed()) : "Property should have indexed=" + indexed + ", but it has indexed=" + definition.isIndexed();
}
Aggregations