Author: jeremy Date: Tue Jan 18 11:27:17 2005 New Revision: 125539 URL: http://svn.apache.org/viewcvs?view=rev&rev=125539 Log: adding OJB persistence to QueryBean block: adjusted gump to remove Lucene's dependence on CForms, adjusted OJB build and split configuration, adjusted Database Tables to add what was needed for persisting queries and add Sequences. Added: cocoon/trunk/src/blocks/ojb/conf/repository_database.xml cocoon/trunk/src/blocks/ojb/conf/repository_internal.xml cocoon/trunk/src/blocks/ojb/conf/repository_user.xml cocoon/trunk/src/blocks/querybean/samples/resources/ cocoon/trunk/src/blocks/querybean/samples/resources/images/ cocoon/trunk/src/blocks/querybean/samples/resources/images/fave.jpg (contents, props changed) cocoon/trunk/src/blocks/querybean/samples/screens/favourites.xml Modified: cocoon/trunk/blocks.properties cocoon/trunk/gump.xml cocoon/trunk/src/blocks/databases/conf/cocoondb.script cocoon/trunk/src/blocks/lucene/WEB-INF/xconf/cocoon-lucene.xconf cocoon/trunk/src/blocks/ojb/build.xml cocoon/trunk/src/blocks/ojb/conf/repository.xml cocoon/trunk/src/blocks/querybean/WEB-INF/xconf/cocoon-querybean.xconf cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java cocoon/trunk/src/blocks/querybean/samples/flow/QueryFavourites.js cocoon/trunk/src/blocks/querybean/samples/flow/QueryHistory.js cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js cocoon/trunk/src/blocks/querybean/samples/flow/query.js cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml cocoon/trunk/src/blocks/querybean/samples/screens/history.xml cocoon/trunk/src/blocks/querybean/samples/screens/index.xml cocoon/trunk/src/blocks/querybean/samples/screens/results.xml cocoon/trunk/src/blocks/querybean/samples/sitemap.xmap
Modified: cocoon/trunk/blocks.properties Url: http://svn.apache.org/viewcvs/cocoon/trunk/blocks.properties?view=diff&rev=125539&p1=cocoon/trunk/blocks.properties&r1=125538&p2=cocoon/trunk/blocks.properties&r2=125539 ============================================================================== --- cocoon/trunk/blocks.properties (original) +++ cocoon/trunk/blocks.properties Tue Jan 18 11:27:17 2005 @@ -67,7 +67,7 @@ #include.block.jfor=false #include.block.jsp=false #include.block.linkrewriter=false -#-----[dependency]: "lucene" depends on "forms" (for samples), "xsp" (for samples). +#-----[dependency]: "lucene" depends on "xsp" (for samples). #-----[dependency]: "lucene" is needed by "querybean". #include.block.lucene=false #include.block.naming=false @@ -129,13 +129,13 @@ #include.block.mail=false #include.block.midi=false #-----[dependency]: "ojb" depends on "databases" (for samples), "forms" (for samples), "hsqldb" (for samples). -#-----[dependency]: "ojb" is needed by "javaflow". +#-----[dependency]: "ojb" is needed by "javaflow", "querybean". #include.block.ojb=false #-----[dependency]: "petstore" depends on "databases", "forms", "hsqldb", "velocity". #include.block.petstore=false #include.block.proxy=false #include.block.qdox=false -#-----[dependency]: "querybean" depends on "forms" (for samples), "lucene". +#-----[dependency]: "querybean" depends on "forms" (for samples), "lucene", "ojb". #include.block.querybean=false #-----[dependency]: "repository" depends on "databases" (for samples), "eventcache". #-----[dependency]: "repository" is needed by "scratchpad", "slide", "webdav". Modified: cocoon/trunk/gump.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/gump.xml?view=diff&rev=125539&p1=cocoon/trunk/gump.xml&r1=125538&p2=cocoon/trunk/gump.xml&r2=125539 ============================================================================== --- cocoon/trunk/gump.xml (original) +++ cocoon/trunk/gump.xml Tue Jan 18 11:27:17 2005 @@ -955,6 +955,7 @@ <depend project="cocoon" inherit="all"/> <depend project="cocoon-block-forms" type="samples"/> <depend project="cocoon-block-lucene"/> + <depend project="cocoon-block-ojb"/> <depend project="jakarta-lucene"/> <work nested="tools/anttasks"/> Modified: cocoon/trunk/src/blocks/databases/conf/cocoondb.script Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/databases/conf/cocoondb.script?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/databases/conf/cocoondb.script&r1=125538&p2=cocoon/trunk/src/blocks/databases/conf/cocoondb.script&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/databases/conf/cocoondb.script (original) +++ cocoon/trunk/src/blocks/databases/conf/cocoondb.script Tue Jan 18 11:27:17 2005 @@ -20,6 +20,9 @@ CREATE TABLE STATE_TAX(CATEGORY VARCHAR NOT NULL,GROSSTAX_COLLECTED DOUBLE NOT NULL,NETTAX_COLLECTED DOUBLE NOT NULL,YEAR INTEGER NOT NULL) CREATE TABLE MEDIA(ID INTEGER IDENTITY PRIMARY KEY,IMAGE BINARY,MIMETYPE VARCHAR) CREATE TABLE SOURCEPROPS(SOURCE VARCHAR NOT NULL,NAMESPACE VARCHAR NOT NULL,NAME VARCHAR NOT NULL,VALUE VARCHAR NOT NULL,CONSTRAINT SYS_CT_11 UNIQUE(SOURCE,NAMESPACE,NAME)) +CREATE TABLE OJB_HL_SEQ(TABLENAME VARCHAR(175) NOT NULL,FIELDNAME VARCHAR(70) NOT NULL,MAX_KEY BIGINT,GRAB_SIZE INTEGER,VERSION INTEGER,CONSTRAINT SYS_PK_OJB_HL_SEQ PRIMARY KEY(TABLENAME,FIELDNAME)) +CREATE TABLE QUERY(ID BIGINT IDENTITY PRIMARY KEY,USER_ID VARCHAR NOT NULL,Q_DATE TIMESTAMP,Q_BOOL VARCHAR,Q_NAME VARCHAR,Q_TYPE VARCHAR,Q_SIZE BIGINT,UNIQUE(ID)) +CREATE TABLE CRITERION(ID BIGINT IDENTITY PRIMARY KEY,Q_ID BIGINT,C_FIELD VARCHAR,C_MATCH VARCHAR,C_TERM VARCHAR,CONSTRAINT SYS_FK_20 FOREIGN KEY(Q_ID) REFERENCES QUERY(ID),UNIQUE(ID)) GRANT ALL ON CLASS "org.hsqldb.Library" TO PUBLIC GRANT ALL ON CLASS "java.lang.Math" TO PUBLIC CREATE USER SA PASSWORD "" ADMIN @@ -137,3 +140,5 @@ INSERT INTO STATE_TAX VALUES('Horse Racing',1.7921198E7,1.7321198E7,2001) INSERT INTO STATE_TAX VALUES('Severance',7981539.0,7967438.0,2001) INSERT INTO STATE_TAX VALUES('School District Income',1.61257059E8,1.53238001E8,2001) +INSERT INTO QUERY VALUES(1,'anon','1970-01-01 01:00:00.0',NULL,'test','simple',20) +INSERT INTO CRITERION VALUES(1,1,'any','any','cocoon') Modified: cocoon/trunk/src/blocks/lucene/WEB-INF/xconf/cocoon-lucene.xconf Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/lucene/WEB-INF/xconf/cocoon-lucene.xconf?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/lucene/WEB-INF/xconf/cocoon-lucene.xconf&r1=125538&p2=cocoon/trunk/src/blocks/lucene/WEB-INF/xconf/cocoon-lucene.xconf&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/lucene/WEB-INF/xconf/cocoon-lucene.xconf (original) +++ cocoon/trunk/src/blocks/lucene/WEB-INF/xconf/cocoon-lucene.xconf Tue Jan 18 11:27:17 2005 @@ -21,7 +21,6 @@ +--> <components> <!-- Include dependencies --> - <include src="context://WEB-INF/xconf/cocoon-forms.xconf"/> <include src="context://WEB-INF/xconf/cocoon-xsp.xconf"/> <!-- Include roles --> Modified: cocoon/trunk/src/blocks/ojb/build.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/build.xml?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/ojb/build.xml&r1=125538&p2=cocoon/trunk/src/blocks/ojb/build.xml&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/ojb/build.xml (original) +++ cocoon/trunk/src/blocks/ojb/build.xml Tue Jan 18 11:27:17 2005 @@ -38,6 +38,9 @@ <copy file="${block.dir}/conf/package.jdo" tofile="${build.blocks.ojb.samples}/package.jdo"/> <copy file="${block.dir}/conf/repository.dtd" tofile="${build.webapp.classes}/repository.dtd"/> <copy file="${block.dir}/conf/repository.xml" tofile="${build.webapp.classes}/repository.xml"/> + <copy file="${block.dir}/conf/repository_database.xml" tofile="${build.webapp.classes}/repository_database.xml"/> + <copy file="${block.dir}/conf/repository_internal.xml" tofile="${build.webapp.classes}/repository_internal.xml"/> + <copy file="${block.dir}/conf/repository_user.xml" tofile="${build.webapp.classes}/repository_user.xml"/> <copy file="${block.dir}/conf/OJB.properties" tofile="${build.webapp.classes}/OJB.properties"/> </target> Modified: cocoon/trunk/src/blocks/ojb/conf/repository.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/conf/repository.xml?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/ojb/conf/repository.xml&r1=125538&p2=cocoon/trunk/src/blocks/ojb/conf/repository.xml&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/ojb/conf/repository.xml (original) +++ cocoon/trunk/src/blocks/ojb/conf/repository.xml Tue Jan 18 11:27:17 2005 @@ -14,63 +14,23 @@ See the License for the specific language governing permissions and limitations under the License. --> -<!DOCTYPE descriptor-repository PUBLIC "-//Apache Software Foundation//DTD OJB Repository//EN" "repository.dtd"> +<!DOCTYPE descriptor-repository PUBLIC + "-//Apache Software Foundation//DTD OJB Repository//EN" + "repository.dtd" +[ + <!ENTITY database SYSTEM "repository_database.xml"> + <!ENTITY internal SYSTEM "repository_internal.xml"> + <!ENTITY user SYSTEM "repository_user.xml"> +]> <descriptor-repository version="1.0" isolation-level="read-uncommitted"> + <!-- include all used database connections --> + &database; -<!-- -Define here all used connections. -One defined connection should be defined as the default one, -by set default-connection="true" - this could be done at runtime too. + <!-- include ojb internal mappings here --> + &internal; -It is possible to set user/password at -runtime or let login different users at runtime using the same -database. Use different PBKey with same jcdAlias name but -different user/password. - -Ditto it is possible to add jdbc-connection-descriptor at runtime -using the MetadataManager. ---> - <jdbc-connection-descriptor - jcd-alias="default" - platform="Hsqldb" - jdbc-level="3.0" - driver="org.hsqldb.jdbcDriver" - protocol="jdbc" - subprotocol="hsqldb" - dbalias="hsql://localhost:9002" - username="sa" - password="" - batch-mode="false" - useAutoCommit="1" - ignoreAutoCommitExceptions="false" - > - <connection-pool - maxActive="2" - maxIdle="2" - whenExhaustedAction="2" - validationQuery="select count(*) from Department" - /> - <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"> - <attribute attribute-name="grabSize" attribute-value="5"/> - </sequence-manager> - </jdbc-connection-descriptor> - - <jdbc-connection-descriptor jcd-alias="personnel" default-connection="true"> - <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"> - <attribute attribute-name="grabSize" attribute-value="5"/> - </sequence-manager> - </jdbc-connection-descriptor> - - <class-descriptor class="org.apache.cocoon.ojb.samples.bean.Department" table="DEPARTMENT"> - <field-descriptor name="id" column="ID" jdbc-type="INTEGER" primarykey="true"/> - <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/> - </class-descriptor> - - <class-descriptor class="org.apache.cocoon.ojb.samples.bean.Employee" table="EMPLOYEE"> - <field-descriptor name="id" column="ID" jdbc-type="INTEGER" primarykey="true"/> - <field-descriptor name="departmentId" column="DEPARTMENT_ID" jdbc-type="INTEGER"/> - <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/> - </class-descriptor> + <!-- include user defined mappings here --> + &user; </descriptor-repository> Added: cocoon/trunk/src/blocks/ojb/conf/repository_database.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/conf/repository_database.xml?view=auto&rev=125539 ============================================================================== --- (empty file) +++ cocoon/trunk/src/blocks/ojb/conf/repository_database.xml Tue Jan 18 11:27:17 2005 @@ -0,0 +1,65 @@ +<!-- OJB DATABASE MAPPINGS START HERE --> +<!-- +#/* Copyright 2002-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> + + +<!-- +Define here all used connections. +One defined connection should be defined as the default one, +by set default-connection="true" - this could be done at runtime too. + +It is possible to set user/password at +runtime or let login different users at runtime using the same +database. Use different PBKey with same jcdAlias name but +different user/password. + +Ditto it is possible to add jdbc-connection-descriptor at runtime +using the MetadataManager. +--> + <jdbc-connection-descriptor + jcd-alias="default" + platform="Hsqldb" + jdbc-level="3.0" + driver="org.hsqldb.jdbcDriver" + protocol="jdbc" + subprotocol="hsqldb" + dbalias="hsql://localhost:9002" + username="sa" + password="" + batch-mode="false" + useAutoCommit="1" + ignoreAutoCommitExceptions="false" + > + <connection-pool + maxActive="2" + maxIdle="2" + whenExhaustedAction="2" + validationQuery="" + /> + <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"> + <attribute attribute-name="grabSize" attribute-value="5"/> + </sequence-manager> + </jdbc-connection-descriptor> + + <jdbc-connection-descriptor jcd-alias="personnel" default-connection="true"> + <sequence-manager className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl"> + <attribute attribute-name="grabSize" attribute-value="5"/> + </sequence-manager> + </jdbc-connection-descriptor> + + + <!-- END OF OJB DATABASE MAPPINGS--> Added: cocoon/trunk/src/blocks/ojb/conf/repository_internal.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/conf/repository_internal.xml?view=auto&rev=125539 ============================================================================== --- (empty file) +++ cocoon/trunk/src/blocks/ojb/conf/repository_internal.xml Tue Jan 18 11:27:17 2005 @@ -0,0 +1,362 @@ +<!-- OJB INTERNAL MAPPINGS START HERE, DO NOT EDIT --> +<!-- +#/* Copyright 2002-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> +<!-- The OJB HIGH/LOW SequenceManagerTable --> + <class-descriptor + class="org.apache.ojb.broker.util.sequence.HighLowSequence" + table="OJB_HL_SEQ" + > + + <object-cache class="org.apache.ojb.broker.cache.ObjectCacheEmptyImpl"> + </object-cache> + + <field-descriptor + name="tableName" + column="TABLENAME" + jdbc-type="VARCHAR" + primarykey="true" + /> + <field-descriptor + name="fieldName" + column="FIELDNAME" + jdbc-type="VARCHAR" + primarykey="true" + /> + <field-descriptor + name="maxKey" + column="MAX_KEY" + jdbc-type="BIGINT" + /> + <field-descriptor + name="grabSize" + column="GRAB_SIZE" + jdbc-type="INTEGER" + /> + <field-descriptor + name="version" + column="VERSION" + jdbc-type="INTEGER" + locking="true" + /> + </class-descriptor> + + +<!-- The OJB Lock Table --> + <class-descriptor + class="org.apache.ojb.odmg.locking.LockEntry" + table="OJB_LOCKENTRY" + > + <field-descriptor + name="oidString" + column="OID_" + jdbc-type="VARCHAR" + primarykey="true" + /> + <field-descriptor + name="transactionId" + column="TX_ID" + jdbc-type="VARCHAR" + primarykey="true" + /> + <field-descriptor + name="timestamp" + column="TIMESTAMP_" + jdbc-type="BIGINT" + /> + <field-descriptor + name="isolationLevel" + column="ISOLATIONLEVEL" + jdbc-type="INTEGER" + /> + <field-descriptor + name="lockType" + column="LOCKTYPE" + jdbc-type="INTEGER" + /> + </class-descriptor> + + +<!-- THIS IS THE OJB NAMED ROOTS TABLE, DO NOT EDIT--> + <class-descriptor + class="org.apache.ojb.odmg.NamedRootsEntry" + table="OJB_NRM" + > + <field-descriptor + name="name" + column="NAME" + jdbc-type="VARCHAR" + primarykey="true" + /> + <field-descriptor + name="oid" + column="OID_" + jdbc-type="LONGVARBINARY" + /> + </class-descriptor> + +<!-- THIS IS THE OJB DLIST IMPLEMENTATION, DO NOT EDIT--> + <class-descriptor + class="org.apache.ojb.odmg.collections.DListImpl" + table="OJB_DLIST" + > + <field-descriptor + name="id" + column="ID" + jdbc-type="INTEGER" + primarykey="true" + autoincrement="true" + /> + <field-descriptor + name="size" + column="SIZE_" + jdbc-type="INTEGER" + /> + <collection-descriptor + name="elements" + element-class-ref="org.apache.ojb.odmg.collections.DListEntry" + > + <inverse-foreignkey field-ref="dlistId"/> + </collection-descriptor> + </class-descriptor> + +<!-- THIS IS THE OJB DLIST ENTRY IMPLEMENTATION, DO NOT EDIT--> + <class-descriptor + class="org.apache.ojb.odmg.collections.DListEntry" + table="OJB_DLIST_ENTRIES" + > + <field-descriptor + name="id" + column="ID" + jdbc-type="INTEGER" + primarykey="true" + autoincrement="true" + /> + <field-descriptor + name="dlistId" + column="DLIST_ID" + jdbc-type="INTEGER" + /> + <field-descriptor + name="position" + column="POSITION_" + jdbc-type="INTEGER" + /> + <field-descriptor + name="oid" + column="OID_" + jdbc-type="LONGVARBINARY" + conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion" + /> + </class-descriptor> + + <!-- THIS IS THE OJB DLIST IMPLEMENTATION, DO NOT EDIT--> + <!-- alternative implementation of DList --> + <class-descriptor + class="org.apache.ojb.odmg.collections.DListImpl_2" + table="OJB_DLIST" + > + <field-descriptor + name="id" + column="ID" + jdbc-type="INTEGER" + primarykey="true" + autoincrement="true" + /> + <field-descriptor + name="size" + column="SIZE_" + jdbc-type="INTEGER" + /> + <collection-descriptor + name="elements" + element-class-ref="org.apache.ojb.odmg.collections.DListEntry_2" + auto-retrieve = "true" + > + <inverse-foreignkey field-ref="dlistId"/> + </collection-descriptor> + </class-descriptor> + +<!-- THIS IS THE OJB DLIST ENTRY IMPLEMENTATION, DO NOT EDIT--> + <class-descriptor + class="org.apache.ojb.odmg.collections.DListEntry_2" + table="OJB_DLIST_ENTRIES" + > + <field-descriptor + name="id" + column="ID" + jdbc-type="INTEGER" + primarykey="true" + autoincrement="true" + /> + <field-descriptor + name="dlistId" + column="DLIST_ID" + jdbc-type="INTEGER" + /> + <field-descriptor + name="position" + column="POSITION_" + jdbc-type="INTEGER" + /> + <field-descriptor + name="oid" + column="OID_" + jdbc-type="LONGVARBINARY" + conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion" + /> + </class-descriptor> + + <!-- THIS IS THE OJB DBAG IMPLEMENTATION, DO NOT EDIT--> + <class-descriptor + class="org.apache.ojb.odmg.collections.DBagImpl" + table="OJB_DLIST" + > + <field-descriptor + name="id" + column="ID" + jdbc-type="INTEGER" + primarykey="true" + autoincrement="true" + /> + <field-descriptor + name="size" + column="SIZE_" + jdbc-type="INTEGER" + /> + <collection-descriptor + name="elements" + element-class-ref="org.apache.ojb.odmg.collections.DListEntry" + > + <inverse-foreignkey field-ref="dlistId"/> + </collection-descriptor> + </class-descriptor> + +<!-- THIS IS THE OJB DSET IMPLEMENTATION, DO NOT EDIT--> + <class-descriptor + class="org.apache.ojb.odmg.collections.DSetImpl" + table="OJB_DSET" + > + <field-descriptor + name="id" + column="ID" + jdbc-type="INTEGER" + primarykey="true" + autoincrement="true" + /> + <field-descriptor + name="size" + column="SIZE_" + jdbc-type="INTEGER" + /> + <collection-descriptor + name="elements" + element-class-ref="org.apache.ojb.odmg.collections.DSetEntry" + > + <inverse-foreignkey field-ref="dlistId"/> + </collection-descriptor> + </class-descriptor> + +<!-- THIS IS THE OJB DSET ENTRY IMPLEMENTATION, DO NOT EDIT--> + <class-descriptor + class="org.apache.ojb.odmg.collections.DSetEntry" + table="OJB_DSET_ENTRIES" + > + <field-descriptor + name="id" + column="ID" + jdbc-type="INTEGER" + primarykey="true" + autoincrement="true" + /> + <field-descriptor + name="dlistId" + column="DLIST_ID" + jdbc-type="INTEGER" + /> + <field-descriptor + name="position" + column="POSITION_" + jdbc-type="INTEGER" + /> + <field-descriptor + name="oid" + column="OID_" + jdbc-type="LONGVARBINARY" + conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion" + /> + </class-descriptor> + +<!-- THIS IS THE OJB DMAP IMPLEMENTATION, DO NOT EDIT--> + <class-descriptor + class="org.apache.ojb.odmg.collections.DMapImpl" + table="OJB_DMAP" + > + <field-descriptor + name="id" + column="ID" + jdbc-type="INTEGER" + primarykey="true" + autoincrement="true" + /> + <field-descriptor + name="size" + column="SIZE_" + jdbc-type="INTEGER" + /> + <collection-descriptor + name="entries" + element-class-ref="org.apache.ojb.odmg.collections.DMapEntry" + collection-class="org.apache.ojb.broker.util.collections.ManageableHashSet" + > + <inverse-foreignkey field-ref="dmapId"/> + </collection-descriptor> + </class-descriptor> + +<!-- THIS IS THE OJB DMAP ENTRY IMPLEMENTATION, DO NOT EDIT--> + <class-descriptor + class="org.apache.ojb.odmg.collections.DMapEntry" + table="OJB_DMAP_ENTRIES" + > + <field-descriptor + name="id" + column="ID" + jdbc-type="INTEGER" + primarykey="true" + autoincrement="true" + /> + <field-descriptor + name="dmapId" + column="DMAP_ID" + jdbc-type="INTEGER" + /> + <field-descriptor + name="keyOID" + column="KEY_OID" + jdbc-type="LONGVARBINARY" + conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion" + /> + <field-descriptor + name="valueOID" + column="VALUE_OID" + jdbc-type="LONGVARBINARY" + conversion="org.apache.ojb.broker.accesslayer.conversions.Object2ByteArrFieldConversion" + /> + </class-descriptor> + + + + <!-- END OF OJB INTERNAL MAPPINGS--> Added: cocoon/trunk/src/blocks/ojb/conf/repository_user.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/ojb/conf/repository_user.xml?view=auto&rev=125539 ============================================================================== --- (empty file) +++ cocoon/trunk/src/blocks/ojb/conf/repository_user.xml Tue Jan 18 11:27:17 2005 @@ -0,0 +1,61 @@ +<!-- OJB USER MAPPINGS START HERE --> +<!-- +#/* Copyright 2002-2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +--> + + <!-- Add your own mappings here --> + + + <class-descriptor class="org.apache.cocoon.ojb.samples.bean.Department" table="DEPARTMENT"> + <field-descriptor name="id" column="ID" jdbc-type="INTEGER" primarykey="true"/> + <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/> + </class-descriptor> + + <class-descriptor class="org.apache.cocoon.ojb.samples.bean.Employee" table="EMPLOYEE"> + <field-descriptor name="id" column="ID" jdbc-type="INTEGER" primarykey="true"/> + <field-descriptor name="departmentId" column="DEPARTMENT_ID" jdbc-type="INTEGER"/> + <field-descriptor name="name" column="NAME" jdbc-type="VARCHAR"/> + </class-descriptor> + + <!-- mappings for the QueryBean Block --> + <class-descriptor class="org.apache.cocoon.bean.query.SimpleLuceneCriterionBean" table="CRITERION"> + <field-descriptor name="id" column="ID" jdbc-type="BIGINT" primarykey="true" autoincrement="true"/> + <field-descriptor name="qid" column="Q_ID" jdbc-type="BIGINT" access="anonymous"/> + <field-descriptor name="field" column="C_FIELD" jdbc-type="VARCHAR"/> + <field-descriptor name="match" column="C_MATCH" jdbc-type="VARCHAR"/> + <field-descriptor name="term" column="C_TERM" jdbc-type="VARCHAR"/> + </class-descriptor> + + <class-descriptor class="org.apache.cocoon.bean.query.SimpleLuceneQueryBean" table="QUERY"> + <field-descriptor name="id" column="ID" jdbc-type="BIGINT" primarykey="true" autoincrement="true"/> + <field-descriptor name="user" column="USER_ID" jdbc-type="VARCHAR"/> + <field-descriptor name="date" column="Q_DATE" jdbc-type="TIMESTAMP" conversion="org.apache.ojb.broker.accesslayer.conversions.JavaDate2SqlTimestampFieldConversion"/> + <field-descriptor name="bool" column="Q_BOOL" jdbc-type="VARCHAR"/> + <field-descriptor name="name" column="Q_NAME" jdbc-type="VARCHAR"/> + <field-descriptor name="type" column="Q_TYPE" jdbc-type="VARCHAR"/> + <field-descriptor name="size" column="Q_SIZE" jdbc-type="BIGINT"/> + <collection-descriptor + name="criteria" + element-class-ref="org.apache.cocoon.bean.query.SimpleLuceneCriterionBean" + auto-retrieve="true" + auto-update="true" + auto-delete="true"> + <inverse-foreignkey field-ref="qid"/> + </collection-descriptor> + </class-descriptor> + + + <!-- END OF OJB USER MAPPINGS--> Modified: cocoon/trunk/src/blocks/querybean/WEB-INF/xconf/cocoon-querybean.xconf Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/WEB-INF/xconf/cocoon-querybean.xconf?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/WEB-INF/xconf/cocoon-querybean.xconf&r1=125538&p2=cocoon/trunk/src/blocks/querybean/WEB-INF/xconf/cocoon-querybean.xconf&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/WEB-INF/xconf/cocoon-querybean.xconf (original) +++ cocoon/trunk/src/blocks/querybean/WEB-INF/xconf/cocoon-querybean.xconf Tue Jan 18 11:27:17 2005 @@ -23,4 +23,5 @@ <!-- Include dependencies --> <include src="context://WEB-INF/xconf/cocoon-forms.xconf"/> <include src="context://WEB-INF/xconf/cocoon-lucene.xconf"/> + <include src="context://WEB-INF/xconf/cocoon-ojb.xconf"/> </components> Modified: cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java&r1=125538&p2=cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java (original) +++ cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneCriterionBean.java Tue Jan 18 11:27:17 2005 @@ -17,6 +17,7 @@ package org.apache.cocoon.bean.query; import java.io.IOException; +import java.io.Serializable; import java.io.StringReader; import java.util.Vector; import org.apache.cocoon.components.search.LuceneXMLIndexer; @@ -39,29 +40,28 @@ * This Bean is designed to be persistable. * </p> * - * @version CVS $Id: SimpleLuceneCriterionBean.java,v 1.1 2004/10/22 12:14:22 jeremy Exp $ */ -public class SimpleLuceneCriterionBean implements SimpleLuceneCriterion, Cloneable { +public class SimpleLuceneCriterionBean implements SimpleLuceneCriterion, Cloneable, Serializable { /** * The Bean's ID. */ - private Long mId; + protected Long id; /** * The Bean's index field to seach in. */ - private String mField; + protected String field; /** * The Bean's match value. */ - private String mMatch; + protected String match; /** * The Bean's search term. */ - private String mTerm; + protected String term; /** * Default constructor. @@ -78,9 +78,9 @@ * @param term the terms to search for */ public SimpleLuceneCriterionBean(String field, String match, String term) { - mField = field; - mMatch = match; - mTerm = term; + this.field = field; + this.match = match; + this.term = term; } public Object clone() throws CloneNotSupportedException { @@ -97,81 +97,81 @@ * @param analyzer The <code>org.apache.lucene.analysis.Analyzer</code> to use to extract the Terms from this Criterion */ public Query getQuery (Analyzer analyzer) { - String field = mField; + String f = this.field; Query query = null; - if (ANY_FIELD.equals (mField)) field = LuceneXMLIndexer.BODY_FIELD; + if (ANY_FIELD.equals(this.field)) f = LuceneXMLIndexer.BODY_FIELD; // extract Terms from the query string - TokenStream tokens = analyzer.tokenStream (field, new StringReader (mTerm)); - Vector words = new Vector (); + TokenStream tokens = analyzer.tokenStream(f, new StringReader (this.term)); + Vector words = new Vector(); Token token; while (true) { try { - token = tokens.next (); + token = tokens.next(); } catch (IOException e) { token = null; } if (token == null) break; - words.addElement (token.termText ()); + words.addElement(token.termText ()); } try { - tokens.close (); + tokens.close(); } catch (IOException e) {} // ignore // assemble the different matches - if (ANY_MATCH.equals (mMatch)) { - if (words.size () > 1) { - query = new BooleanQuery (); - for (int i = 0; i < words.size (); i++) { - ((BooleanQuery)query).add (new TermQuery (new Term (field, (String)words.elementAt(i))), false, false); + if (ANY_MATCH.equals(this.match)) { + if (words.size() > 1) { + query = new BooleanQuery(); + for (int i = 0; i < words.size(); i++) { + ((BooleanQuery)query).add(new TermQuery(new Term(f, (String)words.elementAt(i))), false, false); } - } else if (words.size () == 1) { - query = new TermQuery (new Term (field, (String)words.elementAt(0))); + } else if (words.size() == 1) { + query = new TermQuery(new Term(f, (String)words.elementAt(0))); } } - if (ALL_MATCH.equals (mMatch)) { - if (words.size () > 1) { - query = new BooleanQuery (); - for (int i = 0; i < words.size (); i++) { - ((BooleanQuery)query).add (new TermQuery (new Term (field, (String)words.elementAt(i))), true, false); + if (ALL_MATCH.equals(this.match)) { + if (words.size() > 1) { + query = new BooleanQuery(); + for (int i = 0; i < words.size(); i++) { + ((BooleanQuery)query).add(new TermQuery(new Term (f, (String)words.elementAt(i))), true, false); } - } else if (words.size () == 1) { - query = new TermQuery (new Term (field, (String)words.elementAt(0))); + } else if (words.size() == 1) { + query = new TermQuery(new Term(f, (String)words.elementAt(0))); } } - if (NOT_MATCH.equals (mMatch)) { - if (words.size () > 1) { - query = new BooleanQuery (); - for (int i = 0; i < words.size (); i++) { - ((BooleanQuery)query).add (new TermQuery (new Term (field, (String)words.elementAt(i))), true, true); + if (NOT_MATCH.equals(this.match)) { + if (words.size() > 1) { + query = new BooleanQuery(); + for (int i = 0; i < words.size(); i++) { + ((BooleanQuery)query).add(new TermQuery(new Term(f, (String)words.elementAt(i))), true, true); } - } else if (words.size () == 1) { - query = new TermQuery (new Term (field, (String)words.elementAt(0))); + } else if (words.size() == 1) { + query = new TermQuery(new Term(f, (String)words.elementAt(0))); } } - if (LIKE_MATCH.equals (mMatch)) { - if (words.size () > 1) { - query = new BooleanQuery (); - for (int i = 0; i < words.size (); i++) { - ((BooleanQuery)query).add (new FuzzyQuery (new Term (field, (String)words.elementAt(i))), false, false); + if (LIKE_MATCH.equals(this.match)) { + if (words.size() > 1) { + query = new BooleanQuery(); + for (int i = 0; i < words.size(); i++) { + ((BooleanQuery)query).add(new FuzzyQuery(new Term(f, (String)words.elementAt(i))), false, false); } - } else if (words.size () == 1) { - query = new FuzzyQuery (new Term (field, (String)words.elementAt(0))); + } else if (words.size() == 1) { + query = new FuzzyQuery(new Term(f, (String)words.elementAt(0))); } } - if (PHRASE_MATCH.equals (mMatch)) { - if (words.size () > 1) { - query = new PhraseQuery (); - ((PhraseQuery)query).setSlop (0); - for (int i = 0; i < words.size (); i++) { - ((PhraseQuery)query).add (new Term (field, (String)words.elementAt(i))); + if (PHRASE_MATCH.equals (this.match)) { + if (words.size() > 1) { + query = new PhraseQuery(); + ((PhraseQuery)query).setSlop(0); + for (int i = 0; i < words.size(); i++) { + ((PhraseQuery)query).add(new Term(f, (String)words.elementAt(i))); } - } else if (words.size () == 1) { - query = new TermQuery (new Term (field, (String)words.elementAt(0))); + } else if (words.size() == 1) { + query = new TermQuery(new Term(f, (String)words.elementAt(0))); } } return query; @@ -181,7 +181,7 @@ * Gets the prohibited status from the Criterion */ public boolean isProhibited () { - if (NOT_MATCH.equals (mMatch)) return true; + if (NOT_MATCH.equals(this.match)) return true; return false; } @@ -194,7 +194,7 @@ * @return the <code>Long</code> ID of the Bean. */ public Long getId() { - return mId; + return this.id; } /** @@ -203,7 +203,7 @@ * @param id the <code>Long</code> ID of the Bean. */ public void setId(Long id) { - mId = id; + this.id = id; } /** @@ -212,7 +212,7 @@ * @return the <code>String</code> field of the Bean. */ public String getField() { - return mField; + return this.field; } /** @@ -222,7 +222,7 @@ * @param field the <code>String</code> field of the Bean. */ public void setField(String field) { - mField = field; + this.field = field; } /** @@ -231,7 +231,7 @@ * @return the <code>String</code> match of the Bean. */ public String getMatch() { - return mMatch; + return this.match; } /** @@ -241,7 +241,7 @@ * @param match the <code>String</code> match of the Bean. */ public void setMatch(String match) { - mMatch = match; + this.match = match; } /** @@ -250,7 +250,7 @@ * @return the <code>String</code> term of the Bean. */ public String getTerm() { - return mTerm; + return this.term; } /** @@ -260,7 +260,7 @@ * @param term the <code>String</code> term of the Bean. */ public void setTerm(String term) { - mTerm = term; + this.term = term; } } Modified: cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java&r1=125538&p2=cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java (original) +++ cocoon/trunk/src/blocks/querybean/java/org/apache/cocoon/bean/query/SimpleLuceneQueryBean.java Tue Jan 18 11:27:17 2005 @@ -17,6 +17,7 @@ package org.apache.cocoon.bean.query; import java.io.IOException; +import java.io.Serializable; import java.util.Iterator; import java.util.List; import java.util.Date; @@ -43,7 +44,7 @@ * * @version CVS $Id: SimpleLuceneQueryBean.java,v 1.1 2004/10/22 12:14:22 jeremy Exp $ */ -public class SimpleLuceneQueryBean implements SimpleLuceneQuery, Cloneable { +public class SimpleLuceneQueryBean implements SimpleLuceneQuery, Cloneable, Serializable { /** * The DEFAULT_PAGE_SIZE of this bean. @@ -74,52 +75,52 @@ /** * The date this Query was created. */ - private Date mDate; + private Date date; /** * The Bean's list of Criteria. */ - private List mCriteria; + private List criteria; /** * The Bean's ID. */ - private Long mId; + private Long id; /** * The Bean's current page. */ - private Long mPage; + private Long page; /** * The Bean's page isze. */ - private Long mSize; + private Long size; /** * The Bean's hit count. */ - private Long mTotal; + private Long total; /** * The Bean's query boolean. */ - private String mBool; + private String bool; /** * The Bean's query name. */ - private String mName; + private String name; /** * The Bean's query type. */ - private String mType; + private String type; /** * The Bean's owner. */ - private String mUser; + private String user; /** * Default constructor. @@ -137,22 +138,22 @@ * @param query the terms to search for the generated <code>Criterion</code> */ public SimpleLuceneQueryBean(String type, String bool, String match, String field, String query) { - mName = "My Query"; - mType = type; - mBool = bool; - mSize = DEFAULT_PAGE_SIZE; - mPage = DEFAULT_PAGE; - mTotal = null; - mUser = null; - mId = null; - this.addCriterion (new SimpleLuceneCriterionBean (field, match, query)); + this.name = "My Query"; + this.type = type; + this.bool = bool; + this.size = DEFAULT_PAGE_SIZE; + this.page = DEFAULT_PAGE; + this.total = null; + this.user = null; + this.id = null; + this.addCriterion(new SimpleLuceneCriterionBean(field, match, query)); } public Object clone() throws CloneNotSupportedException { SimpleLuceneQueryBean query = (SimpleLuceneQueryBean)super.clone(); - query.setCriteria(new ArrayList(mCriteria.size())); - Iterator i = this.getCriteria().iterator (); - while (i.hasNext()) query.addCriterion((SimpleLuceneCriterionBean)((SimpleLuceneCriterionBean)i.next()).clone ()); + query.setCriteria(new ArrayList(this.criteria.size())); + Iterator it = this.getCriteria().iterator(); + while (it.hasNext()) query.addCriterion((SimpleLuceneCriterionBean)((SimpleLuceneCriterionBean)it.next()).clone()); return query; } @@ -175,19 +176,19 @@ * @exception IOException thrown when the searcher's directory cannot be found */ public List search (LuceneCocoonSearcher searcher) throws IOException, ProcessingException { - BooleanQuery query = new BooleanQuery (); - Iterator criteria = mCriteria.iterator (); + BooleanQuery query = new BooleanQuery(); + Iterator it = criteria.iterator(); boolean required = false; - if (AND_BOOL.equals (mBool)) required = true; - while (criteria.hasNext ()) { - SimpleLuceneCriterion criterion = (SimpleLuceneCriterion)criteria.next (); - Query subquery = criterion.getQuery (searcher.getAnalyzer ()); - query.add (subquery, required, criterion.isProhibited ()); + if (AND_BOOL.equals(this.bool)) required = true; + while (it.hasNext()) { + SimpleLuceneCriterion criterion = (SimpleLuceneCriterion)it.next(); + Query subquery = criterion.getQuery (searcher.getAnalyzer()); + query.add(subquery, required, criterion.isProhibited()); } - Hits hits = searcher.search (query); - mTotal = new Long (hits.length ()); - mDate = new Date (); - return page (hits); + Hits hits = searcher.search(query); + this.total = new Long (hits.length()); + this.date = new Date(); + return page(hits); } /** @@ -198,23 +199,23 @@ * @exception IOException thrown when the searcher's directory cannot be found */ private List page (Hits hits) throws java.io.IOException { - ArrayList results = new ArrayList (); - int start = getPage().intValue () * getSize().intValue (); - if (start > mTotal.intValue ()) start = mTotal.intValue (); - int end = start + getSize().intValue (); - if (end > mTotal.intValue ()) end = mTotal.intValue (); + ArrayList results = new ArrayList(); + int start = getPage().intValue() * getSize().intValue(); + if (start > this.total.intValue()) start = this.total.intValue(); + int end = start + getSize().intValue(); + if (end > this.total.intValue()) end = this.total.intValue(); for (int i = start; i < end; i++) { - HashMap hit = new HashMap (); - hit.put (SCORE_FIELD, new Float (hits.score (i))); - hit.put (INDEX_FIELD, new Long (i)); - Document doc = hits.doc (i); - for (Enumeration e = doc.fields (); e.hasMoreElements (); ) { - Field field = (Field)e.nextElement (); - if (field.name ().equals (SCORE_FIELD)) continue; - if (field.name ().equals (INDEX_FIELD)) continue; - hit.put (field.name (), field.stringValue ()); + HashMap hit = new HashMap(); + hit.put(SCORE_FIELD, new Float(hits.score (i))); + hit.put(INDEX_FIELD, new Long(i)); + Document doc = hits.doc(i); + for (Enumeration e = doc.fields(); e.hasMoreElements(); ) { + Field field = (Field)e.nextElement(); + if (field.name().equals(SCORE_FIELD)) continue; + if (field.name().equals(INDEX_FIELD)) continue; + hit.put(field.name(), field.stringValue()); } - results.add (hit); + results.add(hit); } return (results); } @@ -225,7 +226,7 @@ * @return the <code>Long</code> ID of the Bean. */ public Long getId() { - return mId; + return this.id; } /** @@ -234,7 +235,7 @@ * @param id the <code>Long</code> ID of the Bean. */ public void setId(Long id) { - mId = id; + this.id = id; } /** @@ -243,7 +244,7 @@ * @return the <code>String</code> name of the Bean. */ public String getName() { - return mName; + return this.name; } /** @@ -252,7 +253,7 @@ * @param name the <code>String</code> name of the Bean. */ public void setName(String name) { - mName = name; + this.name = name; } /** @@ -261,7 +262,7 @@ * @return the <code>String</code> type of the Bean. */ public String getType() { - return mType; + return this.type; } /** @@ -270,7 +271,7 @@ * @param type the <code>String</code> type of the Bean. */ public void setType(String type) { - mType = type; + this.type = type; } /** @@ -279,7 +280,7 @@ * @return the <code>String</code> boolean of the Bean. */ public String getBool() { - return mBool; + return this.bool; } /** @@ -289,7 +290,7 @@ * @param bool the <code>String</code> boolean of the Bean. */ public void setBool(String bool) { - mBool = bool; + this.bool = bool; } /** @@ -298,7 +299,7 @@ * @return the <code>String</code> owner of the Bean. */ public String getUser() { - return mUser; + return this.user; } /** @@ -307,7 +308,7 @@ * @param user the <code>String</code> owner of the Bean. */ public void setUser(String user) { - mUser = user; + this.user = user; } /** @@ -316,10 +317,10 @@ * @return the <code>Long</code> page size of the Bean. */ public Long getSize() { - if (mSize == null) { + if (this.size == null) { return DEFAULT_PAGE_SIZE; } else { - return mSize; + return this.size; } } @@ -330,7 +331,7 @@ * @param size the <code>Long</code> page size of the Bean. */ public void setSize(Long size) { - mSize = size; + this.size = size; } /** @@ -339,10 +340,10 @@ * @return the <code>Long</code> page index of the Bean. */ public Long getPage() { - if (mPage == null) { + if (this.page == null) { return DEFAULT_PAGE; } else { - return mPage; + return this.page; } } @@ -353,7 +354,7 @@ * @param page the <code>Long</code> page index of the Bean. */ public void setPage(Long page) { - mPage = page; + this.page = page; } /** @@ -362,7 +363,7 @@ * @return the <code>Long</code> hit count of the Bean. */ public Long getTotal() { - return mTotal; + return this.total; } /** @@ -371,7 +372,7 @@ * @param total the <code>Long</code> hit count of the Bean. */ public void setTotal(Long total) { - mTotal = total; + this.total = total; } /** @@ -380,7 +381,7 @@ * @return the <code>Date</code> of the Bean. */ public Date getDate() { - return mDate; + return this.date; } /** @@ -389,7 +390,7 @@ * @param date the <code>Date</code> inception date of the Bean. */ public void setDate(Date date) { - mDate = date; + this.date = date; } /** @@ -398,7 +399,7 @@ * @return the <code>List</code> of Bean Query criteria. */ public List getCriteria() { - return mCriteria; + return this.criteria; } /** @@ -407,7 +408,7 @@ * @param criteria the <code>List</code> of Bean Query criteria. */ public void setCriteria(List criteria) { - mCriteria = criteria; + this.criteria = criteria; } /** @@ -416,8 +417,8 @@ * @param criterion the <code>SimpleLuceneCriterionBean</code> to add to the Bean. */ public void addCriterion(SimpleLuceneCriterionBean criterion) { - if (mCriteria == null) mCriteria = new ArrayList (); - mCriteria.add (criterion); + if (this.criteria == null) this.criteria = new ArrayList(); + this.criteria.add(criterion); } /** @@ -426,7 +427,7 @@ * @param criterion the <code>SimpleLuceneCriterionBean</code> to remove from the Bean. */ public void removeCriterion(SimpleLuceneCriterionBean criterion) { - if (mCriteria != null) mCriteria.remove (criterion); + if (this.criteria != null) this.criteria.remove(criterion); } } Modified: cocoon/trunk/src/blocks/querybean/samples/flow/QueryFavourites.js Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/flow/QueryFavourites.js?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/samples/flow/QueryFavourites.js&r1=125538&p2=cocoon/trunk/src/blocks/querybean/samples/flow/QueryFavourites.js&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/samples/flow/QueryFavourites.js (original) +++ cocoon/trunk/src/blocks/querybean/samples/flow/QueryFavourites.js Tue Jan 18 11:27:17 2005 @@ -14,36 +14,97 @@ limitations under the License. */ +importClass(Packages.org.apache.cocoon.ojb.broker.components.PBFactory); +importClass(Packages.org.apache.ojb.broker.query.Criteria); +importClass(Packages.org.apache.ojb.broker.query.QueryByCriteria); +importPackage(Packages.org.apache.cocoon.bean.query); + // QueryFavourites constructor function QueryFavourites(user) { this._user = user; - // to be implemented using Apache OJB + this._factory = cocoon.getComponent(PBFactory.ROLE); } // add a Query to the QueryFavourites QueryFavourites.prototype.add = function(query) { - // to be implemented using Apache OJB + query.user = this._user; + query.date = new java.util.Date(); + var broker = null; + try { + broker = this._factory.defaultPersistenceBroker(); + broker.beginTransaction(); + broker.store(query); + broker.commitTransaction(); + } catch (e) { + cocoon.log.error(e); + if(broker != null) broker.abortTransaction(); + } finally { + if (broker != null) broker.close(); + } } // remove a Query from the QueryFavourites QueryFavourites.prototype.remove = function(id) { - // to be implemented using Apache OJB + var broker = null; + var result = null; + try { + broker = this._factory.defaultPersistenceBroker(); + var criteria = criteria = new Criteria(); + criteria.addEqualTo("id", new java.lang.Long(id)); + //criteria.addEqualTo("user", new String(this._user)); + var query = new QueryByCriteria(SimpleLuceneQueryBean, criteria); + result = broker.getObjectByQuery(query); + broker.beginTransaction(); + broker["delete"](result); + broker.commitTransaction(); + } catch (e) { + cocoon.log.error(e); + throw("error.no.favourite"); + } finally { + if (broker != null) broker.close(); + } + return result; } // get a Query from the QueryFavourites using it's ID QueryFavourites.prototype.get = function(id) { - // to be implemented using Apache OJB - throw("error.no.favourite"); + var broker = null; + var result = null; + try { + broker = this._factory.defaultPersistenceBroker(); + var criteria = criteria = new Criteria(); + criteria.addEqualTo("id", new java.lang.Long(id)); + //criteria.addEqualTo("user", new String(this._user)); + var query = new QueryByCriteria(SimpleLuceneQueryBean, criteria); + result = broker.getObjectByQuery(query); + } catch (e) { + cocoon.log.error(e); + throw("error.no.favourite"); + } finally { + if (broker != null) broker.close(); + } + return result; } // get a list of Queries from the QueryFavourites QueryFavourites.prototype.list = function() { - // to be implemented using Apache OJB - return new java.util.ArrayList(1); + var broker = null; + var result = null; + try { + broker = this._factory.defaultPersistenceBroker(); + var criteria = criteria = new Criteria(); + criteria.addEqualTo("user", new String(this._user)); + var query = new QueryByCriteria(SimpleLuceneQueryBean, criteria); + query.addOrderByAscending("date"); + result = broker.getCollectionByQuery(query); + } finally { + if (broker != null) broker.close(); + } + return result; } // close the QueryFavourites QueryFavourites.prototype.close = function() { - // to be implemented using Apache OJB + cocoon.releaseComponent(this._factory); } Modified: cocoon/trunk/src/blocks/querybean/samples/flow/QueryHistory.js Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/flow/QueryHistory.js?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/samples/flow/QueryHistory.js&r1=125538&p2=cocoon/trunk/src/blocks/querybean/samples/flow/QueryHistory.js&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/samples/flow/QueryHistory.js (original) +++ cocoon/trunk/src/blocks/querybean/samples/flow/QueryHistory.js Tue Jan 18 11:27:17 2005 @@ -59,8 +59,8 @@ } // get a Query from the QueryHistory, using it's ID, always returns a copy -QueryHistory.prototype.get = function(id) { - var clone, item; +QueryHistory.prototype.get = function(id, clone) { + var item; try { item = this._history.get(parseInt(id)); } catch (e1) { @@ -68,12 +68,15 @@ throw("error.no.history"); } try { - clone = item.clone(); + if (clone) { + return item.clone(); + } else { + return item; + } } catch (e2) { cocoon.log.error(e2); throw("items stored in history need to be Cloneable"); } - return clone; } // move a Query to the top of the QueryHistory list Modified: cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js&r1=125538&p2=cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js (original) +++ cocoon/trunk/src/blocks/querybean/samples/flow/QuerySearcher.js Tue Jan 18 11:27:17 2005 @@ -69,10 +69,10 @@ } } -// perform a page using a Query +// perform a page using a Query from history QuerySearcher.prototype.page = function(page, id, history) { var p; - var query = history.get(id); + var query = history.get(id, true); if (query != null) { try { p = new java.lang.Long(page); Modified: cocoon/trunk/src/blocks/querybean/samples/flow/query.js Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/flow/query.js?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/samples/flow/query.js&r1=125538&p2=cocoon/trunk/src/blocks/querybean/samples/flow/query.js&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/samples/flow/query.js (original) +++ cocoon/trunk/src/blocks/querybean/samples/flow/query.js Tue Jan 18 11:27:17 2005 @@ -36,27 +36,27 @@ } // display the User's Favourite Searches -/*function showFavourites() { +function showFavourites() { var favourites = null; try { favourites = new QueryFavourites(cocoon.parameters["user-id"]); cocoon.sendPage(cocoon.parameters["screen"], {queries: favourites.list()}); - } catch (error) { - cocoon.log.error(error); - cocoon.sendPage("screen/error", {message: error}); + /*} catch (error) { + cocoon.log.error("BLAH:" + error); + cocoon.sendPage("screen/error", {message: error});*/ } finally { if (favourites != null) favourites.close(); } -}*/ +} // add a history item to the User's Favourite Searches -/*function addFavourite() { +function addFavourite() { var history = new QueryHistory(cocoon.parameters["history"]); var favourites = null; try { favourites = new QueryFavourites(cocoon.parameters["user-id"]); - var query = history.get(cocoon.parameters["hid"]); + var query = history.get(cocoon.parameters["hid"], false); if (query != null) { favourites.add(query); } @@ -67,10 +67,10 @@ } finally { if (favourites != null) favourites.close(); } -}*/ +} // add an item from the User's Favourite Searches, using it's ID -/*function removeFavourite() { +function removeFavourite() { var favourites = null; try { favourites = new QueryFavourites(cocoon.parameters["user-id"]); @@ -82,7 +82,7 @@ } finally { if (favourites != null) favourites.close(); } -}*/ +} // perform searches function doSearch() { @@ -109,7 +109,7 @@ return; } } else { // editing a Query from history - var query = history.get(cocoon.parameters["hid"]); + var query = history.get(cocoon.parameters["hid"], true); if (edit(query)) { result = searcher.search(query, history); } else { Modified: cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml&r1=125538&p2=cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml (original) +++ cocoon/trunk/src/blocks/querybean/samples/i18n/messages_en.xml Tue Jan 18 11:27:17 2005 @@ -27,7 +27,7 @@ <message key="field.link.label">Document Link</message> <message key="field.p.label">Document Paragraph</message> <message key="[EMAIL PROTECTED]">Author Name</message> - <message key="field.question.label">FAQ Question </message> + <message key="field.question.label">FAQ</message> <message key="[EMAIL PROTECTED]">Level 1 Section Title</message> <message key="[EMAIL PROTECTED]">Level 2 Section Title</message> <message key="field.source.label">Sample Source Code</message> @@ -80,6 +80,21 @@ <message key="history.search.label">Search</message> <message key="history.title.label">Title</message> <message key="history.cleared.note">Your query history has been cleared.</message> + <message key="history.save.label">Save</message> + <message key="history.save.hint">save this query in your favourites</message> + <!-- displaying favourites --> + <message key="favourites.page.title">Search Favourites</message> + <message key="favourites.queries.title">Queries</message> + <message key="favourites.date.label">Date</message> + <message key="favourites.query.label">Query</message> + <message key="favourites.title.label">Title</message> + <message key="favourites.search.label">Search</message> + <message key="favourites.search.hint">perform a search using this favourite</message> + <message key="favourites.delete.label">Delete</message> + <message key="favourites.delete.hint">permanently delete this favourite</message> + <message key="cancel.save.note">you cancelled your save</message> + <message key="history.title.label">Title</message> + <message key="search.fave.hint">one of your favourite searches</message> <!-- linking --> <message key="link.home.hint">the query bean samples home page</message> <message key="link.home.label">Home</message> Added: cocoon/trunk/src/blocks/querybean/samples/resources/images/fave.jpg Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/resources/images/fave.jpg?view=auto&rev=125539 ============================================================================== Binary file. No diff available. Added: cocoon/trunk/src/blocks/querybean/samples/screens/favourites.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/screens/favourites.xml?view=auto&rev=125539 ============================================================================== --- (empty file) +++ cocoon/trunk/src/blocks/querybean/samples/screens/favourites.xml Tue Jan 18 11:27:17 2005 @@ -0,0 +1,92 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright 1999-2004 The Apache Software Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<!-- $Id: history.xml 30942 2004-07-29 20:16:54Z vgritsenko $ --> +<page + xmlns:jx="http://apache.org/cocoon/templates/jx/1.0" + xmlns:i18n="http://apache.org/cocoon/i18n/2.1" + > + <title><i18n:text i18n:catalogue="local">favourites.page.title</i18n:text></title> + <content> + <p class="links"> + <a href="simple.html" title="local:new.simple.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">new.simple.label</i18n:text></a> + <span> | </span> + <a href="advanced.html" title="local:new.advanced.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">new.advanced.label</i18n:text></a> + <span> | </span> + <a href="history.html" title="local:search.history.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">search.history.title</i18n:text></a> + <span> | </span> + <a href="welcome" title="local:link.home.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">link.home.label</i18n:text></a> + </p> + <jx:choose> + <jx:when test="${queries!=null}"> + <p class="favourites.title"> + <i18n:text i18n:catalogue="local">favourites.queries.title</i18n:text>: + <span class="favourites.count"><jx:out value="${queries.size()}"/></span> + </p> + <table width="100%" class="query.favourites" summary="Query Favourites"> + <tr> + <th align="left"><i18n:text i18n:catalogue="local">favourites.date.label</i18n:text></th> + <th align="left"><i18n:text i18n:catalogue="local">favourites.title.label</i18n:text></th> + <th align="left"><i18n:text i18n:catalogue="local">favourites.query.label</i18n:text></th> + </tr> + <jx:forEach var="item" items="${queries}"> + <tr valign="top"> + <td class="favourites.date"> + <jx:formatDate value="${item.date}" type="date" dateStyle="short"/> + </td><td class="favourites.name"> + <a href="${item.type}.html?fid=${item.id}" title="local:favourites.search.hint" i18n:attr="title">${item.name}</a> + </td><td class="query.description"> + <i18n:text i18n:catalogue="local">search.subject.title</i18n:text> + <span class="query.bool" title="local:query.bool.hint" i18n:attr="title"> + <i18n:text i18n:catalogue="local">search.${item.bool}.bool</i18n:text> + </span> + <span class="query.criteria"> + <jx:choose> + <jx:when test="${item.criteria.size() == 1}"> + <i18n:text i18n:catalogue="local">search.criterion.label</i18n:text>: + </jx:when> + <jx:otherwise> + <i18n:text i18n:catalogue="local">search.criteria.label</i18n:text>: + </jx:otherwise> + </jx:choose> + <ul> + <jx:forEach var="crit" items="${item.criteria}"> + <li> + <span class="query.criterion-field" title="local:criterion.field.hint" i18n:attr="title"> + <i18n:text i18n:catalogue="local">search.${crit.field}.field</i18n:text> + </span> + <span class="query.criterion-match" title="local:criterion.match.hint" i18n:attr="title"> + <i18n:text i18n:catalogue="local">search.${crit.match}.match</i18n:text> + </span> + <span class="query.criterion-value" title="local:criterion.value.hint" i18n:attr="title">â${crit.term}â</span> + </li> + </jx:forEach> + </ul> + </span> + </td><td> + <a href="remove-favourite.html?fid=${item.id}" title="local:favourites.delete.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">favourites.delete.label</i18n:text></a> + </td> + </tr> + </jx:forEach> + </table> + </jx:when> + <jx:otherwise> + <i18n:text i18n:catalogue="local">favourites.none</i18n:text> + </jx:otherwise> + </jx:choose> + </content> +</page> Modified: cocoon/trunk/src/blocks/querybean/samples/screens/history.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/screens/history.xml?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/samples/screens/history.xml&r1=125538&p2=cocoon/trunk/src/blocks/querybean/samples/screens/history.xml&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/samples/screens/history.xml (original) +++ cocoon/trunk/src/blocks/querybean/samples/screens/history.xml Tue Jan 18 11:27:17 2005 @@ -22,19 +22,21 @@ > <title><i18n:text i18n:catalogue="local">history.page.title</i18n:text></title> <content> + <p class="links"> + <a href="simple.html" title="local:new.simple.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">new.simple.label</i18n:text></a> + <span> | </span> + <a href="advanced.html" title="local:new.advanced.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">new.advanced.label</i18n:text></a> + <span> | </span> + <a href="favourites.html" title="local:search.favourites.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">search.favourites.title</i18n:text></a> + <span> | </span> + <a href="welcome" title="local:link.home.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">link.home.label</i18n:text></a> + </p> <jx:choose> <jx:when test="${history != null && history.size()!=0}"> <p class="history.title"> <i18n:text i18n:catalogue="local">history.queries.title</i18n:text>: <span class="history.count"><jx:out value="${history.size()}"/></span> </p> - <p class="links"> - <a href="simple.html" title="local:new.simple.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">new.simple.label</i18n:text></a> - <span> | </span> - <a href="advanced.html" title="local:new.advanced.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">new.advanced.label</i18n:text></a> - <span> | </span> - <a href="../query/" title="local:link.home.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">link.home.label</i18n:text></a> - </p> <table width="100%" class="query.history" summary="Query History"> <tr> <th align="left"><i18n:text i18n:catalogue="local">history.date.label</i18n:text></th> @@ -49,7 +51,7 @@ <jx:formatDate value="${item.query.date}" type="time"/> </jx:if> </td><td class="history.name"> - ${item.query.name} + <a href="${item.query.type}.html?hid=${item.id}&page=${item.query.page}" title="local:history.search.hint" i18n:attr="title">${item.query.name}</a> </td><td class="query.description"> <i18n:text i18n:catalogue="local">search.subject.title</i18n:text> <span class="query.bool" title="local:query.bool.hint" i18n:attr="title"> @@ -64,30 +66,36 @@ <i18n:text i18n:catalogue="local">search.criteria.label</i18n:text>: </jx:otherwise> </jx:choose> + <ul> + <jx:forEach var="crit" items="${item.query.criteria}"> + <li> + <span class="query.criterion-field" title="local:criterion.field.hint" i18n:attr="title"> + <i18n:text i18n:catalogue="local">search.${crit.field}.field</i18n:text> + </span> + <span class="query.criterion-match" title="local:criterion.match.hint" i18n:attr="title"> + <i18n:text i18n:catalogue="local">search.${crit.match}.match</i18n:text> + </span> + <span class="query.criterion-value" title="local:criterion.value.hint" i18n:attr="title">â${crit.term}â</span> + </li> + </jx:forEach> + </ul> </span> - <ul class="query.criteria"> - <jx:forEach var="crit" items="${item.query.criteria}"> - <li> - <span class="query.criterion-field" title="local:criterion.field.hint" i18n:attr="title"> - <i18n:text i18n:catalogue="local">search.${crit.field}.field</i18n:text> - </span> - <span class="query.criterion-match" title="local:criterion.match.hint" i18n:attr="title"> - <i18n:text i18n:catalogue="local">search.${crit.match}.match</i18n:text> - </span> - <span class="query.criterion-value" title="local:criterion.value.hint" i18n:attr="title">â${crit.term}â</span> - </li> - </jx:forEach> - </ul> </td><td class="query.hitcount"> ${item.query.total} </td><td> - <a href="${item.query.type}.html?hid=${item.id}&page=${item.query.page}" title="local:history.search.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">history.search.label</i18n:text></a> - </td><td> <a href="${item.query.type}.html?hid=${item.id}" title="local:history.edit.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">history.edit.label</i18n:text></a> + </td><td align="center"> + <jx:choose> + <jx:when test="${item.query.id == null}"> + <a href="add-favourite.html?hid=${item.id}" title="local:history.save.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">history.save.label</i18n:text></a> + </jx:when> + <jx:otherwise><span title="local:search.fave.hint" i18n:attr="title"><img src="images/fave.jpg" alt="favourite"/></span></jx:otherwise> + </jx:choose> </td> </tr> </jx:forEach> </table> + <a href="clear-history.html"><i18n:text i18n:catalogue="local">search.clearhistory.title</i18n:text></a> </jx:when> <jx:otherwise> <p class="history.queries-none"><i18n:text i18n:catalogue="local">history.none</i18n:text></p> Modified: cocoon/trunk/src/blocks/querybean/samples/screens/index.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/screens/index.xml?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/samples/screens/index.xml&r1=125538&p2=cocoon/trunk/src/blocks/querybean/samples/screens/index.xml&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/samples/screens/index.xml (original) +++ cocoon/trunk/src/blocks/querybean/samples/screens/index.xml Tue Jan 18 11:27:17 2005 @@ -40,13 +40,14 @@ <p>You can view, reuse, and re-edit your previous queries:</p> <ul> <li><a href="history.html">History</a>: your search history.</li> + <li><a href="favourites.html">Favourites</a>: your saved searches.</li> </ul> <h3>What it does.</h3> <p>Allows you to assemble complex Lucene Queries without having to use the Lucene Query Language. Keeps a list of the queries you have performed in it's history (for as long as your Session lasts). Allows you to re-use and edit them.</p> <h3>How does it work?</h3> - <p>Through a combination of FlowScript (controller), CForms and JXTemplate (view), Beans (model), i18n and the CocoonLuceneSearcher component.</p> + <p>Through a combination of FlowScript (controller), CForms and JXTemplate (view), Beans and OJB (model), i18n and the CocoonLuceneSearcher component.</p> <h4>FlowScript</h4> The FlowScript controls the flow of the application, it instansiates Beans, manages the History, chooses which Forms and Screens to display, controls the CocoonLuceneSearcher. <h4>CForms</h4> @@ -60,7 +61,7 @@ The history is in the form of a <code>List</code> of Query Beans. </p> <h4>Beans</h4> - <p>The Beans represent an abstract (and potentially persistable) representation of your Query.</p> + <p>The Beans represent an abstract (and persistable) representation of your Query.</p> <h4>i18n</h4> <p>i18n is used to hold all of the display strings used by the Application. Form labels and hints, Query descriptions, Screen labels and hints, Error messages etc.</p> <h4>CocoonLuceneSearcher</h4> @@ -81,7 +82,7 @@ </p><p> Once your CForms selection-lists are setup, you will want to edit the existing i18n message keys in <a href="i18n/messages_en.xml?cocoon-view=pretty-content">i18n/messages_en.xml</a> and/or provide new message files in your own language. </p><p> - The last thing you may choose to do, is to supply some CSS for the screens. The <a href="screens/history.xml?cocoon-view=pretty-content">history</a> and <a href="screens/results.xml?cocoon-view=pretty-content">results</a> screens supply what is hopefully a rich enough + The last thing you may choose to do, is to supply some CSS for the screens. The <a href="screens/history.xml?cocoon-view=pretty-content">history</a>, <a href="screens/favourites.xml?cocoon-view=pretty-content">favourites</a> and <a href="screens/results.xml?cocoon-view=pretty-content">results</a> screens supply what is hopefully a rich enough collection of CSS Classes, have a look at the HTML output to see what there is.</p> <h4>New Forms</h4> @@ -97,7 +98,7 @@ The <code>bool</code> property of the QueryBean specifies how the multiple criteria are combined. The <code>field</code> property of the CriterionBean specifies which Index Field to search, the <code>match</code> property specifies how to match that field and the <code>value</code> property, is the string from which Terms are extracted. All the rest is candy. </p> <h4>Persistance</h4> - <p>Both the Query and Criterion Beans were designed to be Persistable using one of the Object-Relational mapping tools like Hibernate, JDO, ORO etc. (This is why they have the unused <code>id</code> property).</p> + <p>Both the Query and Criterion Beans were designed to be Persistable using one of the Object-Relational mapping tools like Hibernate, OJB etc. This sample currently uses the HSQLDB instance built in to Cocoon.</p> </content> </page> Modified: cocoon/trunk/src/blocks/querybean/samples/screens/results.xml Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/screens/results.xml?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/samples/screens/results.xml&r1=125538&p2=cocoon/trunk/src/blocks/querybean/samples/screens/results.xml&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/samples/screens/results.xml (original) +++ cocoon/trunk/src/blocks/querybean/samples/screens/results.xml Tue Jan 18 11:27:17 2005 @@ -37,20 +37,20 @@ <i18n:text i18n:catalogue="local">search.criteria.label</i18n:text>: </jx:otherwise> </jx:choose> + <ul> + <jx:forEach var="item" items="${result.query.criteria}"> + <li> + <span class="query.criterion-field" title="local:criterion.field.hint" i18n:attr="title"> + <i18n:text i18n:catalogue="local">search.${item.field}.field</i18n:text> + </span> + <span class="query.criterion-match" title="local:criterion.match.hint" i18n:attr="title"> + <i18n:text i18n:catalogue="local">search.${item.match}.match</i18n:text> + </span> + <span class="query.criterion-value" title="local:criterion.value.hint" i18n:attr="title">â${item.term}â.</span> + </li> + </jx:forEach> + </ul> </span> - <ul class="query.criteria"> - <jx:forEach var="item" items="${result.query.criteria}"> - <li> - <span class="query.criterion-field" title="local:criterion.field.hint" i18n:attr="title"> - <i18n:text i18n:catalogue="local">search.${item.field}.field</i18n:text> - </span> - <span class="query.criterion-match" title="local:criterion.match.hint" i18n:attr="title"> - <i18n:text i18n:catalogue="local">search.${item.match}.match</i18n:text> - </span> - <span class="query.criterion-value" title="local:criterion.value.hint" i18n:attr="title">â${item.term}â.</span> - </li> - </jx:forEach> - </ul> </p> <!-- links --> <p class="links"> @@ -58,11 +58,20 @@ <span> | </span> <a href="history.html" title="local:search.history.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">search.history.title</i18n:text></a> <span> | </span> + <a href="favourites.html" title="local:search.favourites.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">search.favourites.title</i18n:text></a> + <span> | </span> <a href="simple.html" title="local:new.simple.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">new.simple.label</i18n:text></a> <span> | </span> <a href="advanced.html" title="local:new.advanced.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">new.advanced.label</i18n:text></a> <span> | </span> <a href="welcome" title="local:link.home.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">link.home.label</i18n:text></a> + <span> | </span> + <jx:choose> + <jx:when test="${result.query.id == null}"> + <a href="add-favourite.html?hid=${result.id}" title="local:history.save.hint" i18n:attr="title"><i18n:text i18n:catalogue="local">history.save.label</i18n:text></a> + </jx:when> + <jx:otherwise><span title="local:search.fave.hint" i18n:attr="title"><img src="images/fave.jpg" alt="favourite"/></span></jx:otherwise> + </jx:choose> </p> <!-- paging --> <title><i18n:text i18n:catalogue="local">search.section.title</i18n:text></title> Modified: cocoon/trunk/src/blocks/querybean/samples/sitemap.xmap Url: http://svn.apache.org/viewcvs/cocoon/trunk/src/blocks/querybean/samples/sitemap.xmap?view=diff&rev=125539&p1=cocoon/trunk/src/blocks/querybean/samples/sitemap.xmap&r1=125538&p2=cocoon/trunk/src/blocks/querybean/samples/sitemap.xmap&r2=125539 ============================================================================== --- cocoon/trunk/src/blocks/querybean/samples/sitemap.xmap (original) +++ cocoon/trunk/src/blocks/querybean/samples/sitemap.xmap Tue Jan 18 11:27:17 2005 @@ -154,6 +154,10 @@ <map:redirect-to uri="cocoon:/screen/index"/> </map:match> + <map:match pattern="images/**"> + <map:read src="resources/images/{1}"/> + </map:match> + <!-- create the index --> <map:match pattern="create.html"> @@ -183,37 +187,43 @@ <!-- clear history --> <map:match pattern="clear-history.html"> <map:call function="clearHistory"> - <map:parameter name="screen" value="screen/clear-history"/> + <map:parameter name="screen" value="screen/history"/> <map:parameter name="history" value="{global:history}"/> </map:call> </map:match> - <!-- list favourites + <!-- list favourites --> <map:match pattern="favourites.html"> <map:call function="showFavourites"> <map:parameter name="screen" value="screen/favourites"/> - <map:parameter name="user-id" value="{session-context:authentication/authentication/ID}"/> + <map:parameter name="user-id" value="anon"/> + <!-- NB. this value is for testing .... it is more likely you would use a value like the commented out one below --> + <!--<map:parameter name="user-id" value="{session-context:authentication/authentication/ID}"/>--> </map:call> - </map:match> --> + </map:match> - <!-- add a history item to the favourites, using the history ID + <!-- add a history item to the favourites, using the history ID --> <map:match pattern="add-favourite.html"> <map:call function="addFavourite"> <map:parameter name="screen" value="screen/favourites"/> - <map:parameter name="user-id" value="{session-context:authentication/authentication/ID}"/> + <map:parameter name="user-id" value="anon"/> + <!-- NB. this value is for testing .... it is more likely you would use a value like the commented out one below --> + <!--<map:parameter name="user-id" value="{session-context:authentication/authentication/ID}"/>--> <map:parameter name="hid" value="{request-param:hid}"/> <map:parameter name="history" value="{global:history}"/> </map:call> - </map:match> --> + </map:match> - <!-- remove an item from the favourites, using the favourite ID + <!-- remove an item from the favourites, using the favourite ID --> <map:match pattern="remove-favourite.html"> <map:call function="removeFavourite"> <map:parameter name="screen" value="screen/favourites"/> - <map:parameter name="user-id" value="{session-context:authentication/authentication/ID}"/> + <map:parameter name="user-id" value="anon"/> + <!-- NB. this value is for testing .... it is more likely you would use a value like the commented out one below --> + <!--<map:parameter name="user-id" value="{session-context:authentication/authentication/ID}"/>--> <map:parameter name="fid" value="{request-param:fid}"/> </map:call> - </map:match> --> + </map:match> <!-- do the searches --> <map:match pattern="*.html">