Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Oct 12, 2016
2 parents 6ea8ed3 + 51c5439 commit 4872e7c
Show file tree
Hide file tree
Showing 18 changed files with 625 additions and 204 deletions.
Expand Up @@ -29,7 +29,7 @@
style="font-size: 10px; position: absolute; top: -1px; right: 50%;"></span>
</a>
</div>
<div class="row" wicket:id="multiButtonTable" style="min-height: 460px; margin-left: 15px;"/>
<div class="row shopping-cart-item-table" wicket:id="multiButtonTable"/>
<div wicket:id="footer"/>
</wicket:panel>

Expand Down
Expand Up @@ -93,7 +93,7 @@ public class CatalogItemsPanel extends BasePanel implements IPageableItems {
private IModel<List<AssignmentEditorDto>> itemsListModel;
private IModel<AssignmentViewType> viewModel;

private long itemsPerRow = 3;
private long itemsPerRow = 4;
private static final long DEFAULT_ROWS_COUNT = 5;
private PageBase pageBase;
private IModel<String> catalogOidModel;
Expand Down
Expand Up @@ -24,10 +24,28 @@
<span class="col-md-5" wicket:id="fromField"/>
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.toLabel" /></label>
<span class="col-md-5" wicket:id="toField" />
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.initiatorLabel" /></label>
<span class="col-md-5" wicket:id="initiatorField" style="width:200px"/>
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.propertyLabel" /></label>
<span class="col-md-5" wicket:id="propertyField" style="width:200px"/>
</div>
<div class="row">
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.initiatorNameLabel" /></label>
<span class="col-md-5" wicket:id="initiatorNameField"/>
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.hostIdentifierLabel" /></label>
<span class="col-md-5" wicket:id="hostIdentifierField" />
</div>
<div class="row">
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.targetNameLabel" /></label>
<span class="col-md-5" wicket:id="targetNameField" />
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.targetOwnerNameLabel" /></label>
<span class="col-md-5" wicket:id="targetOwnerNameField" />
</div>
<div class="row">
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.eventTypeLabel" /></label>
<span class="col-md-5" wicket:id="eventTypeField" />
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.eventStageLabel" /></label>
<span class="col-md-5" wicket:id="eventStageField" />
</div>
<div class="row">
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.outcomeLabel" /></label>
<span class="col-md-5" wicket:id="outcomeField" />
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.channelLabel" /></label>
<span class="col-md-5" wicket:id="channelField" />
</div>
Expand Down
@@ -1,6 +1,7 @@
package com.evolveum.midpoint.web.page.admin.reports;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -14,11 +15,13 @@
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.PropertyModel;
import org.apache.wicket.model.util.ListModel;

import com.evolveum.midpoint.audit.api.AuditEventRecord;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.WebComponentUtil;
import com.evolveum.midpoint.schema.result.OperationResultStatus;
import com.evolveum.midpoint.security.api.AuthorizationConstants;
import com.evolveum.midpoint.web.application.AuthorizationAction;
import com.evolveum.midpoint.web.application.PageDescriptor;
Expand All @@ -28,11 +31,15 @@
import com.evolveum.midpoint.web.component.input.DatePanel;
import com.evolveum.midpoint.web.component.input.DropDownChoicePanel;
import com.evolveum.midpoint.web.component.input.TextPanel;
import com.evolveum.midpoint.web.component.util.SelectableBean;
import com.evolveum.midpoint.web.page.admin.configuration.PageAdminConfiguration;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnBlurAjaxFormUpdatingBehaviour;
import com.evolveum.midpoint.web.page.admin.configuration.component.EmptyOnChangeAjaxFormUpdatingBehavior;
import com.evolveum.midpoint.web.page.admin.reports.dto.AuditEventRecordProvider;
import com.evolveum.midpoint.web.page.admin.reports.dto.AuditSearchDto;
import com.evolveum.midpoint.web.session.UserProfileStorage;
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType;
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventStageType;
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventTypeType;

/**
* Created by honchar.
Expand All @@ -45,7 +52,7 @@
label = "PageAuditLogViewer.auth.auditLogViewer.label",
description = "PageAuditLogViewer.auth.auditLogViewer.description")})
public class PageAuditLogViewer extends PageBase{

private List<AuditEventRecord> auditEventRecordList;

Map<String, Object> params = new HashMap<>();
Expand All @@ -54,34 +61,44 @@ public class PageAuditLogViewer extends PageBase{
private static final String ID_TABLE = "table";
private static final String ID_FROM = "fromField";
private static final String ID_TO = "toField";
private static final String ID_INITIATOR = "initiatorField";
private static final String ID_INITIATOR_NAME = "initiatorNameField";
private static final String ID_CHANNEL = "channelField";
private static final String ID_PROPERTY = "propertyField";
private static final String ID_HOST_IDENTIFIER = "hostIdentifierField";
private static final String ID_TARGET_NAME = "targetNameField";
private static final String ID_TARGET_OWNER_NAME = "targetOwnerNameField";
private static final String ID_EVENT_TYPE = "eventTypeField";
private static final String ID_EVENT_STAGE = "eventStageField";
private static final String ID_OUTCOME = "outcomeField";

private static final String ID_MAIN_FORM = "mainForm";
private static final String ID_SEARCH_BUTTON = "searchButton";

/*
private IModel<XMLGregorianCalendar> fromModel;
private IModel<XMLGregorianCalendar> toModel;
private IModel<String> initiatorModel;
private IModel<String> initiatorNameModel;
private IModel<String> channelModel;
private IModel<String> channelListModel;
private IModel<String> propertyModel;
*/

private IModel<AuditSearchDto> auditSearchDto;

public PageAuditLogViewer(){
/*
fromModel = new Model();
toModel = new Model();
initiatorModel = new Model();
initiatorNameModel = new Model();
channelModel = new Model();
channelListModel = new ListModel(new WebComponentUtil().getChannelList());
propertyModel = new Model();
*/
auditSearchDto = new Model(new AuditSearchDto());
initLayout();
}

private void initLayout(){
Form mainForm = new Form(ID_MAIN_FORM);
mainForm.setOutputMarkupId(true);
add(mainForm);

initParametersPanel(mainForm);
initTable(mainForm);
}
Expand All @@ -91,31 +108,88 @@ private void initParametersPanel(Form mainForm){
parametersPanel.setOutputMarkupId(true);
mainForm.add(parametersPanel);

final DatePanel from = new DatePanel(ID_FROM, fromModel);
IModel<XMLGregorianCalendar> fromModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_FROM_GREG);
DatePanel from = new DatePanel(ID_FROM, fromModel);
from.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
from.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
from.setOutputMarkupId(true);
parametersPanel.add(from);

final DatePanel to = new DatePanel(ID_TO, toModel);
IModel<XMLGregorianCalendar> toModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_TO_GREG);
DatePanel to = new DatePanel(ID_TO, toModel);
to.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
to.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
to.setOutputMarkupId(true);
parametersPanel.add(to);

