Class FeatureContainer

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable

    @Deprecated
    public class FeatureContainer
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.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:
    Serialized Form
    • Field Detail

      • WITHIN_FEATURE_CONTAINER_TRANSACTION

        public static final java.lang.String WITHIN_FEATURE_CONTAINER_TRANSACTION
        Deprecated.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FeatureContainer

        protected FeatureContainer​(Product product,
                                   java.util.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 java.lang.CloneNotSupportedException
        Deprecated.
        Copy constructor. Don't use directly.
        Throws:
        java.lang.CloneNotSupportedException
    • Method Detail

      • isInFeatureContainerTA

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

        public java.lang.String toString()
        Deprecated.
        Overrides:
        toString in class java.lang.Object
      • 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,
                                                   java.util.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,
                                                   java.util.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
      • loadTyped

        public static FeatureContainer loadTyped​(Product product,
                                                 java.util.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,
                                                 java.util.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,
                                                java.util.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,
                                                java.util.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!
      • clone

        public FeatureContainer clone()
                               throws java.lang.CloneNotSupportedException
        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 java.lang.Object
        Throws:
        java.lang.CloneNotSupportedException
      • getSystemVersions

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

        protected ClassificationSystemVersion matchSystemVersion​(java.lang.String catalogID,
                                                                 java.lang.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
      • 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 java.util.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​(java.lang.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
      • getClassificationAttributeAssignment

        public ClassAttributeAssignment getClassificationAttributeAssignment​(java.lang.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
      • getClassificationAttribute

        public ClassificationAttribute getClassificationAttribute​(java.lang.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
      • 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 java.util.Set<ClassAttributeAssignment> getSupportedAttributeAssignments()
                                                                                 throws java.lang.IllegalStateException
        Deprecated.
        Returns all class-attribute assignments which this typed container is able to manage values for.
        Throws:
        java.lang.IllegalStateException - if the container is actually untyped
      • getSupportedAttributeAssignments

        public java.util.List<ClassAttributeAssignment> getSupportedAttributeAssignments​(ClassificationClass cclass)
                                                                                  throws java.lang.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:
        java.lang.IllegalStateException - if the container is actually untyped
      • getSupportedAttributes

        public java.util.Set<ClassificationAttribute> getSupportedAttributes()
                                                                      throws java.lang.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:
        java.lang.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​(java.lang.String qualifer)
                                            throws java.lang.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:
        java.lang.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​(java.lang.String qualifer,
                                                   boolean localized)
                                            throws java.lang.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:
        java.lang.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 java.util.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.

      • unescape

        protected java.lang.String unescape​(java.lang.String qualifier)
        Deprecated.
      • hasFeature

        public boolean hasFeature​(java.lang.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​(java.lang.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​(java.lang.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
      • 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
      • 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 java.lang.IllegalStateException
        Deprecated.
        For untyped containers only : deletes all features (and of course their values too).
        Throws:
        java.lang.IllegalStateException - if the container is typed - typed features are not removable.
      • deleteFeature

        public void deleteFeature​(java.lang.String qualifier)
                           throws java.lang.IllegalStateException
        Deprecated.
        Removes the feature for a given unique key.
        Parameters:
        qualifier - the unique which describes the value
        Throws:
        java.lang.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 java.lang.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
      • writeToDatabase_TX

        protected void writeToDatabase_TX()
        Deprecated.
      • writeToDatabase

        protected void writeToDatabase()
        Deprecated.
      • writeToDatabase_Impl

        protected void writeToDatabase_Impl()
        Deprecated.
      • createTypedFeatures

        protected void createTypedFeatures()
        Deprecated.
      • fillFromDatabase

        protected void fillFromDatabase()
        Deprecated.
      • getEmptyValueString

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

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