Skip to content

Commit

Permalink
Finished "show actions executed" feature (still to be moved out of ta…
Browse files Browse the repository at this point in the history
…sk extension).
  • Loading branch information
mederly committed Oct 19, 2015
1 parent 5ff010d commit abf473b
Show file tree
Hide file tree
Showing 18 changed files with 268 additions and 47 deletions.
Expand Up @@ -16,7 +16,7 @@

package com.evolveum.midpoint.web.page.admin.server.currentState;

import com.evolveum.midpoint.xml.ns._public.common.common_3.ActionsExecutedObjectsEntryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectActionsExecutedEntryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActionsExecutedInformationType;

import java.util.ArrayList;
Expand All @@ -38,7 +38,16 @@ public ActionsExecutedInformationDto(ActionsExecutedInformationType actionsExecu

public List<ActionsExecutedObjectsTableLineDto> getObjectsTableLines() {
List<ActionsExecutedObjectsTableLineDto> rv = new ArrayList<>();
for (ActionsExecutedObjectsEntryType entry : actionsExecutedInformationType.getObjectsEntry()) {
for (ObjectActionsExecutedEntryType entry : actionsExecutedInformationType.getObjectActionsEntry()) {
rv.add(new ActionsExecutedObjectsTableLineDto(entry));
}
Collections.sort(rv);
return rv;
}

public List<ActionsExecutedObjectsTableLineDto> getUniqueObjectsTableLines() {
List<ActionsExecutedObjectsTableLineDto> rv = new ArrayList<>();
for (ObjectActionsExecutedEntryType entry : actionsExecutedInformationType.getResultingObjectActionsEntry()) {
rv.add(new ActionsExecutedObjectsTableLineDto(entry));
}
Collections.sort(rv);
Expand Down
Expand Up @@ -18,6 +18,10 @@
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<h3><wicket:message key="ActionsExecutedInformationPanel.title"/></h3>

<span wicket:id="showResultingActionsOnlyLabel"/>
<a wicket:id="showResultingActionsOnlyLink" ><wicket:message key="ActionsExecutedInformationPanel.changeShowingActions"/></a>

<table class="table table-striped table-condensed" style="width: auto;">
<thead>
<th><wicket:message key="ActionsExecutedInformationPanel.objectType"/></th>
Expand Down
Expand Up @@ -19,9 +19,12 @@
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.util.SimplePanel;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.AbstractReadOnlyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;

Expand All @@ -42,25 +45,91 @@ public class ActionsExecutedInformationPanel extends SimplePanel<ActionsExecuted
private static final String ID_LAST_SUCCESS_OBJECT = "lastSuccessObject";
private static final String ID_LAST_SUCCESS_TIMESTAMP = "lastSuccessTimestamp";
private static final String ID_FAILURE_COUNT = "failureCount";
private static final String ID_SHOW_RESULTING_ACTIONS_ONLY_LABEL = "showResultingActionsOnlyLabel";
private static final String ID_SHOW_RESULTING_ACTIONS_ONLY_LINK = "showResultingActionsOnlyLink";

public ActionsExecutedInformationPanel(String id, IModel<ActionsExecutedInformationDto> model) {
super(id, model);
}

boolean showResultingActionsOnly = true;

@Override
protected void initLayout() {

ListView tableLines = new ListView<ActionsExecutedObjectsTableLineDto>(ID_OBJECT_TABLE_LINES, new PropertyModel<List<ActionsExecutedObjectsTableLineDto>>(getModel(), ActionsExecutedInformationDto.F_OBJECTS_TABLE_LINES)) {
ListView tableLines = new ListView<ActionsExecutedObjectsTableLineDto>(ID_OBJECT_TABLE_LINES,
new AbstractReadOnlyModel<List<? extends ActionsExecutedObjectsTableLineDto>>() {
@Override
public List<? extends ActionsExecutedObjectsTableLineDto> getObject() {
if (showResultingActionsOnly) {
return getModelObject().getUniqueObjectsTableLines();
} else {
return getModelObject().getObjectsTableLines();
}
}
}
) {
protected void populateItem(final ListItem<ActionsExecutedObjectsTableLineDto> item) {
item.add(new Label(ID_OBJECT_TYPE, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_OBJECT_TYPE)));
item.add(new Label(ID_OPERATION, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_OPERATION)));
item.add(new Label(ID_CHANNEL, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_CHANNEL)));
item.add(new Label(ID_OBJECT_TYPE, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
String key = item.getModelObject().getObjectTypeLocalizationKey();
if (key != null) {
return createStringResource(key).getString();
} else {
return item.getModelObject().getObjectType().getLocalPart();
}
}
}));
item.add(new Label(ID_OPERATION, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return createStringResource(item.getModelObject().getOperation()).getString();
}
}));
item.add(new Label(ID_CHANNEL, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
String channel = item.getModelObject().getChannel();
if (channel != null && !channel.isEmpty()) {
String key = "Channel." + channel;
return createStringResource(key).getString();
} else {
return "";
}
}
}));

item.add(new Label(ID_SUCCESS_COUNT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_SUCCESS_COUNT)));
item.add(new Label(ID_LAST_SUCCESS_OBJECT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_LAST_SUCCESS_OBJECT)));
item.add(new Label(ID_LAST_SUCCESS_TIMESTAMP, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_LAST_SUCCESS_TIMESTAMP)));
item.add(new Label(ID_FAILURE_COUNT, new PropertyModel<String>(item.getModel(), ActionsExecutedObjectsTableLineDto.F_FAILURE_COUNT)));
}
};
add(tableLines);

add(new Label(ID_SHOW_RESULTING_ACTIONS_ONLY_LABEL, new AbstractReadOnlyModel<String>() {
@Override
public String getObject() {
return showResultingActionsOnly ?
createStringResource("ActionsExecutedInformationPanel.showingResultingActionsOnly").getString() :
createStringResource("ActionsExecutedInformationPanel.showingAllActions").getString();
}
}));
add(new AjaxFallbackLink<String>(ID_SHOW_RESULTING_ACTIONS_ONLY_LINK) {
@Override
public void onClick(AjaxRequestTarget ajaxRequestTarget) {
showResultingActionsOnly = !showResultingActionsOnly;
ajaxRequestTarget.add(this);
}
});
}

public boolean isShowResultingActionsOnly() {
return showResultingActionsOnly;
}

public void setShowResultingActionsOnly(boolean showResultingActionsOnly) {
this.showResultingActionsOnly = showResultingActionsOnly;
}
}
Expand Up @@ -16,10 +16,13 @@

package com.evolveum.midpoint.web.page.admin.server.currentState;

import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.xml.XmlTypeConverter;
import com.evolveum.midpoint.schema.constants.ObjectTypes;
import com.evolveum.midpoint.web.util.ObjectTypeGuiDescriptor;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ReportType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActionsExecutedObjectsEntryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectActionsExecutedEntryType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
Expand All @@ -35,7 +38,7 @@
*/
public class ActionsExecutedObjectsTableLineDto implements Comparable<ActionsExecutedObjectsTableLineDto> {

public static final String F_OBJECT_TYPE = "objectType";
//public static final String F_OBJECT_TYPE = "objectType";
public static final String F_OPERATION = "operation";
public static final String F_CHANNEL = "channel";
public static final String F_SUCCESS_COUNT = "successCount";
Expand All @@ -48,18 +51,28 @@ public class ActionsExecutedObjectsTableLineDto implements Comparable<ActionsExe
ResourceType.COMPLEX_TYPE, ReportType.COMPLEX_TYPE
};

private ActionsExecutedObjectsEntryType entry;
private ObjectActionsExecutedEntryType entry;

public ActionsExecutedObjectsTableLineDto(ActionsExecutedObjectsEntryType entry) {
public ActionsExecutedObjectsTableLineDto(ObjectActionsExecutedEntryType entry) {
this.entry = entry;
}

public String getObjectType() {
return entry.getObjectType().getLocalPart();
public String getObjectTypeLocalizationKey() {
ObjectTypes type = ObjectTypes.getObjectTypeFromTypeQName(entry.getObjectType());
ObjectTypeGuiDescriptor descriptor = ObjectTypeGuiDescriptor.getDescriptor(type);
if (descriptor != null) {
return descriptor.getLocalizationKey();
} else {
return null;
}
}

public QName getObjectType() {
return entry.getObjectType();
}

public String getOperation() {
return entry.getOperation().toString();
public ChangeType getOperation() {
return ChangeType.toChangeType(entry.getOperation());
}

public String getChannel() {
Expand Down
Expand Up @@ -91,13 +91,13 @@ public Iterator<? extends TaskDto> internalIterator(long first, long count) {
getModelInteractionService(), getTaskManager(), options, result, (PageBase)component);
getAvailableData().add(taskDto);
} catch (Exception ex) {
LoggingUtils.logException(LOGGER, "Unhandled exception when getting task {} details", ex, task.getOid());
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when getting task {} details", ex, task.getOid());
result.recordPartialError("Couldn't get details of task " + task.getOid(), ex);
// todo display the result somehow
}
}
} catch (Exception ex) {
LoggingUtils.logException(LOGGER, "Unhandled exception when listing tasks", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when listing tasks", ex);
result.recordFatalError("Couldn't list tasks.", ex);
} finally {
if (result.hasUnknownStatus()) {
Expand All @@ -116,7 +116,7 @@ protected int internalSize() {
count = getModel().countObjects(TaskType.class, getQuery(), null, task, result);
result.recomputeStatus();
} catch (Exception ex) {
LoggingUtils.logException(LOGGER, "Unhandled exception when counting tasks", ex);
LoggingUtils.logUnexpectedException(LOGGER, "Unhandled exception when counting tasks", ex);
result.recordFatalError("Couldn't count tasks.", ex);
}
if (!result.isSuccess()) {
Expand Down
Expand Up @@ -2449,6 +2449,9 @@ SynchronizationInformationPanel.discoveryWarning=(The following numbers may incl
SynchronizationInformationPanel.unlinked=Unlinked
SynchronizationInformationPanel.unmatched=Unmatched
ActionsExecutedInformationPanel.title=Actions executed
ActionsExecutedInformationPanel.showingResultingActionsOnly=Showing "resulting actions" only. E.g. user ADD and MODIFY in one synchronization operation is shown as ADD.
ActionsExecutedInformationPanel.showingAllActions=Showing all executed actions.
ActionsExecutedInformationPanel.changeShowingActions=Change it.
ActionsExecutedInformationPanel.objectType=Object type
ActionsExecutedInformationPanel.operation=Operation
ActionsExecutedInformationPanel.channel=Channel
Expand Down
Expand Up @@ -289,7 +289,13 @@ public <T> T unmarshall(MapXNode xnode, Class<T> beanClass) throws SchemaExcepti
// for a getter that returns a collection (Collection<Whatever>)
getter = inspector.findPropertyGetter(beanClass, fieldName);
if (getter == null) {
throw new SchemaException("Cannot find setter or getter for field "+fieldName+" in "+beanClass);
String m = "Cannot find setter or getter for field " + fieldName + " in " + beanClass;
if (mode == XNodeProcessorEvaluationMode.COMPAT) {
LOGGER.warn("{}", m);
continue;
} else {
throw new SchemaException(m);
}
}
Class<?> getterReturnType = getter.getReturnType();
if (!Collection.class.isAssignableFrom(getterReturnType)) {
Expand Down

0 comments on commit abf473b

Please sign in to comment.