final TextPanel initiator = new TextPanel(ID_INITIATOR, initiatorModel);
initiator.setOutputMarkupId(true);
parametersPanel.add(initiator);
IModel<String> initiatorNameModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_INITIATOR_NAME);
TextPanel initiatorName = new TextPanel(ID_INITIATOR_NAME, initiatorNameModel);
initiatorName.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
initiatorName.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
initiatorName.setOutputMarkupId(true);
parametersPanel.add(initiatorName);

final DropDownChoicePanel channel = new DropDownChoicePanel(ID_CHANNEL, channelModel, channelListModel);
IModel<String> channelListModel = new ListModel(new WebComponentUtil().getChannelList());
IModel<String> channelModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_CHANNEL);
DropDownChoicePanel channel = new DropDownChoicePanel(ID_CHANNEL, channelModel, channelListModel);
channel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
channel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
channel.setOutputMarkupId(true);
parametersPanel.add(channel);

final TextPanel property = new TextPanel(ID_PROPERTY, propertyModel);
property.setOutputMarkupId(true);
parametersPanel.add(property);
IModel<String> hostIdentifierModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_HOST_IDENTIFIER);
TextPanel hostIdentifier = new TextPanel(ID_HOST_IDENTIFIER, hostIdentifierModel);
hostIdentifier.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
hostIdentifier.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
hostIdentifier.setOutputMarkupId(true);
parametersPanel.add(hostIdentifier);

IModel<String> targetNameModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_TARGET_NAME);
TextPanel targetName = new TextPanel(ID_TARGET_NAME, targetNameModel);
targetName.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
targetName.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
targetName.setOutputMarkupId(true);
parametersPanel.add(targetName);

IModel<String> targetOwnerNameModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_TARGET_OWNER_NAME);
TextPanel targetOwnerName = new TextPanel(ID_TARGET_OWNER_NAME, targetOwnerNameModel);
targetOwnerName.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
targetOwnerName.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
targetOwnerName.setOutputMarkupId(true);
parametersPanel.add(targetOwnerName);

