Source Code Cross Referenced for Assets.java in  » ERP-CRM-Financial » Personal-Finance-Manager » br » com » gfp » data » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » ERP CRM Financial » Personal Finance Manager » br.com.gfp.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on 15/04/2004
003:         * 
004:         * Swing Components - visit http://sf.net/projects/gfd
005:         * 
006:         * Copyright (C) 2004  Igor Regis da Silva Simões
007:         * 
008:         * This program is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public License
010:         * as published by the Free Software Foundation; either version 2
011:         * of the License, or (at your option) any later version.
012:         *
013:         * This program is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:         * GNU General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public License
019:         * along with this program; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
021:         */
022:
023:        package br.com.gfp.data;
024:
025:        import java.security.InvalidParameterException;
026:        import java.sql.SQLException;
027:        import java.util.Calendar;
028:        import java.util.Date;
029:        import java.util.Map;
030:
031:        import br.com.gfp.internationalization.ErrosDeDadosMessages;
032:        import br.com.gfpshare.db.Column;
033:        import br.com.gfpshare.db.Table;
034:
035:        /**
036:         *	Classe que representa um bem e todos os dados que queremos guardar a seu respeito 
037:         * @author  Igor Regis da Silva Simões
038:         */
039:        @Table(name="Bem")
040:        public class Assets extends BasicGFPDataObject {
041:            /**
042:             * Nome do bem
043:             */
044:            @Column(nome="Nome",isPk=false,writeMethodName="setNome",readMethodName="getNome")
045:            private String nome = null;
046:
047:            /**
048:             * Descricao do bem
049:             */
050:            @Column(nome="Descricao",isPk=false,writeMethodName="setDescricao",readMethodName="getDescricao")
051:            private String descricao = null;
052:
053:            /**
054:             * Valor pelo qual o bem foi comprado
055:             */
056:            @Column(nome="ValorCompra",isPk=false,writeMethodName="setValorCompra",readMethodName="getValorCompra")
057:            private Double valorCompra = null;
058:
059:            /**
060:             * Valor atual do bem
061:             */
062:            @Column(nome="ValorAtual",isPk=false,writeMethodName="setValorAtual",readMethodName="getValorAtual")
063:            private Double valorAtual = null;
064:
065:            /**
066:             * Indice anual de depreciação do bem
067:             */
068:            @Column(nome="IndiceDeAtualizacao",isPk=false,writeMethodName="setIndiceDeAtualizacao",readMethodName="getIndiceDeAtualizacao")
069:            private Float indiceDeAtualizacao = null;
070:
071:            /**
072:             * Data em que o bem foi comprado
073:             */
074:            @Column(nome="DataCompra",isPk=false,writeMethodName="setDataCompra",readMethodName="getDataCompra")
075:            private Date dataCompra = null;
076:
077:            /**
078:             *  Local onde o bem foi comprado
079:             */
080:            @Column(nome="LocalCompra",isPk=false,writeMethodName="setLocalCompra",readMethodName="getLocalCompra")
081:            private Integer localCompra = null;
082:
083:            /**
084:             * Data em que o bem foi vendido
085:             */
086:            @Column(nome="DataVenda",isPk=false,writeMethodName="setDataVenda",readMethodName="getDataVenda")
087:            private Date dataVenda = null;
088:
089:            /**
090:             * Valor pelo qual o bem foi vendido
091:             */
092:            @Column(nome="ValorVenda",isPk=false,writeMethodName="setValorVenda",readMethodName="getValorVenda")
093:            private Double valorVenda = null;
094:
095:            /** 
096:             *  Creates a new instance of Entidade
097:             */
098:            public Assets() {
099:                //Não fazemos nada
100:            }
101:
102:            /** 
103:             *  Creates a new instance of Entidade
104:             * @param id Id do Assets
105:             */
106:            public Assets(Integer id) {
107:                setId(id);
108:            }
109:
110:            /** 
111:             *  Creates a new instance of Entidade
112:             * 	@param nome Nome do bem
113:             */
114:            public Assets(String nome) {
115:                setNome(nome);
116:            }
117:
118:            /** 
119:             *  Creates a new instance of Entidade
120:             * @param bem Map contendo os dados para este novo bem
121:             */
122:            public Assets(Map<String, Object> bem) {
123:                setDados(bem);
124:            }
125:
126:            /**
127:             * Getter for property nome.
128:             * @return Value of property nome.
129:             */
130:            public String getNome() {
131:                return nome;
132:            }
133:
134:            /**
135:             * Setter for property nome.
136:             * @param nome New value of property nome.
137:             */
138:            public void setNome(String nome) {
139:
140:                this .nome = nome.equals("") ? null : nome;
141:            }
142:
143:            /**
144:             * Getter for property descricao.
145:             * @return Value of property descricao.
146:             */
147:            public String getDescricao() {
148:                return descricao;
149:            }
150:
151:            /**
152:             * Setter for property descricao.
153:             * @param descricao New value of property descricao.
154:             */
155:            public void setDescricao(String descricao) {
156:                this .descricao = descricao.equals("") ? null : descricao;
157:            }
158:
159:            /**
160:             * Getter for property valorCompra.
161:             * @return Value of property valorCompra.
162:             */
163:            public Double getValorCompra() {
164:                return valorCompra;
165:            }
166:
167:            /**
168:             * Setter for property valorCompra.
169:             * @param valorCompra New value of property valorCompra.
170:             */
171:            public void setValorCompra(Double valorCompra) {
172:                this .valorCompra = valorCompra;
173:            }
174:
175:            /**
176:             * Getter for property ValorAtual.
177:             * @return Value of property ValorAtual.
178:             */
179:            public Double getValorAtual() {
180:                Calendar dtCompra = Calendar.getInstance();
181:                Calendar dtAtual = Calendar.getInstance();
182:                if (getDataCompra() != null)
183:                    dtCompra.setTime(getDataCompra());
184:                else
185:                    dtCompra.setTime(new Date());
186:                dtAtual.setTime(new Date());
187:
188:                long compra = dtCompra.getTimeInMillis();
189:                long hoje = dtAtual.getTimeInMillis();
190:
191:                int dias = (int) ((hoje / 1000 / 60 / 60 / 24) - (compra / 1000 / 60 / 60 / 24));
192:                if (getValorCompra() != null
193:                        && getIndiceDeAtualizacao() != null)
194:                    setValorAtual(new Double(getValorCompra().doubleValue()
195:                            + (getValorCompra().doubleValue() * dias
196:                                    * getIndiceDeAtualizacao().floatValue()
197:                                    / 100 / 365)));
198:
199:                return valorAtual;
200:            }
201:
202:            /**
203:             * Setter for property ValorAtual.
204:             * @param ValorAtual New value of property ValorAtual.
205:             */
206:            public void setValorAtual(Double ValorAtual) {
207:                this .valorAtual = ValorAtual;
208:            }
209:
210:            /**
211:             * Getter for property indiceAnualDepreciacao.
212:             * @return Value of property indiceAnualDepreciacao.
213:             */
214:            public Float getIndiceDeAtualizacao() {
215:                return indiceDeAtualizacao;
216:            }
217:
218:            /**
219:             * Setter for property indiceAnualDepreciacao.
220:             * @param indiceDeAtualizacao New value of property indiceAnualDepreciacao.
221:             */
222:            public void setIndiceDeAtualizacao(Float indiceDeAtualizacao) {
223:                this .indiceDeAtualizacao = indiceDeAtualizacao
224:                        .equals(new Float("0.00")) ? null : indiceDeAtualizacao;
225:            }
226:
227:            /**
228:             * Getter for property dataCompra.
229:             * @return Value of property dataCompra.
230:             */
231:            public Date getDataCompra() {
232:                return dataCompra;
233:            }
234:
235:            /**
236:             * Setter for property dataCompra.
237:             * @param dataCompra New value of property dataCompra.
238:             */
239:            public void setDataCompra(Date dataCompra) {
240:                this .dataCompra = dataCompra;
241:            }
242:
243:            /**
244:             * Getter for property localCompra.
245:             * @return Value of property localCompra.
246:             */
247:            public Integer getLocalCompra() {
248:                return localCompra;
249:            }
250:
251:            /**
252:             * Setter for property localCompra.
253:             * @param localCompra New value of property localCompra.
254:             */
255:            public void setLocalCompra(Integer localCompra) {
256:                this .localCompra = localCompra;
257:            }
258:
259:            /**
260:             * Getter for property DataVenda.
261:             * @return Value of property DataVenda.
262:             */
263:            public Date getDataVenda() {
264:                return dataVenda;
265:            }
266:
267:            /**
268:             * Setter for property DataVenda.
269:             * @param dataVenda New value of property DataVenda.
270:             */
271:            public void setDataVenda(Date dataVenda) {
272:                this .dataVenda = dataVenda;
273:            }
274:
275:            /**
276:             * Getter for property valorVenda.
277:             * @return Value of property valorVenda.
278:             */
279:            public Double getValorVenda() {
280:                return valorVenda;
281:            }
282:
283:            /**
284:             * Setter for property valorVenda.
285:             * @param valorVenda New value of property valorVenda.
286:             */
287:            public void setValorVenda(Double valorVenda) {
288:                this .valorVenda = valorVenda;
289:            }
290:
291:            /**
292:             * @see br.com.gfpshare.db.PersistentObject#validate()
293:             */
294:            public void validate() throws SQLException {
295:                if (this .nome == null)
296:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
297:                            .getString("NomeInvalido"));
298:                if (this .dataCompra == null)
299:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
300:                            .getString("DataCompraInvalido"));
301:                if (this .dataVenda != null && this .dataVenda.before(dataCompra))
302:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
303:                            .getString("DataVendaAnteriorCompra"));
304:                if (this .localCompra == null)
305:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
306:                            .getString("LocalCompraInvalido"));
307:                if (this .valorCompra == null
308:                        || this .valorCompra.doubleValue() < 0)
309:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
310:                            .getString("ValorCompraInvalido"));
311:                if (this .valorVenda != null
312:                        && this .valorVenda.doubleValue() < 0)
313:                    throw new SQLException(ErrosDeDadosMessages.getMessages()
314:                            .getString("ValorVendaInvalido"));
315:            }
316:
317:            /**
318:             * @see br.com.gfpshare.db.PersistentObject#getAsString(int)
319:             */
320:            public String getAsString(int format) {
321:                switch (format) {
322:                case AccountSaving.CURTO:
323:                    return getNome();
324:                case AccountSaving.MEDIO:
325:                    return getNome() + " - " + getDescricao();
326:                case AccountSaving.LONGO:
327:                    return toString();
328:                }
329:                return "";
330:            }
331:
332:            /**
333:             * Valida o campo valor do lançamento
334:             * @param valor Valor a ser validado
335:             * @throws InvalidParameterException
336:             */
337:            public void validateValorCompra(Object valor)
338:                    throws InvalidParameterException {
339:                if (valor != null)
340:                    valorCompra = (Double) valor;
341:                if (this .valorCompra == null
342:                        || this .valorCompra.equals(Double.valueOf("0.0"))
343:                        || this .valorCompra.equals(Double.valueOf("-0.0")))
344:                    throw new RuntimeException(ErrosDeDadosMessages
345:                            .getMessages().getString("ValorCompraInvalido"));
346:            }
347:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.