Source Code Cross Referenced for ProductCategoryModel.java in  » J2EE » Sofia » com » salmonllc » examples » example5 » 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 » J2EE » Sofia » com.salmonllc.examples.example5 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.salmonllc.examples.example5;
002:
003:        import java.sql.SQLException;
004:
005:        import com.salmonllc.sql.*;
006:
007:        //$CUSTOMIMPORTS$
008:        import com.salmonllc.examples.SiteMapConstants;
009:        import com.salmonllc.html.HtmlTreeControl;
010:        import com.salmonllc.html.treeControl.TreeBuffer;
011:
012:        //$ENDCUSTOMIMPORTS$
013:
014:        /**
015:         * ProductCategoryModel: A SOFIA generated model
016:         */
017:        public class ProductCategoryModel extends DataStore {
018:
019:            //constants for columns
020:            public static final String PRODUCT_CATEGORY_PRODUCT_CAT_ID = "product_category.product_cat_id";
021:            public static final String PRODUCT_CATEGORY_PARENT_ID = "product_category.parent_id";
022:            public static final String PRODUCT_CATEGORY_DESCRIPTION = "product_category.description";
023:            public static final String PRODUCT_CATEGORY_QUANTITY = "product_category.quantity";
024:            public static final String PRODUCT_CATEGORY_PRICE = "product_category.price";
025:
026:            //constants for buckets
027:            public static final String SELECTED = "selected";
028:
029:            //$CUSTOMVARS$
030:
031:            //$ENDCUSTOMVARS$
032:
033:            /**
034:             * Create a new ProductCategoryModel object.
035:             * @param appName The SOFIA application name
036:             */
037:            public ProductCategoryModel(String appName) {
038:                this (appName, null);
039:            }
040:
041:            /**
042:             * Create a new ProductCategoryModel object.
043:             * @param appName The SOFIA application name
044:             * @param profile The database profile to use
045:             */
046:            public ProductCategoryModel(String appName, String profile) {
047:                super (appName, profile);
048:
049:                //add columns
050:                addColumn(computeTableName("product_category"),
051:                        "product_cat_id", DataStore.DATATYPE_INT, true, true,
052:                        PRODUCT_CATEGORY_PRODUCT_CAT_ID);
053:                addColumn(computeTableName("product_category"), "parent_id",
054:                        DataStore.DATATYPE_INT, false, true,
055:                        PRODUCT_CATEGORY_PARENT_ID);
056:                addColumn(computeTableName("product_category"), "description",
057:                        DataStore.DATATYPE_STRING, false, true,
058:                        PRODUCT_CATEGORY_DESCRIPTION);
059:                addColumn(computeTableName("product_category"), "quantity",
060:                        DataStore.DATATYPE_INT, false, true,
061:                        PRODUCT_CATEGORY_QUANTITY);
062:                addColumn(computeTableName("product_category"), "price",
063:                        DataStore.DATATYPE_DOUBLE, false, true,
064:                        PRODUCT_CATEGORY_PRICE);
065:
066:                //add buckets
067:                addBucket(SELECTED, DataStore.DATATYPE_INT);
068:
069:                //set order by
070:                setOrderBy(computeTableAndFieldName("product_category.product_cat_id")
071:                        + " ASC");
072:
073:                //$CUSTOMCONSTRUCTOR$
074:
075:                //$ENDCUSTOMCONSTRUCTOR$
076:
077:            }
078:
079:            /**
080:             * Retrieve the value of the product_category.product_cat_id column for the current row.
081:             * @return int
082:             * @throws DataStoreException
083:             */
084:            public int getProductCategoryProductCatId()
085:                    throws DataStoreException {
086:                return getInt(PRODUCT_CATEGORY_PRODUCT_CAT_ID);
087:            }
088:
089:            /**
090:             * Retrieve the value of the product_category.product_cat_id column for the specified row.
091:             * @param row which row in the table
092:             * @return int
093:             * @throws DataStoreException
094:             */
095:            public int getProductCategoryProductCatId(int row)
096:                    throws DataStoreException {
097:                return getInt(row, PRODUCT_CATEGORY_PRODUCT_CAT_ID);
098:            }
099:
100:            /**
101:             * Set the value of the product_category.product_cat_id column for the current row.
102:             * @param newValue the new item value
103:             * @throws DataStoreException
104:             */
105:            public void setProductCategoryProductCatId(int newValue)
106:                    throws DataStoreException {
107:                setInt(PRODUCT_CATEGORY_PRODUCT_CAT_ID, newValue);
108:            }
109:
110:            /**
111:             * Set the value of the product_category.product_cat_id column for the specified row.
112:             * @param row which row in the table
113:             * @param newValue the new item value
114:             * @throws DataStoreException
115:             */
116:            public void setProductCategoryProductCatId(int row, int newValue)
117:                    throws DataStoreException {
118:                setInt(row, PRODUCT_CATEGORY_PRODUCT_CAT_ID, newValue);
119:            }
120:
121:            /**
122:             * Retrieve the value of the product_category.parent_id column for the current row.
123:             * @return int
124:             * @throws DataStoreException
125:             */
126:            public int getProductCategoryParentId() throws DataStoreException {
127:                return getInt(PRODUCT_CATEGORY_PARENT_ID);
128:            }
129:
130:            /**
131:             * Retrieve the value of the product_category.parent_id column for the specified row.
132:             * @param row which row in the table
133:             * @return int
134:             * @throws DataStoreException
135:             */
136:            public int getProductCategoryParentId(int row)
137:                    throws DataStoreException {
138:                return getInt(row, PRODUCT_CATEGORY_PARENT_ID);
139:            }
140:
141:            /**
142:             * Set the value of the product_category.parent_id column for the current row.
143:             * @param newValue the new item value
144:             * @throws DataStoreException
145:             */
146:            public void setProductCategoryParentId(int newValue)
147:                    throws DataStoreException {
148:                setInt(PRODUCT_CATEGORY_PARENT_ID, newValue);
149:            }
150:
151:            /**
152:             * Set the value of the product_category.parent_id column for the specified row.
153:             * @param row which row in the table
154:             * @param newValue the new item value
155:             * @throws DataStoreException
156:             */
157:            public void setProductCategoryParentId(int row, int newValue)
158:                    throws DataStoreException {
159:                setInt(row, PRODUCT_CATEGORY_PARENT_ID, newValue);
160:            }
161:
162:            /**
163:             * Retrieve the value of the product_category.description column for the current row.
164:             * @return String
165:             * @throws DataStoreException
166:             */
167:            public String getProductCategoryDescription()
168:                    throws DataStoreException {
169:                return getString(PRODUCT_CATEGORY_DESCRIPTION);
170:            }
171:
172:            /**
173:             * Retrieve the value of the product_category.description column for the specified row.
174:             * @param row which row in the table
175:             * @return String
176:             * @throws DataStoreException
177:             */
178:            public String getProductCategoryDescription(int row)
179:                    throws DataStoreException {
180:                return getString(row, PRODUCT_CATEGORY_DESCRIPTION);
181:            }
182:
183:            /**
184:             * Set the value of the product_category.description column for the current row.
185:             * @param newValue the new item value
186:             * @throws DataStoreException
187:             */
188:            public void setProductCategoryDescription(String newValue)
189:                    throws DataStoreException {
190:                setString(PRODUCT_CATEGORY_DESCRIPTION, newValue);
191:            }
192:
193:            /**
194:             * Set the value of the product_category.description column for the specified row.
195:             * @param row which row in the table
196:             * @param newValue the new item value
197:             * @throws DataStoreException
198:             */
199:            public void setProductCategoryDescription(int row, String newValue)
200:                    throws DataStoreException {
201:                setString(row, PRODUCT_CATEGORY_DESCRIPTION, newValue);
202:            }
203:
204:            /**
205:             * Retrieve the value of the product_category.quantity column for the current row.
206:             * @return int
207:             * @throws DataStoreException
208:             */
209:            public int getProductCategoryQuantity() throws DataStoreException {
210:                return getInt(PRODUCT_CATEGORY_QUANTITY);
211:            }
212:
213:            /**
214:             * Retrieve the value of the product_category.quantity column for the specified row.
215:             * @param row which row in the table
216:             * @return int
217:             * @throws DataStoreException
218:             */
219:            public int getProductCategoryQuantity(int row)
220:                    throws DataStoreException {
221:                return getInt(row, PRODUCT_CATEGORY_QUANTITY);
222:            }
223:
224:            /**
225:             * Set the value of the product_category.quantity column for the current row.
226:             * @param newValue the new item value
227:             * @throws DataStoreException
228:             */
229:            public void setProductCategoryQuantity(int newValue)
230:                    throws DataStoreException {
231:                setInt(PRODUCT_CATEGORY_QUANTITY, newValue);
232:            }
233:
234:            /**
235:             * Set the value of the product_category.quantity column for the specified row.
236:             * @param row which row in the table
237:             * @param newValue the new item value
238:             * @throws DataStoreException
239:             */
240:            public void setProductCategoryQuantity(int row, int newValue)
241:                    throws DataStoreException {
242:                setInt(row, PRODUCT_CATEGORY_QUANTITY, newValue);
243:            }
244:
245:            /**
246:             * Retrieve the value of the product_category.price column for the current row.
247:             * @return double
248:             * @throws DataStoreException
249:             */
250:            public double getProductCategoryPrice() throws DataStoreException {
251:                return getDouble(PRODUCT_CATEGORY_PRICE);
252:            }
253:
254:            /**
255:             * Retrieve the value of the product_category.price column for the specified row.
256:             * @param row which row in the table
257:             * @return double
258:             * @throws DataStoreException
259:             */
260:            public double getProductCategoryPrice(int row)
261:                    throws DataStoreException {
262:                return getDouble(row, PRODUCT_CATEGORY_PRICE);
263:            }
264:
265:            /**
266:             * Set the value of the product_category.price column for the current row.
267:             * @param newValue the new item value
268:             * @throws DataStoreException
269:             */
270:            public void setProductCategoryPrice(double newValue)
271:                    throws DataStoreException {
272:                setDouble(PRODUCT_CATEGORY_PRICE, newValue);
273:            }
274:
275:            /**
276:             * Set the value of the product_category.price column for the specified row.
277:             * @param row which row in the table
278:             * @param newValue the new item value
279:             * @throws DataStoreException
280:             */
281:            public void setProductCategoryPrice(int row, double newValue)
282:                    throws DataStoreException {
283:                setDouble(row, PRODUCT_CATEGORY_PRICE, newValue);
284:            }
285:
286:            /**
287:             * Retrieve the value of the selected bucket for the current row.
288:             * @return int
289:             * @throws DataStoreException
290:             */
291:            public int getSelected() throws DataStoreException {
292:                return getInt(SELECTED);
293:            }
294:
295:            /**
296:             * Retrieve the value of the selected bucket for the specified row.
297:             * @param row which row in the table
298:             * @return int
299:             * @throws DataStoreException
300:             */
301:            public int getSelected(int row) throws DataStoreException {
302:                return getInt(row, SELECTED);
303:            }
304:
305:            /**
306:             * Set the value of the selected bucket for the current row.
307:             * @param newValue the new item value
308:             * @throws DataStoreException
309:             */
310:            public void setSelected(int newValue) throws DataStoreException {
311:                setInt(SELECTED, newValue);
312:            }
313:
314:            /**
315:             * Set the value of the selected bucket for the specified row.
316:             * @param row which row in the table
317:             * @param newValue the new item value
318:             * @throws DataStoreException
319:             */
320:            public void setSelected(int row, int newValue)
321:                    throws DataStoreException {
322:                setInt(row, SELECTED, newValue);
323:            }
324:
325:            //$CUSTOMMETHODS$
326:            /**
327:             * This method can be used to populate a GUI tree control with the contents of this model
328:             */
329:            public void populateTree(HtmlTreeControl tree) throws SQLException,
330:                    DataStoreException {
331:                //load the data from the database
332:                retrieve();
333:
334:                //create a new tree buffer (model)
335:                TreeBuffer b = new TreeBuffer();
336:
337:                //load the images for the tree
338:                int rootImage = b.addImage(tree.translateSiteMapURL("%"
339:                        + SiteMapConstants.TREE_IMAGE_ROOT));
340:                int leafImage = b.addImage(tree.translateSiteMapURL("%"
341:                        + SiteMapConstants.TREE_IMAGE_FILE));
342:                int expandedImage = b.addImage(tree.translateSiteMapURL("%"
343:                        + SiteMapConstants.TREE_IMAGE_OPENED_FOLDER));
344:                int contractedImage = b.addImage(tree.translateSiteMapURL("%"
345:                        + SiteMapConstants.TREE_IMAGE_CLOSED_FOLDER));
346:
347:                //add the root image
348:                int handle = b.addChild("Products", null, rootImage, rootImage,
349:                        null, null);
350:                populateTreeChildren(1, b, handle,
351:                        getProductCategoryProductCatId(0), contractedImage,
352:                        expandedImage, leafImage);
353:
354:                //add the tree buffer to the tree control
355:                b.setMode(TreeBuffer.MODE_SUBMIT);
356:                b.setSelectMode(TreeBuffer.SELECT_NONE);
357:                tree.setUsePathForClickSort(true);
358:                tree.setTreeBuffer(b);
359:
360:            }
361:
362:            /**
363:             * This method is called recursively to walk through the data and build a tree. Returns true if node has children.
364:             */
365:            private boolean populateTreeChildren(int startRow, TreeBuffer tb,
366:                    int handle, int parent, int image, int expandedImage,
367:                    int leafImage) throws DataStoreException {
368:                boolean retVal = false;
369:                tb.gotoItem(handle);
370:                tb.setExpanded(true);
371:
372:                for (int i = startRow; i < getRowCount(); i++) {
373:                    if (getProductCategoryParentId(i) == parent) {
374:                        retVal = true;
375:                        tb.gotoItem(handle);
376:                        int newHandle = tb.addChild(
377:                                getProductCategoryDescription(i), null, image,
378:                                expandedImage, null, null);
379:                        tb.gotoItem(newHandle);
380:                        tb.setRow(i);
381:                        if (!populateTreeChildren(i + 1, tb, newHandle,
382:                                getProductCategoryProductCatId(i), image,
383:                                expandedImage, leafImage)) {
384:                            tb.gotoItem(newHandle);
385:                            tb.setImages(leafImage, leafImage);
386:                        }
387:                    }
388:                }
389:                return retVal;
390:            }
391:
392:            //$ENDCUSTOMMETHODS$
393:
394:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.