Class ItemContext
Typical example for using this class are:
A client application storing list/table settings
SessionControl sc = ... ItemContext current = sc.getCurrentContext(Item.SAMPLE); current.setRowsPerPage(50); current.setPage(0); current.setSortProperty("name"); current.setSortDirection(SortDirection.DESC); current.setPropertyFilter( new PropertyFilter("name", Operator.LIKE, "Nicklas%", Type.STRING) ); ItemQuery query = Sample.getQuery(); current.configureQuery(query, true); // The query will now return the 50 first samples with a // a name starting with 'Nicklas' sorted in descending order
A client application using filter information when creating new items
SessionControl sc = ... DbControl dc = sc.newDbControl(); ItemContext current = sc.getCurrentContext(Item.SAMPLE); Sample sample = Sample.getNew(dc); if (current.getPropertyValue("name") != null) { sample.setName(current.getPropertyValue("name")); } // The name is now 'Nicklas%'
Plugin finds out which items in a list has been selected
SessionControl sc = ... ItemContext current = sc.getCurrentContext(Item.SAMPLE); ItemQuery query = Sample.getQuery(); Set selected = current.getSelected(); if (selected != null && selected.size() > 0) { query.restrict( Restrictions.in(Hql.property("id"), Expressions.parameter("selected", selected, Type.INT)) ); ) // The query will now return the selected items only
An import plugin asks client application for a file with a specific file type
public RequestInformation getRequestInformation(GuiContext context, String command) throws BaseException { RequestInformation requestInformation = null; if (command.equals(Request.COMMAND_CONFIGURE_PLUGIN)) { requestInformation = getConfigurePluginParameters(context); } else if (command.equals(Request.COMMAND_CONFIGURE_JOB)) { requestInformation = getConfigureJobParameters(context); ItemContext fileContext = sc.getCurrentContext(Item.FILE); fileContext.setPropertyFilter(FileType.getPropertyFilter(FileType.REPORTER)); } return requestInformation; }
- Version:
- 2.0
- Author:
- Nicklas
- See Also:
- Last modified
- $Date: 2024-12-18 11:56:56 +0100 (Wed, 18 Dec 2024) $
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Parameter options forsetSubCategory(AnnotationTypeCategory, AddFilter)
(package private) static class
Holds a pair of filter.(package private) static class
(package private) static class
static enum
Enumeration used to specify the sort direction. -
Field Summary
Modifier and TypeFieldDescriptionprivate int
static final String
This is the name of the default context which is automatically saved when a user is logging out.private Throwable
private boolean
private int
private final Item
private String
private final String
private boolean
private int
private int
private Permission
private Map<String,
ItemContext.PropertyFilterPair> private Query
private int
private ItemContext.SortDirection
private String
private AnnotationTypeCategoryData
private final String
private ItemSubtypeData
-
Constructor Summary
ConstructorDescriptionItemContext
(String sortProperty, ItemContext.SortDirection sortDirection, int rowsPerPage, int page) Create a new context.ItemContext
(ContextData context) Create a new context from a loaded database object.ItemContext
(Item itemType, String subContext, String name) Create a new empty context.ItemContext
(Item itemType, ItemListSyncFilterData syncFilter) Initialize the context from an item list synchronization filter.ItemContext
(Item itemType, PropertyFilter... filters) Initialize the context with the special purpose of configuring a query with the given filters. -
Method Summary
Modifier and TypeMethodDescriptionint
addFilterRows
(int numRows) Add filter rows to the table.private void
applySubCategoryFilter
(ItemContext.AddFilter addFilter) void
Clear all recently used values lists.void
clearRecent
(String key) Clear the recently used values list.void
clearRecent
(Item itemType) Clear the recently used items list from items of the specified type.void
clearRecent
(Item itemType, String subList) Clear the recently used items sublist from items of the specified type.void
clearRecent
(Item itemType, ItemSubtype subtype) Clear the recently used items list from items of the specified type.void
configureQuery
(DbControl dc, EntityQuery query, boolean autoLeftJoin) void
configureQuery
(DbControl dc, EntityQuery query, ClientContext context, boolean autoLeftJoin) Use the settings in this context to configure a query.void
configureQuery
(DbControl dc, SqlQuery query, List<String> selectionList) Use the settings in this context to configure a dynamic query.(package private) void
copyFrom
(ItemContext other, boolean forceAll) Copy settings from another context to this context.(package private) void
copyFromSyncFilter
(ItemListSyncFilterData syncFilter) void
Copies all objects and temporary filters from this context to another context.(package private) void
copyToSyncFilter
(ItemListSyncFilterData syncFilter) Create a new item list synchronization filter from this context.void
filterOnSelectedItems
(EntityQuery query) Add a filter to the given query that restricts it to only return items that have been selected.int
Get the database ID of this context.(package private) ContextData
getData
(String name, UserData user, ClientData client, boolean isPublic) Create a new database context object from this context.static Expression
getDynamicExpression
(DbControl dc, SqlQuery query, String propertyDef) Create anExpression
from a string.static Select
getDynamicSelect
(DbControl dc, SqlQuery query, String propertyDef) Same asgetDynamicExpression(DbControl, SqlQuery, String)
but generates a select object instead.Get the exception that is the cause for the error inconfigureQuery(DbControl, EntityQuery, boolean)
.getFilterRestriction
(String property, int filterRow, DbControl dc, EntityQuery query) Create a restriction from a property filter on the given filter row.getFilterRestriction
(String property, DbControl dc, EntityQuery query) Create a restriction from a property filter on filter row 0.int
Get the number of filter rows to display on the list page.int
getId()
Get the ID of the current item in this context.boolean
Get aSet
object to specifyInclude
options for a query.The permission the logged in user must have for items returned by a query.Get the subtype that is related to this context.Get the type of item this object is storing context for.Get a message that should be displayed by a client application as soon as it is appropriate to do so.getName()
Get the name of this context.int
Get the total number of property filters stored in this context.int
getNumPropertyFilters
(int filterRow) Get the number of property filters stored in this context for the given filter row.int
getNumRecent
(String key) Get the number of recently used value in the list.int
getNumRecent
(Item itemType) Get the number of recently used items in the list.int
getNumRecent
(Item itemType, String subList) Get the number of recently used items in a list with a sublist.int
getNumRecent
(Item itemType, ItemSubtype subtype) Get the number of recently used items in the list.<T> T
Get an object.int
getPage()
Get the current table page.getPropertyFilter
(String property) Get a filter for a property on filter row 0.getPropertyFilter
(String property, int filterRow) Get a filter for a property.Get a collection of all property filters stored in this context.getPropertyFilters
(int filterRow) Get a collection of all property filters stored in this context for a given filter row.<T> T
getPropertyObject
(String property) getPropertyValue
(String property) Get the value of a property filter on row 0.getPropertyValue
(String property, int filterRow) Get the value of a property filter on the given filter row.<T extends Query>
TgetQuery()
Get all recently used values for the specified key.Get all recently used items of the specified type.<T extends BasicItem>
TGet all recently used items of the specified type in a given sublist.<T extends BasicItem>
TgetRecent
(DbControl dc, Item itemType, ItemSubtype subtype) Get all recently used items of the specified type.private String
int
Get the number of rows the current table page is displaying.Get aSet
object to specify the ID:s of all items that are currently selected.getSetting
(String name) Get a value.getSetting
(String name, String defaultValue) Get a value from the settings or the default value if no current value exists.If the items are sorted in ascending or descending order.Get the current sort property as anOrder
instance.Get the name of the property the current listing is sorted by.Get the sub-category that is related to this context.Get the filter on the sub-category annotation column.Check if this context has a filter on the sub-category annotation.Get the sub-context name of this context.boolean
hasCategoryOrSubtype
(AnnotationTypeCategory category, ItemSubtype subtype) Checks if this context has a matching category or subtype.boolean
hasExtensionFilter
(String prefix) Checks if there is an extension filter with a property starting with !boolean
Is this context limited to return items of a given subtype or not?boolean
hasPropertyFilter
(String property) Checks if there is a filter for the given property regardless of filter row.boolean
Is this context related to a given annotation type category or not?private void
initPropertyFilters
(Map<String, PropertyFilterData> filterData) Initialize the property filters by loading them from the given map.loadRecent
(DbControl dc, Item itemType, String key) private <T extends BasicItem>
TloadRecent
(DbControl dc, Item itemType, String key, int index) void
Deprecated.void
removeAllPropertyFilters
(String property) Remove all property filters for the given property.void
removeAllPropertyFilters
(ItemContext.AddFilter subCategoryFilter) Remove all property filters from this context and optionally re-apply sub-category filter.void
Remove all temporary filters.int
removeFilterRow
(int filterIndex) Remove all filters from the specified filter row.<T> T
removeObject
(String name) Remove a value.void
removePropertyFilter
(String property) Remove a property filter on filter row 0.void
removePropertyFilter
(String property, int filterRow) Remove a property filter on the given filter row.removeSetting
(String name) Remove a value.void
removeTemporaryFilter
(String property) Remote a temporary filter for the given property on filter row 0.void
removeTemporaryFilter
(String property, int filterRow) Remote a temporary filter for the given property.void
Set the exception that is the cause for the error inconfigureQuery(DbControl, EntityQuery, boolean)
.void
setId
(int id) Set the ID of the current item in this context.void
setIgnoreSubtypeFilter
(boolean ignoreSubtypeFilter) Set a flag to indicate if the configured subtype should be ignored when configuring a query.void
setItemPermission
(Permission permission) Specify the permission the logged in user must have for items returned by a query.void
setItemSubtype
(ItemSubtype subtype) Set a subtype to relate to this context.void
setMessage
(String message) Set a message to be displayed by a client application as soon as it is appropriate to do so.<T> T
Set a value.void
setPage
(int page) Set the current table page.void
setPropertyFilter
(PropertyFilter filter) Set a property filter.void
setPropertyInspector
(Filter<String> filter) Set a filter for this context that is used to inspect which properties that are allowed to be used in queries.void
void
Add a value to the list of recently used values for the specified key.private void
void
Deprecated.In 3.15, usesetRecent(Item, BasicItem, int)
which support 'null' entriesvoid
Deprecated.In 3.15, usesetRecent(Item, BasicItem, String, int)
which support 'null' entriesvoid
setRecent
(BasicItem item, ItemSubtype subtype, int maxInList) Deprecated.In 3.15, usesetRecent(Item, BasicItem, ItemSubtype, int)
which support 'null' entriesvoid
Add an item to the "recently used items" list.void
Add an item to the "recently used items" list.void
setRecent
(Item itemType, BasicItem item, ItemSubtype subtype, int maxInList) Add an item to the "recently used items" list when used for a specific item subtype.void
setRowsPerPage
(int rowsPerPage) Set the number of rows the current table page should show.setSetting
(String name, String value) Set a value.void
setSortDirection
(ItemContext.SortDirection sortDirection) Set the sort direction (ascending or descending) of the current listing.void
setSortProperty
(String sortProperty) Set the name of the property that the current listing is sorted by.void
setSubCategory
(AnnotationTypeCategory subCategory, ItemContext.AddFilter addFilter) Set a sub-category to relate to this context.private void
storePropertyFilters
(Map<String, PropertyFilterData> filterData) Store the current property filters and save them in the give filterData map.
-
Field Details
-
DEFAULT_NAME
This is the name of the default context which is automatically saved when a user is logging out. A client application shouldn't use this name for other named contexts that it wants to reload in the future.- See Also:
-
name
-
itemType
-
subContext
-
subtype
-
subCategory
-
ignoreSubtypeFilter
private boolean ignoreSubtypeFilter -
contextId
private int contextId -
itemId
private int itemId -
selected
-
noPaging
private boolean noPaging -
rowsPerPage
private int rowsPerPage -
page
private int page -
numFilterRows
private int numFilterRows -
sortProperty
-
message
-
exception
-
sortDirection
-
include
-
permission
-
propertyFilters
-
settings
-
objects
-
query
-
propertyInspector
-
NO_AUTO_JOIN_PREFIXES
-
-
Constructor Details
-
ItemContext
public ItemContext(String sortProperty, ItemContext.SortDirection sortDirection, int rowsPerPage, int page) Create a new context.- Parameters:
sortProperty
- The property used to sort a listsortDirection
- If the items should be sorted in ascending or descending orderrowsPerPage
- The number of rows to display on a single pagepage
- The page number of the currently displayed page, starting at 0
-
ItemContext
Create a new empty context. -
ItemContext
ItemContext(ContextData context) Create a new context from a loaded database object. -
ItemContext
ItemContext(Item itemType, ItemListSyncFilterData syncFilter) Initialize the context from an item list synchronization filter. Note that this creates a special context used for implementing the query functionality of aSyncFilter
. It should not be used for representing context in a GUI. To do this start with a regular context and the usecopyFromSyncFilter(ItemListSyncFilterData)
instead.- Since:
- 3.5
-
ItemContext
ItemContext(Item itemType, PropertyFilter... filters) Initialize the context with the special purpose of configuring a query with the given filters. It should not be used for representing context in a GUI.- Since:
- 3.19.4
-
-
Method Details
-
getData
Create a new database context object from this context.- Parameters:
name
- The name to use, or null if the current name should be useduser
- The user that should own the context objectclient
- The client application currently in useisPublic
- If the context should be public or not
-
copyToSyncFilter
Create a new item list synchronization filter from this context. Basically the same asgetData(String, UserData, ClientData, boolean)
but only keep filter-related settings.- Since:
- 3.5
-
copyFromSyncFilter
-
storePropertyFilters
Store the current property filters and save them in the give filterData map. -
initPropertyFilters
Initialize the property filters by loading them from the given map. Eg. revese ofstorePropertyFilters(Map)
. -
getItemType
Get the type of item this object is storing context for. -
getSubContext
Get the sub-context name of this context. -
getName
Get the name of this context. -
getContextId
public int getContextId()Get the database ID of this context. Can be used to load contexts- Returns:
- The database ID of the context, or 0 if it hasn't been saved to the database
- Since:
- 2.4
-
hasItemSubtype
public boolean hasItemSubtype()Is this context limited to return items of a given subtype or not?- Since:
- 3.20
-
getItemSubtype
Get the subtype that is related to this context.- Since:
- 3.20
-
setItemSubtype
Set a subtype to relate to this context. This affects how queries are configured for this context. The given subtype must have the same main item type as this context.- Parameters:
subtype
- A subtype or null to remove the subtype- Since:
- 3.20
-
setIgnoreSubtypeFilter
public void setIgnoreSubtypeFilter(boolean ignoreSubtypeFilter) Set a flag to indicate if the configured subtype should be ignored when configuring a query. The default is to apply a filter. Note that this setting is not saved in the database and will not survive between sessions.- Since:
- 3.20
-
getIgnoreSubtypeFilter
public boolean getIgnoreSubtypeFilter()- Since:
- 3.20
-
hasSubCategory
public boolean hasSubCategory()Is this context related to a given annotation type category or not?- Since:
- 3.20
-
getSubCategoryFilterName
Check if this context has a filter on the sub-category annotation.- Returns:
- The name of the annotation type if there is a filter, null otherwise
- Since:
- 3.20.1
-
getSubCategoryFilter
Get the filter on the sub-category annotation column.- Returns:
- The filter or null if the subcategory doesn't have a filter
- Since:
- 3.20.1
-
getSubCategory
Get the sub-category that is related to this context.- Since:
- 3.20
-
setSubCategory
Set a sub-category to relate to this context. It is possible to automatically add a filter condition based on theAnnotationTypeCategory.getSubCategoryValues()
andItemSubtype.getSubCategoriesAnnotationType()
.- Parameters:
subCategory
- An annotation type category or null to remove the sub-categoryaddFilter
- Add a filter condition- Since:
- 3.20
-
applySubCategoryFilter
-
hasCategoryOrSubtype
Checks if this context has a matching category or subtype. Null values are considered as matching everything including other null values.- Parameters:
category
- An annotation type category or nullsubtype
- An item subtype or null- Since:
- 3.20
-
getId
public int getId()Get the ID of the current item in this context.- Returns:
- The ID of the item, or 0 if no item is current
-
setId
public void setId(int id) Set the ID of the current item in this context. This property is stored in the database.- Parameters:
id
- The ID of the item, or 0 if no item is current
-
getRowsPerPage
public int getRowsPerPage()Get the number of rows the current table page is displaying.- Returns:
- The number of rows
-
setRowsPerPage
public void setRowsPerPage(int rowsPerPage) Set the number of rows the current table page should show. This property is stored in the database.- Parameters:
rowsPerPage
- The number of rows to show on a page
-
getPage
public int getPage()Get the current table page.- Returns:
- The number of the page, starting at 0
-
setPage
public void setPage(int page) Set the current table page. This property is stored in the database.- Parameters:
page
- The number of the page, starting at 0
-
getFilterRows
public int getFilterRows()Get the number of filter rows to display on the list page.- Since:
- 3.5
-
addFilterRows
public int addFilterRows(int numRows) Add filter rows to the table.- Parameters:
numRows
- The number of rows to add, must be greater than 0- Returns:
- The number of filter rows after adding
- Since:
- 3.5
-
removeFilterRow
public int removeFilterRow(int filterIndex) Remove all filters from the specified filter row. Rows with a higher index are shifted down by one step.- Parameters:
filterIndex
- A value between 0 and number of filter rows (-1)- Returns:
- The number of filter rows after removing
- Since:
- 3.5
-
getSortProperty
Get the name of the property the current listing is sorted by. If multiple properties are used for sorting they are separated by a comma. Each property may also be prefixed by a '+' or '-' to override the global sort direction. -
setSortProperty
Set the name of the property that the current listing is sorted by. If you want to sort by multiple properties, separate them with a comma. By default, each property uses the same sort direction (getSortDirection()
, but this can be overridden by using '+' or '-' as a prefix for a property. This property is stored in the database.- Parameters:
sortProperty
- The name of the property
-
getSortDirection
If the items are sorted in ascending or descending order. -
setSortDirection
Set the sort direction (ascending or descending) of the current listing. This property is stored in the database.- Parameters:
sortDirection
- The sort direction
-
getSortOrder
Get the current sort property as anOrder
instance. If multiple properties are used for sorting, this method only returns the first property.- Returns:
- An Order instance, or null if no sort order has been specified
-
getMessage
Get a message that should be displayed by a client application as soon as it is appropriate to do so. Typically, theconfigureQuery(DbControl, EntityQuery, boolean)
sets an error message if it couldn't configure the query for some reason. -
setMessage
Set a message to be displayed by a client application as soon as it is appropriate to do so. Typically, theconfigureQuery(DbControl, EntityQuery, boolean)
sets an error message if it couldn't configure the query for some reason. This property is not stored in the database.- Parameters:
message
- The message
-
getException
Get the exception that is the cause for the error inconfigureQuery(DbControl, EntityQuery, boolean)
.- Since:
- 3.19.14
-
setException
Set the exception that is the cause for the error inconfigureQuery(DbControl, EntityQuery, boolean)
.- Since:
- 3.19.14
-
getInclude
Get aSet
object to specifyInclude
options for a query. This property is stored in the database.- See Also:
-
setItemPermission
Specify the permission the logged in user must have for items returned by a query. This property is not stored in the database. -
getItemPermission
The permission the logged in user must have for items returned by a query. This property is not stored in the database.- See Also:
-
getSelected
Get aSet
object to specify the ID:s of all items that are currently selected. This property is not stored in the database. -
setPropertyFilter
Set a property filter. If a filter for the same property already exists it is replaced by the new filter. Note that each property may hold two filters, one primary and one temporary. Only primary filters are stored in the database. NOTE! Since BASE 3.20 it is not possible to set a filter for "itemSubtype" if that has been set bysetItemSubtype(ItemSubtype)
- Parameters:
filter
- The new property filter- See Also:
-
getPropertyFilter
Get a filter for a property on filter row 0.- See Also:
-
getPropertyFilter
Get a filter for a property. If the given property has a temporary filter, it is returned, otherwise it's primary filter is returned.- Parameters:
property
- The name of the propertyfilterRow
- The index of the filter row should be between 0 and number of filter rows (-1)- Returns:
- A
PropertyFilter
object or null if no filter exists - Since:
- 3.5
-
getPropertyFilters
Get a collection of all property filters stored in this context. The returned collection may contain both primary and temporary filters, but only one filter for each property.- Returns:
- A Collection containsing PropertyFilter objects or null
-
getPropertyFilters
Get a collection of all property filters stored in this context for a given filter row. The returned collection may contain both primary and temporary filters, but only one filter for each property.- Parameters:
filterRow
- The index of the filter row should be between 0 and number of filter rows (-1)- Returns:
- A Collection containsing PropertyFilter objects or null
- Since:
- 3.5
-
getNumPropertyFilters
public int getNumPropertyFilters()Get the total number of property filters stored in this context.- Since:
- 2.12
-
getNumPropertyFilters
public int getNumPropertyFilters(int filterRow) Get the number of property filters stored in this context for the given filter row.- Parameters:
filterRow
- The index of the filter row should be between 0 and number of filter rows (-1)- Since:
- 3.5
-
hasPropertyFilter
Checks if there is a filter for the given property regardless of filter row. Shortcut for checking each filter row at a time andgetPropertyFilter(String, int)
for non-null.- Parameters:
property
- The name of the property- Returns:
- TRUE if at least one filter exists, FALSE if not
- Since:
- 3.5
-
hasExtensionFilter
Checks if there is an extension filter with a property starting with !x.prefix.- Parameters:
prefix
- The extension prefix to check, or null to check any extension- Since:
- 3.18
-
getPropertyValue
Get the value of a property filter on row 0. NOTE! Since BASE 3.20 this method will return the id of the item subtype if one has been set and the property=itemSubtype. If this is not desired, callgetPropertyValue(String, int)
with row=0 instead.- See Also:
-
getPropertyValue
Get the value of a property filter on the given filter row. It is a shortcut forgetPropertyFilter(property, filterRow).getValue()
but also handles the case of a non-existing filter for the specfied property.- Parameters:
property
- The name of the propertyfilterRow
- The index of the filter row should be between 0 and number of filter rows (-1)- Returns:
- The value as a string
- Since:
- 3.5
-
removePropertyFilter
Remove a property filter on filter row 0.- See Also:
-
removePropertyFilter
Remove a property filter on the given filter row. This method will remove both a primary and a temporary filter.- Parameters:
property
- The name of the propertyfilterRow
- The index of the filter row should be between 0 and number of filter rows (-1)- Since:
- 3.5
-
removeTemporaryFilter
Remote a temporary filter for the given property on filter row 0.- Since:
- 2.16
- See Also:
-
removeTemporaryFilter
Remote a temporary filter for the given property. If a primary filter exists it will now be the effective filter.- Parameters:
property
- The name of the propertyfilterRow
- The index of the filter row should be between 0 and number of filter rows (-1)- Since:
- 3.5
-
getPropertyObject
-
removeAllPropertyFilters
Deprecated.In 3.20.1, useremoveAllPropertyFilters(AddFilter)
insteadRemove all property filters from this context. -
removeAllPropertyFilters
Remove all property filters from this context and optionally re-apply sub-category filter.- Since:
- 3.20.1
-
removeAllPropertyFilters
Remove all property filters for the given property.- Since:
- 3.20
-
removeAllTemporaryFilters
public void removeAllTemporaryFilters()Remove all temporary filters.- Since:
- 2.16
-
getFilterRestriction
Create a restriction from a property filter on filter row 0.- Since:
- 2.15
- See Also:
-
getFilterRestriction
public Restriction getFilterRestriction(String property, int filterRow, DbControl dc, EntityQuery query) Create a restriction from a property filter on the given filter row.- Parameters:
property
- The propertyfilterRow
- The index of the filter row should be between 0 and number of filter rows (-1)dc
- A DbControl that should be used if database access is neededquery
- The query that the filter is going to be used in (can be null for most properties)- Returns:
- A restriction, or null if no filter is active for the given property
- Since:
- 3.5
-
setRecent
Deprecated.In 3.15, usesetRecent(Item, BasicItem, int)
which support 'null' entriesAdd an item to the "recently used items" list. Each type of item has their own list which may contain at mostmaxInList
items.Note! The lists are stored as string of colon-separated ID:s in the setting given by the item type. For example the recently used protocols are found in the setting:
getSetting("PROTOCOL.recent")
. Client code is advised to not change these settings.- Parameters:
item
- The item to addmaxInList
- The maximum number of items in the list
-
setRecent
Add an item to the "recently used items" list. Each type of item has their own list which may contain at mostmaxInList
items.Note! The lists are stored as string of colon-separated ID:s in the setting given by the item type. For example the recently used protocols are found in the setting:
getSetting("PROTOCOL.recent")
. Client code is advised to not change these settings.- Parameters:
itemType
- The type of itemitem
- The item to add (or null to add a 'none' entry)maxInList
- The maximum number of items in the list
-
setRecent
Deprecated.In 3.15, usesetRecent(Item, BasicItem, ItemSubtype, int)
which support 'null' entries- Parameters:
item
- The item to addsubtype
- The subtype of the parent item (can be null)maxInList
- The maximum number of items in the list- Since:
- 3.0
-
setRecent
Add an item to the "recently used items" list when used for a specific item subtype. Each type of item+subtype has their own list which may contain at mostmaxInList
items.Note! The lists are stored as string of colon-separated ID:s in the setting given by the item type. For example the recently used protocols are found in the setting:
getSetting("PROTOCOL.#subtype-id.recent")
. Client code is advised to not change these settings.- Parameters:
itemType
- The type of itemitem
- The item to add (or null to add a 'none' entry)subtype
- The subtype of the parent item (can be null)maxInList
- The maximum number of items in the list- Since:
- 3.15
-
setRecent
Deprecated.In 3.15, usesetRecent(Item, BasicItem, String, int)
which support 'null' entries- Parameters:
item
- The item to addsubList
- The sublistmaxInList
- The maximum number of items in the list- Since:
- 2.5
-
setRecent
Add an item to the "recently used items" list. Each type of item has their own list and sublists which may contain at mostmaxInList
items.Note! The lists are stored as string of colon-separated ID:s in the setting given by the item type and sublist name. For example the recently used protocols are found in the setting:
getSetting("PROTOCOL.subList.recent")
. Client code is advised to not change these settings.- Parameters:
itemType
- The type of itemitem
- The item to add (or null to add a 'none' entry)subList
- The sublistmaxInList
- The maximum number of items in the list- Since:
- 3.15
-
setRecent
Add a value to the list of recently used values for the specified key. Each key has it's own list of values which may contain at mostmaxInList
values. If the value is already in the list it is moved to the front of the list.Note! The lists are stored as string of colon-separated ID:s in the setting given by the key. For example, if key is "RAWDATATYPE", the recently used values are found in the setting:
getSetting("RAWDATATYPE.recent")
. Client code is advised to not change these settings.- Parameters:
key
- The key to the listvalue
- The value to addmaxInList
- The maximum number of values in the list
-
getNumRecent
Get the number of recently used items in the list.- Parameters:
itemType
- The type of items
-
getNumRecent
Get the number of recently used items in the list.- Parameters:
itemType
- The type of itemssubtype
- The subtype of the parent item (can be null)- Since:
- 3.0
-
getNumRecent
Get the number of recently used items in a list with a sublist.- Parameters:
itemType
- The type of itemssubList
- The name of the sublist- Since:
- 2.5
-
getNumRecent
Get the number of recently used value in the list.- Parameters:
key
- The key to the list
-
getRecent
Get all recently used items of the specified type. The list only contains items that the logged in user has read permission to and that hasn't been deleted. Thus, thegetNumRecent(Item)
may return a larger number than what is actually returned in this list.- Parameters:
dc
- The DbControl used to access the databaseitemType
- The type of items- Returns:
- A list with the items (may contain null entries)
-
getRecent
Get all recently used items of the specified type. The list only contains items that the logged in user has read permission to and that hasn't been deleted. Thus, thegetNumRecent(Item, ItemSubtype)
may return a larger number than what is actually returned in this list.- Parameters:
dc
- The DbControl used to access the databaseitemType
- The type of itemssubtype
- The subtype of the parent item (can be null)- Returns:
- A list with the items (may contain null entries)
- Since:
- 3.0
-
getRecent
Get all recently used items of the specified type in a given sublist. The list only contains items that the logged in user has read permission to and that hasn't been deleted. Thus, thegetNumRecent(Item)
may return a larger number than what is actually returned in this list.- Parameters:
dc
- The DbControl used to access the databaseitemType
- The type of itemssubList
- The name of the sublist- Returns:
- A list with the items (may contain null entries)
- Since:
- 2.5
-
loadRecent
-
getRecent
-
getRecent
-
loadRecent
-
getRecent
Get all recently used values for the specified key. Changes to the list are not recorded in the database. UsesetRecent(String, String, int)
instead.- Parameters:
key
- The key to the list- Returns:
- A list containing the values or an empty list if no recently used value has been stored
-
getRecent
-
clearRecent
Clear the recently used items list from items of the specified type.- Parameters:
itemType
- The type of items
-
clearRecent
Clear the recently used items list from items of the specified type.- Parameters:
itemType
- The type of itemssubtype
- The subtype of the parent item (can be null)- Since:
- 3.0
-
clearRecent
Clear the recently used items sublist from items of the specified type.- Parameters:
itemType
- The type of itemssubList
- The name of the sublist
-
clearRecent
Clear the recently used values list.- Parameters:
key
- The key to the list
-
clearAllRecent
public void clearAllRecent()Clear all recently used values lists. -
getRecentSettingName
-
setRecent
-
getSetting
Get a value.- Parameters:
name
- The name of the value- Returns:
- The current value or null if no value exists
- See Also:
-
getSetting
Get a value from the settings or the default value if no current value exists.- Since:
- 3.18.2
-
setSetting
Set a value. This property is stored in the database.- Parameters:
name
- The name of the valuevalue
- The value- Returns:
- The old value or null if no old value existed.
- See Also:
-
removeSetting
Remove a value.- Parameters:
name
- The name of the value- Returns:
- The old value or null if no old value existed.
-
getObject
Get an object.- Parameters:
name
- The name of the value- Returns:
- The current value or null if no value exists
- See Also:
-
setObject
Set a value. This property is not stored in the database.- Parameters:
name
- The name of the valuevalue
- The value- Returns:
- The old value or null if no old value existed.
- See Also:
-
removeObject
Remove a value.- Parameters:
name
- The name of the value- Returns:
- The old value or null if no old value existed.
-
copyObjectsAndTemporaryFilters
Copies all objects and temporary filters from this context to another context.- Since:
- 3.6
-
getQuery
-
setQuery
-
setPropertyInspector
Set a filter for this context that is used to inspect which properties that are allowed to be used in queries. If a filter has been set theconfigureQuery(DbControl, EntityQuery, boolean)
andconfigureQuery(DbControl, SqlQuery, List)
methods will check each property before it is used for sorting, filtering, etc.- Parameters:
filter
- A filter or null to disable property inspection- Since:
- 3.1
-
configureQuery
public void configureQuery(DbControl dc, EntityQuery query, boolean autoLeftJoin) throws BaseException - Throws:
BaseException
-
configureQuery
public void configureQuery(DbControl dc, EntityQuery query, ClientContext context, boolean autoLeftJoin) throws BaseException Use the settings in this context to configure a query.Query.setReturnTotalCount(boolean)
is set to true.Query.setFirstResult(int)
andQuery.setMaxResults(int)
is set usinggetPage()
andgetRowsPerPage()
settings.- The
getSortProperty()
andgetSortDirection()
is used to sort the query. If the sort property starts with a dollar ($) sign it is interpreted as aalias.property
value, ignoring the root alias of the query. The sort property may contain multiple properties if they are separated by a comma. Each property may also be prefixed by a '+' (ASC) or '-' (DESC) to override the global sort direction. getInclude()
is used to setEntityQuery.include(Include[])
or @link EntityQuery#exclude(Include[])} options.- All property filters are added as
Restriction
:s to the query.
- Parameters:
dc
- The DbControl that will be used to execute the queryquery
- The query to configurecontext
- Optional ClientContext for filter extensions (if null, a context is automatically created if needed)autoLeftJoin
- If true, and the sort property and filters are checked for associations to other items, which are automatically left joined to the query (instead of the hibernate default of inner join) (this feature is experimental)- Throws:
BaseException
- If configuring the query fails.- Since:
- 3.18
-
copyFrom
Copy settings from another context to this context. Only settings which doesn't have been set in this context is copied from the other context, unless theforceAll
parameter is set. -
filterOnSelectedItems
Add a filter to the given query that restricts it to only return items that have been selected. If no items have been selected the query is not modified.- Parameters:
query
- The query to filter- Since:
- 2.17
-
configureQuery
public void configureQuery(DbControl dc, SqlQuery query, List<String> selectionList) throws BaseException Use the settings in this context to configure a dynamic query.AbstractQuery.setReturnTotalCount(boolean)
is set to true.AbstractQuery.setFirstResult(int)
andAbstractQuery.setMaxResults(int)
is set usinggetPage()
andgetRowsPerPage()
settings.
- Parameters:
dc
- A DbControl to use if the database needs to be accessedquery
- The query to configureselectionList
- A list of expression that we want to select from the query- Throws:
BaseException
- If the configuring the query fails.- Since:
- 3.1
-
getDynamicExpression
Create anExpression
from a string. If the string starts with:- %: The rest of the string is the channel number. We use the
Dynamic.column(VirtualColumn)
to create the expression forVirtualColumn.channelRaw(int)
- $: The rest of the string is a raw data property name. We use
the
Dynamic.rawData(String)
to create the expression. - @@: The rest of the string is a reporter property name. We use
the
Dynamic.reporter(String, Boolean)
with to create the expression. The second parameter is FALSE to force using the master reporter table. - @: The rest of the string is a reporter property name. We use
the
Dynamic.reporter(String)
to create the expression and let the query decide if it should use the cloned or master reporter table. - #: The rest of the string is the id of an extra value.
We use the
Dynamic.extraValue(ExtraValue)
to create the expression andDynamicSpotQuery.joinExtraValue(ExtraValue, JoinType)
to automatically join the extra values. - =: The rest of the string is JEP expression. It is converted
to an Expression by the
Jep.formulaToExpression(String, JepFunction[])
method.
Dynamic.column(VirtualColumn)
method:- POSITION:
VirtualColumn.POSITION
- COLUMN:
VirtualColumn.COLUMN
- Parameters:
dc
- A DbControl to use if the database needs to be accessedpropertyDef
- The string to use for creating the expression.- Returns:
- An expression object
- Since:
- 3.9.2
- %: The rest of the string is the channel number. We use the
-
getDynamicSelect
Same asgetDynamicExpression(DbControl, SqlQuery, String)
but generates a select object instead.- Parameters:
dc
- DbControl used to access the databasepropertyDef
- The string to use for creating the expression.- Returns:
- An Expression object.
- Since:
- 3.9.2
-
removeAllPropertyFilters(AddFilter)
instead