Files
alfresco-community-repo/source/java/org/alfresco/service/cmr/audit/AuditQueryParameters.java
Raluca Munteanu 8674e2bfc8 Merged 5.1.N (5.1.2) to 5.2.N (5.2.1)
125603 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2)
      125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125781 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2016-04-26 12:48:49 +00:00

201 lines
5.3 KiB
Java

package org.alfresco.service.cmr.audit;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.alfresco.util.Pair;
/**
* Parameters controlling audit queries.
*
* @author Derek Hulley
* @since 3.3
*/
public class AuditQueryParameters
{
private boolean forward;
private String applicationName;
private String user;
private Long fromId;
private Long toId;
private Long fromTime;
private Long toTime;
private List<Pair<String, Serializable>> searchKeyValues;
/**
* Defaults:<br/>
* &nbsp;<code>forward = true;</code><br/>
* &nbsp;<code>searchKeyValues = emptylist</code><br/>
* &nbsp:<code>others = null</code>
*/
public AuditQueryParameters()
{
forward = true;
searchKeyValues = new ArrayList<Pair<String,Serializable>>();
}
/**
* @return Returns <tt>true</tt> if any query using these parameters will
* necessarily yield no results.
*/
public boolean isZeroResultQuery()
{
if (fromId != null && toId != null && fromId.compareTo(toId) > 0)
{
// Inverted IDs
return true;
}
if (fromTime != null && toTime != null && fromTime.compareTo(toTime) > 0)
{
// Inverted IDs
return true;
}
return false;
}
/**
* @return Returns <tt>true</tt> if the results are ordered by increasing ID
*/
public boolean isForward()
{
return forward;
}
/**
* @param forward <tt>true</tt> for results to ordered from first to last,
* or <tt>false</tt> to order from last to first
*/
public void setForward(boolean forward)
{
this.forward = forward;
}
/**
* @return Returns if not <tt>null</tt>, find entries logged against this application
*/
public String getApplicationName()
{
return applicationName;
}
/**
* @param applicationName if not <tt>null</tt>, find entries logged against this application
*/
public void setApplicationName(String applicationName)
{
this.applicationName = applicationName;
}
/**
* @return Returns if not <tt>null</tt>, find entries logged against this user
*/
public String getUser()
{
return user;
}
/**
* @param user if not <tt>null</tt>, find entries logged against this user
*/
public void setUser(String user)
{
this.user = user;
}
/**
* @return Returns the ID to search from (<tt>null</tt> to start at the beginning)
*/
public Long getFromId()
{
return fromId;
}
/**
* @param fromId the ID to search from (<tt>null</tt> to start at the beginning)
*/
public void setFromId(Long fromId)
{
this.fromId = fromId;
}
/**
* @return Returns the ID to search to (<tt>null</tt> for no limit)
*/
public Long getToId()
{
return toId;
}
/**
* @param toId the start ID to search to (<tt>null</tt> for no limit)
*/
public void setToId(Long toId)
{
this.toId = toId;
}
/**
* @return Returns the start search time (<tt>null</tt> to start at the beginning)
*/
public Long getFromTime()
{
return fromTime;
}
/**
* @param fromTime the start search time (<tt>null</tt> to start at the beginning)
*/
public void setFromTime(Long fromTime)
{
this.fromTime = fromTime;
}
/**
* @return Returns the end search time (<tt>null</tt> for no limit)
*/
public Long getToTime()
{
return toTime;
}
/**
* @param toTime the end search time (<tt>null</tt> for no limit)
*/
public void setToTime(Long toTime)
{
this.toTime = toTime;
}
/**
*
* @return Returns the search keys for the query
*/
public List<Pair<String, Serializable>> getSearchKeyValues()
{
return Collections.unmodifiableList(searchKeyValues);
}
/**
* Add a search key pair.
*
* @param searchKey the path-value pair. Either the path ({@link Pair#getFirst() first} value)
* or the search value ({@link Pair#getSecond() second} value) may be <tt>null</tt>,
* but not both.
*/
public void addSearchKey(String searchKey, Serializable searchValue)
{
if (searchKey == null && searchValue == null)
{
throw new IllegalArgumentException("A search key must have a 'searchKey' and/or a 'searchValue'.");
}
if (searchKeyValues.size() > 0)
{
throw new UnsupportedOperationException("Only one search key-value pair is currently supported.");
}
this.searchKeyValues.add(new Pair<String, Serializable>(searchKey, searchValue));
}
}