Skip to content

Commit

Permalink
AuditSearchDto.java is added to the reports dto
Browse files Browse the repository at this point in the history
  • Loading branch information
ozkanbayraktar committed Oct 12, 2016
1 parent 3db857b commit 21f8052
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 26 deletions.
Expand Up @@ -34,22 +34,18 @@
<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.targetTypeLabel" /></label>
<span class="col-md-5" wicket:id="targetTypeField" />
</div>
<div class="row">
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.targetOwnerNameLabel" /></label>
<span class="col-md-5" wicket:id="targetOwnerNameField" />
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.eventTypeLabel" /></label>
<span class="col-md-5" wicket:id="eventTypeField" />
</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" />
<label class="col-md-1"><wicket:message key="PageAuditLogViewer.outcomeLabel" /></label>
<span class="col-md-5" wicket:id="outcomeField" />
</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 @@ -20,6 +21,7 @@
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 @@ -36,6 +38,8 @@
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 @@ -61,12 +65,11 @@ public class PageAuditLogViewer extends PageBase{
private static final String ID_CHANNEL = "channelField";
private static final String ID_HOST_IDENTIFIER = "hostIdentifierField";
private static final String ID_TARGET_NAME = "targetNameField";
private static final String ID_TARGET_TYPE = "targetTypeField";
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";

Expand Down Expand Up @@ -148,36 +151,35 @@ private void initParametersPanel(Form mainForm){
targetName.setOutputMarkupId(true);
parametersPanel.add(targetName);

IModel<String> targetTypeModel = new PropertyModel<>(auditSearchDto, AuditSearchDto.F_TARGET_TYPE);
TextPanel targetType = new TextPanel(ID_TARGET_TYPE, targetTypeModel);
targetType.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
targetType.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
targetType.setOutputMarkupId(true);
parametersPanel.add(targetType);

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);
TextPanel eventType = new TextPanel(ID_EVENT_TYPE, eventTypeModel);
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);
TextPanel eventStage = new TextPanel(ID_EVENT_STAGE, eventStageModel);
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);
// 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);
Expand Down Expand Up @@ -223,7 +225,6 @@ public Map<String, Object> getParameters() {
parameters.put("channel", auditSearchDto.getObject().getChannel());
parameters.put("hostIdentifier", auditSearchDto.getObject().getHostIdentifier());
parameters.put("targetName", auditSearchDto.getObject().getTargetName());
parameters.put("targetType", auditSearchDto.getObject().getTargetType());
parameters.put("targetOwnerName", auditSearchDto.getObject().getTargetOwnerName());
parameters.put("eventType", auditSearchDto.getObject().getEventType());
parameters.put("eventStage", auditSearchDto.getObject().getEventStage());
Expand Down
Expand Up @@ -163,11 +163,6 @@ private String generateFullQuery(String query, boolean orderBy){
} else {
queryParameters.remove("hostIdentifier");
}
if (queryParameters.get("targetType") != null) {
query += "(aer.targetType = :targetType) and ";
} else {
queryParameters.remove("targetType");
}
if (queryParameters.get("targetOwnerName") != null) {
query += "(aer.targetOwnerName = :targetOwnerName) and ";
} else {
Expand Down
@@ -0,0 +1,174 @@
/*
* Copyright (c) 2010-2013 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.web.page.admin.reports.dto;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;

import com.evolveum.midpoint.audit.api.AuditEventType;
import com.evolveum.midpoint.util.MiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExportType;

import javax.xml.datatype.XMLGregorianCalendar;

/**
* TODO - get rid of XMLGregorianCalendar - Date conversions
*
* @author lazyman
*/
public class AuditSearchDto implements Serializable {

public static final String F_FROM_GREG = "fromGreg";
public static final String F_TO_GREG = "toGreg";
public static final String F_FROM = "from";
public static final String F_TO = "to";
public static final String F_INITIATOR_NAME = "initiatorName";
public static final String F_CHANNEL = "channel";
public static final String F_HOST_IDENTIFIER = "hostIdentifier";
public static final String F_TARGET_NAME = "targetName";
public static final String F_TARGET_OWNER_NAME = "targetOwnerName";
public static final String F_EVENT_TYPE = "eventType";
public static final String F_EVENT_STAGE = "eventStage";
public static final String F_OUTCOME = "outcome";

private XMLGregorianCalendar fromGreg;
private XMLGregorianCalendar toGreg;
private Date from;
private Date to;
private String initiatorName;
private String channel;
private String hostIdentifier;
private String targetName;
private String targetOwnerName;
private String eventType;
private String eventStage;
private String outcome;

public XMLGregorianCalendar getFromGreg() {
return MiscUtil.asXMLGregorianCalendar(from);
}

public void setFromGreg(XMLGregorianCalendar fromGreg) {
this.from = MiscUtil.asDate(fromGreg);
this.fromGreg = fromGreg;
}

public XMLGregorianCalendar getToGreg() {
return MiscUtil.asXMLGregorianCalendar(to);
}

public void setToGreg(XMLGregorianCalendar toGreg) {
this.to = MiscUtil.asDate(toGreg);
this.toGreg = toGreg;
}

public Date getFrom() {
if (from == null) {
from = new Date();
}
return from;
}

public void setFrom(Date from) {
this.from = from;
}

public Date getTo() {
if (to == null) {
to = new Date();
}
return to;
}

public void setTo(Date to) {
this.to = to;
}

public Timestamp getDateFrom() {
return new Timestamp(getFrom().getTime());
}

public Timestamp getDateTo() {
return new Timestamp(getTo().getTime());
}

public String getInitiatorName() {
return initiatorName;
}

public void setInitiatorName(String initiatorName) {
this.initiatorName = initiatorName;
}

public String getChannel() {
return channel;
}

public void setChannel(String channel) {
this.channel = channel;
}

public String getHostIdentifier() {
return hostIdentifier;
}

public void setHostIdentifier(String hostIdentifier) {
this.hostIdentifier = hostIdentifier;
}

public String getTargetName() {
return targetName;
}

public void setTargetName(String targetName) {
this.targetName = targetName;
}

public String getTargetOwnerName() {
return targetOwnerName;
}

public void setTargetOwnerName(String targetOwnerName) {
this.targetOwnerName = targetOwnerName;
}

public String getEventType() {
return eventType;
}

public void setEventType(String eventType) {
this.eventType = eventType;
}

public String getEventStage() {
return eventStage;
}

public void setEventStage(String eventStage) {
this.eventStage = eventStage;
}

public String getOutcome() {
return outcome;
}

public void setOutcome(String outcome) {
this.outcome = outcome;
}

}

0 comments on commit 21f8052

Please sign in to comment.