Class PdcClassification
- java.lang.Object
-
- org.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity<E,I>
-
- org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity<PdcClassification,UniqueLongIdentifier>
-
- org.silverpeas.core.pdc.pdc.model.PdcClassification
-
- All Implemented Interfaces:
Serializable
,IdentifiableEntity
@Entity public class PdcClassification extends BasicJpaEntity<PdcClassification,UniqueLongIdentifier>
A classification of a content in Silverpeas on the classification plan (named PdC). A classification of a content is made up of one or more positions on the axis of the PdC. Each position consists of one or several values on some PdC's axis. A classification cannot have two or more identical positions; each of them must be unique. It can also represent, for a Silverpeas component instance or for a node in a component instance, a predefined classification with which any published contents can be classified on the PdC. In this case, the contentId attribute is null. A classification can be or not modifiable; by default, a predefined classification, that is used to classify new contents, is not modifiable whereas a classification of a content can be modified.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static PdcClassification
NONE_CLASSIFICATION
Represents an empty classification (id est no classification on the PdC).
-
Constructor Summary
Constructors Modifier Constructor Description protected
PdcClassification()
Creates an empty classification on the PdC, ready to be completed for a given content published in a given component instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PdcClassification
aPdcClassificationOfContent(String contentId, String inComponentInstanceId)
Creates an empty classification on the PdC of the specified content published in the specified component instance.static PdcClassification
aPdcClassificationOfContent(Contribution contribution)
Creates an empty classification on the PdC of the specified content represented by the givenContribution
.static PdcClassification
aPredefinedPdcClassificationForComponentInstance(String instanceId)
Creates an empty predefined classification for the contents that will published in the specified component instance.void
classifyContent(Contribution content)
Classifies the specified content on the PdC with this classification.void
classifyContent(Contribution content, boolean alertSubscribers)
Classifies the specified content on the PdC with this classification.void
classifyContentOrClearClassificationIfEmpty(Contribution content, boolean alertSubscribers)
Classifies the specified content on the PdC with this classification.PdcClassification
copy()
Copies this classification on the PdC.boolean
equals(Object o)
PdcClassification
forNode(String nodeId)
List<ClassifyPosition>
getClassifyPositions()
Gets the positions on the PdC of this classification in the form of ClassifyPosition instances.String
getComponentInstanceId()
String
getContentId()
String
getNodeId()
Set<PdcPosition>
getPositions()
Gets the positions on the PdC's axis with which the content is classified.int
hashCode()
PdcClassification
inComponentInstance(String instanceId)
boolean
isEmpty()
Is this classification empty?boolean
isModifiable()
Is the PdC classifications generated from this template can be changed?boolean
isPredefined()
Is this classification on the PdC is a predefined one to classify any new contents in the given node or for the given whole component instance?boolean
isPredefinedForANode()
Is this classification on the PdC is a predefined one for the contents published in a given node?boolean
isPredefinedForTheWholeComponentInstance()
Is this classification on the PdC is a predefined one for the contents published in the given whole component instance?PdcClassification
modifiable()
Sets this PdC classification as modifiable.String
toString()
PdcClassification
unmodifiable()
Sets this PdC classification as unmodifiable.void
updateForPdcAxisValuesDeletion(List<PdcAxisValue> deletedValues)
Updates this classification by removing from its positions the specified values because they will be deleted from the PdC's axis.PdcClassification
withPosition(PdcPosition aPosition)
Adds the specified position on the PdC in this classification.PdcClassification
withPositions(Collection<PdcPosition> thePositions)
Sets the positions on the PdC for this classification.-
Methods inherited from class org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity
performBeforePersist, performBeforeRemove, performBeforeUpdate
-
Methods inherited from class org.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity
getId, getNativeId, isPersisted, setId
-
-
-
-
Field Detail
-
NONE_CLASSIFICATION
public static final PdcClassification NONE_CLASSIFICATION
Represents an empty classification (id est no classification on the PdC).
-
-
Method Detail
-
aPredefinedPdcClassificationForComponentInstance
public static PdcClassification aPredefinedPdcClassificationForComponentInstance(String instanceId)
Creates an empty predefined classification for the contents that will published in the specified component instance. By default, a predefined classification isn't modifiable and serves to classify automatically new contents published in the specied component instance.- Parameters:
instanceId
- the unique identifier of the component instance to which the predefined classification will be attached.- Returns:
- an empty predefined classification.
-
aPdcClassificationOfContent
public static PdcClassification aPdcClassificationOfContent(String contentId, String inComponentInstanceId)
Creates an empty classification on the PdC of the specified content published in the specified component instance. By default, the classification of a content can be updated.- Parameters:
contentId
- the unique identifier of the content to classify.inComponentInstanceId
- the unique identifier of the component instance in which the content is published.- Returns:
- an empty classification on the PdC.
-
aPdcClassificationOfContent
public static PdcClassification aPdcClassificationOfContent(Contribution contribution)
Creates an empty classification on the PdC of the specified content represented by the givenContribution
. By default, the classification of a content can be updated.- Parameters:
contribution
- the contribution aimed for classification.- Returns:
- an empty classification on the PdC.
-
getPositions
public Set<PdcPosition> getPositions()
Gets the positions on the PdC's axis with which the content is classified. Positions on the PdC can be added or removed with the returned set.- Returns:
- a set of positions of this classification.
-
isEmpty
public boolean isEmpty()
Is this classification empty?- Returns:
- true if this classification is an empty one, false otherwise.
-
isModifiable
public boolean isModifiable()
Is the PdC classifications generated from this template can be changed?- Returns:
- false if the content have to be automatically classified, true if the classifications from this template should serv as a proposition of classification.
-
modifiable
public PdcClassification modifiable()
Sets this PdC classification as modifiable.- Returns:
- itself.
-
unmodifiable
public PdcClassification unmodifiable()
Sets this PdC classification as unmodifiable.- Returns:
- itself.
-
forNode
public PdcClassification forNode(String nodeId)
-
inComponentInstance
public PdcClassification inComponentInstance(String instanceId)
-
getComponentInstanceId
public String getComponentInstanceId()
-
getContentId
public String getContentId()
-
getNodeId
public String getNodeId()
-
isPredefined
public boolean isPredefined()
Is this classification on the PdC is a predefined one to classify any new contents in the given node or for the given whole component instance? If this classification serves as a template for classifying the contents in a whole component instance or in a node, then true is returned. If this classification is the one of a given content, then false is returned.- Returns:
- true if this classification is a predefined one, false otherwise.
-
isPredefinedForTheWholeComponentInstance
public boolean isPredefinedForTheWholeComponentInstance()
Is this classification on the PdC is a predefined one for the contents published in the given whole component instance? If this classification serves as a template for classifying the contents in a whole component instance, then true is returned. If this classification is a predefined one dedicated to classify only the content in a given node, then false is returned. If this classification is the one of a given content, then false is returned.- Returns:
- true if this classification is a predefined one for the whole component instance, false otherwise.
-
isPredefinedForANode
public boolean isPredefinedForANode()
Is this classification on the PdC is a predefined one for the contents published in a given node? If this classification serves to classify the contents published in a single node of the component instance, then true is returned. If this classification is the one of a given content, then false is returned. If this classification is the predefined one for the whole component instance, then false is returned.- Returns:
- true if this classification is a predefined one for a given node, false otherwise.
-
updateForPdcAxisValuesDeletion
public void updateForPdcAxisValuesDeletion(List<PdcAxisValue> deletedValues)
Updates this classification by removing from its positions the specified values because they will be deleted from the PdC's axis. This method is invoked at axis value deletion. Accordingly, it performs an update of this classification by applying the following algorithm for each deleted value:- The value is a base one of the axis: the value is removed from any positions of the classification. If a position is empty (it has no values) it is then deleted (the classification can be then found empty).
- The value is a leaf in its value hierarchical tree: the value is replaced by its mother value in any positions of this classification.
- Parameters:
deletedValues
- the values that are removed from a PdC's axis.
-
withPositions
public PdcClassification withPositions(Collection<PdcPosition> thePositions)
Sets the positions on the PdC for this classification.- Parameters:
thePositions
- the position to set in this classification.- Returns:
- itself.
-
withPosition
public PdcClassification withPosition(PdcPosition aPosition)
Adds the specified position on the PdC in this classification.- Parameters:
aPosition
- a position on the PdC to add in this classification.- Returns:
- itself.
-
copy
public PdcClassification copy()
Copies this classification on the PdC. The copy isn't persisted and hence its identifier is not set.- Returns:
- a copy of this classification.
-
getClassifyPositions
public List<ClassifyPosition> getClassifyPositions()
Gets the positions on the PdC of this classification in the form of ClassifyPosition instances. This method is for compatibility with the old way to manage the classification.- Returns:
- a list of ClassifyPosition instances, each of them representing a position on the PdC.
-
classifyContent
public void classifyContent(Contribution content)
Classifies the specified content on the PdC with this classification. If the content is already classified, then the given classification replaces the existing one. If the current instance is empty, then nothing is performed. The content must exist in Silverpeas before being classified. If an error occurs while classifying the content, a runtime exception PdcRuntimeException is thrown. Subscribers are notified if at least one of their subscription matches given classification.- Parameters:
content
- the Silverpeas content to classify.
-
classifyContent
public void classifyContent(Contribution content, boolean alertSubscribers)
Classifies the specified content on the PdC with this classification. If the content is already classified, then the given classification replaces the existing one. If the current instance is empty, then nothing is performed. The content must exist in Silverpeas before being classified. If an error occurs while classifying the content, a runtime exception PdcRuntimeException is thrown.- Parameters:
content
- the Silverpeas content to classify.alertSubscribers
- indicates if subscribers must be notified or not
-
classifyContentOrClearClassificationIfEmpty
public void classifyContentOrClearClassificationIfEmpty(Contribution content, boolean alertSubscribers)
Classifies the specified content on the PdC with this classification. If the content is already classified, then the given classification replaces the existing one. If the content is already classified but no position is registered into the current instance, then the content is unclassified. The content must exist in Silverpeas before being classified. If an error occurs while classifying the content, a runtime exception PdcRuntimeException is thrown. Subscribers are notified if at least one of their subscription matches given classification.- Parameters:
content
- the Silverpeas content to classify.alertSubscribers
- indicates if subscribers must be notified or not
-
equals
public boolean equals(Object o)
- Overrides:
equals
in classAbstractJpaEntity<PdcClassification,UniqueLongIdentifier>
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classAbstractJpaEntity<PdcClassification,UniqueLongIdentifier>
-
-