use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class ResourceContentPanel method initLayout.
private void initLayout() {
WebMarkupContainer totals = new WebMarkupContainer(ID_TOTALS);
totals.setOutputMarkupId(true);
add(totals);
initShadowStatistics(totals);
MainObjectListPanel<ShadowType> shadowListPanel = new MainObjectListPanel<ShadowType>(ID_TABLE, ShadowType.class, getTableId(), null, pageBase) {
private static final long serialVersionUID = 1L;
@Override
protected List<InlineMenuItem> createInlineMenu() {
return ResourceContentPanel.this.createRowMenuItems();
}
@Override
protected List<IColumn<SelectableBean<ShadowType>, String>> createColumns() {
return ResourceContentPanel.this.initColumns();
}
@Override
protected IColumn<SelectableBean<ShadowType>, String> createActionsColumn() {
return new InlineMenuHeaderColumn(createHeaderMenuItems());
}
@Override
protected void objectDetailsPerformed(AjaxRequestTarget target, ShadowType object) {
shadowDetailsPerformed(target, WebComponentUtil.getName(object), object.getOid());
}
@Override
protected void newObjectPerformed(AjaxRequestTarget target) {
// TODO Auto-generated method stub
}
@Override
protected BaseSortableDataProvider<SelectableBean<ShadowType>> initProvider() {
provider = (SelectableBeanObjectDataProvider<ShadowType>) super.initProvider();
provider.setEmptyListOnNullQuery(true);
provider.setSort(null);
createSearchOptions(provider);
return provider;
}
@Override
protected ObjectQuery createContentQuery() {
ObjectQuery parentQuery = super.createContentQuery();
List<ObjectFilter> filters = new ArrayList<>();
if (parentQuery != null) {
filters.add(parentQuery.getFilter());
}
ObjectQuery customQuery = ResourceContentPanel.this.createQuery();
if (customQuery != null && customQuery.getFilter() != null) {
filters.add(customQuery.getFilter());
}
ObjectQuery query = new ObjectQuery();
if (filters.size() == 1) {
query = ObjectQuery.createObjectQuery(filters.iterator().next());
// setProviderAvailableDataSize(query);
return query;
}
if (filters.size() == 0) {
// setProviderAvailableDataSize(query);
return null;
}
query = ObjectQuery.createObjectQuery(AndFilter.createAnd(filters));
// setProviderAvailableDataSize(query);
return query;
}
@Override
protected Search createSearch() {
return ResourceContentPanel.this.createSearch();
}
};
shadowListPanel.setOutputMarkupId(true);
shadowListPanel.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return createQuery() != null;
}
});
shadowListPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_SHADOW_BOX_CSS_CLASSES);
add(shadowListPanel);
Label label = new Label(ID_LABEL, "Nothing to show. Select intent to search");
add(label);
label.setOutputMarkupId(true);
label.add(new VisibleEnableBehaviour() {
private static final long serialVersionUID = 1L;
@Override
public boolean isVisible() {
return createQuery() == null;
}
});
OperationResult result = new OperationResult(OPERATION_SEARCH_TASKS_FOR_RESOURCE);
List<PrismObject<TaskType>> tasks = WebModelServiceUtils.searchObjects(TaskType.class, QueryBuilder.queryFor(TaskType.class, getPageBase().getPrismContext()).item(TaskType.F_OBJECT_REF).ref(getResourceModel().getObject().getOid()).build(), result, getPageBase());
List<TaskType> tasksForKind = getTasksForKind(tasks);
List<TaskType> importTasks = new ArrayList<>();
List<TaskType> syncTasks = new ArrayList<>();
List<TaskType> reconTasks = new ArrayList<>();
for (TaskType task : tasksForKind) {
if (TaskCategory.RECONCILIATION.equals(task.getCategory())) {
reconTasks.add(task);
} else if (TaskCategory.LIVE_SYNCHRONIZATION.equals(task.getCategory())) {
syncTasks.add(task);
} else if (TaskCategory.IMPORTING_ACCOUNTS.equals(task.getCategory())) {
importTasks.add(task);
}
}
initButton(ID_IMPORT, "Import", " fa-download", TaskCategory.IMPORTING_ACCOUNTS, importTasks);
initButton(ID_RECONCILIATION, "Reconciliation", " fa-link", TaskCategory.RECONCILIATION, reconTasks);
initButton(ID_LIVE_SYNC, "Live Sync", " fa-refresh", TaskCategory.LIVE_SYNCHRONIZATION, syncTasks);
initCustomLayout();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class ResourceContentPanel method getTasksForKind.
private List<TaskType> getTasksForKind(List<PrismObject<TaskType>> tasks) {
List<TaskType> tasksForKind = new ArrayList<>();
for (PrismObject<TaskType> task : tasks) {
PrismProperty<ShadowKindType> taskKind = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_KIND));
ShadowKindType taskKindValue = null;
if (taskKind != null) {
taskKindValue = taskKind.getRealValue();
PrismProperty<String> taskIntent = task.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.MODEL_EXTENSION_INTENT));
String taskIntentValue = null;
if (taskIntent != null) {
taskIntentValue = taskIntent.getRealValue();
}
if (StringUtils.isNotEmpty(getIntent())) {
if (getKind() == taskKindValue && getIntent().equals(taskIntentValue)) {
tasksForKind.add(task.asObjectable());
}
} else if (getKind() == taskKindValue) {
tasksForKind.add(task.asObjectable());
}
}
}
return tasksForKind;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class PageAdminResources method saveTask.
private void saveTask(PrismObject<TaskType> oldTask, OperationResult result) {
Task task = createSimpleTask(OPERATION_SAVE_SYNC_TASK);
PrismProperty property = oldTask.findProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.SYNC_TOKEN));
if (property == null) {
return;
}
Object value = property.getRealValue();
ObjectDelta<TaskType> delta = ObjectDelta.createModifyDelta(oldTask.getOid(), PropertyDelta.createModificationDeleteProperty(new ItemPath(TaskType.F_EXTENSION, SchemaConstants.SYNC_TOKEN), property.getDefinition(), value), TaskType.class, getPrismContext());
if (LOGGER.isTraceEnabled()) {
LOGGER.trace(delta.debugDump());
}
try {
getModelService().executeChanges(WebComponentUtil.createDeltaCollection(delta), null, task, result);
} catch (Exception e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't save task.", e);
result.recordFatalError("Couldn't save task.", e);
}
result.recomputeStatus();
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class CleanupTest method testTasksCleanup.
@Test
public void testTasksCleanup() throws Exception {
// GIVEN
final File file = new File(FOLDER_REPO, "tasks-for-cleanup.xml");
List<PrismObject<? extends Objectable>> elements = prismContext.parserFor(file).parseObjects();
OperationResult result = new OperationResult("tasks cleanup");
for (PrismObject<? extends Objectable> object : elements) {
String oid = repositoryService.addObject((PrismObject) object, null, result);
AssertJUnit.assertTrue(StringUtils.isNotEmpty(oid));
}
// WHEN
// because now we can't move system time (we're not using DI for it) we create policy
// which should always point to 2013-05-07T12:00:00.000+02:00
final long NOW = System.currentTimeMillis();
Calendar when = create_2013_07_12_12_00_Calendar();
CleanupPolicyType policy = createPolicy(when, NOW);
taskManager.cleanupTasks(policy, taskManager.createTaskInstance(), result);
// THEN
List<PrismObject<TaskType>> tasks = repositoryService.searchObjects(TaskType.class, null, null, result);
AssertJUnit.assertNotNull(tasks);
display("tasks", tasks);
AssertJUnit.assertEquals(1, tasks.size());
PrismObject<TaskType> task = tasks.get(0);
XMLGregorianCalendar timestamp = task.getPropertyRealValue(TaskType.F_COMPLETION_TIMESTAMP, XMLGregorianCalendar.class);
Date finished = XMLGregorianCalendarType.asDate(timestamp);
Date mark = new Date(NOW);
Duration duration = policy.getMaxAge();
duration.addTo(mark);
AssertJUnit.assertTrue("finished: " + finished + ", mark: " + mark, finished.after(mark));
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType in project midpoint by Evolveum.
the class Main method listTasks.
private static Collection<TaskType> listTasks(ModelPortType modelPort) throws SAXException, IOException, FaultMessage {
SelectorQualifiedGetOptionsType operationOptions = new SelectorQualifiedGetOptionsType();
// Let's say we want to retrieve tasks' next scheduled time (because this may be a costly operation if
// JDBC based quartz scheduler is used, the fetching of this attribute has to be explicitly requested)
SelectorQualifiedGetOptionType getNextScheduledTimeOption = new SelectorQualifiedGetOptionType();
// prepare a selector (described by path) + options (saying to retrieve that attribute)
OptionObjectSelectorType selector = new OptionObjectSelectorType();
selector.setPath(ModelClientUtil.createItemPathType("nextRunStartTimestamp"));
getNextScheduledTimeOption.setSelector(selector);
GetOperationOptionsType selectorOptions = new GetOperationOptionsType();
selectorOptions.setRetrieve(RetrieveOptionType.INCLUDE);
getNextScheduledTimeOption.setOptions(selectorOptions);
// add newly created option to the list of operation options
operationOptions.getOption().add(getNextScheduledTimeOption);
Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
modelPort.searchObjects(ModelClientUtil.getTypeQName(TaskType.class), null, operationOptions, objectListHolder, resultHolder);
ObjectListType objectList = objectListHolder.value;
return (Collection) objectList.getObject();
}
Aggregations