use of com.evolveum.midpoint.model.api.context.ModelElementContext in project midpoint by Evolveum.
the class NotificationFunctionsImpl method getContentAsFormattedList.
public String getContentAsFormattedList(Event event, boolean showSynchronizationItems, boolean showAuxiliaryAttributes) {
List<ItemPath> hiddenPaths = new ArrayList<>();
if (!showSynchronizationItems) {
hiddenPaths.addAll(SYNCHRONIZATION_PATHS);
}
if (!showAuxiliaryAttributes) {
hiddenPaths.addAll(AUXILIARY_PATHS);
}
if (event instanceof ResourceObjectEvent) {
final ResourceObjectEvent resourceObjectEvent = (ResourceObjectEvent) event;
final ObjectDelta<ShadowType> shadowDelta = resourceObjectEvent.getShadowDelta();
if (shadowDelta == null) {
return "";
}
if (shadowDelta.isAdd()) {
return getResourceObjectAttributesAsFormattedList(shadowDelta.getObjectToAdd().asObjectable(), hiddenPaths, showAuxiliaryAttributes);
} else if (shadowDelta.isModify()) {
return getResourceObjectModifiedAttributesAsFormattedList(resourceObjectEvent, shadowDelta, hiddenPaths, showAuxiliaryAttributes);
} else {
return "";
}
} else if (event instanceof ModelEvent) {
final ModelEvent modelEvent = (ModelEvent) event;
ModelContext<FocusType> modelContext = (ModelContext) modelEvent.getModelContext();
ModelElementContext<FocusType> focusContext = modelContext.getFocusContext();
ObjectDelta<? extends FocusType> summarizedDelta;
try {
summarizedDelta = modelEvent.getSummarizedFocusDeltas();
} catch (SchemaException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Unable to determine the focus change; focus context = {}", e, focusContext.debugDump());
return ("(unable to determine the change because of schema exception: " + e.getMessage() + ")\n");
}
if (summarizedDelta.isAdd()) {
return textFormatter.formatObject(summarizedDelta.getObjectToAdd(), hiddenPaths, showAuxiliaryAttributes);
} else if (summarizedDelta.isModify()) {
return textFormatter.formatObjectModificationDelta(summarizedDelta, hiddenPaths, showAuxiliaryAttributes, focusContext.getObjectOld(), focusContext.getObjectNew());
} else {
return "";
}
} else {
return "";
}
}
Aggregations