Class SyncFilter

    • Method Detail

      • getQuery

        public static ItemQuery<SyncFilter> getQuery​(ItemList list)
        Get a query configured to retrieve sync filters for the specified item list.
        Parameters:
        list - The item list, null is not allowed
        Returns:
        An ItemQuery object
      • compareByChainOrder

        public static Comparator<SyncFilter> compareByChainOrder()
        Create a comparator that sorts sync filters by: Filter group 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
      • getType

        public Item getType()
        Description copied from interface: Identifiable
        Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.
        Specified by:
        getType in interface Identifiable
        Returns:
        A value indicating the type of item
      • getName

        public String getName()
        Description copied from interface: Nameable
        Get the name of the item.
        Specified by:
        getName in interface Nameable
        Returns:
        A String with the name of the item
      • getDescription

        public String getDescription()
        Description copied from interface: Nameable
        Get the description for the item.
        Specified by:
        getDescription in interface Nameable
        Returns:
        A String with a description of the item
      • setSyncContext

        public void setSyncContext​(ItemContext syncContext,
                                   SyncFilter.SourceItemTransform transform)
        Copy filters and other settings from the given context to this synchronization filter. This changes the source item type (getSourceItemType()), transform (getSourceItemTransformation()) and replaces all existing filters with the filters from the item context.
        Parameters:
        syncContext - The context to copy from, or null to only update the transform
        transform - The new transformation or null to keep the current transformation
      • copyToContext

        public void copyToContext​(ItemContext context)
        Copy the filter settings in this synchronization filter to the given item context. All filter settings in the item context are replaced with this filter. The context must be for the same item type as the source item type of this filter.
      • getFilterGroup

        public String getFilterGroup()
        Get the group this synchronization filter belongs to. The group is a string where the first character is one of A-Z followed by a '+' or '-' sign. Filters that belong to the same group are evaluated together and then merged with UNION operation (for groups with '+' sign) or REMOVE operation (for groups with '-' sign). Groups are processed in alphabetical order (A+, A-, B+, B-, .... Z+, Z-)
        Since:
        3.18
      • setFilterGroup

        public void setFilterGroup​(String filterGroup)
        Set the group that this synchronization filter belongs to. See getFilterGroup() for a description of allowed values.
        Since:
        3.18
      • getSourceItemType

        public Item getSourceItemType()
        Get the source item type that this synchronization filter applies to. This may or may not be the same item type as the member type of the list. If this type is different from the list member type an item transformation is required, but a transformation can also be used for items of the same type.
      • getSourceItemTransformation

        public SyncFilter.SourceItemTransform getSourceItemTransformation()
        Get the transformation to use for converting the items matching this filter to list members.
      • getSourceItemMustExist

        public boolean getSourceItemMustExist()
        If set, a source item that matches the filter must exist, otherwise it must not exist. Only applies to filters with a source item transformation that is to a parent/child item.
      • setSourceItemMustExist

        public void setSourceItemMustExist​(boolean sourceMustExist)
      • isDisabled

        public boolean isDisabled()
        If set, this filter is disabled and is not used when syncing.
      • setDisabled

        public void setDisabled​(boolean disabled)
        Disabled/enable this filter.
      • getLastSyncMatchingSource

        public int getLastSyncMatchingSource()
        Get the number of source items that matched this particular filter during the last synchronization. See ItemList.getSyncDate().
        Returns:
        The number of matching source items, or -1 if not known
      • getLastSyncMatchingTransformed

        public int getLastSyncMatchingTransformed()
        Get the number of transformed items that matched this particular filter during the last synchronization. See ItemList.getSyncDate(). If this filter doesn't use a transform the same number as getLastSyncMatchingSource() is returned.
        Returns:
        The number of matching transformed items, or -1 if not known
      • getCurrentMatchingSource

        public int getCurrentMatchingSource​(DbControl dc)
        Get the number of items that is currently matching this filter. The method will cause a query to be executed against the database, but the result is cached and re-used if called multiple times.
      • isInSync

        public 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. The check is done by comparing the MD5 sum of the concatenated ID values.
      • getFilterRows

        public int getFilterRows()
        Get the number of filter rows in this filter.
      • getPropertyFilters

        public Collection<PropertyFilter> getPropertyFilters​(int filterRow)
        Get the filters in the given filter row.
        Parameters:
        filterRow - The index of the filter row which should be between 0 and number of rows - 1, or use -1 to get all property filters
      • initFilters

        private void initFilters()
      • getListMemberType

        private Item getListMemberType()
      • toMd5

        public static String toMd5​(SortedSet<Integer> listOfIds)
        Calculate the MD5 sum of all all ID values in the collection. Each ID is converted to a 4-byte array and added to the MD5 by 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.
      • getSyncProperties

        static String getSyncProperties​(ItemListSyncFilterData sf)
        Get a string representing the current syncfilter properties that may affect the end result even if the query return the same items. We save this string at sync time and can then compare it with current settings to se if the item list seems to be up to date.
        Since:
        3.18