Class GenericStoreUtils


  • public class GenericStoreUtils
    extends Object
    This is where static generic methods for stores like searches live. These are horribly inefficient but sometimes there is no other way. The intent is that if you need to use these, they are centralized to prevent boiler plating.

    Created by Jeff Gaynor
    on 8/10/21 at 6:38 AM

    • Constructor Detail

      • GenericStoreUtils

        public GenericStoreUtils()
    • Method Detail

      • toXML

        public static XMLMap toXML​(Store store,
                                   Identifiable identifiable)
        Convert an identifiable object to an XMLMap. This is useful for serializing objects in the store, backing them up, etc.
        Parameters:
        store -
        identifiable -
        Returns:
      • fromXMLAndSave

        public static void fromXMLAndSave​(Store store,
                                          XMLMap map)
      • updateRS

        public static <V extends Identifiable> void updateRS​(Store<V> store,
                                                             List<Identifier> ids,
                                                             Map<String,​Object> values)
        Generic implementation of Store.updateRS(List, Map) and will loop through the elements doing the update one at a time. If the store has the capability at all for batch processing, implement it. This is for things like MemoryStores and FileStores that have no such ability. Note that part of the contract is that the element must exist and an exception is thrown of there is no such element.
        Parameters:
        store -
        ids -
        values -
      • update

        public static <V extends Identifiable> void update​(Store<V> store,
                                                           Map<? extends Identifier,​V> m)
        Implements Store.update(Map) for generic stores.This uses iteration and is not intended for large stores. If your store is large, use an SQLStore or one of its many and variegated subclasses.
        Parameters:
        store -
        m -