public abstract class AbstractContentHierarchyDaoImpl<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet> extends AbstractHierarchyDaoImpl<C> implements HierarchyContentSource<C,CA,CF>
ContentDao
AbstractContent.getLocale().Language. Country & variant
are currently practically null and place-holders in the object. In the future respect them in DB queries for extended Locale
and region based support for content.
NOTE: The layer of abstraction allows us to define a class not committed to any @Resource or @Transactional manager. Derived classes can specify which they are bound to.| Modifier and Type | Field and Description |
|---|---|
protected org.apache.commons.collections.Transformer |
relEntitiesDelTransformer
A
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities. |
FILTER_PARENTS, FILTER_PARENTS_IMMEDIATEemct, tATTRIB_CONTENT_PARENT, ATTRIB_HIERARCHY_STARTS_LIKE| Constructor and Description |
|---|
AbstractContentHierarchyDaoImpl() |
AbstractContentHierarchyDaoImpl(Class ref) |
| Modifier and Type | Method and Description |
|---|---|
protected javax.persistence.Query |
constructQueryImpl(String select,
Query<C> query)
Deprecated.
|
Long |
count(Query<C> query)
|
Long |
delete(Long id)
A special Delete operation on the entity that will remove the entity and related entities based on id.
|
int |
deleteContent(String name,
boolean deleteChildren)
Delete a content and all associated content for all locales etc.
|
int |
deleteFacet(Long id) |
int |
deleteFacet(String facetName)
Delete a
ContentFacet |
int |
deleteFacet(String name,
Integer index)
Delete a
ContentFacet @ the index position |
void |
deleteSubHierarchy(C rootNode) |
List<C> |
getAlterEgos(Long id)
For a given id, fetch all Siblings (Status & Locale) that share the same Name (implying they are alternate egos
of the same content; i.e same content parents across hierarchies differentiated by
AbstractContent.getStatus()
and locale. |
C |
getContent(String name,
Locale locale,
Status status)
Get content for Default name and specified locale and Status
|
abstract CF |
getContentFacetInstance(C content,
String facetName) |
Map<Locale,Map<Status,C>> |
getContents(String name)
Get Content for all the locales this content exists for.
|
Map<Status,C> |
getContents(String name,
Locale locale)
Get content for specified name and locale.
|
List<C> |
getContentsList(String name)
Get contents across
Status, Locales etc. |
abstract String |
getEntityName() |
List<CF> |
getFacetArray(Long contentId,
String facetName,
Collection<Integer> indeces)
Fetch specific facets in order of their natural index.
|
List<Integer> |
getFacetArrayIndeces(Long contentId,
String facetName)
The indeces is guaranteed to be in order of its index position which can be any positive, 0 or negative number even.
|
abstract String |
getFacetEntityName() |
List<CF> |
getFacets(C proxyContentQueryObject,
String facetName)
Fetch a particular content for a
AbstractContent query object;
where based on how specific the details within the AbstractContent object are
it will return the result. |
Collection<CF> |
getFacets(Long contentId) |
Collection<CF> |
getFacets(Query<CF> qry)
To keep payload minimal and to support most use case scenarios, the Impl may want
to lazy load the facets in the
C on explicit request.This method allows that explicit request to be fullfilled. |
String |
getLastChildHierarchyCode(C parent) |
Consumer<C> |
getNameSetter()
Set a
AbstractContent.setName(String) if not specified from other variables |
abstract String |
getNativeEntityName() |
protected ExtendedJPAQuery |
getQueryObject(Query<C> query,
boolean count)
Create a {javax.persistence.Query} object based on conditions and criteria (input domain based
Query) |
org.apache.commons.collections.Transformer |
getRelEntitiesDelTransformer()
A
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities. |
boolean |
isExistsAsParent(C node)
A quick check to see if the current node is a parent
|
List<C> |
loadHierarchyFlat(C rootNode) |
Page<C> |
loadPage(Query<C> query)
Simple define requirement attributes fir condition in the entity and additionally if LIKE / pattern match required on hierarchy
then we can set the Related Arribute
ContentDao#ATTRIB_HIERARCHY_STARTS_LIKE also. |
String |
makeSpaceForNodeInParent(C node,
C parent,
Integer sequence) |
void |
moveParent(C content,
C newParent,
Integer sequence) |
C |
publish(C content)
Clone Preview
C record (& related ContentFacets, attributes) to publish |
void |
publish(Collection<C> contents)
Clone Preview
C record(s) (& related ContentFacets, attributes) to publish |
C |
save(C c) |
CF |
saveFacet(CF cf)
Save a Facet
|
C |
setContent(C content) |
void |
setNameSetter(Consumer<C> nameSetter)
Set a
AbstractContent.setName(String) if not specified from other variables |
void |
setRelEntitiesDelTransformer(org.apache.commons.collections.Transformer relEntitiesDelTransformer)
A
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities. |
void |
shiftHierarchy(String currentHierarchyCode,
String newHierarchyCode,
String entityName,
C parent)
Re-organizes the
IHierarchialReference.getHierarchy() code. |
void |
unPublish(C content)
Delete published version from source.
|
protected void |
updateAttribute(List<Long> ids,
String attribute,
String value) |
void |
updateContentMetaAll(C content,
String[] selectedAttribs)
Will update the aspects of
C displayName, attributes & Bit mask across
all copies of the Content(for each Status), but not across languages |
void |
updateContentName(String oldName,
String newName)
Update
C#setName(String) |
int |
updateContentStatus(String name,
Locale locale,
Status oldStatus,
Status newStatus)
This will cause an update to the Content state.
|
convert, delete, delete, deleteSubHierarchy, deleteSubHierarchy, filterParents, getLastChildHierarchyCode, getParents, getPersistTransformer, makeSpaceForNodeInParent, move, setPersistTransformer, verifyHierarchyconditionConstruct, ensureRowIsEntity, ensureRowIsEntity, getEntityInstance, query, query, queryPage, queryPagedelete, getEntityManager, getNativeEntityName, load, load, paginate, query, query, setEntityManager, updateclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitconvertquery, queryPagedelete, load, loadprotected org.apache.commons.collections.Transformer relEntitiesDelTransformer
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities.public AbstractContentHierarchyDaoImpl()
public AbstractContentHierarchyDaoImpl(Class ref)
public abstract String getEntityName()
public abstract String getFacetEntityName()
public abstract String getNativeEntityName()
@Deprecated protected javax.persistence.Query constructQueryImpl(String select, Query<C> query)
protected ExtendedJPAQuery getQueryObject(Query<C> query, boolean count) throws Exception
Query)
getQueryObject in class AbstractQueryableDaoImpl<C extends AbstractContent<CA,CF>>query - as Querycount - as boolean; if true will convert the query to return just a count, in which case dropIfLargeAmt is ignoredExtendedJPAQueryExceptionpublic Page<C> loadPage(Query<C> query)
ContentDao#ATTRIB_HIERARCHY_STARTS_LIKE also.
Will return all records that match all the fields provided with "AND"; i.e. set is set of intersections of conditions.loadPage in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>loadPage in class AbstractHierarchyDaoImpl<C extends AbstractContent<CA,CF>>query - as Query for CCthis#reloadFacets(C)}@Transactional(readOnly=true) public Long count(Query<C> query)
AbstractQueryableDaoImplQuery and on Queryable fields only.
Query.setNullSet(Set)
Queryable fields will face problems.count in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>count in interface QueryableDao<C extends AbstractContent<CA,CF>>count in class AbstractQueryableDaoImpl<C extends AbstractContent<CA,CF>>query - as QueryableCthis#reloadFacets(C)}public Map<Status,C> getContents(String name, Locale locale)
ContentSourceStatus.getContents in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>name - as the identifier of ContentStatus , Cthis#reloadFacets(C)}public Map<Locale,Map<Status,C>> getContents(String name)
ContentSourcegetContents in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>name - identifier of ContentStatus, C) )this#reloadFacets(C)}public List<C> getContentsList(String name)
ContentSourceStatus, Locales etc. for a given unique (across locale & Status) NameIdgetContentsList in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>public C getContent(String name, Locale locale, Status status)
ContentSourcegetContent in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>name - as the identifier of Contentlocale - as Localestatus - as StatusCthis#reloadFacets(C)}public Collection<CF> getFacets(Query<CF> qry)
ContentSourceC on explicit request.getFacets in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>public List<CF> getFacetArray(Long contentId, String facetName, Collection<Integer> indeces)
ContentSourcegetFacetArray in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>contentId - as LongfacetName - as Stringindeces - as optional (Nullable), List of index numbers to fetch. If null will netch all.ContentFacetpublic List<Integer> getFacetArrayIndeces(Long contentId, String facetName)
ContentSourcegetFacetArrayIndeces in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>contentId - as LongfacetName - as Stringpublic Collection<CF> getFacets(Long contentId)
getFacets in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>contentId - as LongContentFacet@Transactional(readOnly=false) public C setContent(C content)
setContent in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>content - as Cthis#reloadFacets(C)} also@Transactional(readOnly=false) public int deleteContent(String name, boolean deleteChildren)
ContentSourcedeleteContent in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>name - of Content as StringdeleteChildren - as boolean; will delete sub-hierarchy to this contentContentAttribute, ContentFacet etc are not counted, just core content entity objects)@Transactional(readOnly=false) public Long delete(Long id)
GenericDaodelete in interface GenericDao<C extends AbstractContent<CA,CF>>delete in class GenericDaoImpl<C extends AbstractContent<CA,CF>>Long@Transactional(readOnly=false) public int deleteFacet(String facetName)
ContentSourceContentFacetdeleteFacet in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>facetName - as String@Transactional(readOnly=false) public int deleteFacet(Long id)
deleteFacet in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>@Transactional(readOnly=false) public int deleteFacet(String name, Integer index)
ContentSourceContentFacet @ the index positiondeleteFacet in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>name - as Stringindex - as Integer (@Nullable)@Transactional(readOnly=false) public int updateContentStatus(String name, Locale locale, Status oldStatus, Status newStatus) throws Exception
ContentSourceStatus.DRAFT, and is being updated to Status.PUBLISH
while another Status.PUBLISH one already exists. Then it should update the PUBLISH record for the content and
mute the Status.DRAFT one (in concept).updateContentStatus in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>name - as identifier for the contentlocale - as the LocaleoldStatus - as the StatusnewStatus - as the Status (replace the oldStatus with this value)Exception@Transactional(readOnly=false) public CF saveFacet(CF cf)
ContentSourcesaveFacet in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>cf - as ContentFacet@Transactional(readOnly=false) public C save(C c)
save in interface GenericDao<C extends AbstractContent<CA,CF>>save in class AbstractHierarchyDaoImpl<C extends AbstractContent<CA,CF>>@Transactional(readOnly=false,
rollbackFor=java.lang.Exception.class)
public C publish(C content)
throws Exception
C record (& related ContentFacets, attributes) to publishpublish in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>content - (this should be a record with C#getStatus() as Status.DRAFT)Exceptionpublic void unPublish(C content)
ContentSourceunPublish in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>public void publish(Collection<C> contents) throws Exception
C record(s) (& related ContentFacets, attributes) to publishpublish in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>Exception@Transactional(readOnly=false,
rollbackFor=java.lang.Exception.class)
public void updateContentMetaAll(C content,
String[] selectedAttribs)
ContentSourceC displayName, attributes & Bit mask across
all copies of the Content(for each Status), but not across languagesupdateContentMetaAll in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>content - (Only Those attributes are updated that are in the content object; Supports partial Attribute update)@Transactional(readOnly=false,
rollbackFor=java.lang.Exception.class)
public void updateContentName(String oldName,
String newName)
ContentSourceC#setName(String)updateContentName in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>@Transactional public String getLastChildHierarchyCode(C parent)
getLastChildHierarchyCode in interface HierarchyContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>@Transactional public String makeSpaceForNodeInParent(C node, C parent, Integer sequence)
makeSpaceForNodeInParent in interface HierarchyContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>AbstractHierarchyDaoImpl@Transactional(readOnly=false,
rollbackFor=java.lang.Exception.class)
public void moveParent(C content,
C newParent,
Integer sequence)
throws Exception
newParent - @nullable true if IHierarchialReference.ROOTExceptionpublic List<C> getAlterEgos(Long id)
AbstractContent.getStatus()
and locale.getAlterEgos in interface HierarchyContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>public List<C> loadHierarchyFlat(C rootNode)
loadHierarchyFlat in interface HierarchyContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>public List<CF> getFacets(C proxyContentQueryObject, String facetName)
ContentSourceAbstractContent query object;
where based on how specific the details within the AbstractContent object are
it will return the result.
List as AbstractContentFacet support arrays and for the same
facet name, there can be multiple AbstractContentFacets for the same AbstractContent.getFacets in interface ContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>facetName - as StringContentFacet type public void deleteSubHierarchy(C rootNode) throws Exception
deleteSubHierarchy in interface HierarchyContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>Exceptionpublic boolean isExistsAsParent(C node)
AbstractHierarchyDaoImplisExistsAsParent in interface HierarchyContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>isExistsAsParent in class AbstractHierarchyDaoImpl<C extends AbstractContent<CA,CF>>public void shiftHierarchy(String currentHierarchyCode, String newHierarchyCode, String entityName, C parent)
AbstractHierarchyDaoImplIHierarchialReference.getHierarchy() code. Note: it does not change parent.shiftHierarchy in interface HierarchyContentSource<C extends AbstractContent<CA,CF>,CA extends AbstractContentAttribute,CF extends AbstractContentFacet>shiftHierarchy in class AbstractHierarchyDaoImpl<C extends AbstractContent<CA,CF>>currentHierarchyCode - as String of the node to be Shifted @nullable true, for any content (like New) that does not require shifting - User Case : IgnorenewHierarchyCode - as String, to the location this will shift (will not check for conflicts, use AbstractHierarchyDaoImpl.getLastChildHierarchyCode(IHierarchialReference, String)
or AbstractHierarchyDaoImpl.makeSpaceForNodeInParent(IHierarchialReference, IHierarchialReference, Integer, String) or HierarchyHelper.getNewHierarchySequence(String, String, int, List) for that.parent - @nullable true; Future UseAbstractHierarchyDaoImplpublic org.apache.commons.collections.Transformer getRelEntitiesDelTransformer()
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities.getRelEntitiesDelTransformer in class AbstractHierarchyDaoImpl<C extends AbstractContent<CA,CF>>public void setRelEntitiesDelTransformer(org.apache.commons.collections.Transformer relEntitiesDelTransformer)
Transformer that accepts a String (hierarchy code), Long (id), List of Long (List of Ids) to delete from related entities.setRelEntitiesDelTransformer in class AbstractHierarchyDaoImpl<C extends AbstractContent<CA,CF>>public Consumer<C> getNameSetter()
AbstractContent.setName(String) if not specified from other variablesMarshalUtils.cleanToDataSafe(String) version of the AbstractContent.getDisplayName()public void setNameSetter(Consumer<C> nameSetter)
AbstractContent.setName(String) if not specified from other variablesMarshalUtils.cleanToDataSafe(String) version of the AbstractContent.getDisplayName()Copyright © 2018. All rights reserved.