19 package org.turro.skills;
21 import java.util.Arrays;
22 import java.util.HashSet;
23 import java.util.List;
25 import java.util.stream.Collectors;
26 import org.turro.string.Strings;
27 import org.turro.elephant.db.ElephantPU;
28 import org.turro.elephant.db.WhereClause;
29 import org.turro.elephant.entities.db.Skill;
30 import org.turro.elephant.entities.db.SkillType;
31 import org.turro.jpa.Dao;
32 import org.turro.sql.SqlClause;
41 return getSkillsFrom(rootFilter ==
null ?
"*" : rootFilter, types);
51 wc.
addClause(
"where s.entityPath = :path");
70 wc.
addClause(
"select new org.turro.skills.SkillRoot(s.skill, s.type, count(s))");
72 wc.
addClause(validated ?
"where s.validated = TRUE" :
"where 1=1");
73 if(!Strings.isBlank(rootFilter)) {
74 wc.
addClause(
"and s.entityPath like :root");
88 dao.saveObject(skill);
94 skills.forEach(s -> s.setEntityPath(entityPath));
105 wc.
addClause(
"where s.entityPath = :path");
118 wc.
addClause(
"where entityPath = :path");
126 return new HashSet<>(SqlClause.select(
"distinct s.entityPath").from(
"Skill s")
127 .where().startsWith(
"s.entityPath",
"/" + root +
"/")
129 .resultList(String.class));
void addClause(String clause)
void addNamedValue(String name, Object value)
void setEntityPath(String entityPath)
int executeUpdate(String query)
void saveCollection(Collection objs)
static List< SkillRoot > getSkillsAsRootFrom(String entityPath, SkillType... types)
static List< SkillRoot > getAvailables(String rootFilter, SkillType... types)
static List< SkillRoot > getValidateds(String rootFilter, SkillType... types)
static void removeSkillsFor(String entityPath, SkillType... types)
static List< SkillRoot > getAvailables(String rootFilter, boolean validated, SkillType... types)
static Set< String > getAllPaths(String root)
static List< Skill > getRootSkillsFrom(String rootFilter, SkillType... types)
static void removeSkills(String entityPath)
static void setSkillsFor(String entityPath, Set< Skill > skills, SkillType... types)
static void removeSkillsFor(Dao dao, String entityPath, SkillType... types)
static List< Skill > getSkillsFrom(String entityPath, SkillType... types)
static void addSkillFor(String entityPath, Skill skill)