Class PropertyJDBC


  • public final class PropertyJDBC
    extends java.lang.Object
    this class reads and writes new style (typed) properties via JDBC
    • Constructor Detail

      • PropertyJDBC

        public PropertyJDBC()
    • Method Detail

      • cutStringToByteLength

        public static java.lang.String cutStringToByteLength​(java.lang.String str,
                                                             int max)
        truncates a string to a certain byte length. is assumes that each non-ascii character takes 2 bytes space which is considered for how much has to be cut off.
        Parameters:
        max - the allowed max byte length
      • preloadLocalizedProperties

        public static void preloadLocalizedProperties​(java.util.Set<PK> langPKs,
                                                      java.util.Collection<LocalizableItemRemote> _items)
      • getProperties

        public static EJBPropertyRowCache getProperties​(TypeInfoMap infoMap,
                                                        PK itemPK,
                                                        PK typePK,
                                                        PK langPK,
                                                        long timestamp)
        reads all unlocalized or localized properties of one language for a specified item in a property cache object.
        Parameters:
        itemPK - the PK of the item these properties belong to
        typePK - the item type - this is needed to get the correct TypeInfoMap
        langPK - the language PK of the properties, or null for unlocalized properties
        timestamp - the property timestamp of the item - the propert cache uses this to check later if it is uptodate
      • updatePropertyTypePKs

        public static void updatePropertyTypePKs​(TypeInfoMap infoMap,
                                                 PK itemPK,
                                                 PK newTypePK)
        changes all property data rows of one item to the new type pk. this will not invalidate any of its property caches - so make sure they are reloaded when the type has changed
      • writeProperties

        public static void writeProperties​(EJBPropertyRowCache prc,
                                           PK itemPK,
                                           PK typePK,
                                           TypeInfoMap infoMap,
                                           boolean localized)
        saves all changed properties of one property cache.
        Parameters:
        prc - the (modified) property cache
        infoMap - provides the correct columns and value classes for these properties
      • getChangeData

        public static java.util.List<java.lang.Object>[] getChangeData​(java.sql.Connection con,
                                                                       TypeInfoMap infoMap,
                                                                       EJBPropertyRowCache prc,
                                                                       boolean localized)
                                                                throws java.sql.SQLException
        for a modified property cache this puts together the list of columns, values and value classes. use these to build and fill you SQL statements.
        Parameters:
        infoMap - provides column names and value classes for properties
        prc - the modified property cache
        localized - tells if localized or unlocalized properties should be written - used for checking correctness of data
        con - the database connection
        Returns:
        ([column - name, value, ValueWriter ])
        Throws:
        java.sql.SQLException
      • removeAllPropertyData

        public static void removeAllPropertyData​(PK itemPK,
                                                 PK typePK)
        removes all property rows for a item.
        Parameters:
        itemPK - the item to remove properties for
        typePK - used for getting the correct TypeInfoMap
      • readPropertyRow

        public static EJBPropertyRowCache readPropertyRow​(java.sql.ResultSet rs,
                                                          PK itemPK,
                                                          PK itemTypePK,
                                                          PK langPK,
                                                          long timestamp,
                                                          TypeInfoMap infoMap)
                                                   throws java.sql.SQLException
        Throws:
        java.sql.SQLException