BrightSide Workbench Full Report + Source Code
org.turro.dossier.search.CategoryResults Class Reference

Public Member Functions

 CategoryResults ()
 
java.util.List getCategoryList ()
 
java.util.List getCategoryRootList ()
 

Static Public Member Functions

static void saveCategory (Category category)
 
static void normalizeUniquePaths ()
 
static void normalizeUniquePaths (Dossier dossier)
 
static void addExistsCategoryAffiliance (WhereClause wc, String categoryIds, String dossierField)
 
static void addParticipantAffiliance (WhereClause wc, String sep, String idContact, String dossierField)
 
static void addParticipantCategoryAffiliance (WhereClause wc, String sep, String idContact, String categoryField)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 36 of file CategoryResults.java.

Constructor & Destructor Documentation

◆ CategoryResults()

org.turro.dossier.search.CategoryResults.CategoryResults ( )

Definition at line 38 of file CategoryResults.java.

38  {
39  }

Member Function Documentation

◆ addExistsCategoryAffiliance()

static void org.turro.dossier.search.CategoryResults.addExistsCategoryAffiliance ( WhereClause  wc,
String  categoryIds,
String  dossierField 
)
static

Definition at line 102 of file CategoryResults.java.

102  {
103  wc.addClause("and exists (select c from Category as c");
104  wc.addClause("where " + dossierField + ".uniquePath like concat(c.uniquePath, '/%')");
105  wc.addClause("and c.id in (" + categoryIds + "))");
106  }
Here is the call graph for this function:

◆ addParticipantAffiliance()

static void org.turro.dossier.search.CategoryResults.addParticipantAffiliance ( WhereClause  wc,
String  sep,
String  idContact,
String  dossierField 
)
static

Definition at line 108 of file CategoryResults.java.

