Class GenericItem

    • Constructor Detail

      • GenericItem

        public GenericItem()
    • Method Detail

      • createItem

        protected Item createItem​(SessionContext ctx,
                                  ComposedType type,
                                  Item.ItemAttributeMap allAttributes)
                           throws JaloBusinessException
        Description copied from class: Item
        Has to be implemented for each concrete subtype of item. This method is responsible for creating a new item instance ( by calling managers, ejb homes, etc. ) during ComposedType.newInstance(Map).

        In case this method uses any of the attribute values during creation it is required to override Item.getNonInitialAttributes(SessionContext, ItemAttributeMap) too.
        Sn example:

        
         public static final String MY_ATTRIBUTE = "someAttribute"; ... protected Item createItem(SessionContext
         ctx, ComposedType type, Map allAttributes ) throws JaloBusinessException { MyManager man = ... return
         man.createMyItem( (String)allAttributes.get(MY_ATTRIBUTE) );
         // here MY_ATTRIBUTE is used for creation, so it must not be set again } protected Map getNonInitialAttributes(
         SessionContext ctx, Map allAttributes ) { // let superclass remove its own initial attributes Map ret =
         super.getNonInitialAttributes( ctx, allAttributes );
         // remove MY_ATTRIBUTE from all attributes since if has already been set ret.remove(MY_ATTRIBUTE); return ret; }
        
         
        Specified by:
        createItem in class Item
        Parameters:
        ctx - the current session context which this item is created within
        type - the actual item type ( since subtypes may not provide a own jalo class this may be different from the type which this method was implemented for )
        Returns:
        the new item instance
        Throws:
        JaloBusinessException - indicates an error during creation - any changes will be rollbacked
      • getInitialProperties

        protected JaloPropertyContainer getInitialProperties​(JaloSession jaloSession,
                                                             Item.ItemAttributeMap allAttributes)
        Override to specify all properties which should be written during ejbCreate. This way is is possible to implement non-null property fields ( means property fields which are written in SQL INSERT ). Properties which are set via Item.setNonInitialAttributes(SessionContext, Item, Item.ItemAttributeMap) are usually written by additional SQL UPDATE statements.
         protected JaloPropertyContainer getInitialProperties(ItemAttributeMap allAttributes)
         {
                JaloPropertyContainer cont = jaloSession.createPropertyContainer();
                cont.setProperty("key", (Serializable) allAttributes.get("myKey"));
                return cont;
         }
         

        The default implementation collects all initial properties (localized and unlocalized ones), which were registered by calling allAttributes.setAttributeMode( MYPROPERTY, Item.AttributeMode.INITIAL ); inside MyType#createItem( SessionContext , ComposedType , Item.ItemAttributeMap ).

        Parameters:
        jaloSession - the jalo session which the new item is create within
        allAttributes - the attribute values of the new item
      • getRelatedItems

        public <T extends Item> java.util.Collection<T> getRelatedItems​(java.lang.String relationQualifier)
        Description copied from class: Item
        Internal method to directly return related items linked by the One To Many relation. Its purpose is to allow the underlying persistence to intercept this call and handle it in a more efficient way.
        Overrides:
        getRelatedItems in class Item
        Parameters:
        relationQualifier - name of the attribute seen from the One end of the relation.
        Returns:
        the collection of related items or null if direct access is not supported by the underlying persistence layer.
      • setRelatedItems

        public <T extends Item> boolean setRelatedItems​(java.lang.String relationQualifier,
                                                        java.util.Collection<T> values)
        Description copied from class: Item
        Internal method to directly set related items linked by the One To Many relation. Its purpose is to allow the underlying persistence to intercept this call and handle it in a more efficient way.
        Overrides:
        setRelatedItems in class Item
        Parameters:
        relationQualifier - name of the attribute seen from the One end of the relation.
        values - collection of Items to be set.
        Returns:
        false if operation is not supported by the underlying persistence layer.