Class ItemCloneCreator.CopyContext

    • Constructor Detail

      • CopyContext

        public CopyContext()
        Creates a new copy context.
    • Method Detail

      • addCopyUntypedPropsFor

        public void addCopyUntypedPropsFor​(Item sourceItem)
        Switches on copying of untyped properties for the specified item. While creating a copy of the specified item all untyped properties are copied as well.
        Parameters:
        sourceItem - the original item to copy props from
      • addCopyUntypedPropsFor

        public void addCopyUntypedPropsFor​(java.util.Collection<Item> sourceItems)
        Switches on copying of untyped properties for the specified items. While creating copies of the specified items all untyped properties are copied as well.
        Parameters:
        sourceItems - the original items to copy props from
      • addPreset

        public void addPreset​(Item srcItem,
                              java.lang.String qualifier,
                              java.lang.Object value)
        Defines a attribute value to be used when creating a copy instead of the original attribute value.

        Example:

         Media original = ...
         ItemCloneCreator creator = new ItemCloneCreator();
         CopyContext ctx = new CopyContext();
         ctx.addPreset( original, Media.CODE, original.getCode()+"(copy") );
         Media copy = creator.copy( original, ctx );
         

        Since you may specify multiple source items it's possible to add preset values for partOf items as well.

        Parameters:
        srcItem - the source item which is used for copying
        qualifier - the attribute qualifier
        value - the value to use
      • gotPreset

        protected boolean gotPreset​(Item src,
                                    java.lang.String qualifier)
      • getPresets

        protected java.util.Map<java.lang.String,​java.lang.Object> getPresets​(Item src)
      • mustBeTranslated

        public boolean mustBeTranslated​(Item original)
        Tells whether or not the item has been registered as (partOf) item to be copied.
        Parameters:
        original - the item to check
      • getCopy

        public Item getCopy​(Item original)
        Returns copy for specified (partOf) source item.
        Parameters:
        original -
        Returns:
        the copy item or null if it hasn't been copied yet
        Throws:
        java.lang.IllegalArgumentException - if item is not registered as (partOf) item to be copied
      • hasPendingItems

        public boolean hasPendingItems()
        Tells whether or not the context contains (partOf) items witch are not copied yet or have attributes which have not been copied completely.
      • getPendingItems

        public java.util.Collection<ItemCloneCreator.CopyItem> getPendingItems()
        Returns all item wrappers which have not been copied or hold attributes which are not copied completely.