}
static public JSONEscapeObject makeJSONCategoryTreeNode(String siteId, Long catId, Long siteProfileClassId, boolean siteProfileClassDefault) throws Exception {
EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
JSONEscapeObject JSONEscapeObject = new JSONEscapeObject();
Category category = CategoryDAO.load(siteId, catId);
JSONEscapeObject.put("catId", category.getCatId());
String catShortTitle = category.getCategoryLanguage().getCatShortTitle();
if (!siteProfileClassDefault) {
for (CategoryLanguage language : category.getCategoryLanguages()) {
if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
if (language.getCatShortTitle() != null) {
catShortTitle = language.getCatShortTitle();
}
}
}
}
JSONEscapeObject.put("catShortTitle", catShortTitle);
Vector<JSONEscapeObject> vector = new Vector<JSONEscapeObject>();
String sql = "from Category category " +
"where category.categoryParent.catId = :catId " +
"order by category.seqNum";
Query query = em.createQuery(sql);
query.setParameter("catId", category.getCatId());
Iterator<?> iterator = query.getResultList().iterator();
while (iterator.hasNext()) {
Category child = (Category) iterator.next();
JSONEscapeObject object = makeJSONCategoryTreeNode(siteId, child.getCatId(), siteProfileClassId, siteProfileClassDefault);
vector.add(object);
}
/*
for (Category child : category.getCategoryChildren()) {
JSONEscapeObject object = makeJSONCategoryTreeNode(siteId, child.getCatId(), siteProfileClassId, siteProfileClassDefault);