View Javadoc

1   /**************************************************************************
2    Copyright 2005 Webstersmalley
3   
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7   
8    http://www.apache.org/licenses/LICENSE-2.0
9   
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15   *************************************************************************/
16  /*
17   * Created on 03-Aug-2005
18   */
19  package com.webstersmalley.picweb.online.bus;
20  
21  import java.util.Collection;
22  import java.util.Iterator;
23  
24  import org.springframework.context.ApplicationContext;
25  import org.springframework.context.support.FileSystemXmlApplicationContext;
26  
27  import com.webstersmalley.picweb.online.db.HsqlUtils;
28  
29  public class TestApp {
30  
31      public static void main(String[] args) {
32  
33          ApplicationContext ac = new FileSystemXmlApplicationContext(
34                  "src/webapp/WEB-INF/dao.xml");
35  
36          CategoryManager mgr = (CategoryManager) ac.getBean("myCategoryManager");
37  
38          Category root = new Category();
39          root.setName("root");
40          root.setDescription("parent of all parents");
41  
42          Category cat1 = new Category();
43          cat1.setName("category1");
44          cat1.setDescription("category1");
45  
46          Category cat2 = new Category();
47          cat2.setName("category2");
48          cat2.setDescription("category2");
49  
50          Picture pic1 = new Picture();
51          pic1.setName("picture1");
52          pic1.setDescription("picture1");
53  
54          root.getSubcategories().add(cat1);
55          cat1.getSubcategories().add(cat2);
56          cat1.getPictures().add(pic1);
57          cat2.getPictures().add(pic1);
58          // mgr.createAndStoreCategory(root);
59  
60          Collection categories = mgr.loadCategories();
61          for (Iterator it = categories.iterator(); it.hasNext();) {
62              Object bob = it.next();
63              System.out.println(bob);
64          }
65  
66          // Category rootCat = mgr.getRootCategory();
67          // System.out.println("Root: " + rootCat);
68  
69          // Collection children = mgr.getSubcategories(rootCat);
70          // for (Iterator it = children.iterator(); it.hasNext();) {
71          // System.out.println(it.next());
72          // }
73  
74          categories = mgr.loadCategories();
75          for (Iterator it = categories.iterator(); it.hasNext();) {
76              Object bob = it.next();
77              System.out.println(bob);
78          }
79  
80          // HsqlUtils utils = (HsqlUtils)ac.getBean("hsqlUtils");
81          // utils.shutDown();
82  
83      }
84  }