BrightSide Workbench Full Report + Source Code
SkillOccurrenceAPI.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2021 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.occurrence;
20 
21 import java.util.List;
22 import org.turro.elephant.db.ElephantPU;
23 import org.turro.elephant.db.WhereClause;
24 import org.turro.elephant.entities.db.Skill;
25 import org.turro.i18n.I_;
26 import org.turro.jpa.Dao;
27 
32 public class SkillOccurrenceAPI extends AbstractOccurrenceAPI<Skill> {
33 
34  @Override
35  public String getName() {
36  return I_.get("Skills");
37  }
38 
39  @Override
40  public List<String> getPossibles(String value) {
41  WhereClause wc = new WhereClause();
42  wc.addClause("select distinct t.skill from Skill t");
43  wc.setPrefix("where");
44  wc.addLikeFields(new String[] { "t.skill" }, value);
45  return getDao().getResultList(String.class, wc);
46  }
47 
48  @Override
49  protected List<Skill> getOccurrences(String value) {
50  WhereClause wc = new WhereClause();
51  wc.addClause("select t from Skill t");
52  wc.addClause("where t.skill = :value");
53  wc.addNamedValue("value", value);
54  return getDao().getResultList(Skill.class, wc);
55  }
56 
57  @Override
58  protected String getValue(Skill value) {
59  return value.getSkill();
60  }
61 
62  @Override
63  protected void setValue(Skill value, String newValue) {
64  getDao().deleteObject(value);
65  value.setSkill(newValue);
66  }
67 
68  @Override
69  protected Dao createDao() {
70  return new ElephantPU();
71  }
72 
73 }
void addLikeFields(String[] fields, String value)
void addNamedValue(String name, Object value)
void setSkill(String skill)
Definition: Skill.java:47
static String get(String msg)
Definition: I_.java:41
void deleteObject(Object obj)
Definition: Dao.java:162
void setValue(Skill value, String newValue)
List< Skill > getOccurrences(String value)
List< String > getPossibles(String value)