BrightSide Workbench Full Report + Source Code
CategoryImpl.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 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 package org.turro.dossier.util;
19 
20 import org.turro.dossier.db.DossierPU;
21 import org.turro.dossier.entity.Category;
22 import org.turro.dossier.search.CategoryResults;
23 import org.turro.jpa.Dao;
24 import org.turro.plugin.dossier.ICategory;
25 
30 public class CategoryImpl implements ICategory {
31 
32  private long id, parentId;
33  private String description;
34 
35  @Override
36  public String getDescription() {
37  return description;
38  }
39 
40  @Override
41  public void setDescription(String description) {
42  this.description = description;
43  }
44 
45  @Override
46  public long getId() {
47  return id;
48  }
49 
50  @Override
51  public void setId(long id) {
52  this.id = id;
53  }
54 
55  @Override
56  public long getParentId() {
57  return parentId;
58  }
59 
60  @Override
61  public void setParentId(long id) {
62  this.parentId = id;
63  }
64 
65  @Override
66  public void save() {
67  Dao dao = new DossierPU();
68  Category cat = dao.find(Category.class, id);
69  if(cat == null) {
71  "insert into Category " +
72  "(identifier, description, knowledgeBase, ownsProjects) " +
73  "values (?, ?, 0, 0)",
74  new Object[] {
75  id, description
76  });
77  } else if(cat.getParent() == null && parentId > 0) {
78  cat.setParent(dao.find(Category.class, parentId));
80  } else {
82  }
83  }
84 
85 }
void setParent(Category parent)
Definition: Category.java:112
static void saveCategory(Category category)
void setDescription(String description)
int executeNativeUpdate(SqlClause sc, Object... pars)
Definition: Dao.java:536