19 package org.turro.alliance.provider;
21 import org.turro.elephant.db.ElephantPU;
22 import org.turro.elephant.entities.db.Tag;
23 import org.turro.jpa.Dao;
24 import org.turro.json.Jsons;
25 import org.turro.sql.SqlClause;
26 import org.turro.string.Strings;
27 import org.turro.util.Cached;
28 import org.turro.ws.WsMember;
29 import org.turro.ws.content.JsonServerProvider;
38 super(member, reason, criteria);
43 Jsons tags = Jsons.array();
44 String search = criteria.getString(
"search",
"");
45 String root = criteria.getString(
"root",
"");
46 String entityPath = criteria.getString(
"path",
"");
47 SqlClause.select(
"t").from(
"Tag t")
48 .startIf(!Strings.isBlank(search))
49 .whereOrAnd().partial(search,
"t.tagName")
51 .startIf(!Strings.isBlank(root))
52 .whereOrAnd().startsWith(
"t.entityPath",
"/" + root +
"/")
54 .startIf(!Strings.isBlank(entityPath))
55 .whereOrAnd().equal(
"t.entityPath", entityPath)
59 .resultList(
Tag.class).forEach(tag -> {
60 tags.addValue(Jsons.read(tag.toJson()));
67 String search = criteria.getString(
"search",
"");
68 String root = criteria.getString(
"root",
"");
69 String entityPath = criteria.getString(
"path",
"");
70 return SqlClause.select(
"count(t)").from(
"Tag t")
71 .startIf(!Strings.isBlank(search))
72 .whereOrAnd().partial(search,
"t.tagName")
74 .startIf(!Strings.isBlank(root))
75 .whereOrAnd().startsWith(
"t.entityPath",
"/" + root +
"/")
77 .startIf(!Strings.isBlank(entityPath))
78 .whereOrAnd().equal(
"t.entityPath", entityPath)
82 .singleResult(Long.class, 0L);
85 private final Cached<Dao> dao = Cached.instance(() ->
new ElephantPU());
TagProvider(WsMember member, String reason, Jsons criteria)
long count(WsMember member, String reason, Jsons criteria)
Jsons loadData(WsMember member, String reason, Jsons criteria)