You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(233) |
Sep
(199) |
Oct
(206) |
Nov
(185) |
Dec
(270) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(232) |
Feb
(426) |
Mar
(623) |
Apr
(592) |
May
(506) |
Jun
(389) |
Jul
(160) |
Aug
(3) |
Sep
(1) |
Oct
(1) |
Nov
(2) |
Dec
(5) |
2007 |
Jan
(1) |
Feb
(1) |
Mar
(2) |
Apr
(2) |
May
(4) |
Jun
(2) |
Jul
|
Aug
(3) |
Sep
(5) |
Oct
(9) |
Nov
(6) |
Dec
(6) |
2008 |
Jan
(3) |
Feb
|
Mar
(1) |
Apr
(3) |
May
(3) |
Jun
(5) |
Jul
(10) |
Aug
(2) |
Sep
(12) |
Oct
(10) |
Nov
(54) |
Dec
(49) |
2009 |
Jan
(19) |
Feb
(13) |
Mar
(20) |
Apr
(24) |
May
(44) |
Jun
(29) |
Jul
(32) |
Aug
(10) |
Sep
(7) |
Oct
(10) |
Nov
(4) |
Dec
(17) |
2010 |
Jan
(14) |
Feb
(5) |
Mar
(23) |
Apr
(50) |
May
(31) |
Jun
(9) |
Jul
(5) |
Aug
(4) |
Sep
(7) |
Oct
(5) |
Nov
(2) |
Dec
(3) |
2011 |
Jan
(12) |
Feb
(5) |
Mar
(5) |
Apr
(3) |
May
(4) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
2012 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
(1) |
Jun
(2) |
Jul
(4) |
Aug
(1) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
(1) |
2015 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jbo...@li...> - 2006-01-24 03:12:33
|
Author: mic...@jb... Date: 2006-01-23 22:12:21 -0500 (Mon, 23 Jan 2006) New Revision: 2180 Added: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLGrammarTest.java Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLGrammar.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLMappingItem.java trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLExpressionCompilerTest.java trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateFactoryTest.java Log: small improvements Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLGrammar.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLGrammar.java 2006-01-23 22:41:41 UTC (rev 2179) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLGrammar.java 2006-01-24 03:12:21 UTC (rev 2180) @@ -23,18 +23,18 @@ /** * When loading from properties, the order in which they apprear in the props file - * is the priority. + * is the priority. (TODO: order means nothing to properties it seems). * * Which makes sense intuitively, the order you read them it the order in which they will be applied. */ public void loadFromProperties(Properties props) { - int i = 0; + int i = props.size(); for ( Iterator iter = props.keySet().iterator(); iter.hasNext(); ) { String key = (String) iter.next(); String property = props.getProperty(key); NLMappingItem item = new NLMappingItem(i, key, property); addNLItem(item); - i++; + i--; } } Modified: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLMappingItem.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLMappingItem.java 2006-01-23 22:41:41 UTC (rev 2179) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLMappingItem.java 2006-01-24 03:12:21 UTC (rev 2180) @@ -40,8 +40,8 @@ if ( arg instanceof NLMappingItem ) { NLMappingItem item = (NLMappingItem) arg; if ( item.priority == this.priority ) return 0; - if ( item.priority > this.priority ) return 1; - if ( item.priority < this.priority ) return -1; + if ( item.priority > this.priority ) return -1; + if ( item.priority < this.priority ) return 1; return 0; } else { @@ -49,4 +49,8 @@ } } + int getPriority() { + return this.priority; + } + } Modified: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLExpressionCompilerTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLExpressionCompilerTest.java 2006-01-23 22:41:41 UTC (rev 2179) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLExpressionCompilerTest.java 2006-01-24 03:12:21 UTC (rev 2180) @@ -14,12 +14,12 @@ String result = compiler.compile("bob likes cheese"); assertEquals("likesCheese(bob)", result); - - + //now lets use a properties Properties props = new Properties(); props.setProperty("{0} likes cheese", "likesCheese({0})"); props.setProperty("the date between {0} and {1}", "dateCompare({0}, {1})"); + props.setProperty("bind", "=>"); grammar = new NLGrammar(); grammar.loadFromProperties(props); @@ -31,6 +31,8 @@ result = compiler.compile("the date between bob and michael"); assertEquals("dateCompare(bob, michael)", result); + result = compiler.compile("bind"); + assertEquals("=>", result); } @@ -56,9 +58,48 @@ long start = System.currentTimeMillis(); String result = compiler.compile("michael likes cheese and michael is happy"); long runtime = System.currentTimeMillis() - start; - System.out.println("Runtime for compile: " + runtime + "ms"); + System.out.println("Runtime for compile with dictionary of 1000: " + runtime + "ms"); assertEquals("michael.likesCheese() and michael.isHappy()", result); } + + public void testNestingAndOrderOfExpressions() { + NLGrammar grammar = new NLGrammar(); + + grammar.addNLItem(new NLMappingItem(0, "{0} likes cheese", "{0}.likesCheese()" )); + grammar.addNLItem(new NLMappingItem(1, "print out cheese fan status {0}", "print({0})" )); + + + NLExpressionCompiler compiler = new NLExpressionCompiler(grammar); + String nl = "print out cheese fan status bob likes cheese"; + String expected = "print(bob.likesCheese())"; + + String result = compiler.compile(nl); + + assertEquals(expected, result); + + + grammar = new NLGrammar(); + + grammar.addNLItem(new NLMappingItem(1, "date of ' {0} '", "dateOf({0})")); + grammar.addNLItem(new NLMappingItem(2, "age of [ {0} ]", "{0}.getAge()")); + grammar.addNLItem(new NLMappingItem(3, "Today", "new java.util.Date()")); + grammar.addNLItem(new NLMappingItem(4, "{0} is before {1}", "({0}).compareTo({1}) > 0")); + + + nl = "date of ' 10-jul-2006 ' is before Today"; + + compiler = new NLExpressionCompiler(grammar); + expected = "(dateOf(10-jul-2006)).compareTo(new java.util.Date()) > 0"; + assertEquals(expected, compiler.compile(nl)); + + nl = "age of [ bob ] < age of [ michael ]"; + expected = "bob.getAge() < michael.getAge()"; + assertEquals(expected, compiler.compile(nl)); + + + + } + } Added: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLGrammarTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLGrammarTest.java 2006-01-23 22:41:41 UTC (rev 2179) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLGrammarTest.java 2006-01-24 03:12:21 UTC (rev 2180) @@ -0,0 +1,63 @@ +package org.drools.natural.template; + +import java.io.ByteArrayInputStream; +import java.util.Collection; +import java.util.Properties; + +import junit.framework.TestCase; + +public class NLGrammarTest extends TestCase { + + /** Check that it sets up priorities correctly */ + public void testLoadFromProperties() throws Exception { + NLGrammar grammar = new NLGrammar(); + + + String data = "number\\ 1=number 1\n" + + "number\\ 2=number 2"; + + Properties props = new Properties(); + + ByteArrayInputStream stream = new ByteArrayInputStream(data.getBytes("UTF-8")); + + props.load(stream); + + grammar.loadFromProperties(props); + + Collection list = grammar.getMappings(); + Object[] items = list.toArray(); + + NLMappingItem item = (NLMappingItem) items[0]; + assertEquals("number 1", item.getNaturalTemplate()); + assertEquals(1, item.getPriority()); + + item = (NLMappingItem) items[1]; + assertEquals("number 2", item.getNaturalTemplate()); + assertEquals(2, item.getPriority()); + + props = new Properties(); + props.setProperty("znumber 1", "number 1"); + props.setProperty("bnumber 2", "number 2"); + props.setProperty("anumber 3", "number 3"); + + grammar = new NLGrammar(); + grammar.loadFromProperties(props); + + list = grammar.getMappings(); + items = list.toArray(); + + item = (NLMappingItem) items[0]; + assertEquals("znumber 1", item.getNaturalTemplate()); + assertEquals(1, item.getPriority()); + + item = (NLMappingItem) items[1]; + assertEquals("bnumber 2", item.getNaturalTemplate()); + assertEquals(2, item.getPriority()); + + item = (NLMappingItem) items[2]; + assertEquals("anumber 3", item.getNaturalTemplate()); + assertEquals(3, item.getPriority()); + + } + +} Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLGrammarTest.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateFactoryTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateFactoryTest.java 2006-01-23 22:41:41 UTC (rev 2179) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateFactoryTest.java 2006-01-24 03:12:21 UTC (rev 2180) @@ -27,13 +27,13 @@ assertEquals("chunks", list.get(2)); - list = factory.lexChunks("{42} more {0} chunks"); + list = factory.lexChunks("{42} more '{0}' chunks"); assertEquals(4, list.size()); assertEquals("{42}", list.get(0)); - assertEquals("more", list.get(1)); + assertEquals("more '", list.get(1)); assertEquals("{0}", list.get(2)); - assertEquals("chunks", list.get(3)); + assertEquals("' chunks", list.get(3)); } |
From: <jbo...@li...> - 2006-01-23 22:43:43
|
Author: mnasato Date: 2006-01-23 17:41:41 -0500 (Mon, 23 Jan 2006) New Revision: 2179 Added: trunk/labs/davcache/.classpath trunk/labs/davcache/.project trunk/labs/davcache/.settings/ trunk/labs/davcache/.settings/org.eclipse.jdt.core.prefs trunk/labs/davcache/.settings/org.eclipse.jdt.ui.prefs trunk/labs/davcache/LICENSE.txt trunk/labs/davcache/README.txt trunk/labs/davcache/build.xml trunk/labs/davcache/etc/ trunk/labs/davcache/etc/META-INF/ trunk/labs/davcache/etc/META-INF/jboss-service.xml trunk/labs/davcache/etc/WEB-INF/ trunk/labs/davcache/etc/WEB-INF/davcache-service.xml trunk/labs/davcache/etc/WEB-INF/jboss-web.xml trunk/labs/davcache/etc/WEB-INF/web-jboss.xml trunk/labs/davcache/etc/WEB-INF/web.xml trunk/labs/davcache/lib/ trunk/labs/davcache/lib/commons-httpclient.jar trunk/labs/davcache/lib/commons-logging.jar trunk/labs/davcache/lib/concurrent.jar trunk/labs/davcache/lib/dom4j.jar trunk/labs/davcache/lib/javax.servlet.jar trunk/labs/davcache/lib/jboss-cache.jar trunk/labs/davcache/lib/jboss-common.jar trunk/labs/davcache/lib/jboss-j2ee.jar trunk/labs/davcache/lib/jboss-jmx.jar trunk/labs/davcache/lib/jboss-system.jar trunk/labs/davcache/lib/jgroups.jar trunk/labs/davcache/lib/junit.jar trunk/labs/davcache/lib/webdavlib.jar trunk/labs/davcache/src/ trunk/labs/davcache/src/net/ trunk/labs/davcache/src/net/sf/ trunk/labs/davcache/src/net/sf/davcache/ trunk/labs/davcache/src/net/sf/davcache/DavXmlUtils.java trunk/labs/davcache/src/net/sf/davcache/FileTypes.java trunk/labs/davcache/src/net/sf/davcache/PropFindResponse.java trunk/labs/davcache/src/net/sf/davcache/PropPatchResponse.java trunk/labs/davcache/src/net/sf/davcache/TreeCacheServletService.java trunk/labs/davcache/src/net/sf/davcache/TreeCacheStore.java trunk/labs/davcache/src/net/sf/davcache/WebdavServlet.java trunk/labs/davcache/src/net/sf/davcache/fileTypes.properties trunk/labs/davcache/tests/ trunk/labs/davcache/tests/functional/ trunk/labs/davcache/tests/functional/net/ trunk/labs/davcache/tests/functional/net/sf/ trunk/labs/davcache/tests/functional/net/sf/davcache/ trunk/labs/davcache/tests/functional/net/sf/davcache/functest/ trunk/labs/davcache/tests/functional/net/sf/davcache/functest/WebdavServletTest.java Modified: trunk/labs/davcache/ Log: initial release 1.0 beta 1 Property changes on: trunk/labs/davcache ___________________________________________________________________ Name: svn:ignore + output Added: trunk/labs/davcache/.classpath =================================================================== --- trunk/labs/davcache/.classpath 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/.classpath 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="output/classes"/> + <classpathentry output="output/test-classes" kind="src" path="tests/functional"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="lib" path="lib/dom4j.jar"/> + <classpathentry kind="lib" path="lib/jboss-cache.jar"/> + <classpathentry kind="lib" path="lib/jboss-common.jar"/> + <classpathentry kind="lib" path="lib/jboss-j2ee.jar"/> + <classpathentry kind="lib" path="lib/jboss-jmx.jar"/> + <classpathentry kind="lib" path="lib/jboss-system.jar"/> + <classpathentry kind="lib" path="lib/jgroups.jar"/> + <classpathentry kind="lib" path="lib/commons-httpclient.jar"/> + <classpathentry kind="lib" path="lib/commons-logging.jar"/> + <classpathentry kind="lib" path="lib/javax.servlet.jar"/> + <classpathentry kind="lib" path="lib/webdavlib.jar"/> + <classpathentry kind="lib" path="lib/junit.jar"/> +</classpath> Added: trunk/labs/davcache/.project =================================================================== --- trunk/labs/davcache/.project 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/.project 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>davcache</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: trunk/labs/davcache/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/labs/davcache/.settings/org.eclipse.jdt.core.prefs 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/.settings/org.eclipse.jdt.core.prefs 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,7 @@ +#Mon Jan 23 22:32:20 GMT 2006 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2 +org.eclipse.jdt.core.compiler.compliance=1.4 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning +org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning +org.eclipse.jdt.core.compiler.source=1.3 Added: trunk/labs/davcache/.settings/org.eclipse.jdt.ui.prefs =================================================================== --- trunk/labs/davcache/.settings/org.eclipse.jdt.ui.prefs 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/.settings/org.eclipse.jdt.ui.prefs 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,5 @@ +#Mon Jan 23 22:23:17 GMT 2006 +eclipse.preferences.version=1 +formatter_settings_version=8 +internal.default.compliance=default +org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/> Added: trunk/labs/davcache/LICENSE.txt =================================================================== --- trunk/labs/davcache/LICENSE.txt 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/LICENSE.txt 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + Added: trunk/labs/davcache/README.txt =================================================================== --- trunk/labs/davcache/README.txt 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/README.txt 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,40 @@ +DavCache: Webdav interface to JBossCache +======================================== + +Version 1.0 beta 1 - 2006-01-22 + +DavCache is a WebDAV interface to JBossCache. + +It allows you to access JBossCache like a filesystem, any modifications being +automatically replicated across the cluster. + +Features +-------- + + * supports most commonly used DAV operations: list, create, move, delete files and directories + * automated tests using the client lib from Jakarta Slides + * deployable as a SAR into JBoss or as a webapp into any servlet container (e.g. Tomcat) + +Quick Start +----------- + +For JBoss (tested with 4.0.3SP1) + + 1. start JBoss (tested with 4.0.3SP1) with the 'all' configuration + 2. deploy 'davcache.sar' + 3. optionally start another JBoss instance to test replication + +For standalone Tomcat (tested with 5.5.12) or any other servlet container + + 1. start JBoss (tested with 4.0.3SP1) with the 'all' configuration + 2. deploy 'davcache.sar' + 3. optionally start another JBoss instance to test replication + +finally + + 4. point your Webdav client to 'http://localhost:8080/davcache' (no auth needed) + +Enjoy, + +Mirko Nasato +<mi...@ar...> Added: trunk/labs/davcache/build.xml =================================================================== --- trunk/labs/davcache/build.xml 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/build.xml 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,105 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- $Id$ --> + +<project name="DavCache" default="compile"> + + <property name="module.name" value="DavCache" /> + <property name="module.version" value="1.0-beta1" /> + <property name="root.dir" value="${basedir}" /> + <property name="src.dir" value="${root.dir}/src" /> + <property name="tests.dir" value="${root.dir}/tests" /> + <property name="functional.tests.dir" value="${tests.dir}/functional" /> + <property name="etc.dir" value="${root.dir}/etc" /> + <property name="output.dir" value="${root.dir}/output" /> + <property name="compile.dir" value="${output.dir}/classes" /> + <property name="compiletest.dir" value="${output.dir}/test-classes" /> + <property name="lib.dir" value="${root.dir}/lib" /> + <property name="dist.dir" value="${root.dir}/dist" /> + <property name="dist.lib" value="${dist.dir}/lib" /> + <property name="war.output.dir" value="${dist.dir}/davcache.war" /> + <property name="sar.output.dir" value="${dist.dir}/davcache.sar" /> + + <path id="library.classpath"> + <fileset dir="${lib.dir}"> + <include name="*.jar" /> + </fileset> + </path> + + <path id="output.classpath"> + <pathelement location="${compile.dir}" /> + <pathelement location="${compiletest.dir}" /> + </path> + + <target name="compile" description="compiles all java files"> + + <mkdir dir="${compile.dir}" /> + <mkdir dir="${compiletest.dir}" /> + + <!-- compile java code --> + <javac destdir="${compile.dir}" source="1.4" target="1.4" debug="on" deprecation="on" optimize="off" includes="**/*.java" failonerror="true"> + <src path="${src.dir}" /> + <classpath refid="library.classpath" /> + </javac> + <copy todir="${compile.dir}"> + <fileset dir="${src.dir}" includes="**/*.properties" /> + </copy> + + <!-- compile test classes --> + <javac destdir="${compiletest.dir}" debug="on" deprecation="on" optimize="off" includes="**/*.java" failonerror="true"> + <src path="${functional.tests.dir}" /> + <classpath path="${compile.dir}" /> + <classpath refid="library.classpath" /> + </javac> + + </target> + + <target name="create-war" description="creates generic webapp module" depends="compile"> + <mkdir dir="${war.output.dir}" /> + <mkdir dir="${war.output.dir}/WEB-INF" /> + <copy todir="${war.output.dir}/WEB-INF"> + <fileset dir="${etc.dir}/WEB-INF" includes="web.xml,davcache-service.xml" /> + </copy> + <mkdir dir="${war.output.dir}/WEB-INF/lib" /> + <copy todir="${war.output.dir}/WEB-INF/lib"> + <fileset dir="${lib.dir}"> + <include name="*.jar" /> + <!-- already included in any servlet container --> + <exclude name="javax.servlet.jar" /> + <!-- required by tests only --> + <exclude name="commons-httpclient.jar" /> + <exclude name="junit.jar" /> + <exclude name="webdavlib.jar" /> + </fileset> + </copy> + <mkdir dir="${war.output.dir}/WEB-INF/classes" /> + <copy todir="${war.output.dir}/WEB-INF/classes"> + <fileset dir="${compile.dir}" includes="**/*" /> + </copy> + </target> + + <target name="create-sar" description="creates jboss service module" depends="compile"> + <mkdir dir="${sar.output.dir}"/> + <mkdir dir="${sar.output.dir}/META-INF"/> + <copy todir="${sar.output.dir}/META-INF" file="${etc.dir}/META-INF/jboss-service.xml"/> + <mkdir dir="${sar.output.dir}/davcache.war"/> + <mkdir dir="${sar.output.dir}/davcache.war/WEB-INF"/> + <copy tofile="${sar.output.dir}/davcache.war/WEB-INF/web.xml" file="${etc.dir}/WEB-INF/web-jboss.xml"/> + <copy todir="${sar.output.dir}/davcache.war/WEB-INF" file="${etc.dir}/WEB-INF/jboss-web.xml"/> + <mkdir dir="${sar.output.dir}/davcache.war/WEB-INF/classes"/> + <copy todir="${sar.output.dir}/davcache.war/WEB-INF/classes"> + <fileset dir="${compile.dir}" includes="**/*"/> + </copy> + </target> + + <target name="clean"> + <delete dir="${output.dir}" /> + <delete dir="${dist.dir}" /> + <delete> + <fileset dir="${basedir}" defaultexcludes="no"> + <include name="**/*~" /> + </fileset> + </delete> + </target> + +</project> Property changes on: trunk/labs/davcache/build.xml ___________________________________________________________________ Name: svn:executable + * Added: trunk/labs/davcache/etc/META-INF/jboss-service.xml =================================================================== --- trunk/labs/davcache/etc/META-INF/jboss-service.xml 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/etc/META-INF/jboss-service.xml 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,171 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- ===================================================================== --> +<!-- --> +<!-- TreeCache Service Configuration for DavCache with JBoss --> +<!-- --> +<!-- ===================================================================== --> + +<server> + + <!-- ==================================================================== --> + <!-- Defines TreeCache configuration --> + <!-- ==================================================================== --> + + <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=WebdavTreeCache"> + + <depends>jboss:service=Naming</depends> + <depends>jboss:service=TransactionManager</depends> + + <!-- + Configure the TransactionManager (default: JBoss) + <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute> + --> + + <!-- + Isolation level : SERIALIZABLE + REPEATABLE_READ (default) + READ_COMMITTED + READ_UNCOMMITTED + NONE + --> + <attribute name="IsolationLevel">REPEATABLE_READ</attribute> + + <!-- + Valid modes are LOCAL, REPL_ASYNC and REPL_SYNC + --> + <attribute name="CacheMode">REPL_SYNC</attribute> + + <!-- + Just used for async repl: use a replication queue + --> + <attribute name="UseReplQueue">false</attribute> + + <!-- + Replication interval for replication queue (in ms) + --> + <attribute name="ReplQueueInterval">0</attribute> + + <!-- + Max number of elements which trigger replication + --> + <attribute name="ReplQueueMaxElements">0</attribute> + + <!-- Name of cluster. Needs to be the same for all clusters, in order + to find each other + --> + <attribute name="ClusterName">WebdavTreeCache-Cluster</attribute> + + <!-- JGroups protocol stack properties. Can also be a URL, + e.g. file:/home/bela/default.xml + <attribute name="ClusterProperties"></attribute> + --> + + <attribute name="ClusterConfig"> + <config> + <!-- UDP: if you have a multihomed machine, + set the bind_addr attribute to the appropriate NIC IP address, e.g bind_addr="192.168.0.2" + --> + <!-- UDP: On Windows machines, because of the media sense feature + being broken with multicast (even after disabling media sense) + set the loopback attribute to true --> + <UDP mcast_addr="228.3.3.1" mcast_port="48331" + ip_ttl="64" ip_mcast="true" + mcast_send_buf_size="150000" mcast_recv_buf_size="80000" + ucast_send_buf_size="150000" ucast_recv_buf_size="80000" + loopback="false"/> + <PING timeout="2000" num_initial_members="3" + up_thread="false" down_thread="false"/> + <MERGE2 min_interval="10000" max_interval="20000"/> + <!-- <FD shun="true" up_thread="true" down_thread="true" />--> + <FD_SOCK/> + <VERIFY_SUSPECT timeout="1500" + up_thread="false" down_thread="false"/> + <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800" + max_xmit_size="8192" up_thread="false" down_thread="false"/> + <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10" + down_thread="false"/> + <pbcast.STABLE desired_avg_gossip="20000" + up_thread="false" down_thread="false"/> + <FRAG frag_size="8192" + down_thread="false" up_thread="false"/> + <pbcast.GMS join_timeout="5000" join_retry_timeout="2000" + shun="true" print_local_addr="true"/> + <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/> + </config> + </attribute> + + + <!-- + Whether or not to fetch state on joining a cluster + --> + <attribute name="FetchStateOnStartup">true</attribute> + + <!-- + The max amount of time (in milliseconds) we wait until the + initial state (ie. the contents of the cache) are retrieved from + existing members in a clustered environment + --> + <attribute name="InitialStateRetrievalTimeout">5000</attribute> + + <!-- + Number of milliseconds to wait until all responses for a + synchronous call have been received. + --> + <attribute name="SyncReplTimeout">15000</attribute> + + <!-- Max number of milliseconds to wait for a lock acquisition --> + <attribute name="LockAcquisitionTimeout">10000</attribute> + + <!-- Name of the eviction policy class. --> + <attribute name="EvictionPolicyClass"></attribute> + + <!-- + Indicate whether to use marshalling or not. Set this to true if you are running under a scoped + class loader, e.g., inside an application server. Default is "false". + --> + <!-- not in version 1.2.3 + <attribute name="UseMarshalling">false</attribute> + --> + + <!-- + <attribute name="CacheLoaderClass">org.jboss.cache.loader.bdbje.BdbjeCacheLoader</attribute> + <attribute name="CacheLoaderConfig"> + location=c:\\tmp\\bdbje + </attribute> + <attribute name="CacheLoaderShared">true</attribute> + <attribute name="CacheLoaderPreload">/</attribute> + <attribute name="CacheLoaderPassivation">false</attribute> + --> + + <!-- + <attribute name="CacheLoaderClass">org.jboss.cache.loader.FileCacheLoader</attribute> + <attribute name="CacheLoaderConfig"> + location=c:\\tmp + </attribute> + <attribute name="CacheLoaderShared">true</attribute> + <attribute name="CacheLoaderPreload">/</attribute> + <attribute name="CacheLoaderPassivation">false</attribute> + --> + </mbean> + + + <!-- Proxy factory for WebdavTreeCache that will call target method on the target service --> + <mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory" + name="jboss.jmx:type=adaptor,name=WebdavTreeCacheInvokeTarget,protocol=jrmp,service=proxyFactory"> + <depends optional-attribute-name="InvokerName">jboss:service=invoker,type=jrmp</depends> + <depends optional-attribute-name="TargetName">jboss.cache:service=WebdavTreeCache</depends> + <attribute name="JndiName">WebdavTreeCache</attribute> + <attribute name="InvokeTargetMethod">true</attribute> + <attribute name="ExportedInterfaces">org.jboss.cache.TreeCacheMBean</attribute> + <attribute name="ClientInterceptors"> + <interceptors> + <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor> + <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor> + <interceptor>org.jboss.jmx.connector.invoker.client.InvokerAdaptorClientInterceptor</interceptor> + <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor> + </interceptors> + </attribute> + </mbean> + +</server> Property changes on: trunk/labs/davcache/etc/META-INF/jboss-service.xml ___________________________________________________________________ Name: svn:executable + * Added: trunk/labs/davcache/etc/WEB-INF/davcache-service.xml =================================================================== --- trunk/labs/davcache/etc/WEB-INF/davcache-service.xml 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/etc/WEB-INF/davcache-service.xml 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- ===================================================================== --> +<!-- --> +<!-- TreeCache Service Configuration for DavCache with any appserver --> +<!-- --> +<!-- ===================================================================== --> + +<server> + + <!-- ==================================================================== --> + <!-- Defines TreeCache configuration --> + <!-- ==================================================================== --> + + <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=WebdavTreeCache"> + + <depends>jboss:service=Naming</depends> + <depends>jboss:service=TransactionManager</depends> + + <!-- + Configure the TransactionManager (default: JBoss) + <attribute name="TransactionManagerLookupClass">org.jboss.cache.DummyTransactionManagerLookup</attribute> + --> + + <!-- + Isolation level : SERIALIZABLE + REPEATABLE_READ (default) + READ_COMMITTED + READ_UNCOMMITTED + NONE + --> + <attribute name="IsolationLevel">REPEATABLE_READ</attribute> + + <!-- + Valid modes are LOCAL, REPL_ASYNC and REPL_SYNC + --> + <attribute name="CacheMode">REPL_SYNC</attribute> + + <!-- + Just used for async repl: use a replication queue + --> + <attribute name="UseReplQueue">false</attribute> + + <!-- + Replication interval for replication queue (in ms) + --> + <attribute name="ReplQueueInterval">0</attribute> + + <!-- + Max number of elements which trigger replication + --> + <attribute name="ReplQueueMaxElements">0</attribute> + + <!-- Name of cluster. Needs to be the same for all clusters, in order + to find each other + --> + <attribute name="ClusterName">WebdavTreeCache-Cluster</attribute> + + <!-- JGroups protocol stack properties. Can also be a URL, + e.g. file:/home/bela/default.xml + <attribute name="ClusterProperties"></attribute> + --> + + <attribute name="ClusterConfig"> + <config> + <!-- UDP: if you have a multihomed machine, + set the bind_addr attribute to the appropriate NIC IP address, e.g bind_addr="192.168.0.2" + --> + <!-- UDP: On Windows machines, because of the media sense feature + being broken with multicast (even after disabling media sense) + set the loopback attribute to true --> + <UDP mcast_addr="228.3.3.1" mcast_port="48331" + ip_ttl="64" ip_mcast="true" + mcast_send_buf_size="150000" mcast_recv_buf_size="80000" + ucast_send_buf_size="150000" ucast_recv_buf_size="80000" + loopback="false"/> + <PING timeout="2000" num_initial_members="3" + up_thread="false" down_thread="false"/> + <MERGE2 min_interval="10000" max_interval="20000"/> + <!-- <FD shun="true" up_thread="true" down_thread="true" />--> + <FD_SOCK/> + <VERIFY_SUSPECT timeout="1500" + up_thread="false" down_thread="false"/> + <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800" + max_xmit_size="8192" up_thread="false" down_thread="false"/> + <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10" + down_thread="false"/> + <pbcast.STABLE desired_avg_gossip="20000" + up_thread="false" down_thread="false"/> + <FRAG frag_size="8192" + down_thread="false" up_thread="false"/> + <pbcast.GMS join_timeout="5000" join_retry_timeout="2000" + shun="true" print_local_addr="true"/> + <pbcast.STATE_TRANSFER up_thread="true" down_thread="true"/> + </config> + </attribute> + + + <!-- + Whether or not to fetch state on joining a cluster + --> + <attribute name="FetchStateOnStartup">true</attribute> + + <!-- + The max amount of time (in milliseconds) we wait until the + initial state (ie. the contents of the cache) are retrieved from + existing members in a clustered environment + --> + <attribute name="InitialStateRetrievalTimeout">5000</attribute> + + <!-- + Number of milliseconds to wait until all responses for a + synchronous call have been received. + --> + <attribute name="SyncReplTimeout">15000</attribute> + + <!-- Max number of milliseconds to wait for a lock acquisition --> + <attribute name="LockAcquisitionTimeout">10000</attribute> + + <!-- Name of the eviction policy class. --> + <attribute name="EvictionPolicyClass"></attribute> + + <!-- + Indicate whether to use marshalling or not. Set this to true if you are running under a scoped + class loader, e.g., inside an application server. Default is "false". + --> + <!-- not in version 1.2.3 + <attribute name="UseMarshalling">false</attribute> + --> + + <!-- + <attribute name="CacheLoaderClass">org.jboss.cache.loader.bdbje.BdbjeCacheLoader</attribute> + <attribute name="CacheLoaderConfig"> + location=c:\\tmp\\bdbje + </attribute> + <attribute name="CacheLoaderShared">true</attribute> + <attribute name="CacheLoaderPreload">/</attribute> + <attribute name="CacheLoaderPassivation">false</attribute> + --> + + <!-- + <attribute name="CacheLoaderClass">org.jboss.cache.loader.FileCacheLoader</attribute> + <attribute name="CacheLoaderConfig"> + location=c:\\tmp + </attribute> + <attribute name="CacheLoaderShared">true</attribute> + <attribute name="CacheLoaderPreload">/</attribute> + <attribute name="CacheLoaderPassivation">false</attribute> + --> + </mbean> + +</server> Property changes on: trunk/labs/davcache/etc/WEB-INF/davcache-service.xml ___________________________________________________________________ Name: svn:executable + * Added: trunk/labs/davcache/etc/WEB-INF/jboss-web.xml =================================================================== --- trunk/labs/davcache/etc/WEB-INF/jboss-web.xml 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/etc/WEB-INF/jboss-web.xml 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<!DOCTYPE jboss-web PUBLIC "-//JBoss//DTD Web Application 2.3V2//EN" "http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd"> +<jboss-web> + <context-root>davcache</context-root> +</jboss-web> Added: trunk/labs/davcache/etc/WEB-INF/web-jboss.xml =================================================================== --- trunk/labs/davcache/etc/WEB-INF/web-jboss.xml 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/etc/WEB-INF/web-jboss.xml 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" + version="2.4"> + + <!-- web.xml for use with an externally configured TreeCache MBean in JBoss --> + + <display-name>DavCache</display-name> + + <servlet> + <servlet-name>WebdavServlet</servlet-name> + <servlet-class>net.sf.davcache.WebdavServlet</servlet-class> + <init-param> + <param-name>TreeCacheJndiName</param-name> + <param-value>WebdavTreeCache</param-value> + </init-param> + </servlet> + + <servlet-mapping> + <servlet-name>WebdavServlet</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + +</web-app> Added: trunk/labs/davcache/etc/WEB-INF/web.xml =================================================================== --- trunk/labs/davcache/etc/WEB-INF/web.xml 2006-01-23 18:54:55 UTC (rev 2178) +++ trunk/labs/davcache/etc/WEB-INF/web.xml 2006-01-23 22:41:41 UTC (rev 2179) @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<web-app xmlns="http://java.sun.com/xml/ns/j2ee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" + version="2.4"> + + <!-- web.xml for use with any servlet container --> + + <display-name>DavCache</display-name> + + <listener> + <listener-class>net.sf.davcache.TreeCacheServletService</listener-class> + </listener> + + <servlet> + <servlet-name>WebdavServlet</servlet-name> + <servlet-class>net.sf.davcache.WebdavServlet</servlet-class> + </servlet> + + <servlet-mapping> + <servlet-name>WebdavServlet</servlet-name> + <url-pattern>/*</url-pattern> + </servlet-mapping> + +</web-app> Added: trunk/labs/davcache/lib/commons-httpclient.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/commons-httpclient.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/commons-logging.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/commons-logging.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/concurrent.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/concurrent.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/dom4j.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/dom4j.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/javax.servlet.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/javax.servlet.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/jboss-cache.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/jboss-cache.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/jboss-common.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/jboss-common.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/jboss-j2ee.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/jboss-j2ee.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/jboss-jmx.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/jboss-jmx.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/jboss-system.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/jboss-system.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/jgroups.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/jgroups.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/junit.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/davcache/lib/junit.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/davcache/lib/webdavlib.jar =================================================================== (Binary files differ) Property changes o... [truncated message content] |
From: <jbo...@li...> - 2006-01-23 18:54:59
|
Author: dam...@jb... Date: 2006-01-23 13:54:55 -0500 (Mon, 23 Jan 2006) New Revision: 2178 Added: trunk/labs/davcache/ Log: Added the davcache project. |
Author: noe...@jb... Date: 2006-01-23 13:34:49 -0500 (Mon, 23 Jan 2006) New Revision: 2176 Added: trunk/labs/reportingservices/reporting-services/testsuite/ trunk/labs/reportingservices/reporting-services/testsuite/build.xml trunk/labs/reportingservices/reporting-services/testsuite/lib/ trunk/labs/reportingservices/reporting-services/testsuite/lib/apache-xerces/ trunk/labs/reportingservices/reporting-services/testsuite/lib/apache-xerces/xercesImpl.jar trunk/labs/reportingservices/reporting-services/testsuite/lib/jboss-test/ trunk/labs/reportingservices/reporting-services/testsuite/lib/jboss-test/jboss-test.jar trunk/labs/reportingservices/reporting-services/testsuite/lib/jboss-transaction/ trunk/labs/reportingservices/reporting-services/testsuite/lib/jboss-transaction/jboss-transaction-client.jar trunk/labs/reportingservices/reporting-services/testsuite/lib/junit/ trunk/labs/reportingservices/reporting-services/testsuite/lib/junit/junit.jar trunk/labs/reportingservices/reporting-services/testsuite/local.properties trunk/labs/reportingservices/reporting-services/testsuite/src/ trunk/labs/reportingservices/reporting-services/testsuite/src/main/ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployer/ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployer/ERADeployerTestCase.java trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/AbstractReportingServiceDeploymentTestCase.java trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/ReportingServiceDeploymentTestCase.java trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/ReportingServiceUndeploymentTestCase.java trunk/labs/reportingservices/reporting-services/testsuite/src/resources/ trunk/labs/reportingservices/reporting-services/testsuite/src/resources/era1/ trunk/labs/reportingservices/reporting-services/testsuite/src/resources/era1/META-INF/ trunk/labs/reportingservices/reporting-services/testsuite/src/resources/era1/META-INF/jboss-report.xml trunk/labs/reportingservices/reporting-services/testsuite/src/resources/era1/test1.jrxml trunk/labs/reportingservices/reporting-services/testsuite/src/resources/jndi.properties Log: testsuite initial version Added: trunk/labs/reportingservices/reporting-services/testsuite/build.xml =================================================================== --- trunk/labs/reportingservices/reporting-services/testsuite/build.xml 2006-01-23 05:17:25 UTC (rev 2175) +++ trunk/labs/reportingservices/reporting-services/testsuite/build.xml 2006-01-23 18:34:49 UTC (rev 2176) @@ -0,0 +1,179 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<!-- ====================================================================== --> +<!-- --> +<!-- JBoss, Home of Professional Open Source --> +<!-- --> +<!-- Distributable under LGPL license. --> +<!-- See terms of license at http://www.gnu.org. --> +<!-- --> +<!-- ====================================================================== --> + +<project default="most" name="Reporting Services Test Suite"> + + <!-- ================================================================== --> + <!-- Properties --> + <!-- ================================================================== --> + <property environment="env"/> + + <!-- ================================================================== --> + <!-- Configuration --> + <!-- ================================================================== --> + <target name="verify-env"> + + <!-- JBOSS_HOME --> + <condition property="jbosshome.available" value="true"> + <and> + <isset property="env.JBOSS_HOME"/> + <available file="${env.JBOSS_HOME}/server/default/deploy" type="dir"/> + </and> + </condition> + <fail unless="jbosshome.available" message="JBOSS_HOME property must be set"/> + <!-- /JBOSS_HOME --> + + </target> + + <target name="configure" unless="configure.disable" depends="verify-env"> + + <!-- Module name(s) & version --> + <property name="module.name" value="reporting" /> + <property name="module.Name" value="Reporting Services" /> + <property name="module.version" value="1.0.0alpha" /> + + <property name="root.dir" value="${basedir}" /> + <property name="project.root.dir" value="${root.dir}/.." /> + + <property name="src.dir" value="${root.dir}/src/main" /> + <property name="src.resources.dir" value="${root.dir}/src/resources" /> + <property name="project.output.dir" value="${project.root.dir}/output" /> + <property name="output.dir" value="${root.dir}/output" /> + <property name="output.gen-src.dir" value="${output.dir}/gen-src" /> + <property name="output.etc.dir" value="${output.dir}/etc" /> + <property name="output.doc.dir" value="${output.dir}/doc" /> + <property name="output.api.dir" value="${output.doc.dir}/api" /> + <property name="compile.dir" value="${output.dir}/classes" /> + <property name="output.resources.dir" value="${output.dir}/resources" /> + <property name="lib.dir" value="${root.dir}/lib" /> + <property name="project.output.lib.dir" value="${project.output.dir}/lib" /> + + <!-- javadoc includes --> + <property name="javadoc.packages" value="org.jboss.reporting.*" /> + <property name="manifest.file" value="${output.etc.dir}/default.mf" /> + + <!-- deploy dir from JBoss AS install --> + <property name="jboss.dir" value="${env.JBOSS_HOME}" /> + <property name="jboss.conf.dir" value="${jboss.dir}/server/default" /> + <property name="jboss.deploy.dir" value="${jboss.conf.dir}/deploy" /> + + <!-- The combined library classpath --> + <path id="library.classpath"> + <pathelement location="${compile.dir}" /> + <pathelement location="${etc.dir}" /> + <fileset dir="${jboss.dir}/lib"> + <include name="**/*.jar" /> + </fileset> + <fileset dir="${jboss.conf.dir}/lib"> + <include name="**/*.jar" /> + </fileset> + <fileset dir="${lib.dir}"> + <include name="**/*.jar" /> + <exclude name="**/jboss/**/*.jar" /> + </fileset> + </path> + + <path id="testsuite.classpath"> + <path refid="library.classpath" /> + <pathelement path="${project.output.lib.dir}/reporting-services.jar" /> + <pathelement path="${project.output.lib.dir}/reporting-services-tests.jar" /> + <pathelement path="${src.resources.dir}" /> + <path refid="library.classpath" /> + </path> + + + </target> + + <target name="prepare-test-files" depends="configure"> + <mkdir dir="${output.resources.dir}"/> + <jar basedir="${src.resources.dir}/era1" compress="true" + destfile="${output.resources.dir}/era1.era"/> + <copy todir="${output.resources.dir}/era1-unpack.era"> + <fileset dir="${src.resources.dir}/era1"/> + </copy> + </target> + + <!-- ================================================================== --> + <!-- Compile --> + <!-- ================================================================== --> + <target name="compile" description="Compile all testsuite source files." depends="configure"> + + <mkdir dir="${compile.dir}" /> + + <!-- mbeans source code generation --> + + <!-- java source compile --> + <javac destdir="${compile.dir}" debug="on" deprecation="on" optimize="off" failonerror="true"> + <src path="${src.dir}"/> + <include name="**/*TestCase.java"/> + <classpath refid="testsuite.classpath" /> + </javac> + + </target> + + <!-- ================================================================== --> + <!-- General --> + <!-- ================================================================== --> + + <target name="clean" depends="configure"> + <delete dir="${output.dir}" /> + </target> + + <target name="most" depends="clean,run-tests" /> + + <target name="javadoc" description="Generate javadoc" depends="configure"> + <javadoc packagenames="${javadoc.packages}" sourcepath="${src.dir}/main" destdir="${output.api.dir}" classpathref="library.classpath" author="true" version="true" use="true" bottom="Copyright © 1998-2005 JBoss Inc . All Rights Reserved." useexternalfile="yes" /> + </target> + + <target name="run-tests" description="run complete test suite" depends="compile, prepare-test-files"> + <mkdir dir="${output.dir}"/> + <echo message="testing deployment"/> + <property environment="env" name="project.root.dir" value="${project.root.dir}"/> + <junit haltonerror="true" fork="true" printsummary="true"> + <jvmarg value="-Droot.dir=${project.root.dir}"/> + <jvmarg value="-Dtestsuite.dir=${basedir}"/> + <classpath refid="testsuite.classpath" /> + <formatter type="plain"/> + <test errorproperty="deployfailed" name="org.jboss.test.reporting.deployment.ReportingServiceDeploymentTestCase" todir="${output.dir}"/> + </junit> + + <junit haltonerror="true" fork="true" printsummary="true"> + <jvmarg value="-Droot.dir=${project.root.dir}"/> + <jvmarg value="-Dtestsuite.dir=${basedir}"/> + <classpath refid="testsuite.classpath" /> + <formatter type="plain"/> + + <batchtest todir="${output.dir}" haltonerror="false"> + <!-- unless="deployfailed"--> + <formatter type="plain"/> + <fileset dir="${src.dir}"> + <include name="**/*TestCase.java"/> + <exclude name="org/jboss/test/reporting/deployment/**/*.java"/> + </fileset> + </batchtest> + </junit> + <junit haltonerror="true" fork="true" printsummary="true"> + <jvmarg value="-Droot.dir=${project.root.dir}"/> + <jvmarg value="-Dtestsuite.dir=${basedir}"/> + <classpath refid="testsuite.classpath" /> + <formatter type="plain"/> + <test name="org.jboss.test.reporting.deployment.ReportingServiceUndeploymentTestCase" todir="${output.dir}"/> + <!-- unless="deployfailed"--> + </junit> + </target> + <!-- ================================================================== --> + <!-- Misc. --> + <!-- ================================================================== --> + + + +</project> + Added: trunk/labs/reportingservices/reporting-services/testsuite/lib/apache-xerces/xercesImpl.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/reportingservices/reporting-services/testsuite/lib/apache-xerces/xercesImpl.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/reportingservices/reporting-services/testsuite/lib/jboss-test/jboss-test.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/reportingservices/reporting-services/testsuite/lib/jboss-test/jboss-test.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/reportingservices/reporting-services/testsuite/lib/jboss-transaction/jboss-transaction-client.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/reportingservices/reporting-services/testsuite/lib/jboss-transaction/jboss-transaction-client.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/reportingservices/reporting-services/testsuite/lib/junit/junit.jar =================================================================== (Binary files differ) Property changes on: trunk/labs/reportingservices/reporting-services/testsuite/lib/junit/junit.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/labs/reportingservices/reporting-services/testsuite/local.properties =================================================================== --- trunk/labs/reportingservices/reporting-services/testsuite/local.properties 2006-01-23 05:17:25 UTC (rev 2175) +++ trunk/labs/reportingservices/reporting-services/testsuite/local.properties 2006-01-23 18:34:49 UTC (rev 2176) @@ -0,0 +1,12 @@ +### ====================================================================== ### +## ## +## Local project properties. ## +## ## +## Define properties that are local to your environment here. This ## +## file (local.properties) should not be checked in. Modify the ## +## example to affect all users. ## +## ## +### ====================================================================== ### + +# +env.JBOSS_HOME=../jboss \ No newline at end of file Added: trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployer/ERADeployerTestCase.java =================================================================== --- trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployer/ERADeployerTestCase.java 2006-01-23 05:17:25 UTC (rev 2175) +++ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployer/ERADeployerTestCase.java 2006-01-23 18:34:49 UTC (rev 2176) @@ -0,0 +1,72 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.test.reporting.deployer; + +import java.io.File; +import java.net.URL; + +import org.jboss.deployment.DeploymentInfo; +import org.jboss.deployment.MainDeployerMBean; +import org.jboss.test.JBossTestCase; + +public class ERADeployerTestCase extends JBossTestCase +{ + String basePath; + + String packedDeploymentURL; + + String unpackedDeploymentURL; + + public ERADeployerTestCase(String name) + { + super(name); + } + + protected void setUp() throws Exception + { + super.setUp(); + + basePath = System.getProperty("testsuite.dir"); + if (basePath == null) + basePath = new File(".").getAbsolutePath(); + + packedDeploymentURL = getDeployURL("file:/" + basePath + "/output/resources/era1.era"); + } + + protected void tearDown() throws Exception + { + super.tearDown(); + } + + public void testPackedERADeployment() throws Exception + { + deploy(packedDeploymentURL); + DeploymentInfo deploymentInfo = getDeploymentInfo(packedDeploymentURL); + + assertNotNull("packed era not deployed", deploymentInfo); + // TODO : testing of the in era reports deployment + } + + public void testPackERAUndeployment() throws Exception + { + undeploy(packedDeploymentURL); + DeploymentInfo deploymentInfo = getDeploymentInfo(packedDeploymentURL); + assertNull("packed era not undeployed", deploymentInfo); + } + + private DeploymentInfo getDeploymentInfo(String path) throws Exception + { + URL url = new URL(path); + DeploymentInfo deploymentInfo = (DeploymentInfo) getServer().invoke(MainDeployerMBean.OBJECT_NAME, + "getDeployment", new Object[] + {url}, new String[] + {URL.class.getName()}); + + return deploymentInfo; + } + +} Added: trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/AbstractReportingServiceDeploymentTestCase.java =================================================================== --- trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/AbstractReportingServiceDeploymentTestCase.java 2006-01-23 05:17:25 UTC (rev 2175) +++ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/AbstractReportingServiceDeploymentTestCase.java 2006-01-23 18:34:49 UTC (rev 2176) @@ -0,0 +1,33 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.test.reporting.deployment; + +import java.io.File; + +import org.jboss.test.JBossTestCase; + +import junit.framework.TestCase; + +public class AbstractReportingServiceDeploymentTestCase extends JBossTestCase +{ + String deploymentURL; + + public AbstractReportingServiceDeploymentTestCase(String name) + { + super(name); + } + + protected void setUp() throws Exception + { + super.setUp(); + String basePath = System.getProperty("root.dir"); + if (basePath == null) + basePath = new File(".").getAbsolutePath(); + + deploymentURL = getDeployURL("file:" + basePath + "/output/lib/reporting-services.sar/"); + } +} Added: trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/ReportingServiceDeploymentTestCase.java =================================================================== --- trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/ReportingServiceDeploymentTestCase.java 2006-01-23 05:17:25 UTC (rev 2175) +++ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/ReportingServiceDeploymentTestCase.java 2006-01-23 18:34:49 UTC (rev 2176) @@ -0,0 +1,66 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.test.reporting.deployment; + +import java.io.File; +import java.net.URL; + +import javax.management.MBeanServerConnection; + +import org.jboss.deployment.DeploymentInfo; +import org.jboss.deployment.MainDeployerMBean; +import org.jboss.test.JBossTestCase; + +/** + * Test to verify the well deployment of the sar on a jboss server + * + * @author <a href="vin...@gm...">Vincent Sellier</a> + * @version $Revision:$ + */ +public class ReportingServiceDeploymentTestCase extends AbstractReportingServiceDeploymentTestCase +{ + + public ReportingServiceDeploymentTestCase(String name) + { + super(name); + } + + protected void setUp() throws Exception + { + super.setUp(); + + } + + protected void tearDown() throws Exception + { + super.tearDown(); + } + + public void testDeployment() throws Exception + { + + deploy(deploymentURL); + + // sar deployed ? + MBeanServerConnection server = getServer(); + URL deployURL = new URL(deploymentURL); + try + { + DeploymentInfo deploymentInfo = (DeploymentInfo) server.invoke(MainDeployerMBean.OBJECT_NAME, "getDeployment", + new Object[] + {deployURL}, new String[] + {URL.class.getName()}); + assertNotNull("SAR not deployed", deploymentInfo); + } + catch (Exception e) + { + System.out.print(e.getMessage()); + throw e; + } + + } +} Added: trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/ReportingServiceUndeploymentTestCase.java =================================================================== --- trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/ReportingServiceUndeploymentTestCase.java 2006-01-23 05:17:25 UTC (rev 2175) +++ trunk/labs/reportingservices/reporting-services/testsuite/src/main/org/jboss/test/reporting/deployment/ReportingServiceUndeploymentTestCase.java 2006-01-23 18:34:49 UTC (rev 2176) @@ -0,0 +1,40 @@ +/* + * JBoss, the OpenSource J2EE webOS + * + * Distributable under LGPL license. + * See terms of license at gnu.org. + */ +package org.jboss.test.reporting.deployment; + +import java.net.URL; + +import javax.management.MBeanServerConnection; + +import org.jboss.deployment.DeploymentInfo; +import org.jboss.deployment.MainDeployerMBean; + +public class ReportingServiceUndeploymentTestCase extends + AbstractReportingServiceDeploymentTestCase { + + + public ReportingServiceUndeploymentTestCase(String name) + { + super(name); + } + + public void testUndeployment() throws Exception + { + undeploy(deploymentURL); + + // sar deployed ? + MBeanServerConnection server = getServer(); + URL deployURL = new URL(deploymentURL); + DeploymentInfo deploymentInfo = (DeploymentInfo) server.invoke(MainDeployerMBean.OBJECT_NAME, "getDeployment", + new Object[] + {deployURL}, new String[] + {URL.class.getName()}); + assertNull("SAR still deployed", deploymentInfo); + + } + +} Added: trunk/labs/reportingservices/reporting-services/testsuite/src/resources/era1/META-INF/jboss-report.xml =================================================================== --- trunk/labs/reportingservices/reporting-services/testsuite/src/resources/era1/META-INF/jboss-report.xml 2006-01-23 05:17:25 UTC (rev 2175) +++ trunk/labs/reportingservices/reporting-services/testsuite/src/resources/era1/META-INF/jboss-report.xml 2006-01-23 18:34:49 UTC (rev 2176) @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE server> + + + <!-- + Empty configuration for the JBoss Enterprise Report Archive. + --> + +<jboss-report> +</jboss-report> + Added: trunk/labs/reportingservices/reporting-services/testsuite/src/resources/era1/test1.jrxml =================================================================== --- trunk/labs/reportingservices/reporting-services/testsuite/src/resources/era1/test1.jrxml 2006-01-23 05:17:25 UTC (rev 2175) +++ trunk/labs/reportingservices/reporting-services/testsuite/src/resources/era1/test1.jrxml 2006-01-23 18:34:49 UTC (rev 2176) @@ -0,0 +1,1266 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- Created with iReport - A designer for JasperReports --> +<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd"> +<jasperReport + name="JBossTest" + columnCount="1" + printOrder="Vertical" + orientation="Portrait" + pageWidth="595" + pageHeight="842" + columnWidth="535" + columnSpacing="0" + leftMargin="30" + rightMargin="30" + topMargin="20" + bottomMargin="20" + whenNoDataType="NoPages" + isTitleNewPage="false" + isSummaryNewPage="false"> + <property name="ireport.scriptlethandling" value="2" /> + <queryString><![CDATA[select * from spip_auteurs]]></queryString> + <field name="id_auteur" class="java.lang.Long"/> + <field name="nom" class="java.lang.String"/> + <field name="bio" class="java.lang.String"/> + <field name="email" class="java.lang.String"/> + <field name="nom_site" class="java.lang.String"/> + <field name="url_site" class="java.lang.String"/> + <field name="login" class="java.lang.String"/> + <field name="pass" class="java.lang.String"/> + <field name="low_sec" class="java.lang.String"/> + <field name="statut" class="java.lang.String"/> + <field name="maj" class="java.sql.Timestamp"/> + <field name="pgp" class="java.lang.String"/> + <field name="htpass" class="java.lang.String"/> + <field name="en_ligne" class="java.sql.Timestamp"/> + <field name="imessage" class="java.lang.String"/> + <field name="messagerie" class="java.lang.String"/> + <field name="alea_actuel" class="java.lang.String"/> + <field name="alea_futur" class="java.lang.String"/> + <field name="prefs" class="java.lang.String"/> + <field name="cookie_oubli" class="java.lang.String"/> + <field name="source" class="java.lang.String"/> + <field name="lang" class="java.lang.String"/> + <field name="extra" class="java.lang.String"/> + <field name="idx" class="java.lang.String"/> + <variable name="test" class="java.lang.String" resetType="None" calculation="Nothing"> + <variableExpression><![CDATA["test"]]></variableExpression> + <initialValueExpression><![CDATA["test"]]></initialValueExpression> + </variable> + <group name="nom" isStartNewColumn="false" isStartNewPage="false" isResetPageNumber="false" isReprintHeaderOnEachPage="false" minHeightToStartNewPage="0" > + <groupExpression><![CDATA[$F{nom}]]></groupExpression> + <groupHeader> + <band height="25" isSplitAllowed="true" > + <rectangle radius="0" > + <reportElement + mode="Opaque" + x="0" + y="0" + width="535" + height="25" + forecolor="#8080FF" + backcolor="#000000" + key="rectangle" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <graphicElement stretchType="NoStretch" pen="None" fill="Solid" /> + </rectangle> + <staticText> + <reportElement + mode="Transparent" + x="3" + y="2" + width="96" + height="23" + forecolor="#FFFFFF" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="Times-Roman" pdfFontName="Times-Roman" size="16" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[nom]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="102" + y="2" + width="98" + height="23" + forecolor="#FFFFFF" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="Times-Roman" pdfFontName="Times-Roman" size="20" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{nom}]]></textFieldExpression> + </textField> + </band> + </groupHeader> + <groupFooter> + <band height="10" isSplitAllowed="true" > + <line direction="BottomUp"> + <reportElement + mode="Opaque" + x="1" + y="4" + width="534" + height="0" + forecolor="#000000" + backcolor="#FFFFFF" + key="line" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> + </line> + </band> + </groupFooter> + </group> + <background> + <band height="0" isSplitAllowed="true" > + </band> + </background> + <title> + <band height="50" isSplitAllowed="true" > + <staticText> + <reportElement + mode="Transparent" + x="61" + y="5" + width="412" + height="40" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Center" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="Times New Roman" pdfFontName="Times-Roman" size="30" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[Classic Report Template]]></text> + </staticText> + <line direction="TopDown"> + <reportElement + mode="Opaque" + x="0" + y="48" + width="534" + height="0" + forecolor="#000000" + backcolor="#FFFFFF" + key="line" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <graphicElement stretchType="NoStretch" pen="2Point" fill="Solid" /> + </line> + <line direction="TopDown"> + <reportElement + mode="Opaque" + x="0" + y="3" + width="534" + height="0" + forecolor="#000000" + backcolor="#FFFFFF" + key="line" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <graphicElement stretchType="NoStretch" pen="2Point" fill="Solid" /> + </line> + </band> + </title> + <pageHeader> + <band height="10" isSplitAllowed="true" > + </band> + </pageHeader> + <columnHeader> + <band height="0" isSplitAllowed="true" > + <line direction="BottomUp"> + <reportElement + mode="Opaque" + x="0" + y="0" + width="535" + height="0" + forecolor="#000000" + backcolor="#FFFFFF" + key="line" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" /> + </line> + </band> + </columnHeader> + <detail> + <band height="449" isSplitAllowed="true" > + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="2" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.Long"><![CDATA[$F{id_auteur}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="2" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[id_auteur]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="21" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{bio}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="21" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[bio]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="40" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{email}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="40" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[email]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="59" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{nom_site}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="59" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[nom_site]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="78" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{url_site}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="78" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[url_site]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="97" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{login}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="97" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[login]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="116" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{pass}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="116" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[pass]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="135" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{low_sec}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="135" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[low_sec]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="154" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{statut}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="154" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[statut]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="173" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.sql.Timestamp"><![CDATA[$F{maj}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="173" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[maj]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="192" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{pgp}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="192" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[pgp]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="211" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{htpass}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="211" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[htpass]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="230" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.sql.Timestamp"><![CDATA[$F{en_ligne}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="230" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[en_ligne]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="249" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{imessage}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="249" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[imessage]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="268" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{messagerie}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="268" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[messagerie]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="287" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{alea_actuel}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="287" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[alea_actuel]]></text> + </staticText> + <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement + mode="Transparent" + x="127" + y="306" + width="398" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="textField" + stretchType="NoStretch" + positionType="FixRelativeToTop" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" /> + </textElement> + <textFieldExpression class="java.lang.String"><![CDATA[$F{alea_futur}]]></textFieldExpression> + </textField> + <staticText> + <reportElement + mode="Transparent" + x="0" + y="306" + width="23" + height="17" + forecolor="#000000" + backcolor="#FFFFFF" + key="staticText" + stretchType="NoStretch" + positionType="Float" + isPrintRepeatedValues="true" + isRemoveLineWhenBlank="false" + isPrintInFirstWholeBand="false" + isPrintWhenDetailOverflows="false"/> + <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single"> + <font fontName="" pdfFontName="Courier" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" /> + </textElement> + <text><![CDATA[alea_futur]]></text> + ... [truncated message content] |
Author: bob.mcwhirter Date: 2006-01-23 00:17:25 -0500 (Mon, 23 Jan 2006) New Revision: 2175 Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ParseException.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/Parser.java trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/ParserTest.java trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/one-rule.drl trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/package-imports.drl trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/package.drl Removed: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/RuleParser.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/RuleSetParser.java trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/RuleParserTest.java Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/DroolsRuntimeException.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Rule.java Log: First shot at a non-xml parser. Using the manners rules for testing. Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/DroolsRuntimeException.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/DroolsRuntimeException.java 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/DroolsRuntimeException.java 2006-01-23 05:17:25 UTC (rev 2175) @@ -8,4 +8,8 @@ public DroolsRuntimeException(DroolsException e) { super( e ); } + + public DroolsRuntimeException(String message) { + super( message ); + } } Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ExpanderContext.java 2006-01-23 05:17:25 UTC (rev 2175) @@ -68,7 +68,7 @@ * If <code>isEnabled()</code> is false then it is not required to * call this method. */ - public CharSequence expand(CharSequence expression, RuleParser context) { + public CharSequence expand(CharSequence expression, Parser context) { return expression; } Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ParseException.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ParseException.java 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/ParseException.java 2006-01-23 05:17:25 UTC (rev 2175) @@ -0,0 +1,11 @@ +package org.drools.lang; + +import org.drools.DroolsRuntimeException; + +public class ParseException extends DroolsRuntimeException { + + public ParseException(String message) { + super( message ); + } + +} Added: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/Parser.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/Parser.java 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/Parser.java 2006-01-23 05:17:25 UTC (rev 2175) @@ -0,0 +1,315 @@ +package org.drools.lang; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.drools.rule.DuplicateRuleNameException; +import org.drools.rule.Rule; +import org.drools.rule.RuleConstructionException; + +public class Parser { + + private static Pattern PACKAGE_DECL = Pattern.compile( "\\s*package\\s*([^;]+);?\\s*" ); + private static Pattern IMPORT_STATEMENT = Pattern.compile( "\\s*import\\s*([^;]+);?\\s*" ); + private static Pattern RULE_DECL = Pattern.compile( "\\s*rule\\s*([^\\s]+)\\s*" ); + + private static Pattern FACT_BINDING = Pattern.compile( "\\s*(\\w+)\\s*=>\\s*(.*)" ); + private static Pattern FIELD_BINDING = Pattern.compile( "\\s*(\\w+):(\\w+)\\s*" ); + + private BufferedReader reader; + + private String packageDeclaration; + private List imports; + private List rules; + + public Parser(Reader reader) { + this.reader = new BufferedReader( reader ); + this.imports = new ArrayList(); + this.rules = new ArrayList(); + } + + public String getPackageDeclaration() { + return packageDeclaration; + } + + public List getImports() { + return imports; + } + + public List getRules() { + return rules; + } + + public void parse() throws IOException, RuleConstructionException { + prolog(); + rules(); + } + + protected void prolog() throws IOException { + packageDeclaration(); + importStatements(); + functions(); + } + + protected void packageDeclaration() throws IOException { + String line = laDiscard(); + + if ( line == null ) { return; } + + Matcher matcher = PACKAGE_DECL.matcher( line ); + + if ( matcher.matches() ) { + consumeDiscard(); + packageDeclaration = matcher.group( 1 ); + } + } + + protected void importStatements() throws IOException { + while ( importStatement() ) { + // just do it again + } + } + + protected boolean importStatement() throws IOException { + String line = laDiscard(); + + if ( line == null ) { return false; } + + Matcher matcher = IMPORT_STATEMENT.matcher( line ); + + if ( matcher.matches() ) { + consumeDiscard(); + imports.add( matcher.group( 1 ) ); + return true; + } + + return false; + } + + protected void functions() { + + } + + protected void rules() throws IOException, RuleConstructionException { + while ( rule() ) { + // do it again! + } + } + + protected boolean rule() throws IOException, RuleConstructionException { + String line = laDiscard(); + + if ( line == null ) { return false; } + + Matcher matcher = RULE_DECL.matcher( line ); + + if ( matcher.matches() ) { + consumeDiscard(); + String ruleName = matcher.group(1); + + for ( Iterator ruleIter = rules.iterator() ; ruleIter.hasNext() ; ) { + Rule rule = (Rule) ruleIter.next(); + if ( rule.getName().equals( ruleName ) ) { + throw new DuplicateRuleNameException( null, rule, null ); + } + } + rules.add( new Rule( ruleName ) ); + } + + ruleConditions(); + ruleConsequence(); + + line = laDiscard(); + + if ( ! line.trim().equals( "end" ) ) { + throw new ParseException( "end expected" ); + } + + consumeDiscard(); + + return true; + } + + protected void ruleConditions() throws IOException { + String line = laDiscard(); + + if ( line == null ) { return; } + + if ( line.trim().equals( "when" ) ) { + consumeDiscard(); + } else { + return; + } + + while ( ruleCondition() ) { + // do it again! + } + } + + protected boolean ruleCondition() throws IOException { + String line = laDiscard(); + + + if ( line == null ) { + return false; + } + + line = line.trim(); + + if ( line.equals( "then" ) || line.equals( "end" ) ) { + return false; + } + + Matcher matcher = FACT_BINDING.matcher( line.trim() ); + + String name = null; + String pattern = null; + + consumeDiscard(); + + if ( matcher.matches() ) { + name = matcher.group( 1 ); + pattern = matcher.group( 2 ); + } else { + pattern = line; + } + + if ( pattern.startsWith( ":" ) ) { + pattern = expand( pattern ); + } + + pattern( pattern ); + + return true; + } + + protected String expand(String pattern) { + // TODO: Michael, here goes the expansion bits + return pattern; + } + + protected void pattern(String pattern) { + int leftParen = pattern.indexOf( "(" ); + + if ( leftParen < 0 ) { + throw new ParseException( "invalid pattern: " + pattern ); + } + + int rightParen = pattern.lastIndexOf( ")" ); + + if ( rightParen < 0 ) { + throw new ParseException( "invalid pattern: " + pattern ); + } + + String guts = pattern.substring( leftParen+1, rightParen ).trim(); + + // TODO: Michael, should be also expand the guts? + + StringTokenizer tokens = new StringTokenizer( guts, "," ); + + while ( tokens.hasMoreTokens() ) { + constraint( tokens.nextToken().trim() ); + //System.err.println( "constraint [" + tokens.nextToken().trim() + "]" ); + } + } + + protected void constraint(String constraint) { + Matcher matcher = FIELD_BINDING.matcher( constraint ); + + if ( matcher.matches() ) { + String bindTo = matcher.group( 1 ); + String field = matcher.group( 2 ); + System.err.println( "bind [" + bindTo + "] to field [" + field + "]" ); + } else { + // TODO: Michael, want to jack in here also? + System.err.println( "further work required for [" + constraint + "]" ); + } + } + + protected void ruleConsequence() throws IOException { + String line = laDiscard(); + + if ( line.trim().equals( "then" ) ) { + consumeDiscard(); + + StringBuffer consequence = new StringBuffer(); + + while ( true ) { + line = laDiscard(); + if ( line == null ) { + throw new ParseException( "end expected" ); + } + if ( line.trim().equals( "end" ) ) { + break; + } + consumeDiscard(); + consequence.append( line + "\n" ); + } + System.err.println( "begin consequence"); + System.err.println( consequence ); + System.err.println( "end consequence"); + } + } + + protected String la() throws IOException { + reader.mark( 1024 ); + String line = reader.readLine(); + reader.reset(); + return line; + } + + protected String laDiscard() throws IOException { + reader.mark( 1024 ); + String line = null; + + while ( line == null ) { + line = reader.readLine(); + + if ( line == null ) { + reader.reset(); + return null; + } + + String trimLine = line.trim(); + + if ( trimLine.length() == 0 || trimLine.startsWith( "#" ) || trimLine.startsWith( "//" ) ) { + line = null; + } + } + + reader.reset(); + return line; + } + + protected String consume() throws IOException { + return reader.readLine(); + } + + protected String consumeDiscard() throws IOException { + String line = null; + + while ( line == null ) { + line = reader.readLine(); + + if ( line == null ) { + reader.reset(); + return null; + } + + String trimLine = line.trim(); + + if ( trimLine.length() == 0 || trimLine.startsWith( "#" ) || trimLine.startsWith( "//" ) ) { + line = null; + } + } + + return line; + } +} Deleted: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/RuleParser.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/RuleParser.java 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/RuleParser.java 2006-01-23 05:17:25 UTC (rev 2175) @@ -1,42 +0,0 @@ -package org.drools.lang; - -import jfun.parsec.Lexers; -import jfun.parsec.Parser; -import jfun.parsec.Parsers; -import jfun.parsec.Scanners; -import jfun.parsec.pattern.Pattern; -import jfun.parsec.pattern.Patterns; -import jfun.parsec.tokens.TokenString; - -public class RuleParser { - - public static final Pattern RULE = Patterns.isString( "rule" ); - public static final Pattern WHEN = Patterns.isString( "when" ); - public static final Pattern THEN = Patterns.isString( "then" ); - - public static final Pattern LEFT_PAREN = Patterns.isChar( '(' ); - public static final Pattern RIGHT_PAREN = Patterns.isChar( ')' ); - - public static final Pattern LEFT_BRACE = Patterns.isChar( '{' ); - public static final Pattern RIGHT_BRACE = Patterns.isChar( '}' ); - - public static final Parser S_RULE = Scanners.isPattern( RULE, "rule" ); - public static final Parser S_WHEN = Scanners.isPattern( WHEN, "when" ); - public static final Parser S_THEN = Scanners.isPattern( THEN, "then" ); - - public static final Parser S_LEFT_PAREN = Scanners.isPattern( LEFT_PAREN, "(" ); - public static final Parser S_RIGHT_PAREN = Scanners.isPattern( RIGHT_PAREN, ")" ); - - public static final Parser S_LEFT_BRACE = Scanners.isPattern( LEFT_BRACE, "{" ); - public static final Parser S_RIGHT_BRACE = Scanners.isPattern( RIGHT_BRACE, "}" ); - - public static final Parser L_RULE = Scanners.lexer( S_RULE, TokenString.getTokenizer() ); - public static final Parser L_WHEN = Scanners.lexer( S_WHEN, TokenString.getTokenizer() ); - public static final Parser L_THEN = Scanners.lexer( S_THEN, TokenString.getTokenizer() ); - - public static final Parser LEXER = Parsers.sum( new Parser[] { - L_RULE, - L_WHEN, - L_THEN, - } ); -} Deleted: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/RuleSetParser.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/RuleSetParser.java 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/lang/RuleSetParser.java 2006-01-23 05:17:25 UTC (rev 2175) @@ -1,10 +0,0 @@ -package org.drools.lang; - -import jfun.parsec.pattern.Pattern; -import jfun.parsec.pattern.Patterns; - -public class RuleSetParser { - - public static final Pattern IMPORT = Patterns.isString( "import" ); - -} Modified: trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Rule.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Rule.java 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/main/java/org/drools/rule/Rule.java 2006-01-23 05:17:25 UTC (rev 2175) @@ -41,12 +41,10 @@ */ import java.io.Serializable; -import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; -import java.util.List; import java.util.Map; import org.drools.spi.ClassObjectType; @@ -55,11 +53,9 @@ import org.drools.spi.Consequence; import org.drools.spi.Constraint; import org.drools.spi.Duration; -import org.drools.spi.Evaluator; import org.drools.spi.Extractor; import org.drools.spi.Importer; import org.drools.spi.Module; -import org.drools.spi.ObjectType; /** * A <code>Rule</code> contains a set of <code>Test</code>s and a Added: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/ParserTest.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/ParserTest.java 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/ParserTest.java 2006-01-23 05:17:25 UTC (rev 2175) @@ -0,0 +1,60 @@ +package org.drools.lang; + +import java.io.InputStream; +import java.io.InputStreamReader; + +import junit.framework.TestCase; + +import org.drools.rule.Rule; + +public class ParserTest extends TestCase { + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void test_package() throws Exception { + Parser parser = parser( "package.drl" ); + + parser.parse(); + + assertEquals( "org.drools.lang", parser.getPackageDeclaration() ); + } + + public void test_package_imports() throws Exception { + Parser parser = parser( "package-imports.drl" ); + + parser.parse(); + + assertEquals( "org.drools.lang", parser.getPackageDeclaration() ); + assertEquals( 2, parser.getImports().size() ); + assertEquals( "java.util.List", parser.getImports().get( 0 ) ); + assertEquals( "java.util.ArrayList", parser.getImports().get( 1 ) ); + } + + public void test_one_rule() throws Exception { + Parser parser = parser( "one-rule.drl" ); + + parser.parse(); + + assertEquals( "org.drools.lang", parser.getPackageDeclaration() ); + assertEquals( 2, parser.getImports().size() ); + assertEquals( "java.util.List", parser.getImports().get( 0 ) ); + assertEquals( "java.util.ArrayList", parser.getImports().get( 1 ) ); + + assertEquals( 1, parser.getRules().size() ); + assertEquals( "find_seating", ((Rule)parser.getRules().get(0)).getName() ); + } + + protected Parser parser(String name) { + InputStream in = getClass().getResourceAsStream( name ); + InputStreamReader reader = new InputStreamReader( in ); + + return new Parser( reader ); + } + +} Deleted: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/RuleParserTest.java =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/RuleParserTest.java 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/RuleParserTest.java 2006-01-23 05:17:25 UTC (rev 2175) @@ -1,23 +0,0 @@ -package org.drools.lang; - -import jfun.parsec.Parsers; -import jfun.parsec.PositionedToken; -import junit.framework.TestCase; - -public class RuleParserTest extends TestCase { - - protected void setUp() throws Exception { - super.setUp(); - } - - protected void tearDown() throws Exception { - - } - - public void testLexer() throws Exception { - PositionedToken result = (PositionedToken) Parsers.runParser( "when", RuleParser.LEXER, "test" ); - - System.err.println( "result:" + result.getClass() ); - } - -} Added: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/one-rule.drl =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/one-rule.drl 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/one-rule.drl 2006-01-23 05:17:25 UTC (rev 2175) @@ -0,0 +1,35 @@ +# Example DRL with only a package decl +# + +// yes, you can use silly java comments + +package org.drools.lang; + +# semi colons are optional, we're line-centric + +import java.util.List +import java.util.ArrayList; + +rule find_seating + when + context => Context( state == Context.ASSIGN_SEATS ) + Seating( seatingId:id, seatingPid:pid, pathDone == true, seatingRightSeat:rightSeat, seatingRightGuestName:rightGuestName ) + + #:bob is in atlanta + + Guest( name == seatingRightGuestName, rightGuestSex:sex, rightGuestHobby:hobby ) + Guest( leftGuestName:name , sex != rightGuestSex, hobby == rightGuestHobby ) + count => Count() + #not ( Path( id == seatingId, guestName == leftGuestName) ) + #not ( Chosen( id == seatingId, guestName == leftGuestName, hobby == rightGuestHobby) ) + then + make a ruckus, damnit + Really, you should +end + + + + + + + Added: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/package-imports.drl =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/package-imports.drl 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/package-imports.drl 2006-01-23 05:17:25 UTC (rev 2175) @@ -0,0 +1,12 @@ +# Example DRL with only a package decl +# + +package org.drools.lang; + +import java.util.List; +import java.util.ArrayList; + + + + + Added: trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/package.drl =================================================================== --- trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/package.drl 2006-01-23 04:20:12 UTC (rev 2174) +++ trunk/labs/jbossrules/drools-core/src/test/java/org/drools/lang/package.drl 2006-01-23 05:17:25 UTC (rev 2175) @@ -0,0 +1,6 @@ +# Example DRL with only a package decl +# + +package org.drools.lang; + + |
Author: mic...@jb... Date: 2006-01-22 23:20:12 -0500 (Sun, 22 Jan 2006) New Revision: 2174 Added: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/Chunk.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLExpressionCompiler.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLGrammar.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLMappingItem.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/TemplateContext.java trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/TemplateFactory.java trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLExpressionCompilerTest.java trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateContextTest.java trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateFactoryTest.java Removed: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java Log: new template based parser/compiler Added: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/Chunk.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/Chunk.java 2006-01-23 01:24:32 UTC (rev 2173) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/Chunk.java 2006-01-23 04:20:12 UTC (rev 2174) @@ -0,0 +1,98 @@ +package org.drools.natural.template; + +import java.util.Map; + +import org.apache.commons.lang.StringUtils; + +/** + * This holds a linked list of chunks of natural language. + * A chunk is basically some text, which is delimited by "holes" in the template. + * + * eg: "this is {0} an {1} expression" + * Would have 5 chunks: "this is", "{0}", "an", "{1}" and "expression". + * + * Chunks also know how to parse themselves to work out the value. + * + * This is used by TemplatePopulateContext. + * This class is very recursive, to be prepated to be confused. + * + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + */ +class Chunk { + + String text; + Chunk next; + + //value if it is a hole, starts out as null. + String value; + + + Chunk(String text) { + this.text = text; + } + + + + /** + * This will build up a key to use to substitute the original string with. + * Can then swap it with the target text. + */ + void buildSubtitutionKey(StringBuffer buffer) { + if (isHole()) { + buffer.append(" " + value + " "); + } else { + buffer.append(text); + } + if (next != null) { + next.buildSubtitutionKey(buffer); + } + } + + boolean isHole() { + return text.startsWith("{"); + } + + void process(String expression) { + if (isHole()) { + //value = text until next next.text is found + if (next == null || next.text == null) { + value = expression.trim(); + } else { + value = StringUtils.substringBefore(expression, next.text).trim(); + } + + } else { + value = text; + } + if (next != null) { + next.process(StringUtils.substringAfter(expression, value)); + } + } + + void buildValueMap(Map map) { + if (this.isHole()) { + map.put(text, value); + } + if (next != null) { + next.buildValueMap(map); + } + } + + void addToEnd(Chunk chunk) { + if (next == null) { + next = chunk; + } else { + next.addToEnd(chunk); + } + } + + + /** recursively reset the values */ + public void clearValues() { + this.value = null; + if (this.next != null) { + next.clearValues(); + } + } + +} Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/Chunk.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLExpressionCompiler.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLExpressionCompiler.java 2006-01-23 01:24:32 UTC (rev 2173) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLExpressionCompiler.java 2006-01-23 04:20:12 UTC (rev 2174) @@ -0,0 +1,45 @@ +package org.drools.natural.template; + +import java.util.Collection; +import java.util.Iterator; + +/** + * This is the utility class for compiling pseudo natural/DSL expression into the target + * language, via the supplied mappings. + * + * This version works off "string templates" rather then infix operators. + * + * Note that this is not particularly efficient for large grammars - IN THEORY ! + * However, I have tested it with grammars of 200 000 terms, and it took less then a second per expression, + * so its no slouch. This could be a problem for bulk compiling of large rulesets with thousands of conditions. + * + * In general, grammars of < 1000 items should be fine. The cost is a parse time cost for Drools, which can be done + * incrementally in a suitable environment ideally anyway. + * + * It will go through each item in the grammar, trying to apply it regardless of if it is needed. + * This may be improved by some early regex scanning, but most likely this will not really save much. + * + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + */ +public class NLExpressionCompiler { + + private TemplateFactory factory; + private Collection grammar; + + public NLExpressionCompiler(NLGrammar grammar) { + this.grammar = grammar.getMappings(); + this.factory = new TemplateFactory(); + } + + public String compile(String expression) { + String nl = expression; + for ( Iterator iter = grammar.iterator(); iter.hasNext(); ) { + NLMappingItem mapping = (NLMappingItem) iter.next(); + TemplateContext ctx = factory.buildContext(mapping.getNaturalTemplate()); + nl = ctx.processAllInstances(nl, mapping.getGrammarTemplate()); + } + return nl; + } + + +} Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLExpressionCompiler.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLGrammar.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLGrammar.java 2006-01-23 01:24:32 UTC (rev 2173) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLGrammar.java 2006-01-23 04:20:12 UTC (rev 2174) @@ -0,0 +1,51 @@ +package org.drools.natural.template; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Properties; + +/** This represents a simple grammar mapping. */ +public class NLGrammar + implements + Serializable { + + + private static final long serialVersionUID = 1L; + private List mappings = new ArrayList(); + + public NLGrammar() { + } + + + /** + * When loading from properties, the order in which they apprear in the props file + * is the priority. + * + * Which makes sense intuitively, the order you read them it the order in which they will be applied. + */ + public void loadFromProperties(Properties props) { + int i = 0; + for ( Iterator iter = props.keySet().iterator(); iter.hasNext(); ) { + String key = (String) iter.next(); + String property = props.getProperty(key); + NLMappingItem item = new NLMappingItem(i, key, property); + addNLItem(item); + i++; + } + } + + public void addNLItem(NLMappingItem item) { + this.mappings.add(item); + } + + public Collection getMappings() { + Collections.sort(mappings); + return Collections.unmodifiableCollection(mappings); + } + + +} Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLGrammar.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLMappingItem.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLMappingItem.java 2006-01-23 01:24:32 UTC (rev 2173) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLMappingItem.java 2006-01-23 04:20:12 UTC (rev 2174) @@ -0,0 +1,52 @@ +package org.drools.natural.template; + +import java.io.Serializable; + +/** + * This contains a single mapping from psuedo NL to a grammarTemplate. + * + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + * + */ +public class NLMappingItem + implements + Comparable, Serializable { + + + private static final long serialVersionUID = 7185580607729787497L; + + private int priority = 0; + + private String naturalTemplate; + private String grammarTemplate; + + public NLMappingItem(int priority, + String naturalTemplate, + String grammarTemplate) { + this.priority = priority; + this.naturalTemplate = naturalTemplate; + this.grammarTemplate = grammarTemplate; + } + + public String getNaturalTemplate() { + return naturalTemplate; + } + + public String getGrammarTemplate() { + return grammarTemplate; + } + + public int compareTo(Object arg) { + if ( arg instanceof NLMappingItem ) { + NLMappingItem item = (NLMappingItem) arg; + if ( item.priority == this.priority ) return 0; + if ( item.priority > this.priority ) return 1; + if ( item.priority < this.priority ) return -1; + return 0; + } + else { + return 0; + } + } + +} Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/NLMappingItem.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/TemplateContext.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/TemplateContext.java 2006-01-23 01:24:32 UTC (rev 2173) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/TemplateContext.java 2006-01-23 04:20:12 UTC (rev 2174) @@ -0,0 +1,119 @@ +package org.drools.natural.template; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.apache.commons.lang.StringUtils; + + +/** + * This class takes a linked list of Chunk objects, and will replace what the chunks represent + * in an nl string with a interpolated grammar template. + * The values are obtained by matching the chunks with the nl. + * + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + * This is an alternative approach to the infix parser. + */ +class TemplateContext { + + //the start of the linked list. + Chunk start; + + /** + * Ad a chunk from the dictionary expression. + * A chunk is a piece of nl, or a hole. + * nl & holes should not be mixed. + */ + TemplateContext addChunk(String chunkText) { + Chunk chunk = new Chunk(chunkText); + if (start == null) { + start = chunk; + } else { + start.addToEnd(chunk); + } + return this; + } + + /** + * This will parse the input nl expression, and build a map of values for the "holes" + * in the grammar expression. + * It does this by getting the Chunks of the grammar to parse themselves. + */ + void processNL(String nl, Map map) { + start.clearValues(); + start.process(nl); + start.buildValueMap(map); + } + + /** + * This builds a fragment of the nl expression which can be used + * to swap out a piece of the original with the target expression. + * + * The target expression is the "right hand side" of the grammar map. + */ + String getSubstitutionKey() { + StringBuffer buffer = new StringBuffer(); + start.buildSubtitutionKey(buffer); + return buffer.toString().trim(); //trim so we don't get any erroneous spaces to stop replacing. + } + + /** + * This will build the target string that you can use to substitute the original with. + * @param map The map of values to hole keys. + * @param grammar_r The grammar item which will have the values plugged into the "holes". + * @return The final expression ready for substitution. + */ + String populateTargetString(Map map, + String grammar_r) { + for ( Iterator iter = map.keySet().iterator(); iter.hasNext(); ) { + String key = (String) iter.next(); + grammar_r = StringUtils.replace(grammar_r, key, (String) map.get(key)); + } + return grammar_r; + } + + /** + * @param nl The natural language expression. + * @param subKey The part of the nl expression to be swapped out. + * @param target The chunk to be swapped in to the nl + * @return The nl with the chunk replaced with the target. + */ + String interpolate(String nl, String subKey, String target) { + return StringUtils.replace(nl, subKey, target); + } + + /** + * This does it all as one call. Requires that chunks have been setup. + * @param nl The nl expression to process. + * @param grammarTemplate The grammar expression that will be interpolated (with the values from the original chunks), + * and then inserted in to the nl. + * @return the NL with the populated grammarRHS replacing the original pattern (from the chunks). + */ + public String process(String nl, String grammarTemplate) { + Map values = new HashMap(); + this.processNL(nl, values); + String subKey = this.getSubstitutionKey(); + String target = this.populateTargetString(values, grammarTemplate); + return this.interpolate(nl, subKey, target); + } + + + /** + * Similar to process, but processes iteratively until there is + * no change in the output. This allows for stuff to be repeated in an NL expression. + */ + public String processAllInstances(String nl, String grammarTemplate) { + String result = nl; + while (true) { + String newResult = process(result, grammarTemplate); + if (newResult.equals(result)) { + break; + } + result = newResult; + } + return result; + } + + +} Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/TemplateContext.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/TemplateFactory.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/TemplateFactory.java 2006-01-23 01:24:32 UTC (rev 2173) +++ trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/TemplateFactory.java 2006-01-23 04:20:12 UTC (rev 2174) @@ -0,0 +1,95 @@ +package org.drools.natural.template; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * This takes a grammar template (the left hand side of a grammar mapping table) + * and builds a TemplateContext for it. + * + * Uses a built in lexer. + * + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + */ +class TemplateFactory { + + /** + * This will lex the template string into chunks. + * @param template From the grammar. eg "{0} likes cheese" is a template. + * @return A template context ready to apply to a nl expression. + */ + public TemplateContext buildContext(String template) { + + TemplateContext ctx = new TemplateContext(); + + List chunkList = lexChunks(template); + for ( Iterator iter = chunkList.iterator(); iter.hasNext(); ) { + ctx.addChunk((String) iter.next()); + + } + return ctx; + } + + + List lexChunks(String grammarTemplate) { + ChunkLexer lexer = new ChunkLexer(); + return lexer.lex(grammarTemplate); + } + + + /** + * Lex out chunks. + * @author <a href="mailto:mic...@gm..."> Michael Neale</a> + */ + static class ChunkLexer { + + private List chunks = new ArrayList(); + + private StringBuffer buffer = new StringBuffer(); + + public List lex(String grammarTemplate) { + + char[] chars = grammarTemplate.toCharArray(); + + for ( int i = 0; i < chars.length; i++ ) { + switch ( chars[i] ) { + case '{' : + startHole(); + break; + case '}' : + endHole(); + break; + default : + buffer.append(chars[i]); + break; + } + } + String buf = this.buffer.toString(); + if (!buf.equals("")) addChunk( buf ); + return this.chunks; + + } + + private boolean addChunk(String buf) { + return this.chunks.add( buf.trim() ); + } + + private void endHole() { + String buf = this.buffer.toString(); + chunks.add("{" + buf + "}"); + this.buffer = new StringBuffer(); + } + + private void startHole() { + String buf = this.buffer.toString(); + if (!buf.equals("")) { + addChunk( buf ); + } + this.buffer = new StringBuffer(); + } + + + } + +} Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/template/TemplateFactory.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLExpressionCompilerTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLExpressionCompilerTest.java 2006-01-23 01:24:32 UTC (rev 2173) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLExpressionCompilerTest.java 2006-01-23 04:20:12 UTC (rev 2174) @@ -0,0 +1,64 @@ +package org.drools.natural.template; + +import java.util.Properties; + +import junit.framework.TestCase; + +public class NLExpressionCompilerTest extends TestCase { + + public void testIntegration() { + NLGrammar grammar = new NLGrammar(); + grammar.addNLItem(new NLMappingItem(0, "{0} likes cheese", "likesCheese({0})")); + + NLExpressionCompiler compiler = new NLExpressionCompiler(grammar); + String result = compiler.compile("bob likes cheese"); + + assertEquals("likesCheese(bob)", result); + + + //now lets use a properties + Properties props = new Properties(); + props.setProperty("{0} likes cheese", "likesCheese({0})"); + props.setProperty("the date between {0} and {1}", "dateCompare({0}, {1})"); + + grammar = new NLGrammar(); + grammar.loadFromProperties(props); + compiler = new NLExpressionCompiler(grammar); + result = compiler.compile("bob likes cheese"); + + assertEquals("likesCheese(bob)", result); + + result = compiler.compile("the date between bob and michael"); + assertEquals("dateCompare(bob, michael)", result); + + + } + + /** This is surprisingly fast. I didn't build it for speed. */ + public void testLargeGrammar() { + Properties props = new Properties(); + + for (int i = 0; i < 1000; i++ ) { + props.put("some {0} grammar" + i, "some mapping{0}"); + if (i == 42) { + props.put("{0} likes cheese", "{0}.likesCheese()"); + props.put("{0} is happy", "{0}.isHappy()"); + } + } + + + + NLGrammar grammar = new NLGrammar(); + grammar.loadFromProperties(props); + + NLExpressionCompiler compiler = new NLExpressionCompiler(grammar); + + long start = System.currentTimeMillis(); + String result = compiler.compile("michael likes cheese and michael is happy"); + long runtime = System.currentTimeMillis() - start; + System.out.println("Runtime for compile: " + runtime + "ms"); + assertEquals("michael.likesCheese() and michael.isHappy()", result); + + } + +} Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/NLExpressionCompilerTest.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateContextTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateContextTest.java 2006-01-23 01:24:32 UTC (rev 2173) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateContextTest.java 2006-01-23 04:20:12 UTC (rev 2174) @@ -0,0 +1,192 @@ +package org.drools.natural.template; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.apache.commons.lang.StringUtils; + +import junit.framework.TestCase; + +public class TemplateContextTest extends TestCase { + + + public void testAllInOne() { + TemplateContext ctx = new TemplateContext(); + //chunks represent a lexed grammar "left hand side" + ctx.addChunk("baby on board") + .addChunk("{0}") + .addChunk("and") + .addChunk("{1}") + .addChunk("burt ward"); + String result = ctx.process("yeah this is an expression baby on board exp1 and exp2 burt ward end.", "something({0}, {1})"); + assertEquals("yeah this is an expression something(exp1, exp2) end.", result); + + + //and check that the iterative one is OK. + result = ctx.process("yeah this is an expression baby on board exp1 and exp2 burt ward end.", "something({0}, {1})"); + assertEquals("yeah this is an expression something(exp1, exp2) end.", result); + } + + public void testBuildStrings() { + + TemplateContext ctx = new TemplateContext(); + + //chunks represent a lexed grammar "left hand side" + ctx.addChunk("baby on board") + .addChunk("{0}") + .addChunk("and") + .addChunk("{1}") + .addChunk("burt ward"); + + //and this is the right hand side grammar mapping (no lexing required, simple hole filling !). + String grammar_r = "something({0}, {1})"; + + //and this is the full expression + String nl = "yeah this is an expression baby on board exp1 and exp2 burt ward end."; + + //match the pattern in nl, put the values in the map + HashMap map = new HashMap(); + ctx.processNL(nl, map); + + //now get the chunk of nl that will be replaced with the target later. + String subKey = ctx.getSubstitutionKey(); + assertEquals("baby on board exp1 and exp2 burt ward", subKey); + + String target = ctx.populateTargetString( map, grammar_r ); + assertEquals("something(exp1, exp2)", target); + + String result = ctx.interpolate(nl, subKey, target); + + assertEquals("yeah this is an expression something(exp1, exp2) end.", result); + + + + } + + + public void testMultipleReplacement() { + + TemplateContext ctx = new TemplateContext(); + + //chunks represent a lexed grammar "left hand side" + ctx.addChunk("{0}") + .addChunk("likes cheese"); + + String nl = "bob likes cheese and michael likes cheese conan likes cheese"; + String grammarTemplate = "{0}.likesCheese()"; + String expected = "bob.likesCheese() and michael.likesCheese() conan.likesCheese()"; + + + String result = ctx.processAllInstances(nl, grammarTemplate); + assertEquals(expected, result); + } + + + + + + public void testBasicExpression() { + + Chunk chunk1 = new Chunk("baby on board"); + Chunk chunk2 = new Chunk("{0}"); + Chunk chunk3 = new Chunk("and"); + Chunk chunk4 = new Chunk("{1}"); + Chunk chunk5 = new Chunk("burt ward"); + + chunk1.next = chunk2; + chunk2.next = chunk3; + chunk3.next = chunk4; + chunk4.next = chunk5; + + String nl = "yeah this is an expression baby on board exp1 and exp2 burt ward"; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + assertEquals("exp1", map.get("{0}")); + assertEquals("exp2", map.get("{1}")); + + } + + public void testStartWith() { + + Chunk chunk1 = new Chunk("{0}"); + Chunk chunk2 = new Chunk("a thing"); + Chunk chunk3 = new Chunk("and"); + Chunk chunk4 = new Chunk("{1}"); + Chunk chunk5 = new Chunk("one more"); + + chunk1.next = chunk2; + chunk2.next = chunk3; + chunk3.next = chunk4; + chunk4.next = chunk5; + + String nl = "exp1 a thing and exp2 one more"; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + assertEquals("exp1", map.get("{0}")); + assertEquals("exp2", map.get("{1}")); + + } + + + public void testEndWith() { + + Chunk chunk1 = new Chunk("blah blah blah"); + Chunk chunk2 = new Chunk("{1}"); + + chunk1.next = chunk2; + + String nl = "blah blah blah exp1"; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + assertEquals("exp1", map.get("{1}")); + assertEquals(1, map.size()); + } + + public void testOneInTheMiddle() { + Chunk chunk1 = new Chunk("yeah "); + Chunk chunk2 = new Chunk("{abc}"); + Chunk chunk3 = new Chunk("one more"); + + chunk1.next = chunk2; + chunk2.next = chunk3; + + String nl = "yeah exp1 one more "; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + assertEquals("exp1", map.get("{abc}")); + + } + + public void testNoTokens() { + Chunk chunk1 = new Chunk("yeah "); + + String nl = "yeah exp1 one more "; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + assertEquals(0, map.size()); + } + + + + + + +} + + Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateContextTest.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateFactoryTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateFactoryTest.java 2006-01-23 01:24:32 UTC (rev 2173) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateFactoryTest.java 2006-01-23 04:20:12 UTC (rev 2174) @@ -0,0 +1,41 @@ +package org.drools.natural.template; + +import java.util.List; + +import junit.framework.TestCase; + +public class TemplateFactoryTest extends TestCase { + + public void testMake() { + TemplateFactory factory = new TemplateFactory(); + TemplateContext ctx = factory.buildContext("something {0} going {1} on."); + assertNotNull(ctx); + } + + public void testLex() { + TemplateFactory factory = new TemplateFactory(); + List list = factory.lexChunks("one chunk"); + assertEquals(1, list.size()); + assertEquals("one chunk", list.get(0)); + + + list = factory.lexChunks("three {0} chunks"); + assertEquals(3, list.size()); + + assertEquals("three", list.get(0)); + assertEquals("{0}", list.get(1)); + assertEquals("chunks", list.get(2)); + + + list = factory.lexChunks("{42} more {0} chunks"); + assertEquals(4, list.size()); + + assertEquals("{42}", list.get(0)); + assertEquals("more", list.get(1)); + assertEquals("{0}", list.get(2)); + assertEquals("chunks", list.get(3)); + + + } + +} Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateFactoryTest.java ___________________________________________________________________ Name: svn:eol-style + native Deleted: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java 2006-01-23 01:24:32 UTC (rev 2173) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java 2006-01-23 04:20:12 UTC (rev 2174) @@ -1,327 +0,0 @@ -package org.drools.natural.template; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import org.apache.commons.lang.StringUtils; - -import junit.framework.TestCase; - -public class TemplateTest extends TestCase { - - String grammar_l = "baby on board {0} and {1} burt ward"; - String grammar_r = "something({0}, {1})"; - String result = "yeah this is an expression something(exp1, exp2)"; - - - - /** - * Lets try it all together. - */ - public void testBuildStrings() { - - Context ctx = new Context(); - - //chunks represent a lexed grammar "left hand side" - ctx.addChunk("baby on board") - .addChunk("{0}") - .addChunk("and") - .addChunk("{1}") - .addChunk("burt ward"); - - //and this is the right hand side grammar mapping (no lexing required, simple hole filling !). - String grammar_r = "something({0}, {1})"; - - //and this is the full expression - String nl = "yeah this is an expression baby on board exp1 and exp2 burt ward end."; - - //match the pattern in nl, put the values in the map - HashMap map = new HashMap(); - ctx.processNL(nl, map); - - //now get the chunk of nl that will be replaced with the target later. - String subKey = ctx.getSubstitutionKey(); - assertEquals("baby on board exp1 and exp2 burt ward", subKey); - - String target = ctx.populateTargetString( map, grammar_r ); - assertEquals("something(exp1, exp2)", target); - - String result = ctx.replaceNlWithTarget(nl, subKey, target); - - assertEquals("yeah this is an expression something(exp1, exp2) end.", result); - - - - } - - public void testAllInOne() { - Context ctx = new Context(); - //chunks represent a lexed grammar "left hand side" - ctx.addChunk("baby on board") - .addChunk("{0}") - .addChunk("and") - .addChunk("{1}") - .addChunk("burt ward"); - String result = ctx.process("yeah this is an expression baby on board exp1 and exp2 burt ward end.", "something({0}, {1})"); - assertEquals("yeah this is an expression something(exp1, exp2) end.", result); - } - - - - - - public void testBasicExpression() { - - Chunk chunk1 = new Chunk("baby on board"); - Chunk chunk2 = new Chunk("{0}"); - Chunk chunk3 = new Chunk("and"); - Chunk chunk4 = new Chunk("{1}"); - Chunk chunk5 = new Chunk("burt ward"); - - chunk1.next = chunk2; - chunk2.next = chunk3; - chunk3.next = chunk4; - chunk4.next = chunk5; - - String nl = "yeah this is an expression baby on board exp1 and exp2 burt ward"; - chunk1.process(nl); - - HashMap map = new HashMap(); - chunk1.buildValueMap(map); - - assertEquals("exp1", map.get("{0}")); - assertEquals("exp2", map.get("{1}")); - - } - - public void testStartWith() { - - Chunk chunk1 = new Chunk("{0}"); - Chunk chunk2 = new Chunk("a thing"); - Chunk chunk3 = new Chunk("and"); - Chunk chunk4 = new Chunk("{1}"); - Chunk chunk5 = new Chunk("one more"); - - chunk1.next = chunk2; - chunk2.next = chunk3; - chunk3.next = chunk4; - chunk4.next = chunk5; - - String nl = "exp1 a thing and exp2 one more"; - chunk1.process(nl); - - HashMap map = new HashMap(); - chunk1.buildValueMap(map); - - assertEquals("exp1", map.get("{0}")); - assertEquals("exp2", map.get("{1}")); - - } - - - public void testEndWith() { - - Chunk chunk1 = new Chunk("blah blah blah"); - Chunk chunk2 = new Chunk("{1}"); - - chunk1.next = chunk2; - - String nl = "blah blah blah exp1"; - chunk1.process(nl); - - HashMap map = new HashMap(); - chunk1.buildValueMap(map); - - assertEquals("exp1", map.get("{1}")); - assertEquals(1, map.size()); - } - - public void testOneInTheMiddle() { - Chunk chunk1 = new Chunk("yeah "); - Chunk chunk2 = new Chunk("{abc}"); - Chunk chunk3 = new Chunk("one more"); - - chunk1.next = chunk2; - chunk2.next = chunk3; - - String nl = "yeah exp1 one more "; - chunk1.process(nl); - - HashMap map = new HashMap(); - chunk1.buildValueMap(map); - - assertEquals("exp1", map.get("{abc}")); - - } - - public void testNoTokens() { - Chunk chunk1 = new Chunk("yeah "); - - String nl = "yeah exp1 one more "; - chunk1.process(nl); - - HashMap map = new HashMap(); - chunk1.buildValueMap(map); - - assertEquals(0, map.size()); - } - - - static class Context { - - Chunk start; - - /** - * Ad a chunk from the dictionary expression. - * A chunk is a piece of nl, or a hole. - * nl & holes should not be mixed. - */ - Context addChunk(String chunkText) { - Chunk chunk = new Chunk(chunkText); - if (start == null) { - start = chunk; - } else { - start.addToEnd(chunk); - } - return this; - } - - /** - * This will parse the input nl expression, and build a map of values for the "holes" - * in the grammar expression. - * It does this by getting the Chunks of the grammar to parse themselves. - */ - void processNL(String nl, Map map) { - start.process(nl); - start.buildValueMap(map); - } - - /** - * This builds a fragment of the nl expression which can be used - * to swap out a piece of the original with the target expression. - * - * The target expression is the "right hand side" of the grammar map. - */ - String getSubstitutionKey() { - StringBuffer buffer = new StringBuffer(); - start.buildSubtitutionKey(buffer); - return buffer.toString(); - } - - /** - * This will build the target string that you can use to substitute the original with. - * @param map The map of values to hole keys. - * @param grammar_r The grammar item which will have the values plugged into the "holes". - * @return The final expression ready for substitution. - */ - String populateTargetString(Map map, - String grammar_r) { - for ( Iterator iter = map.keySet().iterator(); iter.hasNext(); ) { - String key = (String) iter.next(); - grammar_r = StringUtils.replace(grammar_r, key, (String) map.get(key)); - } - return grammar_r; - } - - /** - * @param nl The natural language expression. - * @param subKey The part of the nl expression to be swapped out. - * @param target The chunk to be swapped in to the nl - * @return The nl with the chunk replaced with the target. - */ - String replaceNlWithTarget(String nl, String subKey, String target) { - return StringUtils.replace(nl, subKey, target); - } - - /** - * This does it all as one call. Requires that chunks have been setup. - * @param nl The nl expression to process. - * @param grammarRHS The grammar expression that will be populated, and then inserted in to the nl. - * @return the NL with the populated grammarRHS replacing the original pattern (from the chunks). - */ - public String process(String nl, String grammarRHS) { - Map values = new HashMap(); - this.processNL(nl, values); - String subKey = this.getSubstitutionKey(); - String target = this.populateTargetString(values, grammarRHS); - return this.replaceNlWithTarget(nl, subKey, target); - - } - - - } - - static class Chunk { - String text; - Chunk next; - - //value if it is a hole - String value; - - - Chunk(String text) { - this.text = text; - } - - - - /** - * This will build up a key to use to substitute the original string with. - * Can then swap it with the target text. - */ - public void buildSubtitutionKey(StringBuffer buffer) { - if (isHole()) { - buffer.append(" " + value + " "); - } else { - buffer.append(text); - } - if (next != null) { - next.buildSubtitutionKey(buffer); - } - } - - boolean isHole() { - return text.startsWith("{"); - } - - void process(String expression) { - if (isHole()) { - //value = text until next next.text is found - if (next == null || next.text == null) { - value = expression.trim(); - } else { - value = StringUtils.substringBefore(expression, next.text).trim(); - } - - } else { - value = text; - } - if (next != null) { - next.process(StringUtils.substringAfterLast(expression, value)); - } - } - - void buildValueMap(Map map) { - if (this.isHole()) { - map.put(text, value); - } - if (next != null) { - next.buildValueMap(map); - } - } - - void addToEnd(Chunk chunk) { - if (next == null) { - next = chunk; - } else { - next.addToEnd(chunk); - } - } - - } - - -} - - |
From: <jbo...@li...> - 2006-01-23 01:24:37
|
Author: mic...@jb... Date: 2006-01-22 20:24:32 -0500 (Sun, 22 Jan 2006) New Revision: 2173 Modified: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java Log: more refactoring Modified: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java 2006-01-23 01:06:07 UTC (rev 2172) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java 2006-01-23 01:24:32 UTC (rev 2173) @@ -32,12 +32,11 @@ //and this is the right hand side grammar mapping (no lexing required, simple hole filling !). String grammar_r = "something({0}, {1})"; - //and this is the full expression String nl = "yeah this is an expression baby on board exp1 and exp2 burt ward end."; - //match the pattern, put the values in the map + //match the pattern in nl, put the values in the map HashMap map = new HashMap(); ctx.processNL(nl, map); @@ -52,7 +51,21 @@ assertEquals("yeah this is an expression something(exp1, exp2) end.", result); + + } + + public void testAllInOne() { + Context ctx = new Context(); + //chunks represent a lexed grammar "left hand side" + ctx.addChunk("baby on board") + .addChunk("{0}") + .addChunk("and") + .addChunk("{1}") + .addChunk("burt ward"); + String result = ctx.process("yeah this is an expression baby on board exp1 and exp2 burt ward end.", "something({0}, {1})"); + assertEquals("yeah this is an expression something(exp1, exp2) end.", result); + } @@ -202,7 +215,7 @@ * @param grammar_r The grammar item which will have the values plugged into the "holes". * @return The final expression ready for substitution. */ - String populateTargetString(HashMap map, + String populateTargetString(Map map, String grammar_r) { for ( Iterator iter = map.keySet().iterator(); iter.hasNext(); ) { String key = (String) iter.next(); @@ -220,6 +233,21 @@ String replaceNlWithTarget(String nl, String subKey, String target) { return StringUtils.replace(nl, subKey, target); } + + /** + * This does it all as one call. Requires that chunks have been setup. + * @param nl The nl expression to process. + * @param grammarRHS The grammar expression that will be populated, and then inserted in to the nl. + * @return the NL with the populated grammarRHS replacing the original pattern (from the chunks). + */ + public String process(String nl, String grammarRHS) { + Map values = new HashMap(); + this.processNL(nl, values); + String subKey = this.getSubstitutionKey(); + String target = this.populateTargetString(values, grammarRHS); + return this.replaceNlWithTarget(nl, subKey, target); + + } } |
From: <jbo...@li...> - 2006-01-23 01:06:14
|
Author: mic...@jb... Date: 2006-01-22 20:06:07 -0500 (Sun, 22 Jan 2006) New Revision: 2172 Modified: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java Log: crazy experiment that actually worked. Modified: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java 2006-01-22 13:00:46 UTC (rev 2171) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java 2006-01-23 01:06:07 UTC (rev 2172) @@ -18,52 +18,44 @@ /** * Lets try it all together. - * Print out the target string. - * Print out substitution string. */ public void testBuildStrings() { - Chunk chunk1 = new Chunk("baby on board"); - Chunk chunk2 = new Chunk("{0}"); - Chunk chunk3 = new Chunk("and"); - Chunk chunk4 = new Chunk("{1}"); - Chunk chunk5 = new Chunk("burt ward"); - chunk1.next = chunk2; - chunk2.next = chunk3; - chunk3.next = chunk4; - chunk4.next = chunk5; + Context ctx = new Context(); - String nl = "yeah this is an expression baby on board exp1 and exp2 burt ward end."; - chunk1.process(nl); + //chunks represent a lexed grammar "left hand side" + ctx.addChunk("baby on board") + .addChunk("{0}") + .addChunk("and") + .addChunk("{1}") + .addChunk("burt ward"); - HashMap map = new HashMap(); - chunk1.buildValueMap(map); + //and this is the right hand side grammar mapping (no lexing required, simple hole filling !). + String grammar_r = "something({0}, {1})"; - StringBuffer buffer = new StringBuffer(); - chunk1.buildSubtitutionKey(buffer); - assertEquals("baby on board exp1 and exp2 burt ward", buffer.toString()); + //and this is the full expression + String nl = "yeah this is an expression baby on board exp1 and exp2 burt ward end."; - String grammar_r = "something({0}, {1})"; + //match the pattern, put the values in the map + HashMap map = new HashMap(); + ctx.processNL(nl, map); - String target = buildTarget( map, - grammar_r ); + //now get the chunk of nl that will be replaced with the target later. + String subKey = ctx.getSubstitutionKey(); + assertEquals("baby on board exp1 and exp2 burt ward", subKey); + + String target = ctx.populateTargetString( map, grammar_r ); + assertEquals("something(exp1, exp2)", target); + + String result = ctx.replaceNlWithTarget(nl, subKey, target); - String result = StringUtils.replace(nl, buffer.toString(), target); assertEquals("yeah this is an expression something(exp1, exp2) end.", result); - - + } - private String buildTarget(HashMap map, - String grammar_r) { - for ( Iterator iter = map.keySet().iterator(); iter.hasNext(); ) { - String key = (String) iter.next(); - grammar_r = StringUtils.replace(grammar_r, key, (String) map.get(key)); - } - return grammar_r; - } + public void testBasicExpression() { @@ -165,6 +157,69 @@ static class Context { + Chunk start; + + /** + * Ad a chunk from the dictionary expression. + * A chunk is a piece of nl, or a hole. + * nl & holes should not be mixed. + */ + Context addChunk(String chunkText) { + Chunk chunk = new Chunk(chunkText); + if (start == null) { + start = chunk; + } else { + start.addToEnd(chunk); + } + return this; + } + + /** + * This will parse the input nl expression, and build a map of values for the "holes" + * in the grammar expression. + * It does this by getting the Chunks of the grammar to parse themselves. + */ + void processNL(String nl, Map map) { + start.process(nl); + start.buildValueMap(map); + } + + /** + * This builds a fragment of the nl expression which can be used + * to swap out a piece of the original with the target expression. + * + * The target expression is the "right hand side" of the grammar map. + */ + String getSubstitutionKey() { + StringBuffer buffer = new StringBuffer(); + start.buildSubtitutionKey(buffer); + return buffer.toString(); + } + + /** + * This will build the target string that you can use to substitute the original with. + * @param map The map of values to hole keys. + * @param grammar_r The grammar item which will have the values plugged into the "holes". + * @return The final expression ready for substitution. + */ + String populateTargetString(HashMap map, + String grammar_r) { + for ( Iterator iter = map.keySet().iterator(); iter.hasNext(); ) { + String key = (String) iter.next(); + grammar_r = StringUtils.replace(grammar_r, key, (String) map.get(key)); + } + return grammar_r; + } + + /** + * @param nl The natural language expression. + * @param subKey The part of the nl expression to be swapped out. + * @param target The chunk to be swapped in to the nl + * @return The nl with the chunk replaced with the target. + */ + String replaceNlWithTarget(String nl, String subKey, String target) { + return StringUtils.replace(nl, subKey, target); + } } @@ -228,6 +283,14 @@ } } + void addToEnd(Chunk chunk) { + if (next == null) { + next = chunk; + } else { + next.addToEnd(chunk); + } + } + } |
From: <jbo...@li...> - 2006-01-22 13:01:04
|
Author: mic...@jb... Date: 2006-01-22 08:00:46 -0500 (Sun, 22 Jan 2006) New Revision: 2171 Added: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java Log: crazy experiment that actually worked. Added: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java 2006-01-21 03:43:33 UTC (rev 2170) +++ trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java 2006-01-22 13:00:46 UTC (rev 2171) @@ -0,0 +1,236 @@ +package org.drools.natural.template; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.apache.commons.lang.StringUtils; + +import junit.framework.TestCase; + +public class TemplateTest extends TestCase { + + String grammar_l = "baby on board {0} and {1} burt ward"; + String grammar_r = "something({0}, {1})"; + String result = "yeah this is an expression something(exp1, exp2)"; + + + + /** + * Lets try it all together. + * Print out the target string. + * Print out substitution string. + */ + public void testBuildStrings() { + Chunk chunk1 = new Chunk("baby on board"); + Chunk chunk2 = new Chunk("{0}"); + Chunk chunk3 = new Chunk("and"); + Chunk chunk4 = new Chunk("{1}"); + Chunk chunk5 = new Chunk("burt ward"); + + chunk1.next = chunk2; + chunk2.next = chunk3; + chunk3.next = chunk4; + chunk4.next = chunk5; + + String nl = "yeah this is an expression baby on board exp1 and exp2 burt ward end."; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + StringBuffer buffer = new StringBuffer(); + chunk1.buildSubtitutionKey(buffer); + + assertEquals("baby on board exp1 and exp2 burt ward", buffer.toString()); + + String grammar_r = "something({0}, {1})"; + + String target = buildTarget( map, + grammar_r ); + + String result = StringUtils.replace(nl, buffer.toString(), target); + assertEquals("yeah this is an expression something(exp1, exp2) end.", result); + + + } + + + private String buildTarget(HashMap map, + String grammar_r) { + for ( Iterator iter = map.keySet().iterator(); iter.hasNext(); ) { + String key = (String) iter.next(); + grammar_r = StringUtils.replace(grammar_r, key, (String) map.get(key)); + } + return grammar_r; + } + + + public void testBasicExpression() { + + Chunk chunk1 = new Chunk("baby on board"); + Chunk chunk2 = new Chunk("{0}"); + Chunk chunk3 = new Chunk("and"); + Chunk chunk4 = new Chunk("{1}"); + Chunk chunk5 = new Chunk("burt ward"); + + chunk1.next = chunk2; + chunk2.next = chunk3; + chunk3.next = chunk4; + chunk4.next = chunk5; + + String nl = "yeah this is an expression baby on board exp1 and exp2 burt ward"; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + assertEquals("exp1", map.get("{0}")); + assertEquals("exp2", map.get("{1}")); + + } + + public void testStartWith() { + + Chunk chunk1 = new Chunk("{0}"); + Chunk chunk2 = new Chunk("a thing"); + Chunk chunk3 = new Chunk("and"); + Chunk chunk4 = new Chunk("{1}"); + Chunk chunk5 = new Chunk("one more"); + + chunk1.next = chunk2; + chunk2.next = chunk3; + chunk3.next = chunk4; + chunk4.next = chunk5; + + String nl = "exp1 a thing and exp2 one more"; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + assertEquals("exp1", map.get("{0}")); + assertEquals("exp2", map.get("{1}")); + + } + + + public void testEndWith() { + + Chunk chunk1 = new Chunk("blah blah blah"); + Chunk chunk2 = new Chunk("{1}"); + + chunk1.next = chunk2; + + String nl = "blah blah blah exp1"; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + assertEquals("exp1", map.get("{1}")); + assertEquals(1, map.size()); + } + + public void testOneInTheMiddle() { + Chunk chunk1 = new Chunk("yeah "); + Chunk chunk2 = new Chunk("{abc}"); + Chunk chunk3 = new Chunk("one more"); + + chunk1.next = chunk2; + chunk2.next = chunk3; + + String nl = "yeah exp1 one more "; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + assertEquals("exp1", map.get("{abc}")); + + } + + public void testNoTokens() { + Chunk chunk1 = new Chunk("yeah "); + + String nl = "yeah exp1 one more "; + chunk1.process(nl); + + HashMap map = new HashMap(); + chunk1.buildValueMap(map); + + assertEquals(0, map.size()); + } + + + static class Context { + + + + } + + static class Chunk { + String text; + Chunk next; + + //value if it is a hole + String value; + + + Chunk(String text) { + this.text = text; + } + + + + /** + * This will build up a key to use to substitute the original string with. + * Can then swap it with the target text. + */ + public void buildSubtitutionKey(StringBuffer buffer) { + if (isHole()) { + buffer.append(" " + value + " "); + } else { + buffer.append(text); + } + if (next != null) { + next.buildSubtitutionKey(buffer); + } + } + + boolean isHole() { + return text.startsWith("{"); + } + + void process(String expression) { + if (isHole()) { + //value = text until next next.text is found + if (next == null || next.text == null) { + value = expression.trim(); + } else { + value = StringUtils.substringBefore(expression, next.text).trim(); + } + + } else { + value = text; + } + if (next != null) { + next.process(StringUtils.substringAfterLast(expression, value)); + } + } + + void buildValueMap(Map map) { + if (this.isHole()) { + map.put(text, value); + } + if (next != null) { + next.buildValueMap(map); + } + } + + } + + +} + + Property changes on: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/template/TemplateTest.java ___________________________________________________________________ Name: svn:eol-style + native |
From: <jbo...@li...> - 2006-01-21 03:43:38
|
Author: mic...@jb... Date: 2006-01-20 22:43:33 -0500 (Fri, 20 Jan 2006) New Revision: 2170 Added: trunk/labs/jbossrules/drools-natural-dsl/README.txt Log: seperated out from natural-dsl Added: trunk/labs/jbossrules/drools-natural-dsl/README.txt =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/README.txt 2006-01-21 03:43:00 UTC (rev 2169) +++ trunk/labs/jbossrules/drools-natural-dsl/README.txt 2006-01-21 03:43:33 UTC (rev 2170) @@ -0,0 +1,3 @@ +This is the Drools pseudo natural language parser, and DSL facility. + +Pseudo natural language can be built up from simple DSLs, which is what this supports. \ No newline at end of file Property changes on: trunk/labs/jbossrules/drools-natural-dsl/README.txt ___________________________________________________________________ Name: svn:eol-style + native |
From: <jbo...@li...> - 2006-01-21 03:43:08
|
Author: mic...@jb... Date: 2006-01-20 22:43:00 -0500 (Fri, 20 Jan 2006) New Revision: 2169 Modified: trunk/labs/jbossrules/drools-natural-dsl/pom.xml Log: seperated out from natural-dsl Modified: trunk/labs/jbossrules/drools-natural-dsl/pom.xml =================================================================== --- trunk/labs/jbossrules/drools-natural-dsl/pom.xml 2006-01-21 03:42:31 UTC (rev 2168) +++ trunk/labs/jbossrules/drools-natural-dsl/pom.xml 2006-01-21 03:43:00 UTC (rev 2169) @@ -6,12 +6,11 @@ </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>drools-natural</artifactId> - <name>Drools :: Natural DSL utility</name> + <artifactId>drools-natural-dsl</artifactId> + <name>Drools :: Natural and DSL utility</name> <version>3.0-M1-dev</version> <packaging>jar</packaging> - <dependencies> <dependency> <groupId>junit</groupId> @@ -26,20 +25,6 @@ <version>2.1</version> </dependency> - <dependency> - <groupId>htmlparser</groupId> - <artifactId>htmlparser</artifactId> - <version>1.5</version> - </dependency> - - - <dependency> - <groupId>velocity</groupId> - <artifactId>velocity</artifactId> - <version>1.4</version> - </dependency> - - </dependencies> |
From: <jbo...@li...> - 2006-01-21 03:42:35
|
Author: mic...@jb... Date: 2006-01-20 22:42:31 -0500 (Fri, 20 Jan 2006) New Revision: 2168 Removed: trunk/labs/jbossrules/drools-natural-dsl/src/test/resources/org/drools/natural/ruledoc/ Log: seperated out from natural-dsl |
From: <jbo...@li...> - 2006-01-21 03:42:25
|
Author: mic...@jb... Date: 2006-01-20 22:42:19 -0500 (Fri, 20 Jan 2006) New Revision: 2167 Removed: trunk/labs/jbossrules/drools-natural-dsl/src/test/java/org/drools/natural/ruledoc/ Log: seperated out from natural-dsl |
From: <jbo...@li...> - 2006-01-21 03:42:12
|
Author: mic...@jb... Date: 2006-01-20 22:42:05 -0500 (Fri, 20 Jan 2006) New Revision: 2166 Removed: trunk/labs/jbossrules/drools-natural-dsl/src/main/resources/org/drools/natural/ruledoc/ Log: seperated out from natural-dsl |
From: <jbo...@li...> - 2006-01-21 03:41:56
|
Author: mic...@jb... Date: 2006-01-20 22:41:51 -0500 (Fri, 20 Jan 2006) New Revision: 2165 Removed: trunk/labs/jbossrules/drools-natural-dsl/src/main/java/org/drools/natural/ruledoc/ Log: seperated out from natural-dsl |
From: <jbo...@li...> - 2006-01-21 03:41:40
|
Author: mic...@jb... Date: 2006-01-20 22:41:36 -0500 (Fri, 20 Jan 2006) New Revision: 2164 Removed: trunk/labs/jbossrules/drools-natural-dsl/doc/ Log: seperated out from natural-dsl |
From: <jbo...@li...> - 2006-01-21 03:41:23
|
Author: mic...@jb... Date: 2006-01-20 22:41:19 -0500 (Fri, 20 Jan 2006) New Revision: 2163 Removed: trunk/labs/jbossrules/drools-natural-dsl/3rdparty/ Log: seperated out from natural-dsl |
From: <jbo...@li...> - 2006-01-21 01:55:53
|
Author: mic...@jb... Date: 2006-01-20 20:55:43 -0500 (Fri, 20 Jan 2006) New Revision: 2161 Added: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/MockUser.java Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java Log: copies owning ruleset Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java 2006-01-21 01:13:52 UTC (rev 2160) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java 2006-01-21 01:55:43 UTC (rev 2161) @@ -216,6 +216,7 @@ newVersion.tags = this.copyTags(); newVersion.versionNumber = this.getVersionNumber(); newVersion.versionComment = this.getVersionComment(); + newVersion.owningRuleSetName = this.getOwningRuleSetName(); return newVersion; } Added: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/MockUser.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/MockUser.java 2006-01-21 01:13:52 UTC (rev 2160) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/MockUser.java 2006-01-21 01:55:43 UTC (rev 2161) @@ -0,0 +1,22 @@ +package org.drools.repository; + +import java.security.Principal; + +public class MockUser + implements + Principal { + + private String name; + + public MockUser(String name) { + this.name = name; + } + + public String getName() { + + return name; + } + + + +} Property changes on: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/MockUser.java ___________________________________________________________________ Name: svn:eol-style + native |
From: <jbo...@li...> - 2006-01-21 01:14:06
|
Author: mic...@jb... Date: 2006-01-20 20:13:52 -0500 (Fri, 20 Jan 2006) New Revision: 2160 Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManager.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManagerImpl.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java Log: added user identity stuff Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManager.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManager.java 2006-01-21 01:01:13 UTC (rev 2159) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManager.java 2006-01-21 01:13:52 UTC (rev 2160) @@ -95,7 +95,7 @@ * * This will save the rule as it stands, including any changes. */ - public abstract void checkOutRule(RuleDef rule, String userId); + public abstract void checkOutRule(RuleDef rule); /** * This removes the check out flag. @@ -106,7 +106,7 @@ * This can effectively be "overridden" by either just saving the rule, or passing * in the correct username. It is up to client applications to enforce this behaviour. */ - public abstract void checkInRule(RuleDef rule, String userId); + public abstract void checkInRule(RuleDef rule); /** @@ -115,7 +115,7 @@ * * This will save the attachment as it stands, including any changes. */ - public abstract void checkOutAttachment(RuleSetAttachment attachment, String userId); + public abstract void checkOutAttachment(RuleSetAttachment attachment); /** * This removes the check out flag. @@ -126,7 +126,7 @@ * This can effectively be "overridden" by either just saving the rule, or passing * in the correct username. It is up to client applications to enforce this behaviour. */ - public abstract void checkInAttachment(RuleSetAttachment attachment, String userId); + public abstract void checkInAttachment(RuleSetAttachment attachment); Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManagerImpl.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManagerImpl.java 2006-01-21 01:01:13 UTC (rev 2159) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManagerImpl.java 2006-01-21 01:13:52 UTC (rev 2160) @@ -166,17 +166,30 @@ return list; } - public void checkOutRule(RuleDef rule, - String userId) { + public void checkOutRule(RuleDef rule) { + + String userId = getUserId(); if (rule.isCheckedOut()) { - throw new RepositoryException("Rule is already checked out to " + userId); + throw new RepositoryException("Rule is already checked out to " + rule.getCheckedOutBy()); } rule.setCheckedOut(true); rule.setCheckedOutBy(userId); session.update(rule); } - public void checkInRule(RuleDef rule, String userId) { + + + private String getUserId() { + if (this.currentUser == null) { + throw new RepositoryException("No current user context was provided to the repository."); + } + String userId = this.currentUser.getName(); + return userId; + } + + public void checkInRule(RuleDef rule) { + String userId = getUserId(); + if (!userId.equals(rule.getCheckedOutBy())) { throw new RepositoryException("Unable to check in the rule, as it is currently checked out by " + rule.getCheckedOutBy()); } @@ -185,10 +198,10 @@ session.update(rule); } - public void checkOutAttachment(RuleSetAttachment attachment, - String userId) { + public void checkOutAttachment(RuleSetAttachment attachment) { + String userId = getUserId(); if (attachment.isCheckedOut()) { - throw new RepositoryException("Rule is already checked out to " + userId); + throw new RepositoryException("Rule is already checked out to " + attachment.getCheckedOutBy()); } attachment.setCheckedOut(true); attachment.setCheckedOutBy(userId); @@ -196,8 +209,8 @@ } - public void checkInAttachment(RuleSetAttachment attachment, - String userId) { + public void checkInAttachment(RuleSetAttachment attachment) { + String userId = getUserId(); if (!userId.equals(attachment.getCheckedOutBy())) { throw new RepositoryException("Unable to check in the attachment, as it is currently checked out by " + attachment.getCheckedOutBy()); } Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-21 01:01:13 UTC (rev 2159) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-21 01:13:52 UTC (rev 2160) @@ -83,13 +83,10 @@ /** * Adds a rule to the ruleset. * If the rule has already been saved, then it will be copied for this ruleset. - * (the rulesetname will be prepended to the rule name to keep it unique). * - * ie: rulesetName:originalRuleName - * - * (if you don't like that, then copy() the rule before adding it). + * If a rule is new, obviously there is no copying. * - * If a rule is new, obviously there is no copying, and the name is "as is". + * The owningRuleSetName property is set to the name of this ruleset. * * @return The rule that was just added (which may be a copy). */ Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-21 01:01:13 UTC (rev 2159) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-21 01:13:52 UTC (rev 2160) @@ -1,5 +1,6 @@ package org.drools.repository; +import java.security.Principal; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -188,7 +189,7 @@ assertEquals(2, ruleSet.getAttachments().size()); repo.close(); - repo = RepositoryFactory.getStatefulRepository(); + repo = RepositoryFactory.getRepository(new MockUser("Michael"), false); //now with a new session, lets load up the latest, and add an attachment ruleSet = repo.loadRuleSet("Integration attachments 1", 2); @@ -205,9 +206,9 @@ assertEquals(3, ruleSet.getAttachments().size()); RuleSetAttachment att = (RuleSetAttachment) ruleSet.getAttachments().iterator().next(); - repo.checkOutAttachment(att, "Michael"); + repo.checkOutAttachment(att); assertEquals(true, att.isCheckedOut()); - repo.checkInAttachment(att, "Michael"); + repo.checkInAttachment(att); assertEquals(false, att.isCheckedOut()); repo.close(); @@ -373,4 +374,6 @@ repo.close(); } + + } Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java 2006-01-21 01:01:13 UTC (rev 2159) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java 2006-01-21 01:13:52 UTC (rev 2160) @@ -131,22 +131,28 @@ public void testCheckinOut() { RuleDef rule = new RuleDef("checkin", "some rule"); - RepositoryManager repo = getRepo(); + RepositoryManager repo = RepositoryFactory.getRepository(new MockUser("michael"), false); repo.save(rule); - repo.checkOutRule(rule, "u=Michael.Neale"); + repo.checkOutRule(rule); rule = repo.loadRule("checkin", 1); assertEquals(true, rule.isCheckedOut()); - assertEquals("u=Michael.Neale", rule.getCheckedOutBy()); + assertEquals("michael", rule.getCheckedOutBy()); + repo = RepositoryFactory.getRepository(new MockUser("rohit"), false); + try { - repo.checkInRule(rule, "u=Rohit.Mathur"); + //whoops we cant check it in + repo.checkInRule(rule); } catch (RepositoryException e) { assertNotNull(e.getMessage()); } - repo.checkInRule(rule, "u=Michael.Neale"); + //now we can check it in + repo = RepositoryFactory.getRepository(new MockUser("michael"), false); + + repo.checkInRule(rule); assertEquals(false, rule.isCheckedOut()); } |
From: <jbo...@li...> - 2006-01-21 01:01:24
|
Author: mic...@jb... Date: 2006-01-20 20:01:13 -0500 (Fri, 20 Jan 2006) New Revision: 2159 Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java Log: better tests Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-21 00:46:01 UTC (rev 2158) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/IntegrationTest.java 2006-01-21 01:01:13 UTC (rev 2159) @@ -51,7 +51,7 @@ RepositoryManager repoB = RepositoryFactory.getStatefulRepository(); - //Lets try a simple rule + //Lets try a simple rule, which will stay stand alone RuleDef ruleA = new RuleDef("Concurrent 1", "content1"); repoA.save(ruleA); repoA.close(); @@ -84,13 +84,13 @@ repoA.save(ruleSet); repoA.close(); - //we will add a rule to each one + //we will add a rule to each one, concurrently repoA = RepositoryFactory.getStatefulRepository(); repoB = RepositoryFactory.getStatefulRepository(); RuleSetDef ruleSetA = repoA.loadRuleSet("Integration concurrent 1", 1); RuleSetDef ruleSetB = repoB.loadRuleSet("Integration concurrent 1", 1); - + ruleA = new RuleDef("Concurrent 3", "content"); ruleSetA.addRule(ruleA); ruleSetB.addRule(new RuleDef("Concurrent 4", "content")); @@ -104,6 +104,7 @@ ruleA.setContent("new content"); repoA.save(ruleSetA); + repoA.close(); repoB.close(); @@ -115,7 +116,27 @@ repoA.close(); + //now lets have bob and michael both edit to different rules at once + repoA = RepositoryFactory.getStatefulRepository(); + repoB = RepositoryFactory.getStatefulRepository(); + ruleSetA = repoA.loadRuleSet("Integration concurrent 1", 1); + ruleSetB = repoB.loadRuleSet("Integration concurrent 1", 1); + ruleA = ruleSetA.findRuleByName("Concurrent 3"); + ruleB = ruleSetB.findRuleByName("Concurrent 4"); + + ruleA.setContent("something wild"); + ruleB.setContent("something simple"); + + //should be fine, as different rules. + repoA.save(ruleSetA); + repoB.save(ruleSetB); + + repoA.close(); + repoB.close(); + + + } |
Author: mic...@jb... Date: 2006-01-20 19:46:01 -0500 (Fri, 20 Jan 2006) New Revision: 2158 Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java Log: added owning ruleset name Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java 2006-01-21 00:39:22 UTC (rev 2157) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java 2006-01-21 00:46:01 UTC (rev 2158) @@ -29,8 +29,21 @@ private Long historicalId; private boolean historicalRecord = false; private int lockingVersion = 0; + private String owningRuleSetName; + /** + * If a rule belongs to a ruleset, this will have its name. + * Rulenames should be unique, but at a minimum unique in a ruleset. + * */ + public String getOwningRuleSetName() { + return owningRuleSetName; + } + + void setOwningRuleSetName(String owningRuleSetName) { + this.owningRuleSetName = owningRuleSetName; + } + /** * Use tagging to aid with searching and sorting of large numbers of rules. */ Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-21 00:39:22 UTC (rev 2157) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-21 00:46:01 UTC (rev 2158) @@ -96,12 +96,13 @@ public RuleDef addRule(RuleDef rule) { RuleDef returnVal = rule; if (rule.getId() == null) { + rule.setOwningRuleSetName(this.name); addAssetToSet( rule, this.rules ); } else { //we have to make a copy RuleDef newRule = (RuleDef) rule.copy(); - newRule.setName(this.getName() + ":" + rule.getName()); + newRule.setOwningRuleSetName(this.name); addAssetToSet( newRule, this.rules ); returnVal = newRule; Modified: trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml 2006-01-21 00:39:22 UTC (rev 2157) +++ trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml 2006-01-21 00:46:01 UTC (rev 2158) @@ -26,6 +26,7 @@ <property name="expiryDate" column="EXPIRY_DATE"/> <property name="historicalId" column="HISTORICAL_ID"/> <property name="historicalRecord" column="HISTORICAL_RECORD_FLAG"/> + <property name="owningRuleSetName" column="OWNING_RULESET_NAME" /> <set name="tags" table="RULE_TAGS" lazy="false" cascade="all" optimistic-lock="false"> <key column="RULE_ID"/> Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java 2006-01-21 00:39:22 UTC (rev 2157) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java 2006-01-21 00:46:01 UTC (rev 2158) @@ -34,6 +34,7 @@ def.removeTag("tag1"); repo.save(def); def = repo.loadRule("myRule3", 1); + assertEquals(null, def.getOwningRuleSetName()); assertEquals(2, def.getTags().size()); } Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java 2006-01-21 00:39:22 UTC (rev 2157) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java 2006-01-21 00:46:01 UTC (rev 2158) @@ -49,7 +49,7 @@ repo.save(def2); def2 = repo.loadRuleSet("my ruleset", 1); - newRule = def2.findRuleByName("my ruleset:pre-existing"); + newRule = def2.findRuleByName("pre-existing"); assertEquals("ABC", newRule.getContent()); assertEquals(1, newRule.getTags().size()); } @@ -347,8 +347,11 @@ repo.save(ruleset); RuleDef copied = newruleset.addRule(preExist); - RuleDef other = newruleset.findRuleByName("yao" + ":" + preExist.getName()); + RuleDef other = newruleset.findRuleByName(preExist.getName()); assertEquals(null, other.getId()); //so we know it is a copy + assertEquals(newruleset.getName(), other.getOwningRuleSetName()); + assertEquals(null, preExist.getOwningRuleSetName()); + repo.save(newruleset); assertFalse(other == preExist); @@ -357,7 +360,7 @@ newruleset = repo.loadRuleSet("yao", 1); assertEquals(1, newruleset.getRules().size()); other = (RuleDef) newruleset.getRules().iterator().next(); - assertTrue(other.getName().startsWith("yao")); + assertEquals(newruleset.getName(), other.getOwningRuleSetName()); newruleset.removeRule(other); repo.save(newruleset); |
Author: mic...@jb... Date: 2006-01-20 19:39:22 -0500 (Fri, 20 Jan 2006) New Revision: 2157 Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java Log: fixed up some relationships Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java 2006-01-20 22:46:13 UTC (rev 2156) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleDef.java 2006-01-21 00:39:22 UTC (rev 2157) @@ -29,8 +29,6 @@ private Long historicalId; private boolean historicalRecord = false; private int lockingVersion = 0; - private RuleSetDef owningRuleSet = null; - /** @@ -237,20 +235,7 @@ } } - /** - * When a rule is allocated to a ruleset, it is "owned" by that ruleset. - * If it is added to another ruleset, a copy is added. - * - * This may be null, meaning that it is a free floating rule. - */ - public RuleSetDef getOwningRuleSet() { - return owningRuleSet; - } - void setOwningRuleSet(RuleSetDef owningRuleSet) { - this.owningRuleSet = owningRuleSet; - } - /** return true if different */ private boolean diffStr(String left, String right) { return !left.equals(right); @@ -262,6 +247,8 @@ private void setLockingVersion(int lockingVersion) { this.lockingVersion = lockingVersion; - } + } + + } Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-20 22:46:13 UTC (rev 2156) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RuleSetDef.java 2006-01-21 00:39:22 UTC (rev 2157) @@ -82,30 +82,32 @@ /** * Adds a rule to the ruleset. - * If the rule belongs to another ruleset already, it will be copied, and the name - * prepended with the ruleset name (to ensure it is unique). + * If the rule has already been saved, then it will be copied for this ruleset. + * (the rulesetname will be prepended to the rule name to keep it unique). * * ie: rulesetName:originalRuleName * * (if you don't like that, then copy() the rule before adding it). * * If a rule is new, obviously there is no copying, and the name is "as is". - * The rule may have been stored previously, "unattached" which is also fine (won't be copied). + * + * @return The rule that was just added (which may be a copy). */ - public RuleSetDef addRule(RuleDef rule) { - if (rule.getOwningRuleSet() == null) { - rule.setOwningRuleSet(this); - return addAssetToSet( rule, + public RuleDef addRule(RuleDef rule) { + RuleDef returnVal = rule; + if (rule.getId() == null) { + addAssetToSet( rule, this.rules ); } else { //we have to make a copy RuleDef newRule = (RuleDef) rule.copy(); newRule.setName(this.getName() + ":" + rule.getName()); - newRule.setOwningRuleSet(this); - return addAssetToSet( newRule, + addAssetToSet( newRule, this.rules ); + returnVal = newRule; } + return returnVal; } public RuleSetDef addAttachment(RuleSetAttachment attachmentFile) { @@ -149,7 +151,6 @@ * */ public void removeRule(RuleDef rule) { - rule.setOwningRuleSet(null); rule.setVersionNumber(IVersionable.NO_VERSION); } @@ -201,11 +202,8 @@ asset.setVersionNumber( this.workingVersionNumber ); if ( asset.getId() == null ) { asset.setVersionComment( "new" ); - set.add( asset ); } - else { - set.add( asset ); - } + set.add( asset ); return this; } Modified: trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml 2006-01-20 22:46:13 UTC (rev 2156) +++ trunk/labs/jbossrules/drools-repository/src/main/resources/org/drools/repository/RuleDef.hbm.xml 2006-01-21 00:39:22 UTC (rev 2157) @@ -32,8 +32,6 @@ <one-to-many class="org.drools.repository.Tag" /> </set> - <many-to-one name="owningRuleSet" column="OWNING_RULESET_ID" /> - <component name="metaData"> <property name="title" /> <property name="creator" /> Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java 2006-01-20 22:46:13 UTC (rev 2156) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RulePersistenceTest.java 2006-01-21 00:39:22 UTC (rev 2157) @@ -34,7 +34,7 @@ def.removeTag("tag1"); repo.save(def); def = repo.loadRule("myRule3", 1); - assertEquals(null, def.getOwningRuleSet()); + assertEquals(2, def.getTags().size()); } @@ -80,7 +80,7 @@ public void testRuleRuleSetHistory() { RuleSetDef rs = new RuleSetDef("rule history", null); - rs.addRule(new RuleDef("rh1", "xxxxx")); + RuleDef first = rs.addRule(new RuleDef("rh1", "xxxxx")); rs.addRule(new RuleDef("rh2", "xxxxx")); rs.addRule(new RuleDef("rh3", "xxxxx")); @@ -114,7 +114,17 @@ list = repo.listSaveHistory(rule); assertEquals(2, list.size()); + + rs = repo.loadRuleSet("rule history", 1); + RuleDef firstLoaded = rs.findRuleByName("rh1"); + firstLoaded.setContent("new again"); + repo.save(rs); + rs = repo.loadRuleSet("rule history", 1); + RuleDef loadedAgain = rs.findRuleByName("rh1"); + + assertEquals(firstLoaded.getContent(), loadedAgain.getContent()); + } public void testCheckinOut() { Modified: trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java 2006-01-20 22:46:13 UTC (rev 2156) +++ trunk/labs/jbossrules/drools-repository/src/test/java/org/drools/repository/RuleSetPersistenceTest.java 2006-01-21 00:39:22 UTC (rev 2157) @@ -48,7 +48,8 @@ def2.addRule(newRule); repo.save(def2); def2 = repo.loadRuleSet("my ruleset", 1); - newRule = def2.findRuleByName("pre-existing"); + + newRule = def2.findRuleByName("my ruleset:pre-existing"); assertEquals("ABC", newRule.getContent()); assertEquals(1, newRule.getTags().size()); } @@ -148,7 +149,8 @@ RuleDef def2 = new RuleDef("Rule2", "blah2"); def1.addTag("S").addTag("A"); - set.addRule(def1).addRule(def2); + set.addRule(def1); + set.addRule(def2); set.addAttachment(new RuleSetAttachment("x", "x", "x".getBytes(), "x")); assertEquals(2, set.getRules().size()); @@ -337,19 +339,21 @@ repo.save(ruleset); ruleset.addRule(preExist); - assertEquals(ruleset, preExist.getOwningRuleSet()); + repo.save(ruleset); RuleSetDef newruleset = new RuleSetDef("yao", null); repo.save(ruleset); - newruleset.addRule(preExist); + RuleDef copied = newruleset.addRule(preExist); RuleDef other = newruleset.findRuleByName("yao" + ":" + preExist.getName()); assertEquals(null, other.getId()); //so we know it is a copy - assertEquals(newruleset, other.getOwningRuleSet()); repo.save(newruleset); + assertFalse(other == preExist); + assertEquals(other, copied); + newruleset = repo.loadRuleSet("yao", 1); assertEquals(1, newruleset.getRules().size()); other = (RuleDef) newruleset.getRules().iterator().next(); |
From: <jbo...@li...> - 2006-01-20 22:46:22
|
Author: wrzep Date: 2006-01-20 17:46:13 -0500 (Fri, 20 Jan 2006) New Revision: 2156 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/jira/JiraStatusPlugin.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java Log: finished displaying stats for selected metric, added column containing link associated with metric http://jira.jboss.com/jira/browse/JBLAB-595 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2006-01-20 21:04:14 UTC (rev 2155) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2006-01-20 22:46:13 UTC (rev 2156) @@ -83,6 +83,7 @@ if (value != null) { entryContext.put("value", Long.toString(value)); + entryContext.put("link", plugin.getLink(projectId)); } } catch (Exception e) { log.error("Could not get value for plugin: " + plugin.getId(), e); Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java 2006-01-20 21:04:14 UTC (rev 2155) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java 2006-01-20 22:46:13 UTC (rev 2156) @@ -62,6 +62,13 @@ */ public abstract long getValue(String projectId); + /** For the given project returns link associated with this plugin and project. + * Should be overrided inside plugins that have some links associated with projects. + */ + public String getLink(String projectId) { + return null; + } + /** * @return plugin id */ Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java 2006-01-20 21:04:14 UTC (rev 2155) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/cc/CcStatusPlugin.java 2006-01-20 22:46:13 UTC (rev 2156) @@ -98,4 +98,9 @@ return (ccURL == "" ? null : ccURL); } + @Override + public String getLink(String projectId) { + return getCcURL(projectId); + } + } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/jira/JiraStatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/jira/JiraStatusPlugin.java 2006-01-20 21:04:14 UTC (rev 2155) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/jira/JiraStatusPlugin.java 2006-01-20 22:46:13 UTC (rev 2156) @@ -96,4 +96,8 @@ return (jiraURL == "" ? null : jiraURL); } + @Override + public String getLink(String projectId) { + return getJiraURL(projectId); + } } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java 2006-01-20 21:04:14 UTC (rev 2155) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/svn/SvnStatusPlugin.java 2006-01-20 22:46:13 UTC (rev 2156) @@ -96,4 +96,9 @@ return (repoURL == "" ? null : repoURL); } + @Override + public String getLink(String projectId) { + return getRepoURL(projectId); + } + } |
From: <jbo...@li...> - 2006-01-20 21:04:21
|
Author: wrzep Date: 2006-01-20 16:04:14 -0500 (Fri, 20 Jan 2006) New Revision: 2155 Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusPortlet.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusTools.java trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java Log: Added metric page (available after clicking on column header) to place there not only stats but graphs as well. http://jira.jboss.com/jira/browse/JBLAB-595 Pawel Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2006-01-20 10:54:07 UTC (rev 2154) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Column.java 2006-01-20 21:04:14 UTC (rev 2155) @@ -22,6 +22,10 @@ package org.jboss.forge.status; +import java.util.Set; + +import org.jboss.forge.common.projects.Projects; +import org.jboss.forge.common.projects.permissions.NullPermissionsChecker; import org.jboss.forge.status.plugins.Plugin; import org.jboss.logging.Logger; import org.jboss.portal.common.context.DelegateContext; @@ -53,13 +57,6 @@ } /** - * @return Column name - */ - public String getName() { - return name; - } - - /** * Fills the given context with information appropriate for * the Status Matrix cell, located in the project row and this column. * @@ -70,7 +67,16 @@ DelegateContext entryContext = projectContext.next("entry"); - entryContext.put("name", getName()); + fillHeaderInfo(entryContext); + fillValue(entryContext, projectId); + } + + public void fillHeaderInfo(DelegateContext columnContext) { + columnContext.put("name", getName()); + columnContext.put("id", getId()); + } + + public void fillValue(DelegateContext entryContext, String projectId) { try { Long value = plugin.getValue(projectId); @@ -82,4 +88,42 @@ log.error("Could not get value for plugin: " + plugin.getId(), e); } } + + /** + * Fills the given context with column information for given projects. + * + * @param columnContext context to fill + * @param projects projects to fill context for + */ + public void fillContext(DelegateContext columnContext, Projects projects) { + + fillHeaderInfo(columnContext); + + Set<String> projectIds = projects.getProjectIds( + new NullPermissionsChecker(), null); + for (String projectId : projectIds) { + + DelegateContext projectContext = columnContext.next("project"); + + projectContext.put("name", projects.getProjectName(projectId)); + projectContext.put("link", projects.getProjectLink(projectId)); + projectContext.put("id", projectId); + + fillValue(projectContext, projectId); + } + } + + /** + * @return Column plugin id + */ + public String getId() { + return plugin.getId(); + } + + /** + * @return Column name + */ + public String getName() { + return name; + } } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java 2006-01-20 10:54:07 UTC (rev 2154) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Columns.java 2006-01-20 21:04:14 UTC (rev 2155) @@ -80,6 +80,14 @@ } /** + * @param projects Projects present in the Status Matrix + */ + public Columns(Projects projects) { + this.projects = projects; + columns = new ArrayList<Column>(); + } + + /** * Adds to the columns list columns defined in columnsRoot. * * @param columnsRoot Node defining columns list @@ -135,7 +143,7 @@ * @param context DelegateContext to fill */ public void fillContext(DelegateContext context) { - fillColumnsNames(context); + fillColumnNames(context); fillValues(context); } @@ -147,7 +155,7 @@ * @param projectId id of project to fill context for */ public void fillContext(DelegateContext context, String projectId) { - fillColumnsNames(context); + fillColumnNames(context); fillProjectContext(context, projectId); } @@ -156,13 +164,13 @@ * * @param context DelegateContext to fill */ - private void fillColumnsNames(DelegateContext context) { + private void fillColumnNames(DelegateContext context) { for (Iterator iter = columns.iterator(); iter.hasNext();) { Column column = (Column) iter.next(); DelegateContext columnContext = new DelegateContext(); - columnContext.put("name", column.getName()); + column.fillHeaderInfo(columnContext); context.append("column", columnContext); } @@ -242,4 +250,19 @@ column.fillProjectContext(projectContext, projectId); } } + + /** + * Adds columns from <code>columnsToAdd</code> to the columns list. + */ + public void add(Columns columnsToAdd) { + + for (Column col : columnsToAdd.columns) { + columns.add(col); + } + + } + + public List<Column> getColumns() { + return columns; + } } \ No newline at end of file Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2006-01-20 10:54:07 UTC (rev 2154) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/Status.java 2006-01-20 21:04:14 UTC (rev 2155) @@ -52,6 +52,9 @@ /** Columns to display on the project specyfic page */ private Columns projectPageColumns; + /** All columns used in the Status Matrix */ + private Columns allColumns; + /** Plugins used in the Status Matrix */ private Plugins plugins; @@ -80,6 +83,10 @@ // Get columns to display on the project page Node projectPageRoot = XmlTools.getFirstNodeWithName(statusRoot, PROJECT_PAGE_COLLUMNS_TAG); projectPageColumns = new Columns(projectPageRoot, plugins, projects); + + allColumns = new Columns(projects); + allColumns.add(mainPageColumns); + allColumns.add(projectPageColumns); } /** @@ -96,7 +103,7 @@ */ public Map<String, DelegateContext> getProjectContexts() { - Map<String,DelegateContext> contextsMap = new HashMap<String,DelegateContext>(); + Map<String, DelegateContext> prjMap = new HashMap<String, DelegateContext>(); Set<String> projectIdsSet = projects.getProjectIds( (PermissionsChecker) new NullPermissionsChecker(), null); @@ -106,9 +113,24 @@ DelegateContext context = new DelegateContext(); projectPageColumns.fillContext(context, projectId); - contextsMap.put(projectId, context); + prjMap.put(projectId, context); } - return contextsMap; + return prjMap; } + + public Map<String, DelegateContext> getColumnContexts() { + + Map<String, DelegateContext> colMap = new HashMap<String, DelegateContext>(); + + for (Column col : allColumns.getColumns()) { + + DelegateContext context = new DelegateContext(); + col.fillContext(context, projects); + + colMap.put(col.getId(), context); + } + + return colMap; + } } \ No newline at end of file Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java 2006-01-20 10:54:07 UTC (rev 2154) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusDescriptor.java 2006-01-20 21:04:14 UTC (rev 2155) @@ -44,6 +44,7 @@ private DelegateContext context; private Map<String,DelegateContext> projectContexts; + private Map<String,DelegateContext> columnContexts; private Status status; @@ -74,6 +75,7 @@ status.fillContext(context); projectContexts = status.getProjectContexts(); + columnContexts = status.getColumnContexts(); } public DelegateContext getContext() { @@ -84,6 +86,10 @@ return projectContexts.get(id); } + public DelegateContext getColumnContext(String id) { + return columnContexts.get(id); + } + private Node getRoot(ContentManager cm, String path) throws IOException, SAXException, ResourceDoesNotExist { DOMParser parser = new DOMParser(); parser.parse(new InputSource(cm.getNode(path).getContentInputStream())); Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusPortlet.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusPortlet.java 2006-01-20 10:54:07 UTC (rev 2154) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusPortlet.java 2006-01-20 21:04:14 UTC (rev 2155) @@ -42,6 +42,7 @@ public class StatusPortlet extends JBossPortlet { private static final String PROJECT_DETAILS_ACTION = "viewProjectDetails"; + private static final String COLUMN_DETAILS_ACTION = "viewColumnDetails"; @Override public void doView(JBossRenderRequest request, JBossRenderResponse response) @@ -60,9 +61,16 @@ DelegateContext context = null; if ((id != null) && (action.equals(PROJECT_DETAILS_ACTION))) { - jspPath = StatusTools.getDetailsJspCmPath(); + jspPath = StatusTools.getPrjDetailsJspCmPath(); context = desc.getProjectContext(id); - } else { + } + + if ((id != null) && (action.equals(COLUMN_DETAILS_ACTION))) { + jspPath = StatusTools.getColumnDetailsJspCmPath(); + context = desc.getColumnContext(id); + } + + if (id == null) { // Request for main Matrix page jspPath = StatusTools.getJspCmPath(); context = desc.getContext(); } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusTools.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusTools.java 2006-01-20 10:54:07 UTC (rev 2154) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/StatusTools.java 2006-01-20 21:04:14 UTC (rev 2155) @@ -33,10 +33,26 @@ private final static String STATUS_JSP = "status.jsp"; private final static String STATUS_JSP_DIR = "status"; private final static String PROJECT_DETAILS_JSP = "project_details.jsp"; + private final static String COLUMN_DETAILS_JSP = "column_details.jsp"; @Inject private static ContentManager cm; + public static synchronized StatusDescriptor getDesc(final String portalName) { + String cacheKey = StatusDescriptor.class.getName(); + + StatusDescriptor desc = (StatusDescriptor) ForgeHelper + .getForgeManagement().getFromCache(portalName, cacheKey); + + if (desc == null) + desc = (StatusDescriptor) ForgeHelper.getForgeManagement() + .addNodeWatcher(portalName, + cacheKey, + new StatusNodeWatcher(cm)); + + return desc; + } + /** * Path to the xml file with the Status Matrix properties. */ @@ -93,24 +109,16 @@ } /** - * Path to the jsp file responsible file displaying project details. + * Path to the jsp file responsible for displaying project details. */ - public static String getDetailsJspCmPath() { + public static String getPrjDetailsJspCmPath() { return STATUS_JSP_DIR + "/" + PROJECT_DETAILS_JSP; } - - public static synchronized StatusDescriptor getDesc(final String portalName) { - String cacheKey = StatusDescriptor.class.getName(); - - StatusDescriptor desc = (StatusDescriptor) ForgeHelper - .getForgeManagement().getFromCache(portalName, cacheKey); - if (desc == null) - desc = (StatusDescriptor) ForgeHelper.getForgeManagement() - .addNodeWatcher(portalName, - cacheKey, - new StatusNodeWatcher(cm)); - - return desc; + /** + * Path to the jsp file responsible displaying column details. + */ + public static String getColumnDetailsJspCmPath() { + return STATUS_JSP_DIR + "/" + COLUMN_DETAILS_JSP; } } Modified: trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java =================================================================== --- trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java 2006-01-20 10:54:07 UTC (rev 2154) +++ trunk/forge/portal-extensions/forge-status/src/java/org/jboss/forge/status/plugins/Plugin.java 2006-01-20 21:04:14 UTC (rev 2155) @@ -49,6 +49,8 @@ throws InvalidPluginPropertiesException { this.properties = properties; this.id = id; + + System.out.println("Plugin (" + id + ")"); } /** |
From: <jbo...@li...> - 2006-01-20 10:54:14
|
Author: mic...@jb... Date: 2006-01-20 05:54:07 -0500 (Fri, 20 Jan 2006) New Revision: 2154 Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryFactory.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManagerImpl.java trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java Log: added Principal to interface Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryFactory.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryFactory.java 2006-01-20 10:39:14 UTC (rev 2153) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryFactory.java 2006-01-20 10:54:07 UTC (rev 2154) @@ -20,9 +20,7 @@ * The default repository. This is stateless, meaning that a continuous connection is not required. */ public static RepositoryManager getRepository() { - RepoProxyHandler handler = new RepoProxyHandler(); - RepositoryManager manager = getProxy( handler ); - return manager; + return getRepo(null, false); } /** @@ -33,10 +31,17 @@ * This version can have performance benefits in some cases. */ public static RepositoryManager getStatefulRepository() { - RepoProxyHandler handler = new RepoProxyHandler(true); - RepositoryManager manager = getProxy( handler ); - return manager; + return getRepo(null, true); } + + /** + * User this factory if you want to have audited, controlled access to the repository. + * @param currentUser the user accessing the repository. + * @param stateful If the session is to be stateful or not (generally false is ideal). + */ + public static RepositoryManager getRepository(Principal currentUser, boolean stateful) { + return getRepo(currentUser, stateful); + } private static RepositoryManager getProxy(RepoProxyHandler handler) { RepositoryManager manager = (RepositoryManager) Proxy.newProxyInstance(RepositoryFactory.class.getClassLoader(), @@ -47,5 +52,11 @@ } + private static RepositoryManager getRepo(Principal user, boolean stateful) { + RepoProxyHandler handler = new RepoProxyHandler(stateful); + handler.setCurrentUser(user); + return getProxy(handler); + } + } Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManagerImpl.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManagerImpl.java 2006-01-20 10:39:14 UTC (rev 2153) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/RepositoryManagerImpl.java 2006-01-20 10:54:07 UTC (rev 2154) @@ -1,5 +1,6 @@ package org.drools.repository; +import java.security.Principal; import java.util.Enumeration; import java.util.Iterator; import java.util.List; @@ -27,6 +28,7 @@ RepositoryManager { private Session session; + private Principal currentUser; /** * Session is injected by the proxy. @@ -245,9 +247,10 @@ } - + /** Sets the current user principal for auditing, and access control purposes */ + public void setCurrentUser(Principal user) { + this.currentUser = user; + } - - } Modified: trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java =================================================================== --- trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java 2006-01-20 10:39:14 UTC (rev 2153) +++ trunk/labs/jbossrules/drools-repository/src/main/java/org/drools/repository/db/RepoProxyHandler.java 2006-01-20 10:54:07 UTC (rev 2154) @@ -3,6 +3,7 @@ import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.security.Principal; import org.drools.repository.RepositoryException; import org.drools.repository.RepositoryManagerImpl; @@ -152,6 +153,11 @@ return HibernateUtil.getSessionFactory().getCurrentSession(); } } + + /** Pass through the current user for auditing and control purposes. */ + public void setCurrentUser(Principal user) { + this.repoImpl.setCurrentUser(user); + } } |