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

org.genesys.blocks.auditlog.persistence.AuditLogRepository 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.persistence;

import java.io.Serializable;
import java.util.List;

import org.genesys.blocks.auditlog.model.AuditLog;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.stereotype.Repository;

/**
 * The Interface AuditLogRepository.
 *
 * @author Matija Obreza
 */
@Repository
public interface AuditLogRepository extends AuditLogCustomRepository, JpaRepository, QuerydslPredicateExecutor {

	/**
	 * List audit log entries in descending order (most recent first).
	 *
	 * @param classname the classname
	 * @param entityId the entity id
	 * @return the list
	 */
	@Query("select al from AuditLog al where al.entityId = ?2 and al.classPk.classname = ?1 order by al.id desc")
	List listAuditLogs(String classname, Serializable entityId);

	/**
	 * List audit logs.
	 *
	 * @param name the name
	 * @param id the id
	 * @param page the page
	 * @return the list
	 */
	@Query("select al from AuditLog al where al.entityId = ?2 and al.classPk.classname = ?1 order by al.logDate desc")
	List listAuditLogs(String name, Serializable id, Pageable page);

	/**
	 * List audit logs.
	 *
	 * @param name the name
	 * @param id the id
	 * @param propertyName the property name
	 * @param page the page
	 * @return the list
	 */
	@Query("select al from AuditLog al where al.entityId = ?2 and al.classPk.classname = ?1 and al.propertyName = ?3 order by al.logDate desc")
	List listAuditLogs(String name, Serializable id, String propertyName, Pageable page);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy