public class LinkIndexManager
extends java.lang.Object
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)
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ALL_FIELD_KEY |
static java.lang.String |
REVISION |
Constructor and Description |
---|
LinkIndexManager() |
Modifier and Type | Method and Description |
---|---|
void |
checkLinkIndex()
Check that "all" field entries are consistent with the other fields.
|
java.util.TreeMap<java.lang.String,java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.String,java.util.TreeSet<Data>>>> |
getDbIndex()
Return the internal index used to store referrer of JcmsDB data.
|
java.util.TreeMap<Data,java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.String,java.util.TreeSet<Data>>>> |
getIndex()
Return the internal index used to store referrer of JStore data.
|
<T> java.util.TreeSet<T> |
getIndexedDataSet(Data data,
java.lang.Class<T> clazz)
Returns the Set of clazz instances referring this data (whatever
the field they used for this reference)
|
<T> java.util.TreeSet<T> |
getIndexedDataSet(Data data,
java.lang.Class<T> clazz,
java.lang.String field)
Returns the Set of clazz instances referring this data with the given field.
|
int |
getLinkCount(Data data)
Get the count of Data (referrer) which are linking to the specified data
|
java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.String,java.util.TreeSet<Data>>> |
getReferrerMap(Data data)
Return the class map of the specified Data, by looking in the correct index
depending on whether its a JStore or JcmsDB data
|
java.util.Map<java.lang.Class<? extends Publication>,java.util.Set<TypeFieldEntry>> |
getTypeLinkMap(java.lang.Class<? extends Publication> clazz)
Returns the type link map for the given class.
|
java.util.Set<TypeFieldEntry> |
getTypeLinkSet(java.lang.Class<? extends Publication> attachedClass,
java.lang.Class<? extends Publication> assignedClass)
Returns the set of TypeFieldEntry of assignedClass that can be assigned with attachedClass.
|
void |
printLinkIndex(java.io.PrintWriter pw)
Print an XML view of the index.
|
public static final java.lang.String REVISION
public static final java.lang.String ALL_FIELD_KEY
public java.util.Map<java.lang.Class<? extends Publication>,java.util.Set<TypeFieldEntry>> getTypeLinkMap(java.lang.Class<? extends Publication> clazz)
clazz
- the class.public java.util.Set<TypeFieldEntry> getTypeLinkSet(java.lang.Class<? extends Publication> attachedClass, java.lang.Class<? extends Publication> assignedClass)
attachedClass
- the class to be attached.assignedClass
- the class to be assigned.public java.util.TreeMap<Data,java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.String,java.util.TreeSet<Data>>>> getIndex()
Using this method is NOT recommended as it returns an internal Map, which only handle JStore publication.
Use getReferrerMap(Data)
to access the complete referrer map of a data
Use getIndexedDataSet(Data, Class)
to access referrer of a specific class
getDbIndex()
public java.util.TreeMap<java.lang.String,java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.String,java.util.TreeSet<Data>>>> getDbIndex()
Using this method is NOT recommended as it returns an internal Map, which only handle JcmsDB publication.
Use getReferrerMap(Data)
to access the complete referrer map of a data
Use getIndexedDataSet(Data, Class)
to access referrer of a specific class
getIndex()
public <T> java.util.TreeSet<T> getIndexedDataSet(Data data, java.lang.Class<T> clazz)
T
- any object type (usually something extending Data)data
- the data which is being referenced (may be a JStore or a JcmsDB data)clazz
- the class to search the referring instancespublic java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.String,java.util.TreeSet<Data>>> getReferrerMap(Data data)
data
- the data which is being referenced (may be a JStore or a JcmsDB data)public <T> java.util.TreeSet<T> getIndexedDataSet(Data data, java.lang.Class<T> clazz, java.lang.String field)
T
- any object type (usually something extending Data)data
- the dataclazz
- the class to search the referring instancesfield
- the name of the field which contains the referencepublic int getLinkCount(Data data)
data
- the data which is being referenced, (may be a JStore or a JcmsDB data)public void checkLinkIndex()
public void printLinkIndex(java.io.PrintWriter pw)
pw
- the printWriter where the XML view must be printed.Copyright © 2001-2021 Jalios SA. All Rights Reserved.