public class SyncFilter extends ChildItem implements Nameable
Modifier and Type | Class and Description |
---|---|
static class |
SyncFilter.SourceItemTransform |
Modifier and Type | Field and Description |
---|---|
private static List<Item> |
CHAIN_ORDER |
private List<PropertyFilter> |
filters |
private Item |
listMemberType |
private SortedSet<Integer> |
matching |
private int |
numFilterRows |
private static List<SyncFilter.SourceItemTransform> |
TRANSFORM_ORDER |
static Item |
TYPE
The type of item represented by this class.
|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH
Constructor and Description |
---|
SyncFilter(ItemListSyncFilterData syncFilter) |
Modifier and Type | Method and Description |
---|---|
static Comparator<SyncFilter> |
compareByChainOrder()
Create a comparator that sorts sync filters by:
Source item type: BIOSOURCE, SAMPLE, EXTRACT, PHYSICALBIOASSAY, DERIVEDBIOASSAY, RAWBIOASSAY
Type of transformation: PARENT_TO_CHILD, NONE, CHILD_TO_PARENT
Name
Source item must exists is sorted before source item must not exist
Id
|
void |
copyToContext(ItemContext context)
Copy the filter settings in this synchronization filter to
the given item context.
|
static SyncFilter |
getById(DbControl dc,
int id)
Get a
SyncFilter item when you know the id. |
int |
getCurrentMatchingSource(DbControl dc)
Get the number of items that is currently matching this filter.
|
(package private) ItemListSyncFilterData |
getData()
Get the
BasicData object that holds all data for this item. |
String |
getDescription()
Get the description for the item.
|
int |
getFilterRows()
Get the number of filter rows in this filter.
|
static List<String> |
getFormattedAndSortedFilters(Collection<PropertyFilter> filters,
Formatter<PropertyFilter> filterFormatter)
Utility method for formatting and sorting a list of property filters.
|
ItemList |
getItemList()
Get the item list this filter belongs to.
|
int |
getLastSyncMatchingSource()
Get the number of source items that matched this particular filter during the last
synchronization.
|
int |
getLastSyncMatchingTransformed()
Get the number of transformed items that matched this particular filter during the last
synchronization.
|
private Item |
getListMemberType() |
private SortedSet<Integer> |
getMatching(DbControl dc) |
String |
getName()
Get the name of the item.
|
Collection<PropertyFilter> |
getPropertyFilters(int filterRow)
Get the filters in the given filter row.
|
static ItemQuery<SyncFilter> |
getQuery(ItemList list)
Get a query configured to retrieve
sync filters for the specified item list.
|
(package private) SharedData |
getSharedParent()
Get the shareable parent item of this child item.
|
boolean |
getSourceItemMustExist()
If set, a source item that matches the filter must exist, otherwise it must
not exist.
|
SyncFilter.SourceItemTransform |
getSourceItemTransformation()
Get the transformation to use for converting the items matching
this filter to list members.
|
Item |
getSourceItemType()
Get the source item type that this synchronization filter applies to.
|
Item |
getType()
Get the type of item represented by the object.
|
private void |
initFilters() |
boolean |
isDisabled()
If set, this filter is disabled and is not used when syncing.
|
boolean |
isInSync(DbControl dc)
Checks if the items that are currently matching this filter are
the same as the items that matched it during the last sync.
|
void |
setDescription(String description)
Set the description for the item.
|
void |
setDisabled(boolean disabled)
Disabled/enable this filter.
|
void |
setName(String name)
Set the name of the item.
|
void |
setSourceItemMustExist(boolean sourceMustExist) |
void |
setSyncContext(ItemContext syncContext,
SyncFilter.SourceItemTransform transform)
Copy filters and other settings from the given context
to this synchronization filter.
|
(package private) static String |
toMd5(SortedSet<Integer> listOfIds)
Calculate the MD5 sum of all all ID values in the collection.
|
getPermissionForUse, getPermissionForWriteDeleteAndCreate, getPluginPermissions, initPermissions
addAnnotatableParents, addUsingItems, addUsingItems, checkPermission, equals, getBasicData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getId, getVersion
checkPermission, getPermissions, hasPermission
public static final Item TYPE
Item.SYNCFILTER
,
getType()
private static final List<SyncFilter.SourceItemTransform> TRANSFORM_ORDER
private Item listMemberType
private List<PropertyFilter> filters
private int numFilterRows
SyncFilter(ItemListSyncFilterData syncFilter)
public static SyncFilter getById(DbControl dc, int id) throws ItemNotFoundException, PermissionDeniedException, BaseException
SyncFilter
item when you know the id.dc
- The DbControl
which will be used for
permission checking and database access.id
- The id of the item to loadSyncFilter
itemItemNotFoundException
- If an item with the specified
id is not foundPermissionDeniedException
- If the logged in user doesn't
have Permission.READ
permission to the itemBaseException
- If there is another errorpublic static ItemQuery<SyncFilter> getQuery(ItemList list)
list
- The item list, null is not allowedItemQuery
objectpublic static List<String> getFormattedAndSortedFilters(Collection<PropertyFilter> filters, Formatter<PropertyFilter> filterFormatter)
PropertyFilterFormatter
public static Comparator<SyncFilter> compareByChainOrder()
ItemListSyncFilterData getData()
BasicItem
BasicData
object that holds all data for this item.public Item getType()
Identifiable
Item
enumeration.getType
in interface Identifiable
SharedData getSharedParent()
ChildItem
ChildItem.initPermissions(int, int)
method to calculate
the logged in user's permissions for the child item.getSharedParent
in class ChildItem
public String getName()
Nameable
public void setName(String name) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_NAME_LENGTH
constant.setName
in interface Nameable
name
- The new name for the itemPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the name is null or longer
than specified by the Nameable.MAX_NAME_LENGTH
constantpublic String getDescription()
Nameable
getDescription
in interface Nameable
String
with a description of the itempublic void setDescription(String description) throws PermissionDeniedException, InvalidDataException
Nameable
Nameable.MAX_DESCRIPTION_LENGTH
constant.setDescription
in interface Nameable
description
- The new description for the itemPermissionDeniedException
- If the logged in user doesn't
have write permissionInvalidDataException
- If the description longer
than specified by the Nameable.MAX_DESCRIPTION_LENGTH
constantpublic ItemList getItemList() throws PermissionDeniedException, BaseException
SyncFilter
itemPermissionDeniedException
- If the logged in user doesn't have
Permission.READ
permissionBaseException
- If there is another errorpublic void setSyncContext(ItemContext syncContext, SyncFilter.SourceItemTransform transform)
getSourceItemType()
),
transform (getSourceItemTransformation()
)
and replaces all existing filters with the filters from the
item context.syncContext
- The context to copy from, or null to only update the transformtransform
- The new transformation or null to keep the current transformationpublic void copyToContext(ItemContext context)
public Item getSourceItemType()
public SyncFilter.SourceItemTransform getSourceItemTransformation()
public boolean getSourceItemMustExist()
public void setSourceItemMustExist(boolean sourceMustExist)
public boolean isDisabled()
public void setDisabled(boolean disabled)
public int getLastSyncMatchingSource()
ItemList.getSyncDate()
.public int getLastSyncMatchingTransformed()
ItemList.getSyncDate()
. If this filter
doesn't use a transform the same number as getLastSyncMatchingSource()
is returned.public int getCurrentMatchingSource(DbControl dc)
public boolean isInSync(DbControl dc)
public int getFilterRows()
public Collection<PropertyFilter> getPropertyFilters(int filterRow)
filterRow
- The index of the filter row which should be between 0 and number of rows - 1, or use -1 to
get all property filtersprivate void initFilters()
private Item getListMemberType()
static String toMd5(SortedSet<Integer> listOfIds)
MessageDigest.update(byte[])
The list is assumed to be sorted in ID order so that
if two collections contain the same ID values, they
should produce the same MD5.