All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.genesys.blocks.auditlog.service.AuditTrailService Maven / Gradle / Ivy

/*
 * Copyright 2018 Global Crop Diversity Trust
 *
 * 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 org.genesys.blocks.auditlog.service;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.genesys.blocks.auditlog.component.AuditTrailInterceptor;
import org.genesys.blocks.auditlog.model.AuditAction;
import org.genesys.blocks.auditlog.model.AuditLog;
import org.genesys.blocks.auditlog.model.TransactionAuditLog;
import org.genesys.blocks.auditlog.model.filters.AuditLogFilter;
import org.genesys.blocks.model.EntityId;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

/**
 * The audit trail service declaration.
 *
 * @author Matija Obreza
 */
public interface AuditTrailService {

	/**
	 * Return logs matching AuditSearch filter.
	 *
	 * @param filters filter
	 * @param page the page
	 * @return list of matching logs
	 */
	Page listAuditLogs(AuditLogFilter filters, Pageable page);

	/**
	 * Create a temporary audit log entry. This is used by the
	 * {@link AuditTrailInterceptor}.
	 *
	 * @param action the action
	 * @param entity the entity
	 * @param id the id
	 * @param propertyName the property name
	 * @param previousState the previous state
	 * @param currentState the current state
	 * @param referencedEntity the referenced entity
	 * @param previousObject the previous object (not persisted) 
	 * @param currentObject the current object (not persisted)
	 * @return the transaction audit log
	 */
	TransactionAuditLog auditLogEntry(AuditAction action, Object entity, long id, String propertyName, String previousState, String currentState, Class referencedEntity, Object previousObject, Object currentObject);

	/**
	 * Record audit logs in the database.
	 *
	 * @param auditLogs the audit logs
	 * @return the list
	 */
	List addAuditLogs(Set auditLogs);

	/**
	 * List audit logs for the specified entity. Logs are sorted by log date
	 * (descending). Where logs reference an entity, these are made available in
	 * {@link AuditLog#getNewEntity()} and {@link AuditLog#getPreviousEntity()}.
	 *
	 * @param entity Entity for which to list logs
	 * @return List of all log entries for the specified entity
	 */
	List listAuditLogs(EntityId entity);

	/**
	 * Map audit logs by property for the specified entity.
	 * 
	 * Logs are sorted by log date (descending). Where logs reference an entity,
	 * these are made available in {@link AuditLog#getNewEntity()} and
	 * {@link AuditLog#getPreviousEntity()}.
	 *
	 * @param entity Entity for which to list logs
	 * @return Map of all log entries for the specified entity by property name
	 */
	Map> auditLogs(EntityId entity);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy