Class ItemModelCloneCreator.CopyContext

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void add​(ItemModelCloneCreator.CopyItem item)
      Adds a new (partOf) item copy wrapper to the context.
      void addPreset​(ItemModel 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.
      protected java.util.Collection<ItemModelCloneCreator.CopyItem> getAll()
      Returns all item copy wrappers.
      ItemModel getCopy​(ItemModel original)
      Returns copy for specified (partOf) source item.
      protected ItemModelCloneCreator.CopyItem getCopyWrapper​(ItemModel original)
      Returns associated copy wrapper for a given (partOf) source item
      java.util.Collection<ItemModelCloneCreator.CopyItem> getPendingItems()
      Returns all item wrappers which have not been copied or hold attributes which are not copied completely.
      protected java.lang.Object getPreset​(ItemModel src, java.lang.String qualifier)  
      protected java.util.Map<java.lang.String,​java.lang.Object> getPresets​(ItemModel src)
      Returns all preset values of a source item.
      ComposedTypeModel getTargetType​(ItemModel original)
      Tells which type should be used for creating a copy of the specified original item.
      protected boolean gotPreset​(ItemModel src, java.lang.String qualifier)
      Tells if a attribute got a preset value or not.
      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.
      boolean mustBeTranslated​(ItemModel original)
      Tells whether or not the item has been registered as (partOf) item to be copied.
      protected boolean skipAttribute​(java.lang.Object original, java.lang.String qualifier)
      tell us if attribute have to be skipped
      protected boolean treatAsPartOf​(java.lang.Object original, java.lang.String qualifier)
      tell us if attribute have to be treated as part of
      • Methods inherited from class java.lang.Object

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

      • CopyContext

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

        public CopyContext​(ModelCloningContext cloningContext)
        Creates a new copy context with cloning context
    • Method Detail

      • skipAttribute

        protected boolean skipAttribute​(java.lang.Object original,
                                        java.lang.String qualifier)
        tell us if attribute have to be skipped
      • treatAsPartOf

        protected boolean treatAsPartOf​(java.lang.Object original,
                                        java.lang.String qualifier)
        tell us if attribute have to be treated as part of
      • getTargetType

        public ComposedTypeModel getTargetType​(ItemModel original)
        Tells which type should be used for creating a copy of the specified original item. Default is simply using its current type.
      • addPreset

        public void addPreset​(ItemModel 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​(ItemModel src,
                                    java.lang.String qualifier)
        Tells if a attribute got a preset value or not.
      • getPresets

        protected java.util.Map<java.lang.String,​java.lang.Object> getPresets​(ItemModel src)
        Returns all preset values of a source item.
      • getPreset

        protected java.lang.Object getPreset​(ItemModel src,
                                             java.lang.String qualifier)
      • mustBeTranslated

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

        public ItemModel getCopy​(ItemModel 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<ItemModelCloneCreator.CopyItem> getPendingItems()
        Returns all item wrappers which have not been copied or hold attributes which are not copied completely.