Author: bpapez
Date: Wed Jun 6 17:48:33 2007
New Revision: 17491
URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D17491&repname=
=3Djahia
Log:
[MAN-16] Performance improvement for loading categories tab
Modified:
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/content/ObjectLink=
.java
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/dao/Jahi=
aLinkDAO.java
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/manager/=
JahiaLinkManager.java
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/Category.java
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/CategoryService.java
branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/CategoryServiceImpl.java
Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/content/Obje=
ctLink.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/content/ObjectLink.java&rev=3D17491&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/content/ObjectLink=
.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/content/ObjectLink=
.java Wed Jun 6 17:48:33 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/da=
o/JahiaLinkDAO.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/hibernate/dao/JahiaLinkDAO.java&rev=3D17491=
&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/dao/Jahi=
aLinkDAO.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/dao/Jahi=
aLinkDAO.java Wed Jun 6 17:48:33 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/ma=
nager/JahiaLinkManager.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/hibernate/manager/JahiaLinkManager.java&rev=
=3D17491&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/manager/=
JahiaLinkManager.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/hibernate/manager/=
JahiaLinkManager.java Wed Jun 6 17:48:33 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: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cat=
egories/Category.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/categories/Category.java&rev=3D174=
91&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/Category.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/Category.java Wed Jun 6 17:48:33 2007
@@ -277,7 +277,7 @@
static public JahiaObject getChildInstance (ObjectKey objectKey, Princ=
ipal p) {
try {
Category category =3D categoryService.
- getCategory (Integer.parseInt (objectKey.getIDInType (=
)));
+ getCategory (objectKey.getIdInType ());
if (p =3D=3D null) {
return category;
}
@@ -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;
@@ -503,6 +501,20 @@
}
=
/**
+ * 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 database
+ */
+ public List getChildCategoryKeys ()
+ throws JahiaException {
+ return categoryService.
+ getCategoryChildCategories (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.
Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cat=
egories/CategoryService.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/categories/CategoryService.java&re=
v=3D17491&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/CategoryService.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/CategoryService.java Wed Jun 6 17:48:33 2007
@@ -88,6 +88,20 @@
*/
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
Modified: branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/cat=
egories/CategoryServiceImpl.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-SP=
-BRANCH/core/src/java/org/jahia/services/categories/CategoryServiceImpl.jav=
a&rev=3D17491&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
--- branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/CategoryServiceImpl.java (original)
+++ branches/JAHIA-5-0-SP-BRANCH/core/src/java/org/jahia/services/categorie=
s/CategoryServiceImpl.java Wed Jun 6 17:48:33 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