BrightSide Workbench Full Report + Source Code
Account.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.financials.entity;
19 
20 import java.util.List;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.Id;
24 import org.turro.string.Strings;
25 import org.turro.financials.db.FinancialsPU;
26 import org.turro.jpa.entity.IDaoEntity;
27 
32 @Entity
33 public class Account implements java.io.Serializable, IDaoEntity {
34 
35  @Id
36  @Column(name="IDENTIFIER")
37  private String id;
38 
39  private String description;
40 
41  public String getDescription() {
42  return description;
43  }
44 
45  public void setDescription(String description) {
46  this.description = description;
47  }
48 
49  public String getId() {
50  return id;
51  }
52 
53  public void setId(String id) {
54  this.id = id;
55  }
56 
57  /* IDaoEntity */
58 
59  @Override
60  public Object entityId() {
61  return id;
62  }
63 
64  @Override
65  public boolean isEmpty() {
66  return Strings.isBlank(id) || Strings.isBlank(description);
67  }
68 
69  /* Helpers */
70 
71  public String getFullDescription() {
72  return "#" + id + " - " + description;
73  }
74 
76  if(id != null && id.length() > 1) {
77  List l = new FinancialsPU().getResultList(
78  "select m from MajorAccount as m " +
79  "where '" + id + "' " + "like concat(m.account, '%') " +
80  "order by m.account desc");
81  if(!l.isEmpty()) {
82  return (MajorAccount) l.get(0);
83  }
84  }
85  return null;
86  }
87 
88  public void proposeDescription() {
89  MajorAccount ma = getParent();
90  if(ma != null) {
92  }
93  }
94 
95 }
void setDescription(String description)
Definition: Account.java:45