19 package org.turro.skills.tags;
21 import java.util.ArrayList;
22 import java.util.Collections;
23 import java.util.List;
24 import java.util.Optional;
26 import java.util.stream.Collectors;
27 import org.turro.string.Strings;
28 import org.turro.elephant.db.ElephantPU;
29 import org.turro.elephant.db.WhereClause;
30 import org.turro.elephant.entities.db.SkillType;
31 import org.turro.entities.Entities;
32 import org.turro.jpa.Dao;
33 import org.turro.path.Path;
34 import org.turro.util.Arrays;
45 wc.
addClause(
"select new org.turro.skills.tags.SkillItem(t.skill, t.type, count(t))");
48 if(!Strings.isBlank(root)) {
49 wc.
addClause(
"and t.entityPath like concat('/', :root, '/%')");
53 return new SkillSet(dao.getResultList(wc));
59 wc.
addClause(
"select new org.turro.skills.tags.SkillItem(t.skill, t.type, count(t))");
62 if(!Strings.isBlank(root)) {
63 wc.
addClause(
"and t.entityPath like concat('/', :root, '/%')");
67 return new SkillSet(dao.getResultList(wc));
73 for(String tag : skillNames) {
75 if(finalSet !=
null) {
76 finalSet.retainAll(
set);
81 return Optional.ofNullable(finalSet).orElseGet(() ->
SkillSet.
empty());
86 wc.
addClause(
"select new org.turro.skills.tags.SkillItem(t.skill, t.type, count(t))");
88 wc.
addClause(
"join Skill t1 on t.entityPath = t1.entityPath");
92 if(!Strings.isBlank(root)) {
93 wc.
addClause(
"and t.entityPath like concat('/', :root, '/%')");
97 return new SkillSet(dao.getResultList(wc));
105 return getEntityPaths(dao, root,
set).stream().map(s -> Path.getIdentifier(s)).collect(Collectors.toList());
113 List<String> skills =
set.stream().map(t -> t.getSkillName()).collect(Collectors.toList());
114 if(!skills.isEmpty()) {
116 wc.
addClause(
"select distinct t.entityPath from Skill t");
118 if(!Strings.isBlank(root)) {
119 wc.
addClause(
"and t.entityPath like concat('/', :root, '/%')");
123 for(String skill : skills) {
125 wc.
addClause(
"select t2.entityPath from Skill t2");
126 wc.
addClause(
"where t2.entityPath = t.entityPath");
127 wc.
addClause(
"and t2.skill = :skill" + count);
132 return dao.getResultList(String.class, wc);
134 return Collections.EMPTY_LIST;
144 wc.
addClause(
"select new org.turro.skils.tags.SkillItem(t.skill, t.type, count(t))");
146 wc.
addClause(
"where t.entityPath = :path");
148 wc.
addClause(
"group by t.skill, t.type");
149 return new SkillSet(dao.getResultList(wc));
void addClause(String clause)
void addIn(String operator, String field, List values)
void addNamedValue(String name, Object value)
static IElephantEntity getController(String path)
static Set< SkillType > getJuridicals()
static Set< SkillType > getNaturals()