Class EJBTools


  • public abstract class EJBTools
    extends java.lang.Object
    tools that are useful when writing own EJBs for the hybris system.
    • Constructor Summary

      Constructors 
      Constructor Description
      EJBTools()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String addPKToPKCollectionString​(java.lang.String pkCollectionString, PK pk)  
      static java.lang.Object convertEntityFinderResult​(java.lang.Object finderResult, SystemEJB sys)
      converts the result of a EJBHome finder method (findXY) from s to real Entities
      static java.lang.String convertFromDatabase​(java.lang.String databaseString)
      utility function to cope with behaviour of Oracle, with cannot distinguish between null and empty strings
      static java.lang.String convertToDatabase​(java.lang.String realString)
      utility function to cope with behaviour of Oracle, with cannot distinguish between null and empty strings
      static ItemPropertyValue createItemPropertyValue​(ItemRemote item)  
      static ItemPropertyValueCollection getCollectionFromString​(java.lang.String value)  
      static PK getPK​(ItemRemote remote)  
      static java.util.List<java.lang.String> getPKCollection​(java.lang.String pks)  
      static java.lang.String getPKCollectionString​(java.util.Collection items)
      Converts a collection of Items to a String with comma-seperated PKs.
      static java.lang.String getPKInLIKEFragment​(ItemRemote remote)
      Returns a SQL LIKE fragment which should be used to find a single remote object within a pk collection string (@see #getPKCollectionString(Collection)}.
      static java.util.List instantiateCommaSeparatedPKString​(java.lang.String pks)
      Creates a Collection of EJBObject from a given String with comma seperated PKs.
      Use this method from inside a bean if you want to get a List of existing EJBObjects from a comma seperated PK String.
      If the String was null, a null is returned If the String was en empty string, an empty collection is returned if one of the EJBObjects could not be found, a warning is printed to the System.err stream and the resulting collection will not contain this EJBObject.
      static java.util.List instantiateCommaSeparatedPKString​(java.lang.String pks, boolean ignoreNull)
      Creates a Collection of EJBObject from a given String with comma seperated PKs.
      Use this method from inside a bean if you want to get a List of existing EJBObjects from a comma seperated PK String.
      If the String was null, a null is returned or an empty collection if ignoreNull was set to true .
      static ItemRemote instantiateItemPropertyValue​(ItemPropertyValue ipv)  
      static java.util.Collection instantiateItemPropertyValueCollection​(java.util.Collection ipvs)  
      static ItemRemote instantiatePK​(PK pk)  
      static java.util.List instantiatePKCollection​(java.util.Collection<PK> pks)
      Creates a Collection of EJBObject from a given Collection of EJB PK String.
      Use this method from inside a bean if you want to get a List of existing EJBObjects from a given Collection of PK.
      If the PK-Collection was null, a null is returned if one of the EJBObjects could not be found, a warning is printed to the System.err stream and the resulting collection will not contain this EJBObject.
      static void removeAllRowsFromTable​(java.lang.String tablename)  
      static void removeBeanCollection​(java.util.Collection<? extends ItemRemote> c)
      Removes a collection of ItemRemotes.
      static java.util.List<PK> toPKList​(java.util.Collection items)
      Converts a collection of Items, ItemRemotes or ItemPropertyValues to a Collection of PKs.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ITEMCOLLECTION_TYPE_MARKER

        public static final java.lang.String ITEMCOLLECTION_TYPE_MARKER
      • EMPTY_PK_COLLECTION_STRING

        public static final java.lang.String EMPTY_PK_COLLECTION_STRING
    • Constructor Detail

      • EJBTools

        public EJBTools()
    • Method Detail

      • removeBeanCollection

        public static void removeBeanCollection​(java.util.Collection<? extends ItemRemote> c)
        Removes a collection of ItemRemotes.

      • removeAllRowsFromTable

        public static void removeAllRowsFromTable​(java.lang.String tablename)
      • instantiatePK

        public static final ItemRemote instantiatePK​(PK pk)
      • instantiateItemPropertyValue

        public static ItemRemote instantiateItemPropertyValue​(ItemPropertyValue ipv)
        Parameters:
        ipv - may be null, will return null
      • instantiateItemPropertyValueCollection

        public static java.util.Collection instantiateItemPropertyValueCollection​(java.util.Collection ipvs)
      • createItemPropertyValue

        public static ItemPropertyValue createItemPropertyValue​(ItemRemote item)
        Parameters:
        item - may be null, will return null
      • instantiatePKCollection

        public static java.util.List instantiatePKCollection​(java.util.Collection<PK> pks)
        Creates a Collection of EJBObject from a given Collection of EJB PK String.
        Use this method from inside a bean if you want to get a List of existing EJBObjects from a given Collection of PK.
        • If the PK-Collection was null, a null is returned
        • if one of the EJBObjects could not be found, a warning is printed to the System.err stream and the resulting collection will not contain this EJBObject.
      • instantiateCommaSeparatedPKString

        public static java.util.List instantiateCommaSeparatedPKString​(java.lang.String pks)
        Creates a Collection of EJBObject from a given String with comma seperated PKs.
        Use this method from inside a bean if you want to get a List of existing EJBObjects from a comma seperated PK String.
        • If the String was null, a null is returned
        • If the String was en empty string, an empty collection is returned
        • if one of the EJBObjects could not be found, a warning is printed to the System.err stream and the resulting collection will not contain this EJBObject.
      • instantiateCommaSeparatedPKString

        public static java.util.List instantiateCommaSeparatedPKString​(java.lang.String pks,
                                                                       boolean ignoreNull)
        Creates a Collection of EJBObject from a given String with comma seperated PKs.
        Use this method from inside a bean if you want to get a List of existing EJBObjects from a comma seperated PK String.
        • If the String was null, a null is returned or an empty collection if ignoreNull was set to true .
        • If the String was en empty string, an empty collection is returned
        • if one of the EJBObjects could not be found, a warning is printed to the System.err stream and the resulting collection will not contain this EJBObject.
      • getPKInLIKEFragment

        public static java.lang.String getPKInLIKEFragment​(ItemRemote remote)
        Returns a SQL LIKE fragment which should be used to find a single remote object within a pk collection string (@see #getPKCollectionString(Collection)}.
      • toPKList

        public static java.util.List<PK> toPKList​(java.util.Collection items)
        Converts a collection of Items, ItemRemotes or ItemPropertyValues to a Collection of PKs.

        • if the collection is null, a null is returned.
        • If the collection is empty, an empty collection is returned.
        • If a pk could not be retrieved due to an exception in getPrimaryKey() a EJBSystemException is thrown.
      • getPKCollectionString

        public static java.lang.String getPKCollectionString​(java.util.Collection items)
        Converts a collection of Items to a String with comma-seperated PKs.

        • If the collection is null, a null is returned.
        • If the collection is empty, the string "," is returned.
        • If a pk could not be retrieved due to an exception in getPrimaryKey() a EJBSystemException is thrown.
      • addPKToPKCollectionString

        public static java.lang.String addPKToPKCollectionString​(java.lang.String pkCollectionString,
                                                                 PK pk)
      • getPKCollection

        public static java.util.List<java.lang.String> getPKCollection​(java.lang.String pks)
        Returns:
        A collection of primary key strings, which has been build from a comma separated list in parameter pks.
      • convertToDatabase

        public static java.lang.String convertToDatabase​(java.lang.String realString)
        utility function to cope with behaviour of Oracle, with cannot distinguish between null and empty strings
        See Also:
        convertFromDatabase(java.lang.String)
      • convertFromDatabase

        public static java.lang.String convertFromDatabase​(java.lang.String databaseString)
        utility function to cope with behaviour of Oracle, with cannot distinguish between null and empty strings
        See Also:
        convertToDatabase(java.lang.String)
      • convertEntityFinderResult

        public static java.lang.Object convertEntityFinderResult​(java.lang.Object finderResult,
                                                                 SystemEJB sys)
                                                          throws YFinderException
        converts the result of a EJBHome finder method (findXY) from s to real Entities
        Parameters:
        finderResult - the finder result
        Returns:
        the entity or collection of entities
        Throws:
        YFinderException