IModel<String> eventTypeListModel = new ListModel(Arrays.asList(AuditEventTypeType.values()));
IModel<String> eventTypeModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_EVENT_TYPE);
DropDownChoicePanel eventType = new DropDownChoicePanel(ID_EVENT_TYPE, eventTypeModel, eventTypeListModel);
// TextPanel eventType = new TextPanel(ID_EVENT_TYPE, eventTypeModel);
eventType.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
eventType.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
eventType.setOutputMarkupId(true);
parametersPanel.add(eventType);

IModel<String> eventStageListModel = new ListModel(Arrays.asList(AuditEventStageType.values()));
IModel<String> eventStageModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_EVENT_STAGE);
DropDownChoicePanel eventStage = new DropDownChoicePanel(ID_EVENT_STAGE, eventStageModel, eventStageListModel);
// TextPanel eventStage = new TextPanel(ID_EVENT_STAGE, eventStageModel);
eventStage.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
eventStage.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
eventStage.setOutputMarkupId(true);
parametersPanel.add(eventStage);

IModel<String> outcomeListModel = new ListModel(Arrays.asList(OperationResultStatus.values()));
IModel<String> outcomeModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_OUTCOME);
// TextPanel outcome = new TextPanel(ID_OUTCOME, outcomeModel);
DropDownChoicePanel outcome = new DropDownChoicePanel(ID_OUTCOME, outcomeModel, outcomeListModel);
outcome.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
outcome.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
outcome.setOutputMarkupId(true);
parametersPanel.add(outcome);

AjaxButton ajaxButton = new AjaxButton(ID_SEARCH_BUTTON, createStringResource("BasicSearchPanel.search")) {
@Override
public void onClick(AjaxRequestTarget arg0) {
Form mainForm = (Form)getParent().getParent();
initTable(mainForm);
refreshTable(mainForm);
arg0.add(mainForm);
// TODO Auto-generated method stub
}
Expand All @@ -135,16 +209,51 @@ private void initTable(Form mainForm){
mainForm.addOrReplace(table);
}

private void refreshTable(Form mainForm){
/*
System.out.println("1:" + auditSearchDto.getObject().getFromGreg());
System.out.println("1:" + auditSearchDto.getObject().getToGreg());
System.out.println("1:" + auditSearchDto.getObject().getInitiatorName());
System.out.println("1:" + auditSearchDto.getObject().getChannel());
*/
AuditEventRecordProvider provider = new AuditEventRecordProvider(PageAuditLogViewer.this){
public Map<String, Object> getParameters() {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("from", auditSearchDto.getObject().getFromGreg());
parameters.put("to", auditSearchDto.getObject().getToGreg());
parameters.put("initiatorName", auditSearchDto.getObject().getInitiatorName());
parameters.put("channel", auditSearchDto.getObject().getChannel());
parameters.put("hostIdentifier", auditSearchDto.getObject().getHostIdentifier());
parameters.put("targetName", auditSearchDto.getObject().getTargetName());
parameters.put("targetOwnerName", auditSearchDto.getObject().getTargetOwnerName());
parameters.put("eventType", auditSearchDto.getObject().getEventType());
parameters.put("eventStage", auditSearchDto.getObject().getEventStage());
parameters.put("outcome", auditSearchDto.getObject().getOutcome());
/*
System.out.println("2:" + auditSearchDto.getObject().getFromGreg());
System.out.println("2:" + auditSearchDto.getObject().getToGreg());
System.out.println("2:" + auditSearchDto.getObject().getInitiatorName());
System.out.println("2:" + auditSearchDto.getObject().getChannel());
*/
return parameters;
}
};
BoxedTablePanel table = new BoxedTablePanel(ID_TABLE, provider,
initColumns(),
UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER,
(int) getItemsPerPage(UserProfileStorage.TableId.PAGE_AUDIT_LOG_VIEWER));
table.setShowPaging(true);
table.setOutputMarkupId(true);
mainForm.addOrReplace(table);
}

private List<IColumn<AuditEventRecordType, String>> initColumns() {
List<IColumn<AuditEventRecordType, String>> columns = new ArrayList<>();
IColumn<AuditEventRecordType, String> linkColumn = new LinkColumn<AuditEventRecordType>(createStringResource("PageAuditLogViewer.column.time"), "timestamp"){

@Override
public void onClick(AjaxRequestTarget target, IModel<AuditEventRecordType> rowModel) {
setResponsePage(new PageAuditLogDetails(rowModel.getObject()));
}


};
columns.add(linkColumn);
IColumn timeColumn = new PropertyColumn(createStringResource("PageAuditLogViewer.column.time"), "timestamp");
Expand Down

0 comments on commit 4872e7c

Please sign in to comment.