Source Code Cross Referenced for Article.java in  » Database-ORM » db-ojb » org » apache » ojb » odmg » shared » 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 » Database ORM » db ojb » org.apache.ojb.odmg.shared 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.ojb.odmg.shared;
002:
003:        import org.apache.ojb.odmg.shared.ProductGroup;
004:        import org.apache.commons.lang.builder.ToStringBuilder;
005:        import org.apache.commons.lang.builder.EqualsBuilder;
006:
007:        /** Simple Article class is not derived from any base class nor does it implement any Interface,
008:         * but still it can be made persistent by the PersistenceBroker.
009:         * Has a lot of private members to be mapped to rdbms columns, but only few business methods
010:         */
011:        public class Article implements  org.apache.ojb.odmg.TransactionAware {
012:            /** return a string representaion of an article*/
013:            public String toString() {
014:                return new ToStringBuilder(this ).append("articleId", articleId)
015:                        .append("articleName", articleName).append(
016:                                "productGroup",
017:                                (productGroup != null ? productGroup.getName()
018:                                        : null)).append("productGroupId",
019:                                productGroupId).append("isSelloutArticle",
020:                                isSelloutArticle).append("minimumStock",
021:                                minimumStock).append("orderedUnits",
022:                                orderedUnits).append("price", price).append(
023:                                "orderedUnits", orderedUnits).append("stock",
024:                                stock).append("supplierId", supplierId).append(
025:                                "unit", unit).toString();
026:            }
027:
028:            /** maps to db-column "Artikel-Nr";INT;PrimaryKey*/
029:            private int articleId;
030:            /** maps to db-column Artikelname;CHAR*/
031:            private String articleName;
032:            /** maps to db-column Auslaufartikel;SMALL INT*/
033:            private boolean isSelloutArticle;
034:            /** maps to db-column Mindestbestand;INT*/
035:            private int minimumStock;
036:            /** maps to db-column BestellteEinheiten;INT*/
037:            private int orderedUnits;
038:            /** maps to db-column Einzelpreis;DECIMAL*/
039:            private double price;
040:            /** reference to the articles category*/
041:            private ProductGroup productGroup;
042:            /** maps to db-column Kategorie-Nr;INT*/
043:            private int productGroupId;
044:            /** maps to db-column Lagerbestand;INT*/
045:            private int stock;
046:            /** maps to db-column Lieferanten-Nr;INT*/
047:            private int supplierId;
048:            /** maps to db-column Liefereinheit;CHAR*/
049:            private String unit;
050:
051:            public Article(int pArticleId, String pArticleName,
052:                    int pSupplierId, int pProcuctGroupId, String pUnit,
053:                    double pPrice, int pStock, int pOrderedUnits,
054:                    int pMinimumStock, boolean pIsSelloutArticle) {
055:                articleId = pArticleId;
056:                articleName = pArticleName;
057:                supplierId = pSupplierId;
058:                productGroupId = pProcuctGroupId;
059:                unit = pUnit;
060:                price = pPrice;
061:                stock = pStock;
062:                orderedUnits = pOrderedUnits;
063:                minimumStock = pMinimumStock;
064:                isSelloutArticle = pIsSelloutArticle;
065:
066:            }
067:
068:            public Article() {
069:            }
070:
071:            public static Article createInstance() {
072:                return new Article();
073:            }
074:
075:            /** increase the amount of articles in stock by diff
076:             * mark the object as modified only if value changes (i.e. diff != 0 )
077:             */
078:            public void addToStock(int diff) {
079:                stock += diff;
080:            }
081:
082:            /**
083:             * return an articles unique id.
084:             * @return int the articles unique id
085:             */
086:            public int getArticleId() {
087:                return articleId;
088:            }
089:
090:            /**
091:             * return an articles name.
092:             * @return java.lang.String
093:             */
094:            public String getArticleName() {
095:                return articleName;
096:            }
097:
098:            /** return an articles ProductGroup*/
099:            public ProductGroup getProductGroup() {
100:                return productGroup;
101:            }
102:
103:            /**
104:             * return stock of Article.
105:             * @return int
106:             */
107:            public int getStock() {
108:                return stock;
109:            }
110:
111:            /** compute the total value of an articles stock*/
112:            public double getStockValue() {
113:                return price * stock;
114:            }
115:
116:            /**
117:             * Sets the articleId.
118:             * @param articleId The articleId to set
119:             */
120:            public void setArticleId(int articleId) {
121:                this .articleId = articleId;
122:            }
123:
124:            /**
125:             * Sets the articleName.
126:             * @param articleName The articleName to set
127:             */
128:            public void setArticleName(String articleName) {
129:                this .articleName = articleName;
130:            }
131:
132:            /**
133:             * Sets the stock.
134:             * @param stock The stock to set
135:             */
136:            public void setStock(int stock) {
137:                this .stock = stock;
138:            }
139:
140:            /**
141:             * afterAbort will be called after a transaction has been aborted.
142:             * The values of fields which get persisted will have changed to
143:             * what they were at the begining of the transaction.  This method
144:             * should be overridden to reset any transient or non-persistent
145:             * fields.
146:             */
147:            public void afterAbort() {
148:                //System.out.println("afterAbort: " + new Identity(this));
149:            }
150:
151:            /**
152:             * afterCommit is called only after a successful commit has taken
153:             * place.
154:             */
155:            public void afterCommit() {
156:                //System.out.println("afterCommit: " + new Identity(this));
157:            }
158:
159:            /**
160:             * beforeAbort is called before a transaction is aborted.
161:             */
162:            public void beforeAbort() {
163:                //System.out.println("beforeAbort: " + new Identity(this));
164:            }
165:
166:            /**
167:             * beforeCommit will give an object a chance to kill a
168:             * transaction before it is committed.
169:             *
170:             * To kill a transaction, throw a new TransactionAbortedException.
171:             */
172:            public void beforeCommit()
173:                    throws org.odmg.TransactionAbortedException {
174:                //System.out.println("beforeCommit: " + new Identity(this));
175:            }
176:
177:            public boolean equals(Object obj) {
178:                if (obj instanceof  Article) {
179:                    Article other = ((Article) obj);
180:                    return new EqualsBuilder().append(articleId,
181:                            other.articleId).append(articleName,
182:                            other.articleName).append(productGroupId,
183:                            other.productGroupId).append(isSelloutArticle,
184:                            other.isSelloutArticle).append(minimumStock,
185:                            other.minimumStock).append(orderedUnits,
186:                            other.orderedUnits).append(price, other.price)
187:                            .append(orderedUnits, other.orderedUnits).append(
188:                                    stock, other.stock).append(supplierId,
189:                                    other.supplierId).append(unit, other.unit)
190:                            .isEquals();
191:                } else
192:                    return false;
193:            }
194:
195:            /* (non-Javadoc)
196:             * @see java.lang.Object#hashCode()
197:             */
198:            public int hashCode() {
199:                // Since we redefined equals, we have to redefine hashCode as well
200:                return articleId;
201:            }
202:
203:            /**
204:             * Gets the isSelloutArticle.
205:             * @return Returns a boolean
206:             */
207:            public boolean getIsSelloutArticle() {
208:                return isSelloutArticle;
209:            }
210:
211:            /**
212:             * Sets the isSelloutArticle.
213:             * @param isSelloutArticle The isSelloutArticle to set
214:             */
215:            public void setIsSelloutArticle(boolean isSelloutArticle) {
216:                this .isSelloutArticle = isSelloutArticle;
217:            }
218:
219:            /**
220:             * Gets the minimumStock.
221:             * @return Returns a int
222:             */
223:            public int getMinimumStock() {
224:                return minimumStock;
225:            }
226:
227:            /**
228:             * Sets the minimumStock.
229:             * @param minimumStock The minimumStock to set
230:             */
231:            public void setMinimumStock(int minimumStock) {
232:                this .minimumStock = minimumStock;
233:            }
234:
235:            /**
236:             * Gets the orderedUnits.
237:             * @return Returns a int
238:             */
239:            public int getOrderedUnits() {
240:                return orderedUnits;
241:            }
242:
243:            /**
244:             * Sets the orderedUnits.
245:             * @param orderedUnits The orderedUnits to set
246:             */
247:            public void setOrderedUnits(int orderedUnits) {
248:                this .orderedUnits = orderedUnits;
249:            }
250:
251:            /**
252:             * Gets the price.
253:             * @return Returns a double
254:             */
255:            public double getPrice() {
256:                return price;
257:            }
258:
259:            /**
260:             * Sets the price.
261:             * @param price The price to set
262:             */
263:            public void setPrice(double price) {
264:                this .price = price;
265:            }
266:
267:            /**
268:             * Sets the productGroup.
269:             * @param productGroup The productGroup to set
270:             */
271:            public void setProductGroup(ProductGroup productGroup) {
272:                this .productGroup = productGroup;
273:            }
274:
275:            /**
276:             * Gets the productGroupId.
277:             * @return Returns a int
278:             */
279:            public int getProductGroupId() {
280:                return productGroupId;
281:            }
282:
283:            /**
284:             * Sets the productGroupId.
285:             * @param productGroupId The productGroupId to set
286:             */
287:            public void setProductGroupId(int productGroupId) {
288:                this .productGroupId = productGroupId;
289:            }
290:
291:            /**
292:             * Gets the supplierId.
293:             * @return Returns a int
294:             */
295:            public int getSupplierId() {
296:                return supplierId;
297:            }
298:
299:            /**
300:             * Sets the supplierId.
301:             * @param supplierId The supplierId to set
302:             */
303:            public void setSupplierId(int supplierId) {
304:                this .supplierId = supplierId;
305:            }
306:
307:            /**
308:             * Gets the unit.
309:             * @return Returns a String
310:             */
311:            public String getUnit() {
312:                return unit;
313:            }
314:
315:            /**
316:             * Sets the unit.
317:             * @param unit The unit to set
318:             */
319:            public void setUnit(String unit) {
320:                this.unit = unit;
321:            }
322:
323:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.