108  {
109  wc.addClause(sep + " exists (");
110  wc.addClause("select cp from CategoryParticipant as cp");
111  wc.addClause("where cp.idContact = :idContact");
112  wc.addNamedValue("idContact", idContact);
113  wc.addClause("and (cp.role = :cprole1 or cp.role = :cprole2)");
114  wc.addNamedValue("cprole1", ParticipantRole.PARTICIPANT_OWNER);
115  wc.addNamedValue("cprole2", ParticipantRole.PARTICIPANT_ASSISTANT);
116  wc.addClause("and (");
117  wc.addClause("cp.category.uniquePath = " + dossierField + ".category.uniquePath");
118  wc.addClause("or " + dossierField + ".category.uniquePath like concat(cp.category.uniquePath, '/%')");
119  wc.addClause("))");
120  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addParticipantCategoryAffiliance()

static void org.turro.dossier.search.CategoryResults.addParticipantCategoryAffiliance ( WhereClause  wc,
String  sep,
String  idContact,
String  categoryField 
)
static

Definition at line 122 of file CategoryResults.java.

122  {
123  wc.addClause(sep + " ( exists (");
124  wc.addClause("select cp from CategoryParticipant as cp");
125  wc.addClause("where cp.idContact = :idContact");
126  wc.addNamedValue("idContact", idContact);
127  wc.addClause("and (cp.role = :cprole1 or cp.role = :cprole2)");
128  wc.addNamedValue("cprole1", ParticipantRole.PARTICIPANT_OWNER);
129  wc.addNamedValue("cprole2", ParticipantRole.PARTICIPANT_ASSISTANT);
130  wc.addClause("and (");
131  wc.addClause("cp.category.uniquePath = " + categoryField + ".uniquePath");
132  wc.addClause("or cp.category.uniquePath like concat(" + categoryField + ".uniquePath, '/%')");
133  wc.addClause("or " + categoryField + ".uniquePath like concat(cp.category.uniquePath, '/%')");
134  wc.addClause(")) or exists (");
135  wc.addClause("select dp from Participant as dp");
136  wc.addClause("where (");
137  wc.addClause("dp.dossier.category.uniquePath = " + categoryField + ".uniquePath");
138  wc.addClause("or dp.dossier.category.uniquePath like concat(" + categoryField + ".uniquePath, '/%')");
139  wc.addClause(")");
140  wc.addClause("and dp.idContact = :idContact");
141  wc.addNamedValue("idContact", idContact);
142  wc.addClause("and (dp.role = :dpdrole1 or dp.role = :dpdrole2)");
143  wc.addNamedValue("dpdrole1", ParticipantRole.PARTICIPANT_OWNER);
144  wc.addNamedValue("dpdrole2", ParticipantRole.PARTICIPANT_ASSISTANT);
145  wc.addClause("))");
146  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCategoryList()

java.util.List org.turro.dossier.search.CategoryResults.getCategoryList ( )

Definition at line 41 of file CategoryResults.java.

41  {
42  WhereClause wc = new WhereClause();
43  wc.addClause("select distinct category");
44  wc.addClause("from Category as category");
45  wc.addClause("order by category.fullDescription");
46  return new DossierPU().getResultList(wc);
47  }
Here is the call graph for this function:

◆ getCategoryRootList()

java.util.List org.turro.dossier.search.CategoryResults.getCategoryRootList ( )

Definition at line 49 of file CategoryResults.java.

49  {
50  WhereClause wc = new WhereClause();
51  wc.addClause("select distinct category");
52  wc.addClause("from Category as category");
53  wc.addClause("where parent is null");
54  wc.addClause("order by category.fullDescription");
55  return new DossierPU().getResultList(wc);
56  }
Here is the call graph for this function:

◆ normalizeUniquePaths() [1/2]

static void org.turro.dossier.search.CategoryResults.normalizeUniquePaths ( )
static

Definition at line 65 of file CategoryResults.java.

65  {
66  Dao dao = new DossierPU(); //query
67  Dao execute = new DossierPU(); //update within query
68  JpaCriteria criteria = new JpaCriteria(dao);
69  JpaQuery<Category> jqc = criteria.query(Category.class);
70  dao.getResultList(jqc.select()).forEach((category) -> {
71  String uniquePath = "/c" + category.getId();
72  String fullDescription = category.getDescription();
73  Category c = category.getParent();
74  while(c != null) {
75  uniquePath = "/c" + c.getId() + uniquePath;
76  fullDescription = c.getDescription() + Chars.backward().spaced() + fullDescription;
77  c = c.getParent();
78  }
79  JpaCriteriaUpdate<Category> juc = criteria.createCriteriaUpdate(Category.class);
80  execute.executeUpdate(juc.set("uniquePath", uniquePath)
81  .set("fullDescription", fullDescription)
82  .where(criteria.equal(juc.field("id"), category.getId())));
83  });
84  JpaQuery<Dossier> jqd = criteria.query(Dossier.class);
85  try(Stream<Dossier> dossiers = dao.stream(Dossier.class, jqd.select())) {
86  dossiers.forEach((dossier) -> {
87  JpaCriteriaUpdate<Dossier> jud = criteria.createCriteriaUpdate(Dossier.class);
88  execute.executeUpdate(jud.set("uniquePath", dossier.getCategory().getUniquePath() + "/d" + dossier.getId())
89  .where(criteria.equal(jud.field("id"), dossier.getId())));
90  });
91  }
92  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalizeUniquePaths() [2/2]

static void org.turro.dossier.search.CategoryResults.normalizeUniquePaths ( Dossier  dossier)
static

Definition at line 94 of file CategoryResults.java.

94  {
95  Dao dao = new DossierPU();
96  JpaCriteria criteria = new JpaCriteria(dao);
97  JpaCriteriaUpdate<Dossier> jud = criteria.createCriteriaUpdate(Dossier.class);
98  dao.executeUpdate(jud.set("uniquePath", dossier.getCategory().getUniquePath() + "/d" + dossier.getId())
99  .where(criteria.equal(jud.field("id"), dossier.getId())));
100  }
Here is the call graph for this function:

◆ saveCategory()

static void org.turro.dossier.search.CategoryResults.saveCategory ( Category  category)
static

Definition at line 58 of file CategoryResults.java.

58  {
59  Dao dao = new DossierPU();
60  category.prepareSave();
61  dao.saveObject(category);
63  }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: