[jboss-svn-commits] JBL Code SVN: r5962 - in labs/jbossrules/trunk/drools-repository/src: java/org/drools/repository java/org/drools/repository/test node_type_definitions
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 23 02:41:48 EDT 2006
Author: bentruitt
Date: 2006-08-23 02:41:42 -0400 (Wed, 23 Aug 2006)
New Revision: 5962
Added:
labs/jbossrules/trunk/drools-repository/src/node_type_definitions/versionable_node_type.cnd
Modified:
labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/RuleItem.java
labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/RulesRepository.java
labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/VersionableItem.java
labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/DslItemTestCase.java
labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RuleItemTestCase.java
labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RulePackageItemTestCase.java
labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RulesRepositoryTestCase.java
labs/jbossrules/trunk/drools-repository/src/node_type_definitions/dsl_node_type.cnd
labs/jbossrules/trunk/drools-repository/src/node_type_definitions/rule_node_type.cnd
labs/jbossrules/trunk/drools-repository/src/node_type_definitions/rulepackage_node_type.cnd
Log:
Finished dublin core stuff.
Modified: labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/RuleItem.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/RuleItem.java 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/RuleItem.java 2006-08-23 06:41:42 UTC (rev 5962)
@@ -1,8 +1,5 @@
package org.drools.repository;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
@@ -14,8 +11,6 @@
import javax.jcr.RepositoryException;
import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.Value;
-import javax.jcr.version.Version;
-import javax.jcr.version.VersionIterator;
import org.apache.log4j.Logger;
@@ -46,14 +41,9 @@
/**
* The name of the state property on the rule node type
*/
- public static final String STATE_PROPERTY_NAME = "drools:state_reference";
+ public static final String STATE_PROPERTY_NAME = "drools:state_reference";
/**
- * The name of the last modified property on the rule node type
- */
- public static final String LAST_MODIFIED_PROPERTY_NAME = "drools:last_modified";
-
- /**
* The name of the lhs property on the rule node type
*/
public static final String LHS_PROPERTY_NAME = "drools:lhs";
@@ -71,19 +61,9 @@
/**
* The name of the date expired property on the rule node type
*/
- public static final String DATE_EXPIRED_PROPERTY_NAME = "drools:date_expired";
+ public static final String DATE_EXPIRED_PROPERTY_NAME = "drools:date_expired";
- /**
- * The name of the description property on the rule node type
- */
- public static final String DESCRIPTION_PROPERTY_NAME = "drools:description";
-
- /**
- * The name of the additional docuementation child node on the rule node type
- */
- public static final String ADDITIONAL_DOCUMENTATION_NODE_NAME = "drools:additional_documentation";
-
/**
* Constructs a RuleItem object, setting its node attribute to the specified node.
*
@@ -160,38 +140,8 @@
throw new RulesRepositoryException(e);
}
}
-
+
/**
- * returns the description of this object's rule node
- *
- * @return the description of this object's rule node
- * @throws RulesRepositoryException
- */
- public String getDescription() throws RulesRepositoryException {
- try {
- Node ruleNode;
- if(this.node.getPrimaryNodeType().getName().equals("nt:version")) {
- ruleNode = this.node.getNode("jcr:frozenNode");
- }
- else {
- ruleNode = this.node;
- }
-
- //grab the description of the node and dump it into a string
- Property data = ruleNode.getProperty(DESCRIPTION_PROPERTY_NAME);
- return data.getValue().getString();
- }
- catch(PathNotFoundException e) {
- //no description set yet
- return null;
- }
- catch(Exception e) {
- log.error("Caught Exception", e);
- throw new RulesRepositoryException(e);
- }
- }
-
- /**
* @return the date the rule node (this version) was last modified
* @throws RulesRepositoryException
*/
@@ -465,53 +415,9 @@
log.error("Caught Exception", e);
throw new RulesRepositoryException(e);
}
- }
+ }
/**
- * Creates a new version of this object's rule node, updating the description content
- * for the rule node.
- *
- * @param newDescriptionContent the new description content for the rule
- * @throws RulesRepositoryException
- */
- public void updateDescription(String newDescriptionContent) throws RulesRepositoryException {
- try {
- this.node.checkout();
- }
- catch(UnsupportedRepositoryOperationException e) {
- String message = "";
- try {
- message = "Error: Caught UnsupportedRepositoryOperationException when attempting to checkout rule: " + this.node.getName() + ". Are you sure your JCR repository supports versioning? ";
- log.error(message, e);
- }
- catch (RepositoryException e1) {
- log.error("Caught Exception", e);
- throw new RulesRepositoryException(e1);
- }
- throw new RulesRepositoryException(message, e);
- }
- catch(Exception e) {
- log.error("Caught Exception", e);
- throw new RulesRepositoryException(e);
- }
-
- try {
- this.node.setProperty(DESCRIPTION_PROPERTY_NAME, newDescriptionContent);
-
- Calendar lastModified = Calendar.getInstance();
- this.node.setProperty(LAST_MODIFIED_PROPERTY_NAME, lastModified);
-
- this.node.getSession().save();
-
- this.node.checkin();
- }
- catch(Exception e) {
- log.error("Caught Exception", e);
- throw new RulesRepositoryException(e);
- }
- }
-
- /**
* Adds the specified tag to this object's rule node. Tags are stored as nodes in a tag area of
* the repository. If the specified tag does not already have a corresponding node, a node is
* created for it.
@@ -650,6 +556,7 @@
* @return a list of TagItem objects for each tag on the rule. If there are no tags, an empty list.
* @throws RulesRepositoryException
*/
+ @SuppressWarnings("unchecked")
public List getTags() throws RulesRepositoryException {
try {
Node ruleNode;
Modified: labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/RulesRepository.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/RulesRepository.java 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/RulesRepository.java 2006-08-23 06:41:42 UTC (rev 5962)
@@ -218,6 +218,15 @@
log.info("drools namespace already registered");
}
+ // Setup the versionable node type
+ try {
+ //TODO: remove hard-coded path
+ this.registerNodeTypesFromCndFile("./src/node_type_definitions/versionable_node_type.cnd", ws);
+ }
+ catch(InvalidNodeTypeDefException e) {
+ //This will happen in the node type is already registered, so ignore it
+ }
+
// Setup the dsl node type
try {
//TODO: remove hard-coded path
@@ -436,6 +445,14 @@
//create the node - see section 6.7.22.6 of the spec
Node dslNode = folderNode.addNode(file.getName(), DslItem.DSL_NODE_TYPE_NAME);
+ dslNode.setProperty(DslItem.TITLE_PROPERTY_NAME, file.getName());
+
+ //TODO: set this property correctly once we've figured out logging in / JAAS
+ dslNode.setProperty(DslItem.CONTRIBUTOR_PROPERTY_NAME, "not yet implemented");
+
+ dslNode.setProperty(DslItem.DESCRIPTION_PROPERTY_NAME, "");
+ dslNode.setProperty(DslItem.FORMAT_PROPERTY_NAME, DslItem.DSL_FORMAT);
+
//create the mandatory child node - jcr:content
Node resNode = dslNode.addNode("jcr:content", "nt:resource");
resNode.setProperty("jcr:mimeType", "text/plain");
@@ -444,6 +461,8 @@
Calendar lastModified = Calendar.getInstance();
lastModified.setTimeInMillis(file.lastModified());
resNode.setProperty("jcr:lastModified", lastModified);
+
+ dslNode.setProperty(DslItem.LAST_MODIFIED_PROPERTY_NAME, lastModified);
this.session.save();
@@ -483,7 +502,7 @@
//create the node - see section 6.7.22.6 of the spec
Node ruleNode = folderNode.addNode(ruleName, RuleItem.RULE_NODE_TYPE_NAME);
- ruleNode.setProperty(RuleItem.NAME_PROPERTY_NAME, ruleName);
+ ruleNode.setProperty(RuleItem.TITLE_PROPERTY_NAME, ruleName);
ruleNode.setProperty(RuleItem.LHS_PROPERTY_NAME, lhsContent);
ruleNode.setProperty(RuleItem.RHS_PROPERTY_NAME, rhsContent);
@@ -528,17 +547,24 @@
* @param followDslHead whether or not to follow the head revision of the DSL node
* @param effectiveDate the date the rule becomes effective
* @param expiredDate the date teh rule expires
+ * @param description the description of the rule
* @return a RuleItem object encapsulating the node that gets added
* @throws RulesRepositoryException
*/
- public RuleItem addRule(String ruleName, String lhsContent, String rhsContent, DslItem dslItem, boolean followDslHead, Calendar effectiveDate, Calendar expiredDate) throws RulesRepositoryException {
+ public RuleItem addRule(String ruleName, String lhsContent, String rhsContent, DslItem dslItem, boolean followDslHead, Calendar effectiveDate, Calendar expiredDate, String description) throws RulesRepositoryException {
Node folderNode = this.getAreaNode(RULE_AREA);
try {
//create the node - see section 6.7.22.6 of the spec
Node ruleNode = folderNode.addNode(ruleName, RuleItem.RULE_NODE_TYPE_NAME);
- ruleNode.setProperty(RuleItem.NAME_PROPERTY_NAME, ruleName);
+ ruleNode.setProperty(RuleItem.TITLE_PROPERTY_NAME, ruleName);
+
+ //TODO: set this property correctly once we've figured out logging in / JAAS
+ ruleNode.setProperty(RuleItem.CONTRIBUTOR_PROPERTY_NAME, "not yet implemented");
+
+ ruleNode.setProperty(RuleItem.DESCRIPTION_PROPERTY_NAME, description);
+ ruleNode.setProperty(RuleItem.FORMAT_PROPERTY_NAME, RuleItem.RULE_FORMAT);
ruleNode.setProperty(RuleItem.LHS_PROPERTY_NAME, lhsContent);
ruleNode.setProperty(RuleItem.RHS_PROPERTY_NAME, rhsContent);
ruleNode.setProperty(RuleItem.DSL_PROPERTY_NAME, dslItem.getNode());
@@ -583,9 +609,15 @@
//create the node - see section 6.7.22.6 of the spec
Node ruleNode = folderNode.addNode(ruleName, RuleItem.RULE_NODE_TYPE_NAME);
- ruleNode.setProperty(RuleItem.NAME_PROPERTY_NAME, ruleName);
+ ruleNode.setProperty(RuleItem.TITLE_PROPERTY_NAME, ruleName);
+
+ //TODO: set this property correctly once we've figured out logging in / JAAS
+ ruleNode.setProperty(RuleItem.CONTRIBUTOR_PROPERTY_NAME, "not yet implemented");
+
+ ruleNode.setProperty(RuleItem.DESCRIPTION_PROPERTY_NAME, "");
+ ruleNode.setProperty(RuleItem.FORMAT_PROPERTY_NAME, RuleItem.RULE_FORMAT);
ruleNode.setProperty(RuleItem.LHS_PROPERTY_NAME, lhsContent);
- ruleNode.setProperty(RuleItem.RHS_PROPERTY_NAME, rhsContent);
+ ruleNode.setProperty(RuleItem.RHS_PROPERTY_NAME, rhsContent);
Calendar lastModified = Calendar.getInstance();
ruleNode.setProperty(RuleItem.LAST_MODIFIED_PROPERTY_NAME, lastModified);
@@ -628,7 +660,14 @@
//create the node - see section 6.7.22.6 of the spec
Node ruleNode = folderNode.addNode(ruleName, RuleItem.RULE_NODE_TYPE_NAME);
- ruleNode.setProperty(RuleItem.NAME_PROPERTY_NAME, ruleName);
+ ruleNode.setProperty(RuleItem.TITLE_PROPERTY_NAME, ruleName);
+
+ //TODO: set this property correctly once we've figured out logging in / JAAS
+ ruleNode.setProperty(RuleItem.CONTRIBUTOR_PROPERTY_NAME, "not yet implemented");
+
+ ruleNode.setProperty(RuleItem.DESCRIPTION_PROPERTY_NAME, "");
+ ruleNode.setProperty(RuleItem.FORMAT_PROPERTY_NAME, RuleItem.RULE_FORMAT);
+
ruleNode.setProperty(RuleItem.LHS_PROPERTY_NAME, lhsContent);
ruleNode.setProperty(RuleItem.RHS_PROPERTY_NAME, rhsContent);
ruleNode.setProperty(RuleItem.DATE_EFFECTIVE_PROPERTY_NAME, effectiveDate);
@@ -670,7 +709,19 @@
try {
//create the node - see section 6.7.22.6 of the spec
- Node rulePackageNode = folderNode.addNode(name, RulePackageItem.RULE_PACKAGE_TYPE_NAME);
+ Node rulePackageNode = folderNode.addNode(name, RulePackageItem.RULE_PACKAGE_TYPE_NAME);
+
+ rulePackageNode.setProperty(RulePackageItem.TITLE_PROPERTY_NAME, name);
+
+ //TODO: set this property correctly once we've figured out logging in / JAAS
+ rulePackageNode.setProperty(RulePackageItem.CONTRIBUTOR_PROPERTY_NAME, "not yet implemented");
+
+ rulePackageNode.setProperty(RulePackageItem.DESCRIPTION_PROPERTY_NAME, "");
+ rulePackageNode.setProperty(RulePackageItem.FORMAT_PROPERTY_NAME, RulePackageItem.RULE_PACKAGE_FORMAT);
+
+ Calendar lastModified = Calendar.getInstance();
+ rulePackageNode.setProperty(RulePackageItem.LAST_MODIFIED_PROPERTY_NAME, lastModified);
+
this.session.save();
rulePackageNode.checkin();
return new RulePackageItem(this, rulePackageNode);
@@ -680,6 +731,44 @@
throw new RulesRepositoryException(e);
}
}
+
+ /**
+ * Adds a rule package node in the repository. This node has a property called
+ * drools:rule_reference that is a multi-value reference property. It will hold an array of
+ * references to rule nodes that are subsequently added.
+ *
+ * @param name what to name the node added
+ * @param description what description to use for the node
+ * @return a RulePackageItem, encapsulating the created node
+ * @throws RulesRepositoryException
+ */
+ public RulePackageItem createRulePackage(String name, String description) throws RulesRepositoryException {
+ Node folderNode = this.getAreaNode(RULE_PACKAGE_AREA);
+
+ try {
+ //create the node - see section 6.7.22.6 of the spec
+ Node rulePackageNode = folderNode.addNode(name, RulePackageItem.RULE_PACKAGE_TYPE_NAME);
+
+ rulePackageNode.setProperty(RulePackageItem.TITLE_PROPERTY_NAME, name);
+
+ //TODO: set this property correctly once we've figured out logging in / JAAS
+ rulePackageNode.setProperty(RuleItem.CONTRIBUTOR_PROPERTY_NAME, "not yet implemented");
+
+ rulePackageNode.setProperty(RuleItem.DESCRIPTION_PROPERTY_NAME, description);
+ rulePackageNode.setProperty(RuleItem.FORMAT_PROPERTY_NAME, RuleItem.RULE_PACKAGE_FORMAT);
+
+ Calendar lastModified = Calendar.getInstance();
+ rulePackageNode.setProperty(RulePackageItem.LAST_MODIFIED_PROPERTY_NAME, lastModified);
+
+ this.session.save();
+ rulePackageNode.checkin();
+ return new RulePackageItem(this, rulePackageNode);
+ }
+ catch(Exception e) {
+ log.error("Caught Exception", e);
+ throw new RulesRepositoryException(e);
+ }
+ }
/**
* Gets a StateItem for the specified state name. If a node for the specified state does not
@@ -741,6 +830,7 @@
* Only the latest versions of each RuleItem will be returned (you will have
* to delve into the rules deepest darkest history yourself... mahahahaha).
*/
+ @SuppressWarnings("unchecked")
public List findRulesByTag(String categoryTag) throws RulesRepositoryException {
CategoryItem item = this.getOrCreateCategory( categoryTag );
@@ -774,6 +864,7 @@
* This will provide a list of top level category strings.
* Use getCategory to get a specific category to drill down into it.
*/
+ @SuppressWarnings("unchecked")
public List listCategoryNames() throws RulesRepositoryException {
try {
Modified: labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/VersionableItem.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/VersionableItem.java 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/VersionableItem.java 2006-08-23 06:41:42 UTC (rev 5962)
@@ -1,8 +1,12 @@
package org.drools.repository;
+import java.util.Calendar;
+
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.UnsupportedRepositoryOperationException;
import javax.jcr.Value;
import org.drools.repository.Item;
@@ -10,11 +14,39 @@
public abstract class VersionableItem extends Item {
/**
- * The name of the name property on the node type
+ * The name of the title property on the node type
*/
- public static final String NAME_PROPERTY_NAME = "drools:name";
+ public static final String TITLE_PROPERTY_NAME = "drools:title";
/**
+ * The name of the contributor property on the node type
+ */
+ public static final String CONTRIBUTOR_PROPERTY_NAME = "drools:contributor";
+
+ /**
+ * The name of the description property on the rule node type
+ */
+ public static final String DESCRIPTION_PROPERTY_NAME = "drools:description";
+
+ /**
+ * The name of the last modified property on the rule node type
+ */
+ public static final String LAST_MODIFIED_PROPERTY_NAME = "drools:last_modified";
+
+ /**
+ * The name of the last modified property on the rule node type
+ */
+ public static final String FORMAT_PROPERTY_NAME = "drools:format";
+
+
+ /**
+ * The possible formats for the format property of the node
+ */
+ public static final String RULE_FORMAT = "Rule";
+ public static final String DSL_FORMAT = "DSL";
+ public static final String RULE_PACKAGE_FORMAT = "Rule Package";
+
+ /**
* Sets this object's node attribute to the specified node
*
* @param rulesRepository the RulesRepository object that this object is being created from
@@ -134,18 +166,24 @@
*/
public abstract VersionableItem getSucceedingVersion() throws RulesRepositoryException;
- @Override
- public String getName() throws RulesRepositoryException {
+ /**
+ * Gets the Title of the versionable node. See the Dublin Core documentation for more
+ * explanation: http://dublincore.org/documents/dces/
+ *
+ * @return the title of the node this object encapsulates
+ * @throws RulesRepositoryException
+ */
+ public String getTitle() throws RulesRepositoryException {
try {
- Node ruleNode;
+ Node theNode;
if(this.node.getPrimaryNodeType().getName().equals("nt:version")) {
- ruleNode = this.node.getNode("jcr:frozenNode");
+ theNode = this.node.getNode("jcr:frozenNode");
}
else {
- ruleNode = this.node;
+ theNode = this.node;
}
- Property data = ruleNode.getProperty(NAME_PROPERTY_NAME);
+ Property data = theNode.getProperty(TITLE_PROPERTY_NAME);
return data.getValue().getString();
}
catch(Exception e) {
@@ -153,4 +191,164 @@
throw new RulesRepositoryException(e);
}
}
+
+ /**
+ * Creates a new version of this object's node, updating the title content
+ * for the node.
+ * <br>
+ * See the Dublin Core documentation for more
+ * explanation: http://dublincore.org/documents/dces/
+ *
+ * @param title the new title for the node
+ * @throws RulesRepositoryException
+ */
+ public void updateTitle(String title) throws RulesRepositoryException {
+ try {
+ Node theNode;
+ if(this.node.getPrimaryNodeType().getName().equals("nt:version")) {
+ theNode = this.node.getNode("jcr:frozenNode");
+ }
+ else {
+ theNode = this.node;
+ }
+
+ theNode.checkout();
+ theNode.setProperty(TITLE_PROPERTY_NAME, title);
+
+ Calendar lastModified = Calendar.getInstance();
+ this.node.setProperty(LAST_MODIFIED_PROPERTY_NAME, lastModified);
+
+ theNode.save();
+ theNode.checkin();
+ }
+ catch(Exception e) {
+ log.error("Caught Exception", e);
+ throw new RulesRepositoryException(e);
+ }
+ }
+
+ /**
+ * Gets the Contributor of the versionable node. See the Dublin Core documentation for more
+ * explanation: http://dublincore.org/documents/dces/
+ *
+ * @return the contributor of the node this object encapsulates
+ * @throws RulesRepositoryException
+ */
+ public String getContributor() {
+ try {
+ Node theNode;
+ if(this.node.getPrimaryNodeType().getName().equals("nt:version")) {
+ theNode = this.node.getNode("jcr:frozenNode");
+ }
+ else {
+ theNode = this.node;
+ }
+
+ Property data = theNode.getProperty(CONTRIBUTOR_PROPERTY_NAME);
+ return data.getValue().getString();
+ }
+ catch(Exception e) {
+ log.error("Caught Exception", e);
+ throw new RulesRepositoryException(e);
+ }
+ }
+
+ /**
+ * See the Dublin Core documentation for more
+ * explanation: http://dublincore.org/documents/dces/
+ *
+ * @return the description of this object's node.
+ * @throws RulesRepositoryException
+ */
+ public String getDescription() throws RulesRepositoryException {
+ try {
+ Node theNode;
+ if(this.node.getPrimaryNodeType().getName().equals("nt:version")) {
+ theNode = this.node.getNode("jcr:frozenNode");
+ }
+ else {
+ theNode = this.node;
+ }
+
+ Property data = theNode.getProperty(DESCRIPTION_PROPERTY_NAME);
+ return data.getValue().getString();
+ }
+ catch(Exception e) {
+ log.error("Caught Exception", e);
+ throw new RulesRepositoryException(e);
+ }
+ }
+
+ /**
+ * Creates a new version of this object's node, updating the description content
+ * for the node.
+ * <br>
+ * See the Dublin Core documentation for more
+ * explanation: http://dublincore.org/documents/dces/
+ *
+ * @param newDescriptionContent the new description content for the rule
+ * @throws RulesRepositoryException
+ */
+ public void updateDescription(String newDescriptionContent) throws RulesRepositoryException {
+ try {
+ this.node.checkout();
+ }
+ catch(UnsupportedRepositoryOperationException e) {
+ String message = "";
+ try {
+ message = "Error: Caught UnsupportedRepositoryOperationException when attempting to checkout node: " + this.node.getName() + ". Are you sure your JCR repository supports versioning? ";
+ log.error(message, e);
+ }
+ catch (RepositoryException e1) {
+ log.error("Caught Exception", e);
+ throw new RulesRepositoryException(e1);
+ }
+ throw new RulesRepositoryException(message, e);
+ }
+ catch(Exception e) {
+ log.error("Caught Exception", e);
+ throw new RulesRepositoryException(e);
+ }
+
+ try {
+ this.node.setProperty(DESCRIPTION_PROPERTY_NAME, newDescriptionContent);
+
+ Calendar lastModified = Calendar.getInstance();
+ this.node.setProperty(LAST_MODIFIED_PROPERTY_NAME, lastModified);
+
+ this.node.getSession().save();
+
+ this.node.checkin();
+ }
+ catch(Exception e) {
+ log.error("Caught Exception", e);
+ throw new RulesRepositoryException(e);
+ }
+ }
+
+ /**
+ * See the Dublin Core documentation for more
+ * explanation: http://dublincore.org/documents/dces/
+ *
+ * @return the format of this object's node
+ * @throws RulesRepositoryException
+ */
+ public String getFormat() throws RulesRepositoryException {
+ try {
+ Node theNode;
+ if(this.node.getPrimaryNodeType().getName().equals("nt:version")) {
+ theNode = this.node.getNode("jcr:frozenNode");
+ }
+ else {
+ theNode = this.node;
+ }
+
+ Property data = theNode.getProperty(FORMAT_PROPERTY_NAME);
+ return data.getValue().getString();
+ }
+ catch(Exception e) {
+ log.error("Caught Exception", e);
+ throw new RulesRepositoryException(e);
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/DslItemTestCase.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/DslItemTestCase.java 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/DslItemTestCase.java 2006-08-23 06:41:42 UTC (rev 5962)
@@ -90,4 +90,27 @@
//This is covered by the test in RuleItemTestCase - all functionality under test
// resides in the common subclass, VersionableItem
}
+
+ public void testGetTitle() {
+ //This is covered by the test in RuleItemTestCase - all functionality under test
+ // resides in the common subclass, VersionableItem
+ }
+
+ public void testGetContributor() {
+ //This is covered by the test in RuleItemTestCase - all functionality under test
+ // resides in the common subclass, VersionableItem
+ }
+
+ public void testGetFormat() {
+ try {
+ File dslFile1 = new File("./src/java/org/drools/repository/test/test_data/dsl1.dsl");
+
+ DslItem dslItem1 = rulesRepository.addDslFromFile(dslFile1);
+
+ assertEquals("DSL", dslItem1.getFormat());
+ }
+ catch(Exception e) {
+ fail("Caught unexpected exception: " + e);
+ }
+ }
}
Modified: labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RuleItemTestCase.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RuleItemTestCase.java 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RuleItemTestCase.java 2006-08-23 06:41:42 UTC (rev 5962)
@@ -2,7 +2,6 @@
import java.io.File;
import java.util.Calendar;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -311,8 +310,8 @@
try {
RuleItem ruleItem1 = this.rulesRepository.addRule("test rule", "test lhs content", "test rhs content");
- //it should be null to begin with
- assertTrue(ruleItem1.getDescription() == null);
+ //it should be "" to begin with
+ assertEquals("", ruleItem1.getDescription());
ruleItem1.updateDescription("test description");
assertEquals("test description", ruleItem1.getDescription());
@@ -441,4 +440,31 @@
fail("Caught unexpected exception: " + e);
}
}
-}
\ No newline at end of file
+
+ public void testGetTitle() {
+ try {
+ RuleItem ruleItem1 = this.rulesRepository.addRule("test rule", "test lhs content", "test rhs content");
+
+ assertEquals("test rule", ruleItem1.getTitle());
+ }
+ catch(Exception e) {
+ fail("Caught unexpected exception: " + e);
+ }
+ }
+
+ public void testGetContributor() {
+ //can't implement this until we figure out login / JAAS stuff.
+ fail("not yet implemented");
+ }
+
+ public void testGetFormat() {
+ try {
+ RuleItem ruleItem1 = this.rulesRepository.addRule("test rule", "test lhs content", "test rhs content");
+
+ assertEquals("Rule", ruleItem1.getFormat());
+ }
+ catch(Exception e) {
+ fail("Caught unexpected exception: " + e);
+ }
+ }
+}
Modified: labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RulePackageItemTestCase.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RulePackageItemTestCase.java 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RulePackageItemTestCase.java 2006-08-23 06:41:42 UTC (rev 5962)
@@ -265,4 +265,25 @@
//This is covered by the test in RuleItemTestCase - all functionality under test
// resides in the common subclass, VersionableItem
}
+
+ public void testGetTitle() {
+ //This is covered by the test in RuleItemTestCase - all functionality under test
+ // resides in the common subclass, VersionableItem
+ }
+
+ public void testGetContributor() {
+ //This is covered by the test in RuleItemTestCase - all functionality under test
+ // resides in the common subclass, VersionableItem
+ }
+
+ public void testGetFormat() {
+ try {
+ RulePackageItem rulePackageItem1 = this.rulesRepository.createRulePackage("testRulePackage");
+ assertNotNull(rulePackageItem1);
+ assertEquals("Rule Package", rulePackageItem1.getFormat());
+ }
+ catch(Exception e) {
+ fail("Caught unexpected exception: " + e);
+ }
+ }
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RulesRepositoryTestCase.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RulesRepositoryTestCase.java 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/java/org/drools/repository/test/RulesRepositoryTestCase.java 2006-08-23 06:41:42 UTC (rev 5962)
@@ -145,7 +145,7 @@
Calendar expiredDate = Calendar.getInstance();
expiredDate.setTimeInMillis(effectiveDate.getTimeInMillis() + (1000 * 60 * 60 * 24));
- RuleItem ruleItem1 = rulesRepository.addRule("test rule", "test lhs content", "test rhs content", dslItem1, true, effectiveDate, expiredDate);
+ RuleItem ruleItem1 = rulesRepository.addRule("test rule", "test lhs content", "test rhs content", dslItem1, true, effectiveDate, expiredDate, "test description");
assertNotNull(ruleItem1);
assertNotNull(ruleItem1.getNode());
@@ -153,6 +153,7 @@
assertEquals(dslItem1.getContent(), ruleItem1.getDsl().getContent());
assertEquals(effectiveDate, ruleItem1.getDateEffective());
assertEquals(expiredDate, ruleItem1.getDateExpired());
+ assertEquals("test description", ruleItem1.getDescription());
//test that this follows the head version
File dslFile2 = new File("./src/java/org/drools/repository/test/test_data/dsl2.dsl");
@@ -162,14 +163,15 @@
assertEquals(dslItem1.getContent(), ruleItem1.getDsl().getContent());
//now do the same thing, but test not following head:
- RuleItem ruleItem2 = rulesRepository.addRule("test rule 2", "test lhs content", "test rhs content", dslItem1, false, effectiveDate, expiredDate);
+ RuleItem ruleItem2 = rulesRepository.addRule("test rule 2", "test lhs content", "test rhs content", dslItem1, false, effectiveDate, expiredDate, "test description 2");
assertNotNull(ruleItem2);
assertNotNull(ruleItem2.getNode());
assertNotNull(ruleItem2.getDsl());
assertEquals(dslItem1.getContent(), ruleItem2.getDsl().getContent());
- assertEquals(effectiveDate, ruleItem1.getDateEffective());
- assertEquals(expiredDate, ruleItem1.getDateExpired());
+ assertEquals(effectiveDate, ruleItem2.getDateEffective());
+ assertEquals(expiredDate, ruleItem2.getDateExpired());
+ assertEquals("test description 2", ruleItem2.getDescription());
//test that this stays tied to the specific revision of the DSL node
String originalContent = ruleItem2.getDsl().getContent();
Modified: labs/jbossrules/trunk/drools-repository/src/node_type_definitions/dsl_node_type.cnd
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/node_type_definitions/dsl_node_type.cnd 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/node_type_definitions/dsl_node_type.cnd 2006-08-23 06:41:42 UTC (rev 5962)
@@ -11,4 +11,4 @@
[drools:dsl_node_type]
// Supertypes
-> 'nt:file','mix:versionable'
+> 'drools:versionable_node_type','nt:file'
Modified: labs/jbossrules/trunk/drools-repository/src/node_type_definitions/rule_node_type.cnd
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/node_type_definitions/rule_node_type.cnd 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/node_type_definitions/rule_node_type.cnd 2006-08-23 06:41:42 UTC (rev 5962)
@@ -11,21 +11,15 @@
[drools:rule_node_type]
// Supertypes
-> 'nt:hierarchyNode','mix:versionable'
+> 'drools:versionable_node_type'
// Properties:
-- drools:name (string)
- mandatory
-
- drools:lhs (string)
mandatory
- drools:rhs (string)
mandatory
-- drools:last_modified (date)
- mandatory
-
- drools:date_effective (date)
- drools:date_expired (date)
@@ -33,8 +27,6 @@
- drools:rule_language (string)
= 'DRL'
mandatory autocreated
-
-- drools:description (string)
- drools:dsl_reference (reference)
copy
Modified: labs/jbossrules/trunk/drools-repository/src/node_type_definitions/rulepackage_node_type.cnd
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/node_type_definitions/rulepackage_node_type.cnd 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/node_type_definitions/rulepackage_node_type.cnd 2006-08-23 06:41:42 UTC (rev 5962)
@@ -11,16 +11,9 @@
[drools:rulepackage_node_type]
// Supertypes
-> nt:hierarchyNode,'mix:versionable'
-
-// Nodes of this node type have a property called 'drools:rule_reference' of type reference
+> 'drools:versionable_node_type'
+
- drools:rule_reference (reference)
-
-// and multi-valued
-multiple
-
-// It has an on-parent-version setting of ...
-copy
-
-// the reference must be of one of these types...
-< 'drools:rule_node_type','nt:version'
+ multiple
+ copy
+ < 'drools:rule_node_type','nt:version'
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-repository/src/node_type_definitions/versionable_node_type.cnd
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/node_type_definitions/versionable_node_type.cnd 2006-08-23 04:45:14 UTC (rev 5961)
+++ labs/jbossrules/trunk/drools-repository/src/node_type_definitions/versionable_node_type.cnd 2006-08-23 06:41:42 UTC (rev 5962)
@@ -0,0 +1,32 @@
+/* The node type definition for the rule node type.
+ See http://jackrabbit.apache.org/doc/nodetype/cnd.html for an explanation
+
+ See the Dublin Core documentation for more explanation: http://dublincore.org/documents/dces/
+*/
+
+// The namespace declaration
+<drools = 'http://www.jboss.org/drools-repository/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+
+// Node type name
+[drools:versionable_node_type]
+
+// Supertypes
+> 'nt:hierarchyNode','mix:versionable'
+
+// Properties:
+- drools:title (string)
+ mandatory
+
+- drools:contributor (string)
+ mandatory
+
+- drools:last_modified (date)
+ mandatory
+
+- drools:description (string)
+ mandatory
+
+ - drools:format (string)
+ mandatory
\ No newline at end of file
More information about the jboss-svn-commits
mailing list