Author: bpapez
Date: Sat Sep 1 23:46:34 2007
New Revision: 18344
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D18344&repname=
=3Djahia
Log:
issues UNIL-7, UNIL-10 and UNIL-11
* There was a bug in fetching the container IDs for a list in the JahiaCont=
ainerDAO. The select returns staged and live versions sorted by rank and wo=
rkflowstate, but this caused that in the result the top most staging contai=
ner was first and then the top most live container second, although this on=
e could have been moved further down. =
* Changed the SQL back to the original Jahia 4 version, but slightly optimi=
zed the filtering. =
Modified:
trunk/core/src/java/org/jahia/hibernate/dao/JahiaContainerDAO.java
trunk/core/src/java/org/jahia/hibernate/manager/JahiaContainerManager.j=
ava
Modified: trunk/core/src/java/org/jahia/hibernate/dao/JahiaContainerDAO.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/hibernate/dao/JahiaContainerDAO.java&rev=3D18344&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/java/org/jahia/hibernate/dao/JahiaContainerDAO.java (ori=
ginal)
+++ trunk/core/src/java/org/jahia/hibernate/dao/JahiaContainerDAO.java Sat =
Sep 1 23:46:34 2007
@@ -67,9 +67,9 @@
=
public List getAllNonDeletedStagingContainerIds() {
List retVal;
- String hql =3D "select distinct c.comp_id.id,c.comp_id.versionId,c=
.comp_id.workflowState,c.rank from JahiaContainer c "+
- "where c.comp_id.workflowState>=3D1 "+
- "order by c.rank,c.comp_id.workflowState desc,c.comp_=
id.id";
+ String hql =3D "select distinct c.comp_id.id,c.comp_id.versionId,c=
.rank,c.comp_id.workflowState from JahiaContainer c "
+ + "where c.comp_id.workflowState>=3D1 "
+ + "order by c.comp_id.id,c.comp_id.workflowState desc";
final HibernateTemplate template =3D getHibernateTemplate();
template.setCacheQueries(true);
template.setFlushMode(HibernateTemplate.FLUSH_NEVER);
@@ -92,14 +92,13 @@
=
public List getAllStagingContainerIds() {
List retVal;
- String hql =3D "select distinct c.comp_id.id,c.rank,c.comp_id.work=
flowState from JahiaContainer c "+
- "where c.comp_id.workflowState>=3D1 "+
- "order by c.rank,c.comp_id.workflowState desc,c.comp_=
id.id";
+ String hql =3D "select distinct c.comp_id.id,c.comp_id.versionId,c=
.rank,c.comp_id.workflowState from JahiaContainer c "
+ + "where c.comp_id.workflowState>=3D1 "
+ + "order by c.comp_id.id,c.comp_id.workflowState desc";
final HibernateTemplate template =3D getHibernateTemplate();
template.setCacheQueries(true);
template.setFlushMode(HibernateTemplate.FLUSH_NEVER);
- List list =3D template.find(hql);
- retVal =3D fillContainerIdList(list);
+ retVal =3D template.find(hql);
return retVal;
}
=
@@ -405,8 +404,7 @@
}
=
private List fillContainerIdList(List list) {
- List retVal;
- retVal=3Dnew FastArrayList(list.size());
+ List retVal =3D new FastArrayList(list.size());
for (int i =3D 0; i < list.size(); i++) {
Object[] objects =3D (Object[]) list.get(i);
if(!retVal.contains(objects[0]))
@@ -433,15 +431,14 @@
=
public List getAllVersionedContainerIds(Long version) {
List retVal =3D null;
- String hql =3D "select distinct c.comp_id.id,c.rank,c.comp_id.vers=
ionId from JahiaContainer c "+
- "where c.comp_id.workflowState<=3D1 and c.comp_id.ver=
sionId>-1 and c.comp_id.versionId<=3D? "+
- "order by c.rank,c.comp_id.id,c.comp_id.versionId des=
c";
+ String hql =3D "select distinct c.comp_id.id,c.comp_id.versionId,c=
.rank from JahiaContainer c "
+ + "where c.comp_id.workflowState<=3D1 and c.comp_id.versio=
nId>-1 and c.comp_id.versionId<=3D? "
+ + "order by c.comp_id.id,c.comp_id.versionId desc";
if (version !=3D null) {
final HibernateTemplate template =3D getHibernateTemplate();
template.setCacheQueries(true);
template.setFlushMode(HibernateTemplate.FLUSH_NEVER);
- List list =3D template.find(hql, new Object[]{version});
- retVal =3D fillContainerIdList(list);
+ retVal =3D template.find(hql, new Object[]{version});
}
return retVal;
}
@@ -465,9 +462,9 @@
=
public List getNonDeletedStagingContainerIdsFromList(Integer listId) {
List retVal =3D null;
- String hql =3D "select distinct c.comp_id.id,c.comp_id.versionId,c=
.rank,c.comp_id.workflowState from JahiaContainer c "+
- "where c.comp_id.workflowState>=3D1 and c.listid=3D? =
"+
- "order by c.rank,c.comp_id.workflowState desc,c.comp_=
id.id";
+ String hql =3D "select distinct c.comp_id.id,c.comp_id.versionId,c=
.rank,c.comp_id.workflowState from JahiaContainer c "
+ + "where c.comp_id.workflowState>=3D1 and c.listid=3D? "
+ + "order by c.comp_id.id,c.comp_id.workflowState desc";
if (listId !=3D null) {
final HibernateTemplate template =3D getHibernateTemplate();
template.setCacheQueries(false);
@@ -542,31 +539,29 @@
=
public List getStagingContainerIdsFromList(Integer listId) {
List retVal =3D null;
- String hql =3D "select distinct c.comp_id.id,c.rank,c.comp_id.work=
flowState from JahiaContainer c "+
- "where c.comp_id.workflowState>=3D1 and c.listid=3D? =
"+
- "order by c.rank,c.comp_id.workflowState desc,c.comp_=
id.id";
+ String hql =3D "select distinct c.comp_id.id,c.comp_id.versionId,c=
.rank,c.comp_id.workflowState from JahiaContainer c "
+ + "where c.comp_id.workflowState>=3D1 and c.listid=3D? "
+ + "order by c.comp_id.id,c.comp_id.workflowState desc";
if (listId !=3D null) {
final HibernateTemplate template =3D getHibernateTemplate();
template.setCacheQueries(true);
template.setFlushMode(HibernateTemplate.FLUSH_NEVER);
- List list =3D template.find(hql, new Object[]{listId});
- retVal =3D fillContainerIdList(list);
+ retVal =3D template.find(hql, new Object[]{listId});
}
return retVal;
}
=
public List getVersionedContainerIdsFromList(Integer listId, Long vers=
ion) {
List retVal =3D null;
- String hql =3D "select distinct c.comp_id.id,c.rank,c.comp_id.vers=
ionId from JahiaContainer c "+
- "where c.comp_id.workflowState<=3D1 and c.comp_id.ver=
sionId>-1 and c.comp_id.versionId<=3D? "+
- "and c.listid=3D? "+
- "order by c.rank,c.comp_id.id,c.comp_id.versionId des=
c";
+ String hql =3D "select distinct c.comp_id.id,c.comp_id.versionId,c=
.rank from JahiaContainer c "
+ + "where c.comp_id.workflowState<=3D1 and c.comp_id.versio=
nId>-1 and c.comp_id.versionId<=3D? "
+ + "and c.listid=3D? "
+ + "order by c.comp_id.id,c.comp_id.versionId desc";
if (listId !=3D null && version !=3D null) {
HibernateTemplate template =3D getHibernateTemplate();
template.setCacheQueries(true);
template.setFlushMode(HibernateTemplate.FLUSH_NEVER);
- List list =3D template.find(hql, new Object[]{version, listId}=
);
- retVal =3D fillContainerIdList(list);
+ retVal =3D template.find(hql, new Object[]{version, listId});
}
return retVal;
}
@@ -677,7 +672,7 @@
new Object[]{new Integer(containerId.intValue()-batchSize),
new Integer(containerId.intValue()+batchSize)});
ArrayList filteredList =3D new ArrayList();
- ArrayList alreadyAddedCtns =3D new ArrayList();
+ Set alreadyAddedCtns =3D new HashSet();
if ( list.size()>0 ){
Iterator it =3D list.iterator();
JahiaContainer jahiaContainer =3D null;
@@ -725,7 +720,7 @@
template.setFlushMode(HibernateTemplate.FLUSH_NEVER);
final List list =3D template.find(queryString.toString());
ArrayList filteredList =3D new ArrayList();
- ArrayList alreadyAddedCtns =3D new ArrayList();
+ Set alreadyAddedCtns =3D new HashSet();
if ( list.size()>0 ){
it =3D list.iterator();
JahiaContainer jahiaContainer =3D null;
Modified: trunk/core/src/java/org/jahia/hibernate/manager/JahiaContainerMan=
ager.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/hibernate/manager/JahiaContainerManager.java&rev=3D18344&repname=
=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/core/src/java/org/jahia/hibernate/manager/JahiaContainerManager.j=
ava (original)
+++ trunk/core/src/java/org/jahia/hibernate/manager/JahiaContainerManager.j=
ava Sat Sep 1 23:46:34 2007
@@ -324,24 +324,39 @@
retval =3D dao.getPublishedContainerIdsFromList(id);
}
}
- if (loadVersion !=3D null && loadVersion.isStaging() && !loadV=
ersion.isWithMarkedForDeletion()) {
- List list =3D retval;
- retval =3D new ArrayList(list.size());
- Set addedCtnIds =3D new HashSet();
- Set deletedInStaging =3D new HashSet();
- =
- for (int i =3D 0; i < list.size(); i++) {
- Object[] objects =3D (Object[])
list.get(i);
- long version =3D ((Long)
objects[1]).longValue();
- if
(!deletedInStaging.contains(objects[0])
- &&
!addedCtnIds.contains(objects[0]) && version > -1) {
- retval.add(objects[0]);
- addedCtnIds.add(objects[0]);
- } else if (!compareMode && version
=3D=3D -1) {
-
deletedInStaging.add(objects[0]);
- }
- }
- } =
+ if (loadVersion !=3D null && (loadVersion.isStaging() || (load=
Version.isVersioned() && !compareMode))) {
+ Set addedCtnIds =3D new HashSet();
+ List sortedRanks =3D new ArrayList();
+ Integer previousCtnID =3D new Integer(-2);
+ =
+ List list =3D retval;
+ retval =3D new ArrayList(list.size());
+ =
+ for (int i =3D 0, size =3D list.size(); i < size; i++) {
+ Object[] objects =3D (Object[]) list.get(i);
+ =
+ Integer ctnID =3D (Integer)objects[0];
+ =
+ if (!addedCtnIds.contains(ctnID) && !previousCtnID.equ=
als(ctnID)
+ && (loadVersion.isWithMarkedForDeletion() || (=
(Long) objects[1]).longValue() !=3D -1)) {
+ int rank =3D ((Integer)objects[2]).intValue(); =
=
+ if (rank !=3D 0) {
+ int index =3D 0;
+ int sortedRankSize =3D sortedRanks.size();
+ while (index < sortedRankSize && ((Integer) so=
rtedRanks.get(index)).intValue() < rank) {
+ index++;
+ }
+ =
+ sortedRanks.add(index, new Integer(rank));
+ retval.add(index, ctnID);
+ } else {
+ retval.add(ctnID);
+ }
+ addedCtnIds.add(ctnID);
+ }
+ previousCtnID =3D ctnID; =
+ }
+ } =
if(!compareMode && cache!=3Dnull && !(loadVersion !=3D null &&=
loadVersion.getWorkflowState()<=3DEntryLoadRequest.VERSIONED_WORKFLOW_STAT=
E)) {
cache.put(cacheKey,retval);
}
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list