Class HarvestStatusQuery
- java.lang.Object
-
- dk.netarkivet.harvester.webinterface.HarvestStatusQuery
-
public class HarvestStatusQuery extends Object
Represents a query for a set of jobs. Filtering can be performed on:- Job Status (multiple)
- Harvest name (single)
- Job start date (day of month and year)
- Job end date (day of month and year)
The semantics of the date filters is as follows:
- If only a start date is specified, will fetch jobs whose start date is equal or posterior
- If only an end date is specified, will fetch jobs whose end date is equal or anterior
- If both are specified, will fetch jobs whose start and end date are equal or comprised between the specified bounds.
The class enforces that end date is set at a date posterior to start date.
Additionally a sort order (applied to job IDs) can be set (ascending or descending), and the query can be limited to a certain row number and a start index.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
HarvestStatusQuery.SORT_ORDER
Enum class defining the different sort-orders.static class
HarvestStatusQuery.UI_FIELD
Defines the UI fields and their default values.
-
Field Summary
Fields Modifier and Type Field Description static String
CALENDAR_UI_DATE_FORMAT
The date format used by the calendar widget.static long
DATE_NONE
Value used to define date undefined.static String
HARVEST_NAME_ALL
The String code to select all harvests.static String
HARVEST_NAME_WILDCARD
String to check, if there is a wildcard in the harvestname.static String
JOBSTATUS_ALL
The String code to select all states.static long
PAGE_SIZE_NONE
Value used to define page size undefined.
-
Constructor Summary
Constructors Constructor Description HarvestStatusQuery()
Builds a default query that will select all jobs.HarvestStatusQuery(long harvestId, long harvestRunNumber)
Builds a default query that will find jobs for a given run of a harvest.HarvestStatusQuery(javax.servlet.ServletRequest req)
Builds a query from a servlet request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getCaseSensitiveHarvestName()
long
getEndDate()
String
getEndDateAsString()
Long
getHarvestId()
String
getHarvestName()
Long
getHarvestRunNumber()
String
getJobIdRange()
long
getPageSize()
List<String>
getPartialJobIdRangeAsList(boolean isRange)
return only the ids or only the range if isRange is true : 2,3,5-9,14-18 -> 5-9,14-18 if isRange is false : 2,3,5-9,14-18 -> 2,3JobStatus[]
getSelectedJobStatuses()
Set<JobStatus>
getSelectedJobStatusesAsSet()
long
getStartDate()
String
getStartDateAsString()
long
getStartPageIndex()
boolean
isSortAscending()
void
setCaseSensitiveHarvestName(boolean isHarvestNameCaseSensitive)
Define whether or not the harvest name is case sensitive.void
setHarvestName(String harvestName)
Set the harvest name.void
setJobStatus(Set<JobStatus> chosenStates)
Set the selected states in the query.void
setPageSize(long pageSize)
Sets the page size.
-
-
-
Field Detail
-
JOBSTATUS_ALL
public static final String JOBSTATUS_ALL
The String code to select all states.- See Also:
- Constant Field Values
-
HARVEST_NAME_ALL
public static final String HARVEST_NAME_ALL
The String code to select all harvests.- See Also:
- Constant Field Values
-
HARVEST_NAME_WILDCARD
public static final String HARVEST_NAME_WILDCARD
String to check, if there is a wildcard in the harvestname.- See Also:
- Constant Field Values
-
PAGE_SIZE_NONE
public static final long PAGE_SIZE_NONE
Value used to define page size undefined.- See Also:
- Constant Field Values
-
DATE_NONE
public static final long DATE_NONE
Value used to define date undefined.- See Also:
- Constant Field Values
-
CALENDAR_UI_DATE_FORMAT
public static final String CALENDAR_UI_DATE_FORMAT
The date format used by the calendar widget. It is actually the same format as the one represented by the DATE_FORMAT.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HarvestStatusQuery
public HarvestStatusQuery()
Builds a default query that will select all jobs.
-
HarvestStatusQuery
public HarvestStatusQuery(long harvestId, long harvestRunNumber)
Builds a default query that will find jobs for a given run of a harvest.- Parameters:
harvestId
- A given harvestIdharvestRunNumber
- a given harvestRunNumber
-
HarvestStatusQuery
public HarvestStatusQuery(javax.servlet.ServletRequest req)
Builds a query from a servlet request. Unspecified fields are set to their default value.- Parameters:
req
- a servlet request
-
-
Method Detail
-
getSelectedJobStatuses
public JobStatus[] getSelectedJobStatuses()
- Returns:
- the selected job states as an array.
-
getSelectedJobStatusesAsSet
public Set<JobStatus> getSelectedJobStatusesAsSet()
- Returns:
- the selected job states as a set..
-
getHarvestName
public String getHarvestName()
- Returns:
- the harvest name.
-
setHarvestName
public void setHarvestName(String harvestName)
Set the harvest name.- Parameters:
harvestName
- The harvest name
-
getHarvestId
public Long getHarvestId()
- Returns:
- the harvest ID.
-
getHarvestRunNumber
public Long getHarvestRunNumber()
- Returns:
- the harvest run number.
-
getStartDate
public long getStartDate()
- Returns:
- the start date as milliseconds since Epoch or
DATE_NONE
if start date is undefined
-
getEndDate
public long getEndDate()
- Returns:
- the end date as milliseconds since Epoch, or
DATE_NONE
if end date is undefined
-
getJobIdRange
public String getJobIdRange()
- Returns:
- the job ids range as String
-
getPartialJobIdRangeAsList
public List<String> getPartialJobIdRangeAsList(boolean isRange)
return only the ids or only the range if isRange is true : 2,3,5-9,14-18 -> 5-9,14-18 if isRange is false : 2,3,5-9,14-18 -> 2,3- Returns:
- the job ids range as List, only the ids or only the ranges
-
getStartDateAsString
public String getStartDateAsString()
- Returns:
- the start date as a string, or an empty string if start date is undefined
-
getEndDateAsString
public String getEndDateAsString()
- Returns:
- the end date as a string, or an empty string if end date is undefined
-
isSortAscending
public boolean isSortAscending()
- Returns:
- true, if the sorting order is Ascending, otherwise false.
-
getPageSize
public long getPageSize()
- Returns:
- the page size, i.e. the number of results on each page.
-
setPageSize
public void setPageSize(long pageSize)
Sets the page size.- Parameters:
pageSize
- a number > 0.
-
getStartPageIndex
public long getStartPageIndex()
- Returns:
- the start page
-
setCaseSensitiveHarvestName
public void setCaseSensitiveHarvestName(boolean isHarvestNameCaseSensitive)
Define whether or not the harvest name is case sensitive.- Parameters:
isHarvestNameCaseSensitive
- If true, harvestname is case sensitive, otherwise not.
-
getCaseSensitiveHarvestName
public boolean getCaseSensitiveHarvestName()
- Returns:
- true, if the harvest name is case sensitive, otherwise false
-
-