de.hybris.platform.classification.features.FeatureList instead.@Deprecated public class FeatureContainer extends Object implements Cloneable, Serializable
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();
| Modifier and Type | Field and Description |
|---|---|
static String |
WITHIN_FEATURE_CONTAINER_TRANSACTION
Deprecated.
|
| Modifier | Constructor and Description |
|---|---|
protected |
FeatureContainer(FeatureContainer src)
Deprecated.
Copy constructor.
|
protected |
FeatureContainer(Product product,
List<ClassAttributeAssignment> classAssignments)
Deprecated.
Creates a new feature container with exactly specified class-attribute mappings.
|
| Modifier and Type | Method and Description |
|---|---|
protected Feature |
addFeature(Feature feat)
Deprecated.
Adds a new feature to this container.
|
void |
clearFeatures()
Deprecated.
For untyped containers only : deletes all features (and of course their values too).
|
void |
clearValues()
Deprecated.
Deletes all features but leaves features itself unchanged.
|
FeatureContainer |
clone()
Deprecated.
Creates a deep copy of this feature container.
|
static FeatureContainer |
create(Product product)
Deprecated.
Creates an empty product feature container.
|
<T> UntypedFeature<T> |
createFeature(String qualifer)
Deprecated.
Factory method to create (and add) a new unlocalized untyped feature.
|
<T> UntypedFeature<T> |
createFeature(String qualifer,
boolean localized)
Deprecated.
Factory method to create (and add) a new untyped feature.
|
static FeatureContainer |
createTyped(Product product,
List<ClassAttributeAssignment> assignments)
Deprecated.
Creates an empty product feature container which is able to handle all features for the specified set of
classification attribute assignments.
|
static FeatureContainer |
createTyped(Product product,
Set<ClassificationClass> classes)
Deprecated.
Creates an empty product feature container which is able to handle all features for the specified set of
classification classes.
|
protected void |
createTypedFeatures()
Deprecated.
|
static String |
createUniqueKey(ClassAttributeAssignment assignment)
Deprecated.
Assembles the unique key representation for a typed feature.
|
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.
|
void |
deleteFeature(String qualifier)
Deprecated.
Removes the feature for a given unique key.
|
protected static List<ClassAttributeAssignment> |
extractAssignments(Set<ClassificationClass> classes)
Deprecated.
|
protected static Set<ClassificationClass> |
extractClasses(Collection<ClassAttributeAssignment> assignments)
Deprecated.
|
protected static Set<ClassificationSystemVersion> |
extractVersions(Collection<ClassificationClass> classes)
Deprecated.
|
protected Map<ClassAttributeAssignment,List<ProductFeature>> |
fetchItems(Product product,
Set<ClassAttributeAssignment> assignments,
Collection<PK> excludePKs)
Deprecated.
|
protected void |
fillFromDatabase()
Deprecated.
|
protected ClassAttributeAssignment |
getAssignment(ClassificationAttribute attr)
Deprecated.
|
protected Set<ClassAttributeAssignment> |
getAssignmentsInternal()
Deprecated.
|
protected String |
getBooleanString(boolean booleanToString)
Deprecated.
Provides the textual representation for boolean values.
|
Set<ClassificationClass> |
getClasses()
Deprecated.
Returns the classification classes which are managed by this container.
|
ClassificationAttribute |
getClassificationAttribute(String code)
Deprecated.
Provides a textual shortcut for getting a classification attribute out of the attributes which are managed by this
container.
|
ClassAttributeAssignment |
getClassificationAttributeAssignment(String code)
Deprecated.
Provides a textual shortcut for getting a classification attribute assignment out of the assignments which are
managed by this container.
|
protected ClassAttributeAssignment |
getClassificationAttributeAssignment(String code,
boolean failIfNotExists)
Deprecated.
|
ClassificationClass |
getClassificationClass(String code)
Deprecated.
Provides a textual shortcut for getting a class out of the classes which are managed by this container.
|
protected String |
getEmptyValueString()
Deprecated.
Provides the empty textual representation.
|
<T> TypedFeature<T> |
getFeature(ClassAttributeAssignment assignment)
Deprecated.
Returns the feature for a given classification attribute assignment.
|
TypedFeature |
getFeature(ClassificationAttribute attr)
Deprecated.
Returns the feature for a given classification attribute.
|
<T> TypedFeature<T> |
getFeature(ClassificationClass cclass,
ClassificationAttribute attr)
Deprecated.
Returns the feature for a given classification class and attribute.
|
<T> Feature<T> |
getFeature(String qualifier)
Deprecated.
Retrieves a feature by its unique key.
|
Set<ClassificationClass> |
getFeatureProvidingClasses()
Deprecated.
Returns all classes which provided manageable features to this container.
|
List<? extends Feature> |
getFeatures()
Deprecated.
Returns all features currently held within this container.
|
List<? extends Feature> |
getFeatures(ClassificationClass cclass)
Deprecated.
|
<T> Feature<T> |
getOrCreateFeature(String qualifier)
Deprecated.
Returns a (untyped) feature with a specified qualifier.
|
Product |
getProduct()
Deprecated.
|
Set<ClassAttributeAssignment> |
getSupportedAttributeAssignments()
Deprecated.
Returns all class-attribute assignments which this typed container is able to manage values for.
|
List<ClassAttributeAssignment> |
getSupportedAttributeAssignments(ClassificationClass cclass)
Deprecated.
Returns all class-attribute assignments of the given class which are managed by this typed container.
|
Set<ClassificationAttribute> |
getSupportedAttributes()
Deprecated.
Returns all classification attributes which this container is managing values for.
|
protected Set<ClassificationClass> |
getSupportedSuperClasses(ClassificationClass classificationClass)
Deprecated.
|
Set<ClassificationSystemVersion> |
getSystemVersions()
Deprecated.
Returns all classification system versions which this container manages assignments for.
|
static Map<ClassificationClass,List<ClassAttributeAssignment>> |
groupAssignments(Collection<ClassAttributeAssignment> assignments)
Deprecated.
|
boolean |
hasClass(ClassificationClass cclass)
Deprecated.
Tells whether or not this container manages features of this class.
|
boolean |
hasFeature(ClassAttributeAssignment assignment)
Deprecated.
Checks whether or not the class-attribute assignment is supported by this container.
|
boolean |
hasFeature(ClassificationAttribute attr)
Deprecated.
Checks whether or not the attribute is supported by this container.
|
boolean |
hasFeature(String qualifier)
Deprecated.
Tells whether or not this container holds a
Feature instance with the specified key. |
boolean |
isEmpty()
Deprecated.
Returns
true if this container doesn't hold any value. |
static boolean |
isInFeatureContainerTA(SessionContext ctx)
Deprecated.
|
boolean |
isUntyped()
Deprecated.
Tells whether or not the container actually manages features belonging to
classes
reps. |
static FeatureContainer |
load(Product product)
Deprecated.
Loads all features for a given product from existing
ProductFeature items. |
static FeatureContainer |
loadTyped(Product product)
Deprecated.
Loads all typed features of the given product according to the classification classes it has been assigned to.
|
static FeatureContainer |
loadTyped(Product product,
ClassAttributeAssignment... assignments)
Deprecated.
Loads all typed features of the given product according to the classification attribute assignments specified.
|
static FeatureContainer |
loadTyped(Product product,
ClassificationClass... classes)
Deprecated.
Loads all typed features of the given product according to the classification classes specified.
|
static FeatureContainer |
loadTyped(Product product,
List<ClassAttributeAssignment> assignments)
Deprecated.
Loads all typed features of the given product according to the classification attribute assignments specified.
|
static FeatureContainer |
loadTyped(Product product,
Set<ClassificationClass> classes)
Deprecated.
Loads all typed features of the given product according to the classification classes specified.
|
static FeatureContainer |
loadUntyped(Product product)
Deprecated.
Provides a container for all untyped features (and values) of the given product.
|
protected ClassAttributeAssignment |
matchAttribute(ClassificationSystemVersion clSys,
Set<ClassificationClass> permittedClasses,
String attributeIdentifier)
Deprecated.
|
protected ClassificationClass |
matchClass(ClassificationSystemVersion clSys,
String classIdentifier)
Deprecated.
|
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.
|
void |
reload()
Deprecated.
Discards any contained features and reloads the whole container from database.
|
static void |
removeAllTypedValues(Product product)
Deprecated.
Shortcut for removing all typed values.
|
static void |
removeAllTypedValues(Product product,
ClassificationClass... classes)
Deprecated.
Shortcut for removing all values for the specified classification classes.
|
static void |
removeAllTypedValues(Product product,
List<ClassAttributeAssignment> assignments)
Deprecated.
Shortcut for removing all values for the specified classification attribute assignments.
|
static void |
removeAllTypedValues(Product product,
Set<ClassificationClass> classes)
Deprecated.
Shortcut for removing all values for the specified classification classes.
|
static void |
removeAllUntypedValues(Product product)
Deprecated.
Shortcut for removing all untyped features for the given product.
|
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. |
void |
store()
Deprecated.
Persists the whole container by creating, removing or changing
ProductFeature items. |
String |
toString()
Deprecated.
|
protected String |
unescape(String qualifier)
Deprecated.
|
protected void |
writeToDatabase_Impl()
Deprecated.
|
protected void |
writeToDatabase_TX()
Deprecated.
|
protected void |
writeToDatabase()
Deprecated.
|
public static final String WITHIN_FEATURE_CONTAINER_TRANSACTION
protected FeatureContainer(Product product, List<ClassAttributeAssignment> classAssignments)
product - the product owning the featuresclassAssignments - the class-attribute assignments which should be manageable by this containerprotected FeatureContainer(FeatureContainer src) throws CloneNotSupportedException
CloneNotSupportedExceptionpublic static final boolean isInFeatureContainerTA(SessionContext ctx)
protected Set<ClassAttributeAssignment> getAssignmentsInternal()
public static FeatureContainer create(Product product)
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!
product - the product to create a new container forpublic static FeatureContainer createTyped(Product product, Set<ClassificationClass> classes) throws JaloInvalidParameterException
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!
product - the product to create a new container forclasses - the set of classification classes which this container should supportJaloInvalidParameterException - if now classes are providedpublic static FeatureContainer createTyped(Product product, List<ClassAttributeAssignment> assignments) throws JaloInvalidParameterException
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!
product - the product to create a new container forassignments - the set of classification classes which this container should supportJaloInvalidParameterException - if now classes are providedpublic static FeatureContainer createUntyped(Product product)
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!
product - the product to create a new container forpublic static FeatureContainer load(Product product)
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!
product - the product to load features forpublic static FeatureContainer loadTyped(Product product) throws JaloInvalidParameterException
Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!
product - the product to load a feature container forJaloInvalidParameterException - if the product is not classified at allpublic static void removeAllTypedValues(Product product) throws JaloInvalidParameterException
product - the product to remove all values forJaloInvalidParameterException - if the product is not classified at allpublic static FeatureContainer loadTyped(Product product, Set<ClassificationClass> classes) throws JaloInvalidParameterException
Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!
product - the product to load a feature container forclasses - the classification classes to manage features forJaloInvalidParameterException - if no classes are providedpublic static FeatureContainer loadTyped(Product product, ClassAttributeAssignment... assignments) throws JaloInvalidParameterException
Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!
product - the product to load a feature container forassignments - the class attribute assignments to manage features forJaloInvalidParameterException - if no assignments are providedpublic static FeatureContainer loadTyped(Product product, List<ClassAttributeAssignment> assignments) throws JaloInvalidParameterException
Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!
product - the product to load a feature container forassignments - the class attribute assignments to manage features forJaloInvalidParameterException - if no assignments are providedpublic static void removeAllTypedValues(Product product, Set<ClassificationClass> classes) throws JaloInvalidParameterException
product - the product to remove all values forclasses - the classes to remove all values forJaloInvalidParameterException - if no assignments have been specifiedpublic static FeatureContainer loadTyped(Product product, ClassificationClass... classes) throws JaloInvalidParameterException
Please note that the container is not kept synchronous with the database - it merely shows the product's features at loading time!
product - the product to load a feature container forclasses - the classification classes to manage features forJaloInvalidParameterException - if no classes are providedpublic static void removeAllTypedValues(Product product, ClassificationClass... classes) throws JaloInvalidParameterException
product - the product to remove all values forclasses - the classes to remove all values forJaloInvalidParameterException - if no assignments have been specifiedpublic static void removeAllTypedValues(Product product, List<ClassAttributeAssignment> assignments) throws JaloInvalidParameterException
product - the product to remove all values forassignments - the assignments to remove all values forJaloInvalidParameterException - if no assignments have been specifiedpublic static FeatureContainer loadUntyped(Product 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!
product - the product to read untyped feature (-values) forpublic static void removeAllUntypedValues(Product product)
public void store()
throws ConsistencyCheckException
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.
ConsistencyCheckException - in case two containers for the same product are persisted concurrentlypublic void reload()
protected static Set<ClassificationClass> resolveClasses(Product product)
classes which the
given product belongs to.
As default CatalogManager.getClassificationClasses(Product) is called.
public FeatureContainer clone() throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic Set<ClassificationSystemVersion> getSystemVersions()
protected ClassificationSystemVersion matchSystemVersion(String catalogID, String versionID, boolean failIfAmbiguous)
catalogID - optional, the catalog idversionID - the version nameJaloInvalidParameterException - if just the version has been specified and more than one version is matchingpublic Set<ClassificationClass> getClasses()
createTyped(Product, Set),
createTyped(Product, List), loadTyped(Product, ClassificationClass...),
loadTyped(Product, List) or loadTyped(Product, Set).protected Set<ClassificationClass> getSupportedSuperClasses(ClassificationClass classificationClass)
public boolean hasClass(ClassificationClass cclass)
hasFeature(ClassAttributeAssignment) to be sure.cclass - the classification class to checkpublic Set<ClassificationClass> getFeatureProvidingClasses()
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.public ClassificationClass getClassificationClass(String code) throws JaloInvalidParameterException
code - the class identifier patternJaloInvalidParameterException - if there is no such class or more than one class matchesprotected ClassificationClass matchClass(ClassificationSystemVersion clSys, String classIdentifier)
public ClassAttributeAssignment getClassificationAttributeAssignment(String code) throws JaloInvalidParameterException
code - the class identifier patternJaloInvalidParameterException - if there is no such class or more than one class matchesprotected ClassAttributeAssignment getClassificationAttributeAssignment(String code, boolean failIfNotExists) throws JaloInvalidParameterException
JaloInvalidParameterExceptionpublic ClassificationAttribute getClassificationAttribute(String code) throws JaloInvalidParameterException
code - the class identifier patternJaloInvalidParameterException - if there is no such class or more than one class matchesprotected ClassAttributeAssignment matchAttribute(ClassificationSystemVersion clSys, Set<ClassificationClass> permittedClasses, String attributeIdentifier)
public boolean isUntyped()
classes
reps. assignments or simply collects untyped features.true if the container does not manage typed featurespublic boolean isEmpty()
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.public Set<ClassAttributeAssignment> getSupportedAttributeAssignments() throws IllegalStateException
IllegalStateException - if the container is actually untypedpublic List<ClassAttributeAssignment> getSupportedAttributeAssignments(ClassificationClass cclass) throws IllegalStateException
Please note that this will also include inherited assignments!
cclass - the classification class to get supported assignments forIllegalStateException - if the container is actually untypedpublic Set<ClassificationAttribute> getSupportedAttributes() throws IllegalStateException
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()!
IllegalStateException - if the container is actually untypedpublic Product getProduct()
public <T> UntypedFeature<T> createFeature(String qualifer) throws IllegalStateException, JaloInvalidParameterException
qualifer - the unique key of the feature within this containerIllegalStateException - if the container is typed so it cannot manage untyped features.JaloInvalidParameterException - if the container already holds a untyped feature with the same qualifierpublic <T> UntypedFeature<T> createFeature(String qualifer, boolean localized) throws IllegalStateException, JaloInvalidParameterException
qualifer - the unique key of the value within this containerlocalized - whether or not the attribute should be able to store localized valuesIllegalStateException - if the container is typed so it cannot manage untyped features.JaloInvalidParameterException - if the container already holds a untyped feature with the same qualifierpublic List<? extends Feature> getFeatures()
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.
public List<? extends Feature> getFeatures(ClassificationClass cclass)
public boolean hasFeature(String qualifier)
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.
qualifier - the feature qualifierpublic <T> Feature<T> getFeature(String qualifier) throws JaloInvalidParameterException
Since the container may only either untyped or typed features exclusively there are different allowed qualifiers:
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.
qualifier - the unique key.JaloInvalidParameterException - if the container is typed and no feature exists with the specified qualifierpublic <T> Feature<T> getOrCreateFeature(String qualifier)
T - the feature classqualifier - the feature qualifierpublic <T> TypedFeature<T> getFeature(ClassAttributeAssignment assignment) throws JaloInvalidParameterException
assignment - the attribute assignment describing the valueJaloInvalidParameterExceptionpublic <T> TypedFeature<T> getFeature(ClassificationClass cclass, ClassificationAttribute attr) throws JaloInvalidParameterException
cclass - the class of the featureattr - the attribute of the feature (within the class)JaloInvalidParameterExceptionpublic boolean hasFeature(ClassAttributeAssignment assignment)
assignment - the assignment to checktrue if the container is type and is configured to manage values for this assignmentpublic boolean hasFeature(ClassificationAttribute attr) throws JaloInvalidParameterException
attr - the attribute to checktrue if the container is type and is configured to manage values for this attributeJaloInvalidParameterException - if more than one assignment exists for the given attributepublic TypedFeature getFeature(ClassificationAttribute attr) throws JaloInvalidParameterException
attr - the attribute describing the valueJaloInvalidParameterException - if no assignment exists for this attribute and the product's classification classespublic void clearValues()
Please note that this only affects this container. To persist these changes ( means: removing the database entries
as well ) store() must be called.
public void clearFeatures()
throws IllegalStateException
IllegalStateException - if the container is typed - typed features are not removable.public void deleteFeature(String qualifier) throws IllegalStateException
qualifier - the unique which describes the valueIllegalStateException - if the container is typed - typed features are not removable.protected Feature addFeature(Feature feat)
Adding is done implicitly by the createFeature(String) methods!
feat - the new valuepublic static String createUniqueKey(ClassAttributeAssignment assignment)
assignment - the class-attribute assignment which the feature is based uponassignment.class.code+'.'+assignment.attribute.codeprotected static Set<ClassificationSystemVersion> extractVersions(Collection<ClassificationClass> classes)
protected static Set<ClassificationClass> extractClasses(Collection<ClassAttributeAssignment> assignments)
protected static List<ClassAttributeAssignment> extractAssignments(Set<ClassificationClass> classes)
protected void writeToDatabase_TX()
protected void writeToDatabase()
protected void writeToDatabase_Impl()
protected Map<ClassAttributeAssignment,List<ProductFeature>> fetchItems(Product product, Set<ClassAttributeAssignment> assignments, Collection<PK> excludePKs)
protected void createTypedFeatures()
protected void fillFromDatabase()
protected ClassAttributeAssignment getAssignment(ClassificationAttribute attr) throws JaloInvalidParameterException
JaloInvalidParameterExceptionprotected String getEmptyValueString()
- as default.protected String getBooleanString(boolean booleanToString)
Boolean.toString(b) as default.public static Map<ClassificationClass,List<ClassAttributeAssignment>> groupAssignments(Collection<ClassAttributeAssignment> assignments)
Copyright © 2017 SAP SE. All Rights Reserved.