14 package cz.vutbr.fit.knot.annotations.web;
20 import java.io.Serializable;
21 import java.util.ArrayList;
22 import java.util.Iterator;
23 import java.util.List;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import javax.faces.bean.ManagedBean;
27 import javax.faces.bean.SessionScoped;
28 import javax.persistence.EntityManager;
29 import javax.persistence.Query;
30 import org.openfaces.util.Faces;
100 @SuppressWarnings(
"unchecked")
101 List<UserGroup> retList = AppBean.getPersistenceManager().queryDB(
"UserGroup.findAll");
111 List<AnnotType> rList =
new ArrayList<AnnotType>();
112 AnnotType annotT = Faces.var(
"annotT", AnnotType.class);
114 if (annotT != null) {
117 EntityManager em = AppBean.getPersistenceManager().getEM();
120 Query query = em.createQuery(
"SELECT a FROM AnnotType a JOIN a.ancestorTypes at WHERE at.id='" + annotT.getId() +
"'");
121 tList = query.getResultList();
122 }
catch (Exception e) {
124 String msg =
"DB query in getNodeChildren failed.";
125 Logger.getLogger(ATypes.class.getName()).log(Level.SEVERE, msg, e);
131 if (tList != null && !tList.isEmpty()) {
132 for (Iterator tIt = tList.iterator(); tIt.hasNext();) {
140 Object[] params =
new Object[2];
141 params[0] =
"ancestor";
142 params[1] = annotT.getId();
143 tList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByAncestor", params);
144 if (tList != null && !tList.isEmpty()) {
145 for (Iterator tIt = tList.iterator(); tIt.hasNext();) {
147 if (!rList.contains(at)) {
163 EntityManager em = AppBean.getPersistenceManager().getEM();
165 Query query = em.createQuery(
"SELECT a FROM AnnotType a WHERE a.groupId = '" +
selectedId +
"' AND a.ancestor IS NULL");
166 tList = query.getResultList();
167 }
catch (Exception e) {
169 String msg =
"DB query in getNodeChildren failed.";
170 Logger.getLogger(ATypes.class.getName()).log(Level.SEVERE, msg, e);
177 if (tList != null && !tList.isEmpty()) {
178 for (Iterator tIt = tList.iterator(); tIt.hasNext();) {
194 AnnotType annotT = Faces.var(
"annotT", AnnotType.class);
196 if (annotT != null) {
198 EntityManager em = AppBean.getPersistenceManager().getEM();
201 Query query = em.createQuery(
"SELECT a FROM AnnotType a JOIN a.ancestorTypes at WHERE at.id='" + annotT.getId() +
"'");
202 tList = query.getResultList();
203 }
catch (Exception e) {
205 String msg =
"DB query in getNodeHasChildren failed.";
206 Logger.getLogger(ATypes.class.getName()).log(Level.SEVERE, msg, e);
212 if (tList != null && !tList.isEmpty()) {
217 Object[] params =
new Object[2];
218 params[0] =
"ancestor";
219 params[1] = annotT.getId();
220 tList = AppBean.getPersistenceManager().queryDB(
"AnnotType.findByAncestor", params);
221 if (tList != null && !tList.isEmpty()) {
235 else SessionManager.getSession().setAnnotationTypeAddress(null);
237 return SessionManager.getSession().getComeFrom();
240 return "addSubscription";
250 SessionManager.getSession().setAnnotationTypeAddress(null);
252 return SessionManager.getSession().getComeFrom();
255 SessionManager.getSession().setEditedSubscription(null);
256 return "addSubscription";
static WebSession getSession()
List< AnnotType > getNodeChildren()
Class for manipulating with session.
Backbean for page with selection of annotation type.
Singleton for storing global variables.
String btnSelectGroupAction()
Class representing user group.
void setSelectedId(Integer selectedId)
static final int LOG_LEVEL
Class representing type of annotation.
static final int LOG_LEVEL_SERVER_ERRORS
void setSelType(AnnotType selType)
List< UserGroup > getGroups()
boolean getNodeHasChildren()