Class FeatureContainer

java.lang.Object
de.hybris.platform.catalog.jalo.classification.util.FeatureContainer
All Implemented Interfaces:
Serializable, Cloneable

@Deprecated(since="ages", forRemoval=false) public class FeatureContainer extends Object implements Cloneable, Serializable
Deprecated.
since ages - useFeatureList instead.
Container object for all features of a specified product. It ensures that no duplicate features are added and provides easy persistence logic.

Loading and storing of features is done like this:

        FeatureContainer typed = FeatureContainer.loadTyped( myProduct );

        Feature f = all.getFeature("MyClass.myTextAttr");
        FeatureValue v = f.get( 0 );
        v.setDescription("Some Text here");

        Feature f2 = all.getFeature("MyClass.myNumberAttr");
    FeatureValue newOne = f2.createValue( new Double(1.234) );
    newOne.setClassificationUnit( myUnit );

    all.store();

    // or if just features of one class should be managed
    ClassificationClass myClass = ...
    FeatureContainer cont = featureContainer.loadTyped( p, myClass );
    // ... make changed
    cont.store();
 
See Also:
  • Field Details

    • WITHIN_FEATURE_CONTAINER_TRANSACTION

      public static final String WITHIN_FEATURE_CONTAINER_TRANSACTION
      Deprecated.
      See Also:
  • Constructor Details

    • FeatureContainer

      protected FeatureContainer(Product product, List<ClassAttributeAssignment> classAssignments)
      Deprecated.
      Creates a new feature container with exactly specified class-attribute mappings. This way it is possible to manage even subsets of class attributes.
      Parameters:
      product - the product owning the features
      classAssignments - the class-attribute assignments which should be manageable by this container
    • FeatureContainer

      protected FeatureContainer(FeatureContainer src) throws CloneNotSupportedException
      Deprecated.
      Copy constructor. Don't use directly.
      Throws:
      CloneNotSupportedException
  • Method Details

    • isInFeatureContainerTA

      public static final boolean isInFeatureContainerTA(SessionContext ctx)
      Deprecated.
    • toString

      public String toString()
      Deprecated.
      Overrides:
      toString in class Object
    • getAssignmentsInternal

      protected Set<ClassAttributeAssignment> getAssignmentsInternal()
      Deprecated.
    • create

      public static FeatureContainer create(Product product)
      Deprecated.
      Creates an empty product feature container. Depending upon whether or not the product actually is classified (see CatalogManager.getClassificationClasses(Product) ) this method returns a container covering all its classification classes - otherwise it will include untyped features only!

      Please note that the container is neither loaded from the database not does it check whether or not features are existing for the given product!

      Parameters:
      product - the product to create a new container for
      Returns:
      the new container
    • createTyped

      public static FeatureContainer createTyped(Product product, Set<ClassificationClass> classes) throws JaloInvalidParameterException
      Deprecated.
      Creates an empty product feature container which is able to handle all features for the specified set of classification classes. In case the product is actually assigned to other classes as well this container wont change their values.

      Please note that the container is neither loaded from the database not does it check whether or not features are existing for the given product!

      Parameters:
      product - the product to create a new container for
      classes - the set of classification classes which this container should support
      Returns:
      the new container
      Throws:
      JaloInvalidParameterException - if now classes are provided
    • createTyped

      public static FeatureContainer createTyped(Product product, List<ClassAttributeAssignment> assignments) throws JaloInvalidParameterException
      Deprecated.
      Creates an empty product feature container which is able to handle all features for the specified set of classification attribute assignments. In case the product is actually assigned to other classes as well this container wont change their values.

      Please note that the container is neither loaded from the database not does it check whether or not features are existing for the given product!

      Parameters:
      product - the product to create a new container for
      assignments - the set of classification classes which this container should support
      Returns:
      the new container
      Throws:
      JaloInvalidParameterException - if now classes are provided
    • createUntyped

      public static FeatureContainer createUntyped(Product product)
      Deprecated.
      Creates an empty product feature container which will only handle feature values which are not associated with a classification class. In case the product is actually assigned to other classes as well this container wont change their values.

      Please note that the container is neither loaded from the database not does it check whether or not features are existing for the given product!

      Parameters:
      product - the product to create a new container for
      Returns:
      the new container
    • load

      public static FeatureContainer load(Product product)
      Deprecated.
      Loads all features for a given product from existing ProductFeature items. The container may either be typed or untyped depending upon whether or not the product has been assigned to classification classes or not.

      To assure the correct type of features please use methods like loadTyped(Product) or loadUntyped(Product) instead.

      Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!

      Parameters:
      product - the product to load features for
      Returns:
      a new feature container
    • loadTyped

      public static FeatureContainer loadTyped(Product product) throws JaloInvalidParameterException
      Deprecated.
      Loads all typed features of the given product according to the classification classes it has been assigned to.

      Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!

      Parameters:
      product - the product to load a feature container for
      Returns:
      the new container
      Throws:
      JaloInvalidParameterException - if the product is not classified at all
    • removeAllTypedValues

      public static void removeAllTypedValues(Product product) throws JaloInvalidParameterException
      Deprecated.
      Shortcut for removing all typed values.
      Parameters:
      product - the product to remove all values for
      Throws:
      JaloInvalidParameterException - if the product is not classified at all
    • loadTyped

      public static FeatureContainer loadTyped(Product product, Set<ClassificationClass> classes) throws JaloInvalidParameterException
      Deprecated.
      Loads all typed features of the given product according to the classification classes specified.

      Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!

      Parameters:
      product - the product to load a feature container for
      classes - the classification classes to manage features for
      Returns:
      the new container
      Throws:
      JaloInvalidParameterException - if no classes are provided
    • loadTyped

      public static FeatureContainer loadTyped(Product product, ClassAttributeAssignment... assignments) throws JaloInvalidParameterException
      Deprecated.
      Loads all typed features of the given product according to the classification attribute assignments specified.

      Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!

      Parameters:
      product - the product to load a feature container for
      assignments - the class attribute assignments to manage features for
      Returns:
      the new container
      Throws:
      JaloInvalidParameterException - if no assignments are provided
    • loadTyped

      public static FeatureContainer loadTyped(Product product, List<ClassAttributeAssignment> assignments) throws JaloInvalidParameterException
      Deprecated.
      Loads all typed features of the given product according to the classification attribute assignments specified.

      Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!

      Parameters:
      product - the product to load a feature container for
      assignments - the class attribute assignments to manage features for
      Returns:
      the new container
      Throws:
      JaloInvalidParameterException - if no assignments are provided
    • removeAllTypedValues

      public static void removeAllTypedValues(Product product, Set<ClassificationClass> classes) throws JaloInvalidParameterException
      Deprecated.
      Shortcut for removing all values for the specified classification classes.
      Parameters:
      product - the product to remove all values for
      classes - the classes to remove all values for
      Throws:
      JaloInvalidParameterException - if no assignments have been specified
    • loadTyped

      public static FeatureContainer loadTyped(Product product, ClassificationClass... classes) throws JaloInvalidParameterException
      Deprecated.
      Loads all typed features of the given product according to the classification classes specified.

      Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!

      Parameters:
      product - the product to load a feature container for
      classes - the classification classes to manage features for
      Returns:
      the new container
      Throws:
      JaloInvalidParameterException - if no classes are provided
    • removeAllTypedValues

      public static void removeAllTypedValues(Product product, ClassificationClass... classes) throws JaloInvalidParameterException
      Deprecated.
      Shortcut for removing all values for the specified classification classes.
      Parameters:
      product - the product to remove all values for
      classes - the classes to remove all values for
      Throws:
      JaloInvalidParameterException - if no assignments have been specified
    • removeAllTypedValues

      public static void removeAllTypedValues(Product product, List<ClassAttributeAssignment> assignments) throws JaloInvalidParameterException
      Deprecated.
      Shortcut for removing all values for the specified classification attribute assignments.
      Parameters:
      product - the product to remove all values for
      assignments - the assignments to remove all values for
      Throws:
      JaloInvalidParameterException - if no assignments have been specified
    • loadUntyped

      public static FeatureContainer loadUntyped(Product product)
      Deprecated.
      Provides a container for all untyped features (and values) of the given product.

      Untyped features are not assigned to a ClassAttributeAssignment. Apart from that they offer full feature functionality like localization etc.

      Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!

      Parameters:
      product - the product to read untyped feature (-values) for
      Returns:
      the feature container
    • removeAllUntypedValues

      public static void removeAllUntypedValues(Product product)
      Deprecated.
      Shortcut for removing all untyped features for the given product.
    • store

      public void store() throws ConsistencyCheckException
      Deprecated.
      Persists the whole container by creating, removing or changing ProductFeature items. If the container is typed the features are stored ordered as their associated ClassAttributeAssignment define - a typed container just stores them as they are ordered inside the container.

      The storage algorithm will preserve all ProductFeature items which have been used for loading it - all other feature items actually belonging to features within this container are removed resp. replaced while storing values.

      Throws:
      ConsistencyCheckException - in case two containers for the same product are persisted concurrently
    • reload

      public void reload()
      Deprecated.
      Discards any contained features and reloads the whole container from database. The current class assignments and typed status are kept unchanged!
    • resolveClasses

      protected static Set<ClassificationClass> resolveClasses(Product product)
      Deprecated.
      This method is called during container creation and locates all classes which the given product belongs to.

      As default CatalogManager.getClassificationClasses(Product) is called.

    • clone

      Deprecated.
      Creates a deep copy of this feature container. This means that all features and their included values are being copied as well.
      Overrides:
      clone in class Object
      Throws:
      CloneNotSupportedException
    • getSystemVersions

      public Set<ClassificationSystemVersion> getSystemVersions()
      Deprecated.
      Returns all classification system versions which this container manages assignments for.
    • matchSystemVersion

      protected ClassificationSystemVersion matchSystemVersion(String catalogID, String versionID, boolean failIfAmbiguous)
      Deprecated.
      Tries to find a matching classification system version using the version name and optionally the catalog id.
      Parameters:
      catalogID - optional, the catalog id
      versionID - the version name
      Throws:
      JaloInvalidParameterException - if just the version has been specified and more than one version is matching
    • getClasses

      public Set<ClassificationClass> getClasses()
      Deprecated.
      Returns the classification classes which are managed by this container. These are the classes which the owning product has been assigned to or which have been configured using createTyped(Product, Set), createTyped(Product, List), loadTyped(Product, ClassificationClass...), loadTyped(Product, List) or loadTyped(Product, Set).
    • getSupportedSuperClasses

      protected Set<ClassificationClass> getSupportedSuperClasses(ClassificationClass classificationClass)
      Deprecated.
    • hasClass

      public boolean hasClass(ClassificationClass cclass)
      Deprecated.
      Tells whether or not this container manages features of this class. Since there are several ways of configuring the container it may manage all features of this class or just a subset. Please check via hasFeature(ClassAttributeAssignment) to be sure.
      Parameters:
      cclass - the classification class to check
    • getFeatureProvidingClasses

      public Set<ClassificationClass> getFeatureProvidingClasses()
      Deprecated.
      Returns all classes which provided manageable features to this container. These may differ from getClasses() since not each assigned class must actually provide a feature and on the other hand there may be features inherited from super classes which are show here as well.
    • getClassificationClass

      public ClassificationClass getClassificationClass(String code) throws JaloInvalidParameterException
      Deprecated.
      Provides a textual shortcut for getting a class out of the classes which are managed by this container. Since classes from different classification systems may be contained the identifier may be defined as one of the following patterns:
      • {code of class} - may throw exception if ambigous
      • {version of systemversion}/{code of class} - may throw exception if ambigous
      • {id of system}/{version of systemversion}/{code of class} - fully qualified
      Parameters:
      code - the class identifier pattern
      Throws:
      JaloInvalidParameterException - if there is no such class or more than one class matches
    • matchClass

      protected ClassificationClass matchClass(ClassificationSystemVersion clSys, String classIdentifier)
      Deprecated.
    • getClassificationAttributeAssignment

      public ClassAttributeAssignment getClassificationAttributeAssignment(String code) throws JaloInvalidParameterException
      Deprecated.
      Provides a textual shortcut for getting a classification attribute assignment out of the assignments which are managed by this container. Since classes from different classification systems may be contained the identifier may be defined as one of the following patterns:
      • {code of attribute} - may throw exception if ambigous
      • {code of class}/{code of attribute} - may throw exception if ambigous
      • {version of systemversion}/{code of class}/{code of attribute} - may throw exception if ambigous
      • {id of system}/{version of systemversion}/{code of class}/{code of attribute} - fully qualified
      Parameters:
      code - the class identifier pattern
      Throws:
      JaloInvalidParameterException - if there is no such class or more than one class matches
    • getClassificationAttributeAssignment

      protected ClassAttributeAssignment getClassificationAttributeAssignment(String code, boolean failIfNotExists) throws JaloInvalidParameterException
      Deprecated.
      Throws:
      JaloInvalidParameterException
    • getClassificationAttribute

      public ClassificationAttribute getClassificationAttribute(String code) throws JaloInvalidParameterException
      Deprecated.
      Provides a textual shortcut for getting a classification attribute out of the attributes which are managed by this container. Since classes from different classification systems may be contained the identifier may be defined as one of the following patterns:
      • {code of attribute} - may throw exception if ambigous
      • {code of class}/{code of attribute} - may throw exception if ambigous
      • {version of systemversion}/{code of class}/{code of attribute} - may throw exception if ambigous
      • {id of system}/{version of systemversion}/{code of class}/{code of attribute} - fully qualified
      Parameters:
      code - the class identifier pattern
      Throws:
      JaloInvalidParameterException - if there is no such class or more than one class matches
    • matchAttribute

      protected ClassAttributeAssignment matchAttribute(ClassificationSystemVersion clSys, Set<ClassificationClass> permittedClasses, String attributeIdentifier)
      Deprecated.
    • isUntyped

      public boolean isUntyped()
      Deprecated.
      Tells whether or not the container actually manages features belonging to classes reps. assignments or simply collects untyped features.
      Returns:
      true if the container does not manage typed features
    • isEmpty

      public boolean isEmpty()
      Deprecated.
      Returns true if this container doesn't hold any value. This does not necessarily mean that there is no feature - just no feature with existing value.
    • getSupportedAttributeAssignments

      public Set<ClassAttributeAssignment> getSupportedAttributeAssignments() throws IllegalStateException
      Deprecated.
      Returns all class-attribute assignments which this typed container is able to manage values for.
      Throws:
      IllegalStateException - if the container is actually untyped
    • getSupportedAttributeAssignments

      public List<ClassAttributeAssignment> getSupportedAttributeAssignments(ClassificationClass cclass) throws IllegalStateException
      Deprecated.
      Returns all class-attribute assignments of the given class which are managed by this typed container.

      Please note that this will also include inherited assignments!

      Parameters:
      cclass - the classification class to get supported assignments for
      Throws:
      IllegalStateException - if the container is actually untyped
    • getSupportedAttributes

      public Set<ClassificationAttribute> getSupportedAttributes() throws IllegalStateException
      Deprecated.
      Returns all classification attributes which this container is managing values for.

      Since the container may manage values for multiple classes, which may have separate assignments for the same attribute this method may return less elements than getSupportedAttributeAssignments()!

      Throws:
      IllegalStateException - if the container is actually untyped
    • getProduct

      public Product getProduct()
      Deprecated.
      Returns:
      the product which this container belongs to
    • createFeature

      public <T> UntypedFeature<T> createFeature(String qualifer) throws IllegalStateException, JaloInvalidParameterException
      Deprecated.
      Factory method to create (and add) a new unlocalized untyped feature.
      Parameters:
      qualifer - the unique key of the feature within this container
      Returns:
      the new feature
      Throws:
      IllegalStateException - if the container is typed so it cannot manage untyped features.
      JaloInvalidParameterException - if the container already holds a untyped feature with the same qualifier
    • createFeature

      public <T> UntypedFeature<T> createFeature(String qualifer, boolean localized) throws IllegalStateException, JaloInvalidParameterException
      Deprecated.
      Factory method to create (and add) a new untyped feature.
      Parameters:
      qualifer - the unique key of the value within this container
      localized - whether or not the attribute should be able to store localized values
      Returns:
      the new feature
      Throws:
      IllegalStateException - if the container is typed so it cannot manage untyped features.
      JaloInvalidParameterException - if the container already holds a untyped feature with the same qualifier
    • getFeatures

      public List<? extends Feature> getFeatures()
      Deprecated.
      Returns all features currently held within this container.

      If the container is untyped this returns all features which were added or loaded explicitly. If the container is typed a feature for each manageable class-attribute assignment is returned regardless if it actually got values.

    • getFeatures

      public List<? extends Feature> getFeatures(ClassificationClass cclass)
      Deprecated.
    • unescape

      protected String unescape(String qualifier)
      Deprecated.
    • hasFeature

      public boolean hasFeature(String qualifier)
      Deprecated.
      Tells whether or not this container holds a Feature instance with the specified key.

      A feature should be qualified as follows: classification system id"/"version"/" class code"."attribute code. Nevertheless system id, version or class may be omitted in case the remaining qualifier is not ambiguous. In case one of these codes contain '/' or '.' these characters must be escaped by putting a '\' in front of them !

      For example if there is just one attribute color calling hasFeature("color") would be legal. If there are two classes having color the qualifier must specify which class is meant: hasFeature("Car.color") etc.

      Parameters:
      qualifier - the feature qualifier
    • getFeature

      public <T> Feature<T> getFeature(String qualifier) throws JaloInvalidParameterException
      Deprecated.
      Retrieves a feature by its unique key.

      Since the container may only either untyped or typed features exclusively there are different allowed qualifiers:

      • untyped container : here the qualifier is simply the feature qualifier
      • typed container : a typed feature is always described as classification system id"/" version"/"class code"."attribute code e.g. eclass/4.1.80c/27020102.AAA009

        Nevertheless system id, version or class may be omitted in case the remaining qualifier is not ambiguous.

        For example if there is just one attribute color calling hasFeature("color") would be legal. If there are two classes having color the qualifier must specify which class is meant: hasFeature("Car.color") etc.

      Parameters:
      qualifier - the unique key.
      Returns:
      the stored feature or null, if nothing has been stored
      Throws:
      JaloInvalidParameterException - if the container is typed and no feature exists with the specified qualifier
    • getOrCreateFeature

      public <T> Feature<T> getOrCreateFeature(String qualifier)
      Deprecated.
      Returns a (untyped) feature with a specified qualifier. If no such feature exists a new untyped feature is beeing created.
      Type Parameters:
      T - the feature class
      Parameters:
      qualifier - the feature qualifier
      Returns:
      the existing or newly created feature
    • getFeature

      public <T> TypedFeature<T> getFeature(ClassAttributeAssignment assignment) throws JaloInvalidParameterException
      Deprecated.
      Returns the feature for a given classification attribute assignment.
      Parameters:
      assignment - the attribute assignment describing the value
      Returns:
      the feature object
      Throws:
      JaloInvalidParameterException
    • getFeature

      Deprecated.
      Returns the feature for a given classification class and attribute.
      Parameters:
      cclass - the class of the feature
      attr - the attribute of the feature (within the class)
      Returns:
      the feature object
      Throws:
      JaloInvalidParameterException
    • hasFeature

      public boolean hasFeature(ClassAttributeAssignment assignment)
      Deprecated.
      Checks whether or not the class-attribute assignment is supported by this container.
      Parameters:
      assignment - the assignment to check
      Returns:
      true if the container is type and is configured to manage values for this assignment
    • hasFeature

      public boolean hasFeature(ClassificationAttribute attr) throws JaloInvalidParameterException
      Deprecated.
      Checks whether or not the attribute is supported by this container.
      Parameters:
      attr - the attribute to check
      Returns:
      true if the container is type and is configured to manage values for this attribute
      Throws:
      JaloInvalidParameterException - if more than one assignment exists for the given attribute
    • getFeature

      Deprecated.
      Returns the feature for a given classification attribute.
      Parameters:
      attr - the attribute describing the value
      Returns:
      the feature object
      Throws:
      JaloInvalidParameterException - if no assignment exists for this attribute and the product's classification classes
    • clearValues

      public void clearValues()
      Deprecated.
      Deletes all features but leaves features itself unchanged.

      Please note that this only affects this container. To persist these changes ( means: removing the database entries as well ) store() must be called.

    • clearFeatures

      public void clearFeatures() throws IllegalStateException
      Deprecated.
      For untyped containers only : deletes all features (and of course their values too).
      Throws:
      IllegalStateException - if the container is typed - typed features are not removable.
    • deleteFeature

      public void deleteFeature(String qualifier) throws IllegalStateException
      Deprecated.
      Removes the feature for a given unique key.
      Parameters:
      qualifier - the unique which describes the value
      Throws:
      IllegalStateException - if the container is typed - typed features are not removable.
    • addFeature

      protected Feature addFeature(Feature feat)
      Deprecated.
      Adds a new feature to this container.

      Adding is done implicitly by the createFeature(String) methods!

      Parameters:
      feat - the new value
      Returns:
      the previously stored feature with the same key or null
    • createUniqueKey

      public static String createUniqueKey(ClassAttributeAssignment assignment)
      Deprecated.
      Assembles the unique key representation for a typed feature.
      Parameters:
      assignment - the class-attribute assignment which the feature is based upon
      Returns:
      assignment.class.code+'.'+assignment.attribute.code
    • extractVersions

      protected static Set<ClassificationSystemVersion> extractVersions(Collection<ClassificationClass> classes)
      Deprecated.
    • extractClasses

      protected static Set<ClassificationClass> extractClasses(Collection<ClassAttributeAssignment> assignments)
      Deprecated.
    • extractAssignments

      protected static List<ClassAttributeAssignment> extractAssignments(Set<ClassificationClass> classes)
      Deprecated.
    • writeToDatabase_TX

      protected void writeToDatabase_TX()
      Deprecated.
    • writeToDatabase

      protected void writeToDatabase()
      Deprecated.
    • writeToDatabase_Impl

      protected void writeToDatabase_Impl()
      Deprecated.
    • fetchItems

      protected Map<ClassAttributeAssignment,List<ProductFeature>> fetchItems(Product product, Set<ClassAttributeAssignment> assignments, Collection<PK> excludePKs)
      Deprecated.
    • createTypedFeatures

      protected void createTypedFeatures()
      Deprecated.
    • fillFromDatabase

      protected void fillFromDatabase()
      Deprecated.
    • getAssignment

      Deprecated.
      Throws:
      JaloInvalidParameterException
    • getEmptyValueString

      protected String getEmptyValueString()
      Deprecated.
      Provides the empty textual representation. Returns - as default.
    • getBooleanString

      protected String getBooleanString(boolean booleanToString)
      Deprecated.
      Provides the textual representation for boolean values. Returns Boolean.toString(b) as default.
    • groupAssignments

      Deprecated.