Source Code Cross Referenced for CategoryItem.java in  » Rule-Engine » drolls-Rule-Engine » org » drools » repository » 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 » Rule Engine » drolls Rule Engine » org.drools.repository 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.drools.repository;
002:
003:        import java.util.ArrayList;
004:        import java.util.List;
005:
006:        import javax.jcr.Node;
007:        import javax.jcr.NodeIterator;
008:        import javax.jcr.RepositoryException;
009:
010:        import org.apache.log4j.Logger;
011:
012:        /**
013:         * The TagItem class abstracts away details of the underlying JCR repository.
014:         * 
015:         * @author btruitt
016:         */
017:        public class CategoryItem extends Item {
018:            private Logger log = Logger.getLogger(CategoryItem.class);
019:
020:            /**
021:             * The name of the tag node type
022:             */
023:            public static final String TAG_NODE_TYPE_NAME = "drools:categoryNodeType";
024:
025:            /**
026:             * Constructs an object of type TagItem corresponding the specified node
027:             * @param rulesRepository the rulesRepository that instantiated this object
028:             * @param node the node to which this object corresponds
029:             * @throws RulesRepositoryException 
030:             */
031:            public CategoryItem(RulesRepository rulesRepository, Node node)
032:                    throws RulesRepositoryException {
033:                super (rulesRepository, node);
034:
035:                //        try {
036:                //            //make sure this node is a tag node       
037:                //            if(!(this.node.getPrimaryNodeType().getName().equals(TAG_NODE_TYPE_NAME))) {
038:                //                String message = this.node.getName() + " is not a node of type " + TAG_NODE_TYPE_NAME + ". It is a node of type: " + this.node.getPrimaryNodeType().getName();
039:                //                log.error(message);
040:                //                throw new RulesRepositoryException(message);
041:                //            }    
042:                //        }
043:                //        catch(Exception e) {
044:                //            log.error("Caught exception: " + e);
045:                //            throw new RulesRepositoryException(e);
046:                //        }
047:            }
048:
049:            /**
050:             * @return the full path of this tag, rooted at the tag area of the repository. 
051:             * @throws RulesRepositoryException 
052:             */
053:            public String getFullPath() throws RulesRepositoryException {
054:                try {
055:
056:                    StringBuffer returnString = new StringBuffer();
057:                    returnString.append(this .node.getName());
058:                    Node parentNode = this .node.getParent();
059:                    while (!parentNode.getName().equals(
060:                            RulesRepository.TAG_AREA)) {
061:                        returnString.insert(0, parentNode.getName() + "/");
062:                        parentNode = parentNode.getParent();
063:                    }
064:                    return returnString.toString();
065:                } catch (Exception e) {
066:                    log.error("Caught Exception: " + e);
067:                    throw new RulesRepositoryException(e);
068:                }
069:            }
070:
071:            /**
072:             * @return a List of the immediate children of this tag
073:             * @throws RulesRepositoryException 
074:             */
075:            public List getChildTags() throws RulesRepositoryException {
076:                List children = new ArrayList();
077:
078:                try {
079:                    NodeIterator it = this .node.getNodes();
080:                    while (it.hasNext()) {
081:                        Node currentNode = it.nextNode();
082:                        children.add(new CategoryItem(this .rulesRepository,
083:                                currentNode));
084:                    }
085:                } catch (Exception e) {
086:                    log.error("Caught Exception: " + e);
087:                    throw new RulesRepositoryException(e);
088:                }
089:
090:                return children;
091:            }
092:
093:            /**
094:             * This will create a child category under this one
095:             */
096:            public CategoryItem addCategory(String name, String description) {
097:                try {
098:                    Node child = this .node.addNode(name,
099:                            CategoryItem.TAG_NODE_TYPE_NAME);
100:                    this .rulesRepository.getSession().save();
101:                    return new CategoryItem(this .rulesRepository, child);
102:                } catch (Exception e) {
103:                    if (e instanceof  RuntimeException) {
104:                        throw (RuntimeException) e;
105:                    } else {
106:                        throw new RulesRepositoryException(e);
107:                    }
108:                }
109:
110:            }
111:
112:            /**
113:             * This will remove the category and any ones under it. 
114:             * This will only work if you have no current assets linked to the category.
115:             */
116:            public void remove() {
117:                try {
118:                    if (this .node.getReferences().hasNext()) {
119:                        throw new RulesRepositoryException(
120:                                "The category still has some assets linked to it. You will need to remove the links so you can delete the cateogory.");
121:                    }
122:                    this .node.remove();
123:                } catch (RepositoryException e) {
124:                    log.error(e);
125:                }
126:            }
127:
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.