Class LinkIndexManager
Its goal is to list all data (aka "referrers") in which a link to
a specific data (aka the "referenced data") have been filled.
Referrers of a Data are organized by class (e.g. Article.class, ...)
and by field name that were used to link to the "referenced data" (e.g. "relatedContent", "myLink", ...)
Example (where MyArticle is a subclass of Article, and MyCustomType a Content) :
MyCustomType MCT1 references SmallNews SM1 and SM2 in its "myLink1" field MyCustomType MCT2 references SmallNews SM1 in its "myLink2" field Article A1 references SmallNews SM1 and SM2 in its "relatedContent" field Article A2 references SmallNews SM2 in its "relatedContent" field MyArticle MA1 references SmallNews SM2 in its "relatedContent" field MyArticle MA2 references SmallNews SM1 in its "myOtherLink" field // Access with class, with support for class hierarchy *when the specified class is an an abstract class* linkIndexManager.getIndexedDataSet(sm1, MyCustomType.class) ==> [ MCT1, MCT2 ] linkIndexManager.getIndexedDataSet(sm2, MyCustomType.class) ==> [ MCT1 ] linkIndexManager.getIndexedDataSet(sm1, Article.class) ==> [ A1 ] linkIndexManager.getIndexedDataSet(sm1, Publication.class) ==> [ A1, MA2, MCT1, MCT2 ] linkIndexManager.getIndexedDataSet(sm2, Article.class) ==> [ A1, A2 ] // Access with class and fieldName linkIndexManager.getIndexedDataSet(sm2, Publication.class, "relatedContent") ==> [ A1, MA1 ] linkIndexManager.getIndexedDataSet(sm2, MyArticle.class, "relatedContent") ==> [ MA1 ] linkIndexManager.getIndexedDataSet(sm2, Publication.class, "myLink1") ==> [ MCT1 ]
The structure of the internal index is as follow :
TreeMap
Key: The data which is referenced :
- the Data instance for the JStore index,
- the DBData id for the JcmsDB index
Value:
HashMap: (classMap)
Key: Class (the class referencing the data)
Value: (fieldMap)
HashMap:
Key: String (the name of the field referencing the data)
Value: TreeSet containing all the referencing data (aka the referrers)
- Author:
- Olivier Dedieu
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCheck that "all" field entries are consistent with the other fields.Return the internal index used to store referrer of JcmsDB data.getIndex()Return the internal index used to store referrer of JStore data.<T> TreeSet<T> getIndexedDataSet(Data data, Class<T> clazz) Returns the Set of clazz instances referring this data (whatever the field they used for this reference)<T> TreeSet<T> getIndexedDataSet(Data data, Class<T> clazz, String field) Returns the Set of clazz instances referring this data with the given field.intgetLinkCount(Data data) Get the count of Data (referrer) which are linking to the specified datagetReferrerMap(Data data) Return the class map of the specified Data, by looking in the correct index depending on whether its a JStore or JcmsDB dataMap<Class<? extends Publication>, Set<TypeFieldEntry>> getTypeLinkMap(Class<? extends Publication> clazz) Returns the type link map for the given class.getTypeLinkSet(Class<? extends Publication> attachedClass, Class<? extends Publication> assignedClass) Returns the set of TypeFieldEntry of assignedClass that can be assigned with attachedClass.voidPrint an XML view of the index.
-
Field Details
-
ALL_FIELD_KEY
- See Also:
-
-
Constructor Details
-
LinkIndexManager
public LinkIndexManager()
-
-
Method Details
-
getTypeLinkMap
public Map<Class<? extends Publication>,Set<TypeFieldEntry>> getTypeLinkMap(Class<? extends Publication> clazz) Returns the type link map for the given class. The type link map contains the class .- Parameters:
clazz- the class.- Returns:
- the link link map for the given class.
- Since:
- jcms-9.0.0
-
getTypeLinkSet
public Set<TypeFieldEntry> getTypeLinkSet(Class<? extends Publication> attachedClass, Class<? extends Publication> assignedClass) Returns the set of TypeFieldEntry of assignedClass that can be assigned with attachedClass.- Parameters:
attachedClass- the class to be attached.assignedClass- the class to be assigned.- Returns:
- the set of TypeFieldEntry of assignedClass that can be assigned with attachedClass.
- Since:
- jcms-9.0.0
-
getIndex
Return the internal index used to store referrer of JStore data.Using this method is NOT recommended as it returns an internal Map, which only handle JStore publication.
UsegetReferrerMap(Data)to access the complete referrer map of a data UsegetIndexedDataSet(Data, Class)to access referrer of a specific class- Returns:
- the INTERNAL index
- See Also:
-
getDbIndex
Return the internal index used to store referrer of JcmsDB data.Using this method is NOT recommended as it returns an internal Map, which only handle JcmsDB publication.
UsegetReferrerMap(Data)to access the complete referrer map of a data UsegetIndexedDataSet(Data, Class)to access referrer of a specific class- Returns:
- the INTERNAL index
- See Also:
-
getIndexedDataSet
Returns the Set of clazz instances referring this data (whatever the field they used for this reference)- Type Parameters:
T- any object type (usually something extending Data)- Parameters:
data- the data which is being referenced (may be a JStore or a JcmsDB data)clazz- the class to search the referring instances- Returns:
- a TreeSet of Data, never return null an : empty set is returned if invalid parameters where specified or when not referrer could be found
- Since:
- jcms-3.0
-
getReferrerMap
Return the class map of the specified Data, by looking in the correct index depending on whether its a JStore or JcmsDB data- Parameters:
data- the data which is being referenced (may be a JStore or a JcmsDB data)- Returns:
- a unmodifiable Map of the class to refererrer associated to the specified data, never null (returns an empty map)
- Since:
- jcms-10.0.4 / JCMS-7832
-
getIndexedDataSet
Returns the Set of clazz instances referring this data with the given field.- Type Parameters:
T- any object type (usually something extending Data)- Parameters:
data- the dataclazz- the class to search the referring instancesfield- the name of the field which contains the reference- Returns:
- a TreeSet of Data, never return null : an empty set is returned if invalid parameters where specified or when not referrer could be found
- Since:
- jcms-4.0
-
getLinkCount
Get the count of Data (referrer) which are linking to the specified data- Parameters:
data- the data which is being referenced, (may be a JStore or a JcmsDB data)- Returns:
- the number of instances referring this data
- Since:
- jcms-3.0
-
checkLinkIndex
public void checkLinkIndex()Check that "all" field entries are consistent with the other fields.- Since:
- jcms-5.0.5
-
printLinkIndex
Print an XML view of the index.- Parameters:
pw- the printWriter where the XML view must be printed.- Since:
- jcms-5.0.5
-