Author: bpapez
Date: Fri Jun 15 14:34:56 2007
New Revision: 17589
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D17589&repname=
=3Djahia
Log:
[MAN-16] Performance improvement for loading categories tab
Modified:
trunk/core/src/java/org/jahia/content/ObjectLink.java
trunk/core/src/java/org/jahia/hibernate/dao/JahiaLinkDAO.java
trunk/core/src/java/org/jahia/hibernate/manager/JahiaLinkManager.java
trunk/core/src/java/org/jahia/services/categories/Category.java
trunk/core/src/java/org/jahia/services/categories/CategoryService.java
trunk/core/src/java/org/jahia/services/categories/CategoryServiceImpl.j=
ava
Modified: trunk/core/src/java/org/jahia/content/ObjectLink.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/content/ObjectLink.java&rev=3D17589&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/content/ObjectLink.java (original)
+++ trunk/core/src/java/org/jahia/content/ObjectLink.java Fri Jun 15 14:34:=
56 2007
@@ -132,6 +132,14 @@
return linkManager.findByTypeAndLeftAndRightObjectKeys(type, leftO=
bjectKey, rightObjectKey);
}
=
+ static public List findByTypeAndLeftAndLikeRightObjectKeys (String typ=
e,
+ ObjectKey leftObjectKey,
+ String rightObjectKey)
+ throws JahiaException {
+ JahiaLinkManager linkManager =3D (JahiaLinkManager) SpringContextSing=
leton.getInstance().getContext().getBean(JahiaLinkManager.class.getName());=
=
+ return linkManager.findByTypeAndLeftAndLikeRightObjectKeys(type, l=
eftObjectKey, rightObjectKey);
+ } =
+ =
static public List findByTypeAndLeftObjectKey (String type,
ObjectKey leftObjectKey)
throws JahiaException {
Modified: trunk/core/src/java/org/jahia/hibernate/dao/JahiaLinkDAO.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/hibernate/dao/JahiaLinkDAO.java&rev=3D17589&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/JahiaLinkDAO.java (original)
+++ trunk/core/src/java/org/jahia/hibernate/dao/JahiaLinkDAO.java Fri Jun 1=
5 14:34:56 2007
@@ -69,6 +69,15 @@
hibernateTemplate.setFlushMode(HibernateTemplate.FLUSH_NEVER);
return hibernateTemplate.find("from JahiaLink link where link.righ=
tOid=3D?", objectKey);
}
+ =
+ public List findByTypeAndLeftAndLikeRightObjectKeys(String leftKey, St=
ring rightKey, String type) {
+ HibernateTemplate hibernateTemplate =3D getHibernateTemplate();
+ hibernateTemplate.setCacheQueries(true);
+ hibernateTemplate.setFlushMode(HibernateTemplate.FLUSH_NEVER);
+ return hibernateTemplate.find(
+ "from JahiaLink link where link.type=3D? and link.leftOid=
=3D? and link.rightOid like ?",
+ new Object[]{type, leftKey, rightKey});
+ } =
=
public List findByTypeAndLeftAndRightObjectKeys(String leftKey, String=
rightKey, String type) {
HibernateTemplate hibernateTemplate =3D getHibernateTemplate();
Modified: trunk/core/src/java/org/jahia/hibernate/manager/JahiaLinkManager.=
java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/hibernate/manager/JahiaLinkManager.java&rev=3D17589&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/JahiaLinkManager.java (=
original)
+++ trunk/core/src/java/org/jahia/hibernate/manager/JahiaLinkManager.java F=
ri Jun 15 14:34:56 2007
@@ -162,6 +162,22 @@
return objectLinks;
}
=
+ public List findByTypeAndLeftAndLikeRightObjectKeys(String type, Objec=
tKey leftObjectKey, String rightObjectKey) {
+ List objectLinks =3D null;
+
+ if (objectLinks =3D=3D null) {
+ List jahiaLinks =3D dao.findByTypeAndLeftAndLikeRightObjectKey=
s(leftObjectKey.toString(), rightObjectKey,
+ type=
);
+ objectLinks =3D new FastArrayList(jahiaLinks.size());
+ for (int i =3D 0; i < jahiaLinks.size(); i++) {
+ JahiaLink jahiaLink =3D (JahiaLink) jahiaLinks.get(i);
+ ObjectLink objectLink =3D fillObjectLink(jahiaLink);
+ objectLinks.add(objectLink);
+ }
+ }
+ return objectLinks;
+ } =
+
public List findByTypeAndLeftAndRightObjectKeys(String type, ObjectKey=
leftObjectKey, ObjectKey rightObjectKey) {
List objectLinks =3D null;
Cache cache =3D cacheService.getCache(CACHE_NAME+"findByTypeAndLef=
tAndRightObjectKeys");
Modified: trunk/core/src/java/org/jahia/services/categories/Category.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/services/categories/Category.java&rev=3D17589&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/services/categories/Category.java (origin=
al)
+++ trunk/core/src/java/org/jahia/services/categories/Category.java Fri Jun=
15 14:34:56 2007
@@ -435,16 +435,14 @@
*/
public List getChildCategories (Principal p)
throws JahiaException {
- List childKeys =3D getChildObjectKeys ();
+ List childKeys =3D getChildCategoryKeys();
List childCategories =3D new ArrayList ();
Iterator childKeyIter =3D childKeys.iterator ();
while (childKeyIter.hasNext ()) {
ObjectKey curKey =3D (ObjectKey) childKeyIter.next ();
- if (curKey instanceof CategoryKey) {
- Category curChildCategory =3D (Category) Category.getChild=
Instance (curKey, p);
- if (curChildCategory !=3D null) {
- childCategories.add (curChildCategory);
- }
+ Category curChildCategory =3D (Category) Category.getChildInst=
ance (curKey, p);
+ if (curChildCategory !=3D null) {
+ childCategories.add (curChildCategory);
}
}
return childCategories;
@@ -501,15 +499,29 @@
return categoryService.
getCategoryChildKeys (this);
}
-
- /**
- * Retrieves the list of parent object keys for this category. This sh=
ould
- * normally be Categories, unless there has been some manual associati=
ons
- * done.
- * @return an ArrayList containing ObjectKey classes or sub-classes
- * @throws JahiaException thrown if there was a problem communicating =
with
- * the database
- */
+ =
+ /**
+ * Retrieves the list of child category keys for this category.
+ * =
+ * @return an ArrayList containing CagegoryKey classes
+ * =
+ * @throws JahiaException
+ * thrown if there was a problem communicating with the
datab=
ase
+ */
+ public List getChildCategoryKeys() throws JahiaException {
+ return categoryService.getCategoryChildCategories(this);
+ } =
+ =
+ /**
+ * =
+ * /** Retrieves the list of parent object keys for this category. This
+ * should normally be Categories, unless there has been some manual
+ * associations done.
+ * =
+ * @return an ArrayList containing ObjectKey classes or sub-classes
+ * @throws JahiaException
+ * thrown if there was a problem communicating with the
datab=
ase
+ */
public List getParentObjectKeys()
throws JahiaException {
return categoryService.getCategoryParentKeys(this);
Modified: trunk/core/src/java/org/jahia/services/categories/CategoryService=
.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/services/categories/CategoryService.java&rev=3D17589&repname=3Djah=
ia
=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/services/categories/CategoryService.java =
(original)
+++ trunk/core/src/java/org/jahia/services/categories/CategoryService.java =
Fri Jun 15 14:34:56 2007
@@ -89,6 +89,21 @@
public abstract List getCategoryChildKeys (Category parentCategory)
throws JahiaException;
=
+ =
+ /**
+ * Retrieves the child category keys that are associated with the given
+ * parent category. =
+ *
+ * @param parentCategory the category for which to retrieve the sub-ca=
tegories
+ *
+ * @return a list of CategoryKey objects.
+ *
+ * @throws JahiaException thrown if there was a problem communicating =
with
+ * the database
+ */
+ public abstract List getCategoryChildCategories (Category parentCatego=
ry)
+ throws JahiaException; =
+ =
/**
* Retrieves the parent object keys that are associated with the given
* child category. The parent objects should only be other categories,
Modified: trunk/core/src/java/org/jahia/services/categories/CategoryService=
Impl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/trunk/core/src/java/o=
rg/jahia/services/categories/CategoryServiceImpl.java&rev=3D17589&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/services/categories/CategoryServiceImpl.j=
ava (original)
+++ trunk/core/src/java/org/jahia/services/categories/CategoryServiceImpl.j=
ava Fri Jun 15 14:34:56 2007
@@ -63,6 +63,7 @@
=
private static final String ROOT_CATEGORY_KEY =3D "root";
private static final String CATEGORY_LINKTYPE =3D "category";
+ private static final String CATEGORY_CHILD_PREFIX =3D "Category_%"; =
=
private static final String CATEGORY_RESOURCEKEY_PREFIX =3D "org.jahia=
.category.title.";
=
private CacheService cacheService;
@@ -140,6 +141,20 @@
childCategory.getOb=
jectKey ());
}
=
+ public List getCategoryChildCategories(Category parentCategory)
+ throws JahiaException {
+ List links =3D
ObjectLink.findByTypeAndLeftAndLikeRightObjectKeys(
+ CATEGORY_LINKTYPE,
parentCategory.getObjectKey(),
+ CATEGORY_CHILD_PREFIX);
+ List rightObjectKeys =3D new ArrayList();
+ Iterator linkIter =3D links.iterator();
+ while (linkIter.hasNext()) {
+ ObjectLink curLink =3D (ObjectLink) linkIter.next();
+ rightObjectKeys.add(curLink.getRightObjectKey());
+ }
+ return rightObjectKeys;
+ } =
+ =
public List getCategoryChildKeys (Category parentCategory)
throws JahiaException {
List links =3D getCategoryChildLinks (parentCategory);
_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list