Index: lams_central/conf/language/lams/ApplicationResources.properties
===================================================================
diff -u -r1cf90e56ebe02f3b378f08d40a73871d37eb97bf -r3538b4ae424da479962e98b7528ad22b44cdd368
--- lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 1cf90e56ebe02f3b378f08d40a73871d37eb97bf)
+++ lams_central/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -215,5 +215,11 @@
button.select.another.importfile =Select Another File To Import
error.forgot.password.incorrect.key =The request key is incorrect or has already been used. Please click the "Forgot your Password" link again to make a new request.
-
+textsearch.heading =Text that...
+textsearch.all.words =has all these words:
+textsearch.phrase =has this exact wording or phrase:
+textsearch.any.words =has one or more of these words:
+textsearch.excluded.words =has none of these unwanted words:
+textsearch.save=Save
+textsearch.cancel=Cancel
#======= End labels: Exported 208 labels for en AU =====
Index: lams_central/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
diff -u -r1cf90e56ebe02f3b378f08d40a73871d37eb97bf -r3538b4ae424da479962e98b7528ad22b44cdd368
--- lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 1cf90e56ebe02f3b378f08d40a73871d37eb97bf)
+++ lams_central/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -215,5 +215,11 @@
button.select.another.importfile =Select Another File To Import
error.forgot.password.incorrect.key =The request key is incorrect or has already been used. Please click the "Forgot your Password" link again to make a new request.
-
+textsearch.heading =Text that...
+textsearch.all.words =has all these words:
+textsearch.phrase =has this exact wording or phrase:
+textsearch.any.words =has one or more of these words:
+textsearch.excluded.words =has none of these unwanted words:
+textsearch.save=Save
+textsearch.cancel=Cancel
#======= End labels: Exported 208 labels for en AU =====
Index: lams_central/conf/xdoclet/taglib-tag.xml
===================================================================
diff -u -r472bcb813040efc160e074021be5c71c15455f00 -r3538b4ae424da479962e98b7528ad22b44cdd368
--- lams_central/conf/xdoclet/taglib-tag.xml (.../taglib-tag.xml) (revision 472bcb813040efc160e074021be5c71c15455f00)
+++ lams_central/conf/xdoclet/taglib-tag.xml (.../taglib-tag.xml) (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -227,6 +227,10 @@
ImgButtonWrapper
/WEB-INF/tags/ImgButtonWrapper.tag
+
+
+ TextSearch
+ /WEB-INF/tags/TextSearch.tag
textarea
Index: lams_central/src/java/org/lamsfoundation/lams/web/TextSearchActionForm.java
===================================================================
diff -u
--- lams_central/src/java/org/lamsfoundation/lams/web/TextSearchActionForm.java (revision 0)
+++ lams_central/src/java/org/lamsfoundation/lams/web/TextSearchActionForm.java (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -0,0 +1,100 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+/* $$Id$$ */
+package org.lamsfoundation.lams.web;
+
+import org.apache.struts.action.ActionForm;
+import org.lamsfoundation.lams.learningdesign.TextSearchCondition;
+
+/**
+ * The form that contains all the fields provided in lams:TextSearch
tag.
+ *
+ * @author Marcin Cieslak
+ *
+ * @struts:form name="TextSearchActionForm" include-pk="true" include-all="true"
+ */
+public class TextSearchActionForm extends ActionForm {
+
+ public static final String formName = "TextSearchActionForm";
+ private String allWords;
+ private String phrase;
+ private String anyWords;
+ private String excludedWords;
+ private String sessionMapID;
+
+ public TextSearchActionForm() {
+ }
+
+ /**
+ * Fills the form with data provided by condition.
+ *
+ * @param condition
+ * condition to read the data from
+ */
+ public void populateForm(TextSearchCondition condition) {
+ allWords = condition.getAllWords();
+ phrase = condition.getPhrase();
+ anyWords = condition.getAnyWords();
+ excludedWords = condition.getExcludedWords();
+ }
+
+ public String getAllWords() {
+ return allWords;
+ }
+
+ public void setAllWords(String allWords) {
+ this.allWords = allWords;
+ }
+
+ public String getPhrase() {
+ return phrase;
+ }
+
+ public void setPhrase(String phrase) {
+ this.phrase = phrase;
+ }
+
+ public String getAnyWords() {
+ return anyWords;
+ }
+
+ public void setAnyWords(String anyWords) {
+ this.anyWords = anyWords;
+ }
+
+ public String getExcludedWords() {
+ return excludedWords;
+ }
+
+ public void setExcludedWords(String excludedWords) {
+ this.excludedWords = excludedWords;
+ }
+
+ public String getSessionMapID() {
+ return sessionMapID;
+ }
+
+ public void setSessionMapID(String sessionMapID) {
+ this.sessionMapID = sessionMapID;
+ }
+}
\ No newline at end of file
Index: lams_central/web/WEB-INF/lams.tld
===================================================================
diff -u -rc209be8131f22f6fe37bd8d6c14b56425a78b766 -r3538b4ae424da479962e98b7528ad22b44cdd368
--- lams_central/web/WEB-INF/lams.tld (.../lams.tld) (revision c209be8131f22f6fe37bd8d6c14b56425a78b766)
+++ lams_central/web/WEB-INF/lams.tld (.../lams.tld) (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -13,28 +13,36 @@
- Output the basic URL for the current webapp. e.g. http://server/lams/tool/nb11/
- Base URL for the current web app
+ Output the Server URL as defined in the lams.xml configuration file.
+ LAMS URL
- WebAppURL
- org.lamsfoundation.lams.web.tag.WebAppURLTag
+ LAMSURL
+ org.lamsfoundation.lams.web.tag.LAMSURLTag
empty
- Output a random number for the learner and passon flash movies to communicate directly.
- generate unique ID
+ Converts text from \n or \r\n to <BR> before rendering
+ Converts text from \n or \r\n to <BR> before rendering
- generateID
- org.lamsfoundation.lams.web.tag.GenerateIDTag
+ out
+ org.lamsfoundation.lams.web.tag.MultiLinesOutputTag
empty
- Output a random number for the learner and passon flash movies to communicate directly.
- id
+ Converts text from \n or \r\n to <BR> before rendering
+ value
+ true
+
+ true
+
+
+
+ Converts text from \n or \r\n to <BR> before rendering
+ escapeHtml
false
true
@@ -44,6 +52,26 @@
+ Render html tag with direction and language
+ Render html tag with direction and language
+
+
+ html
+ org.lamsfoundation.lams.web.tag.HtmlTag
+ JSP
+
+
+ Render html tag with direction and language
+ xhtml
+ false
+
+ true
+
+
+
+
+
+
Get the configuration value for the specified key
Configuration value
@@ -64,28 +92,17 @@
- Output the Server URL as defined in the lams.xml configuration file.
- LAMS URL
+ Output a random number for the learner and passon flash movies to communicate directly.
+ generate unique ID
- LAMSURL
- org.lamsfoundation.lams.web.tag.LAMSURLTag
+ generateID
+ org.lamsfoundation.lams.web.tag.GenerateIDTag
empty
-
-
-
- Render html tag with direction and language
- Render html tag with direction and language
-
-
- html
- org.lamsfoundation.lams.web.tag.HtmlTag
- JSP
-
- Render html tag with direction and language
- xhtml
+ Output a random number for the learner and passon flash movies to communicate directly.
+ id
false
true
@@ -95,26 +112,29 @@
- Converts text from \n or \r\n to <BR> before rendering
- Converts text from \n or \r\n to <BR> before rendering
+ Output the basic URL for the current webapp. e.g. http://server/lams/tool/nb11/
+ Base URL for the current web app
- out
- org.lamsfoundation.lams.web.tag.MultiLinesOutputTag
+ WebAppURL
+ org.lamsfoundation.lams.web.tag.WebAppURLTag
empty
-
- Converts text from \n or \r\n to <BR> before rendering
- value
- true
+
+
- true
+ Converts role name into form usable as message resources key
+ Converts role name into form usable as message resources key
+
+
+ role
+ org.lamsfoundation.lams.web.tag.RoleTag
+ empty
-
- Converts text from \n or \r\n to <BR> before rendering
- escapeHtml
- false
+ Converts role name into form usable as message resources key
+ role
+ true
true
@@ -167,17 +187,17 @@
- Converts role name into form usable as message resources key
- Converts role name into form usable as message resources key
+ Output details from the shared session UserDTO object
+ user details
- role
- org.lamsfoundation.lams.web.tag.RoleTag
+ user
+ org.lamsfoundation.lams.web.tag.UserTag
empty
- Converts role name into form usable as message resources key
- role
+ Output details from the shared session UserDTO object
+ property
true
true
@@ -213,27 +233,7 @@
-
- Output details from the shared session UserDTO object
- user details
-
-
- user
- org.lamsfoundation.lams.web.tag.UserTag
- empty
-
-
- Output details from the shared session UserDTO object
- property
- true
-
- true
-
-
-
-
-
STRUTS-textarea
org.lamsfoundation.lams.web.tag.MultiLinesTextareaTag
@@ -461,6 +461,10 @@
ImgButtonWrapper
/WEB-INF/tags/ImgButtonWrapper.tag
+
+
+ TextSearch
+ /WEB-INF/tags/TextSearch.tag
textarea
Index: lams_central/web/WEB-INF/tags/TextSearch.tag
===================================================================
diff -u
--- lams_central/web/WEB-INF/tags/TextSearch.tag (revision 0)
+++ lams_central/web/WEB-INF/tags/TextSearch.tag (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -0,0 +1,136 @@
+<%
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+ /**
+ * TextSearch.tag
+ * Author: Marcin Cieslak
+ * Description: Displays form for creating text search conditions.
+ */
+
+ %>
+<%@ tag body-content="scriptless" %>
+<%@ taglib uri="tags-core" prefix="c" %>
+<%@ taglib uri="tags-fmt" prefix="fmt" %>
+<%@ taglib uri="tags-html" prefix="html" %>
+<%@ taglib uri="tags-lams" prefix="lams" %>
+
+<%-- Required attributes --%>
+<%@ attribute name="sessionMapID" required="true" rtexprvalue="true" %>
+<%@ attribute name="wrapInFormTag" required="true" rtexprvalue="true" %>
+
+<%-- Optional attributes --%>
+<%@ attribute name="action" required="false" rtexprvalue="true" %>
+<%@ attribute name="formID" required="false" rtexprvalue="true" %>
+<%@ attribute name="headingLabelKey" required="false" rtexprvalue="true" %>
+<%@ attribute name="allWordsLabelKey" required="false" rtexprvalue="true" %>
+<%@ attribute name="phraseLabelKey" required="false" rtexprvalue="true" %>
+<%@ attribute name="anyWordsLabelKey" required="false" rtexprvalue="true" %>
+<%@ attribute name="excludedWordsLabelKey" required="false" rtexprvalue="true" %>
+<%@ attribute name="saveButtonLabelKey" required="false" rtexprvalue="true" %>
+<%@ attribute name="cancelButtonLabelKey" required="false" rtexprvalue="true" %>
+<%@ attribute name="cancelAction" required="false" rtexprvalue="true" %>
+
+<%-- Default value for message key --%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+ |
+
+
+ |
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/BranchCondition.hbm.xml
===================================================================
diff -u -r97612142f4697066beb66064e83ff31fef1712b9 -r3538b4ae424da479962e98b7528ad22b44cdd368
--- lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/BranchCondition.hbm.xml (.../BranchCondition.hbm.xml) (revision 97612142f4697066beb66064e83ff31fef1712b9)
+++ lams_common/conf/hibernate/mappings/org/lamsfoundation/lams/learningdesign/BranchCondition.hbm.xml (.../BranchCondition.hbm.xml) (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -9,6 +9,7 @@
@hibernate.property column="exact_match_value" length="255"
+
+ @hibernate.class
+
+
+
+
+ @hibernate.property column="text_search_all_words"
+
+
+
+ @hibernate.property column="text_search_phrase"
+
+
+
+ @hibernate.property column="text_search_any_words"
+
+
+
+ @hibernate.property column="text_search_excluded_words"
+
+
-
+
\ No newline at end of file
Index: lams_common/db/sql/create_lams_11_tables.sql
===================================================================
diff -u -r44cd820aae2478d1f77a2008b90fcea6cab6baba -r3538b4ae424da479962e98b7528ad22b44cdd368
--- lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 44cd820aae2478d1f77a2008b90fcea6cab6baba)
+++ lams_common/db/sql/create_lams_11_tables.sql (.../create_lams_11_tables.sql) (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -598,6 +598,17 @@
, PRIMARY KEY (condition_id)
)TYPE=InnoDB;
+CREATE TABLE lams_text_search_condition (
+ condition_id BIGINT(20) NOT NULL
+ , text_search_all_words TEXT
+ , text_search_phrase TEXT
+ , text_search_any_words TEXT
+ , text_search_excluded_words TEXT
+ , PRIMARY KEY (condition_id)
+ , CONSTRAINT TextSearchConditionInheritance FOREIGN KEY (condition_id)
+ REFERENCES lams_branch_condition(condition_id) ON DELETE CASCADE ON UPDATE CASCADE
+)TYPE=InnoDB;
+
CREATE TABLE lams_branch_activity_entry (
entry_id BIGINT(20) NOT NULL AUTO_INCREMENT
, entry_ui_id INT(11)
@@ -1037,3 +1048,4 @@
, patch_in_progress CHAR(1) NOT NULL DEFAULT 'F'
, PRIMARY KEY (system_name)
)TYPE=InnoDB;
+
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch0013_updateFrom21.sql
===================================================================
diff -u -rce2df8052e0f7e2733b20c676ded769f3a48650f -r3538b4ae424da479962e98b7528ad22b44cdd368
--- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch0013_updateFrom21.sql (.../patch0013_updateFrom21.sql) (revision ce2df8052e0f7e2733b20c676ded769f3a48650f)
+++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch0013_updateFrom21.sql (.../patch0013_updateFrom21.sql) (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -1,5 +1,4 @@
-- SQL statements to update from LAMS 2.1/2.1.1
-
-- LDEV1909 - Competence Editor Update Scripts ---------------------------------
CREATE TABLE lams_competence (
competence_id BIGINT NOT NULL UNIQUE auto_increment
@@ -25,4 +24,14 @@
REFERENCES lams_competence (competence_id) ON DELETE CASCADE ON UPDATE CASCADE
)TYPE=InnoDB;
---------------------------------------------------------------------------------
\ No newline at end of file
+-- LDEV-1604 - Text based complex conditions -----------------------------------
+CREATE TABLE lams_text_search_condition (
+ condition_id BIGINT(20) NOT NULL
+ , text_search_all_words TEXT
+ , text_search_phrase TEXT
+ , text_search_any_words TEXT
+ , text_search_excluded_words TEXT
+ , PRIMARY KEY (condition_id)
+ , CONSTRAINT TextSearchConditionInheritance FOREIGN KEY (condition_id)
+ REFERENCES lams_branch_condition(condition_id) ON DELETE CASCADE ON UPDATE CASCADE
+)TYPE=InnoDB;
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/BranchCondition.java
===================================================================
diff -u -r209087915bc219f430c282ad00e5d1e6462f9b5f -r3538b4ae424da479962e98b7528ad22b44cdd368
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/BranchCondition.java (.../BranchCondition.java) (revision 209087915bc219f430c282ad00e5d1e6462f9b5f)
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/BranchCondition.java (.../BranchCondition.java) (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -33,349 +33,337 @@
import org.lamsfoundation.lams.tool.ToolOutputValue;
/**
- * The ToolOutputBranchActivityEntries record the branch selection details for tool output based branching. During
- * authoring, the tool will have supplied a ToolOutputDefinition object and this will have been used to configure
- * which tool outputs match to a particular branch. This mapping is as a ToolOutputBranchActivityEntry.
+ * The ToolOutputBranchActivityEntries record the branch selection details for tool output based branching. During
+ * authoring, the tool will have supplied a ToolOutputDefinition object and this will have been used to configure which
+ * tool outputs match to a particular branch. This mapping is as a ToolOutputBranchActivityEntry.
*
* There should be one branch condition for each ToolOutputBranchActivityEntry.
*/
public class BranchCondition implements Comparable {
- private static Logger log = Logger.getLogger(BranchCondition.class);
+ private static Logger log = Logger.getLogger(BranchCondition.class);
- private Long conditionId;
- private Integer conditionUIID;
- private Integer orderId;
- private String name;
- private String displayName;
- private String type;
- private String startValue;
- private String endValue;
- private String exactMatchValue;
+ protected Long conditionId;
+ protected Integer conditionUIID;
+ protected Integer orderId;
+ protected String name;
+ protected String displayName;
+ protected String type;
+ protected String startValue;
+ protected String endValue;
+ protected String exactMatchValue;
- /** default constructor */
- public BranchCondition() {
- }
+ /** default constructor */
+ public BranchCondition() {
+ }
- /** full constructor */
- public BranchCondition(Long conditionId, Integer conditionUIID, Integer orderId, String name, String displayName,
- String type, String startValue, String endValue, String exactMatchValue) {
- this.conditionId = conditionId;
- this.conditionUIID = conditionUIID;
- this.orderId = orderId;
- this.name = name;
- this.displayName = displayName;
- this.type = type;
- this.startValue = startValue;
- this.endValue = endValue;
- this.exactMatchValue = exactMatchValue;
- }
+ /** full constructor */
+ public BranchCondition(Long conditionId, Integer conditionUIID, Integer orderId, String name, String displayName,
+ String type, String startValue, String endValue, String exactMatchValue) {
+ this.conditionId = conditionId;
+ this.conditionUIID = conditionUIID;
+ this.orderId = orderId;
+ this.name = name;
+ this.displayName = displayName;
+ this.type = type;
+ this.startValue = startValue;
+ this.endValue = endValue;
+ this.exactMatchValue = exactMatchValue;
+ }
- /** Create a condition object based on an existing DTO object. Copies all fields including the id field */
- public BranchCondition(BranchConditionDTO conditionDTO) {
- this(conditionDTO.getConditionId(), conditionDTO.getConditionUIID(), conditionDTO.getOrderID(), conditionDTO.getName(),
- conditionDTO.getDisplayName(), conditionDTO.getType(), conditionDTO.getStartValue(), conditionDTO.getEndValue(),
- conditionDTO.getExactMatchValue());
- }
+ /** Create a condition object based on an existing DTO object. Copies all fields including the id field */
+ public BranchCondition(BranchConditionDTO conditionDTO) {
+ this(conditionDTO.getConditionId(), conditionDTO.getConditionUIID(), conditionDTO.getOrderID(), conditionDTO
+ .getName(), conditionDTO.getDisplayName(), conditionDTO.getType(), conditionDTO.getStartValue(),
+ conditionDTO.getEndValue(), conditionDTO.getExactMatchValue());
+ }
- /**
- * @hibernate.id
- * generator-class="native"
- * type="java.lang.Long"
- * column="condition_id"
- *
- */
- public Long getConditionId() {
- return conditionId;
- }
+ /**
+ * @hibernate.id generator-class="native" type="java.lang.Long" column="condition_id"
+ *
+ */
+ public Long getConditionId() {
+ return conditionId;
+ }
- public void setConditionId(Long conditionId) {
- this.conditionId = conditionId;
- }
+ public void setConditionId(Long conditionId) {
+ this.conditionId = conditionId;
+ }
- /**
- * @hibernate.property column="condition_ui_id" length="11"
- *
- */
- public Integer getConditionUIID() {
- return conditionUIID;
- }
+ /**
+ * @hibernate.property column="condition_ui_id" length="11"
+ *
+ */
+ public Integer getConditionUIID() {
+ return conditionUIID;
+ }
- public void setConditionUIID(Integer conditionUIID) {
- this.conditionUIID = conditionUIID;
- }
+ public void setConditionUIID(Integer conditionUIID) {
+ this.conditionUIID = conditionUIID;
+ }
- /**
- * @hibernate.property column="order_id" length="11"
- */
- public Integer getOrderId() {
- return orderId;
- }
+ /**
+ * @hibernate.property column="order_id" length="11"
+ */
+ public Integer getOrderId() {
+ return orderId;
+ }
- public void setOrderId(Integer orderId) {
- this.orderId = orderId;
- }
+ public void setOrderId(Integer orderId) {
+ this.orderId = orderId;
+ }
- /**
- * @hibernate.property column="name" length="255"
- */
- public String getName() {
- return name;
- }
+ /**
+ * @hibernate.property column="name" length="255"
+ */
+ public String getName() {
+ return name;
+ }
- public void setName(String name) {
- this.name = name;
- }
+ public void setName(String name) {
+ this.name = name;
+ }
- /**
- * The display name is a name shown to the user so they can link a condition to a branch.
- * @hibernate.property column="display_name" length="255"
- */
- public String getDisplayName() {
- return displayName;
- }
+ /**
+ * The display name is a name shown to the user so they can link a condition to a branch.
+ *
+ * @hibernate.property column="display_name" length="255"
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
- /**
- * @hibernate.property column="type" length="255"
- */
- public String getType() {
- return type;
- }
+ /**
+ * @hibernate.property column="type" length="255"
+ */
+ public String getType() {
+ return type;
+ }
- public void setType(String type) {
- this.type = type;
- }
+ public void setType(String type) {
+ this.type = type;
+ }
- /**
- * @hibernate.property column="start_value" length="255"
- */
- public String getStartValue() {
- return startValue;
- }
+ /**
+ * @hibernate.property column="start_value" length="255"
+ */
+ public String getStartValue() {
+ return startValue;
+ }
- public void setStartValue(String startValue) {
- this.startValue = startValue;
- }
+ public void setStartValue(String startValue) {
+ this.startValue = startValue;
+ }
- /**
- * @hibernate.property column="end_value" length="255"
- */
- public String getEndValue() {
- return endValue;
- }
+ /**
+ * @hibernate.property column="end_value" length="255"
+ */
+ public String getEndValue() {
+ return endValue;
+ }
- public void setEndValue(String endValue) {
- this.endValue = endValue;
- }
+ public void setEndValue(String endValue) {
+ this.endValue = endValue;
+ }
- /**
- * @hibernate.property column="exact_match_value" length="255"
- */
- public String getExactMatchValue() {
- return exactMatchValue;
- }
+ /**
+ * @hibernate.property column="exact_match_value" length="255"
+ */
+ public String getExactMatchValue() {
+ return exactMatchValue;
+ }
- public void setExactMatchValue(String exactMatchValue) {
- this.exactMatchValue = exactMatchValue;
- }
+ public void setExactMatchValue(String exactMatchValue) {
+ this.exactMatchValue = exactMatchValue;
+ }
- public BranchConditionDTO getBranchConditionDTO(Integer toolActivityUIID) {
- return new BranchConditionDTO(this, toolActivityUIID);
- }
+ public BranchConditionDTO getBranchConditionDTO(Integer toolActivityUIID) {
+ return new BranchConditionDTO(this, toolActivityUIID);
+ }
- @Override
- public String toString() {
- return new ToStringBuilder(this).append("conditionId", conditionId).append("conditionUIID", conditionUIID).append(
- "orderId", orderId).append("name", name).append("displayName", displayName).append("type", type).append(
- "startValue", startValue).append("endValue", endValue).append("exactMatchValue", exactMatchValue).toString();
- }
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("conditionId", conditionId).append("conditionUIID", conditionUIID)
+ .append("orderId", orderId).append("name", name).append("displayName", displayName)
+ .append("type", type).append("startValue", startValue).append("endValue", endValue).append(
+ "exactMatchValue", exactMatchValue).toString();
+ }
- /** Allocate this condition to the given branch, in a branching activity. This creates the BranchActivityEntry record and adds it
- * to the branchActivities set. EntryUIID will only be populated if this is called from authoring
- */
- public BranchActivityEntry allocateBranchToCondition(Integer entryUIID, SequenceActivity branch, Activity branchingActivity) {
- BranchActivityEntry entry = new BranchActivityEntry(null, entryUIID, branch, branchingActivity, this);
- return entry;
- }
+ /**
+ * Allocate this condition to the given branch, in a branching activity or as a gate opening condition in condition
+ * gate. This creates the BranchActivityEntry record and adds it to the branchActivities set. EntryUIID will only be
+ * populated if this is called from authoring
+ */
+ public BranchActivityEntry allocateBranchToCondition(Integer entryUIID, SequenceActivity branch,
+ Activity outputBasedActivity) {
+ BranchActivityEntry entry = new BranchActivityEntry(null, entryUIID, branch, outputBasedActivity, this);
+ return entry;
+ }
- /** Create a new BranchCondition based on itself, leaving conditionId as null */
- public BranchCondition clone(int uiidOffset) {
- Integer newConditionUIID = LearningDesign.addOffset(conditionUIID, uiidOffset);
- return new BranchCondition(null, newConditionUIID, orderId, name, displayName, type, startValue, endValue,
- exactMatchValue);
- }
+ /** Create a new BranchCondition based on itself, leaving conditionId as null */
+ public BranchCondition clone(int uiidOffset) {
+ Integer newConditionUIID = LearningDesign.addOffset(conditionUIID, uiidOffset);
+ return new BranchCondition(null, newConditionUIID, orderId, name, displayName, type, startValue, endValue,
+ exactMatchValue);
+ }
- public int compareTo(Object arg0) {
- BranchCondition other = (BranchCondition) arg0;
- return new CompareToBuilder().append(orderId, other.getOrderId()).append(conditionId, other.getConditionId()).append(
- name, other.getName()).append(conditionUIID, other.getConditionUIID()).toComparison();
- }
+ public int compareTo(Object arg0) {
+ BranchCondition other = (BranchCondition) arg0;
+ return new CompareToBuilder().append(orderId, other.getOrderId()).append(conditionId, other.getConditionId())
+ .append(name, other.getName()).append(conditionUIID, other.getConditionUIID()).toComparison();
+ }
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(orderId).append(conditionId).append(name).append(conditionUIID).toHashCode();
- }
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(orderId).append(conditionId).append(name).append(conditionUIID)
+ .toHashCode();
+ }
- @Override
- public boolean equals(Object arg0) {
- BranchCondition other = (BranchCondition) arg0;
- return new EqualsBuilder().append(orderId, other.getOrderId()).append(conditionId, other.getConditionId()).append(name,
- other.getName()).append(conditionUIID, other.getConditionUIID()).isEquals();
- }
+ @Override
+ public boolean equals(Object arg0) {
+ BranchCondition other = (BranchCondition) arg0;
+ return new EqualsBuilder().append(orderId, other.getOrderId()).append(conditionId, other.getConditionId())
+ .append(name, other.getName()).append(conditionUIID, other.getConditionUIID()).isEquals();
+ }
- /** Is this condition met? */
- public boolean isMet(ToolOutput output) {
- if (output != null) {
- if (exactMatchValue != null) {
- return exactMatchMet(output.getValue());
- }
- else if (startValue != null || endValue != null) {
- return inRange(output.getValue());
- }
- }
- return false;
+ /** Is this condition met? */
+ public boolean isMet(ToolOutput output) {
+ if (output != null) {
+ if (exactMatchValue != null) {
+ return exactMatchMet(output.getValue());
+ } else if (startValue != null || endValue != null) {
+ return inRange(output.getValue());
+ }
}
+ return false;
+ }
- public boolean exactMatchMet(ToolOutputValue outputValue) {
- if ("OUTPUT_LONG".equals(type)) {
- Long exactMatchObj = exactMatchValue != null ? convertToLong(exactMatchValue) : null;
- Long actualValue = outputValue.getLong();
- return actualValue != null && actualValue.equals(exactMatchObj);
- }
- else if ("OUTPUT_DOUBLE".equals(type)) {
- Double exactMatchObj = exactMatchValue != null ? Double.parseDouble(exactMatchValue) : null;
- Double actualValue = outputValue.getDouble();
- return actualValue != null && actualValue.equals(exactMatchObj);
- }
- else if ("OUTPUT_BOOLEAN".equals(type)) {
- Boolean exactMatchObj = exactMatchValue != null ? Boolean.parseBoolean(exactMatchValue) : null;
- Boolean actualValue = outputValue.getBoolean();
- return actualValue != null && actualValue.equals(exactMatchObj);
- }
- else if ("OUTPUT_STRING".equals(type)) {
- Double actualValue = outputValue.getDouble();
- return actualValue != null && actualValue.equals(exactMatchValue);
- }
- return false;
+ public boolean exactMatchMet(ToolOutputValue outputValue) {
+ if ("OUTPUT_LONG".equals(type)) {
+ Long exactMatchObj = exactMatchValue != null ? convertToLong(exactMatchValue) : null;
+ Long actualValue = outputValue.getLong();
+ return actualValue != null && actualValue.equals(exactMatchObj);
+ } else if ("OUTPUT_DOUBLE".equals(type)) {
+ Double exactMatchObj = exactMatchValue != null ? Double.parseDouble(exactMatchValue) : null;
+ Double actualValue = outputValue.getDouble();
+ return actualValue != null && actualValue.equals(exactMatchObj);
+ } else if ("OUTPUT_BOOLEAN".equals(type)) {
+ Boolean exactMatchObj = exactMatchValue != null ? Boolean.parseBoolean(exactMatchValue) : null;
+ Boolean actualValue = outputValue.getBoolean();
+ return actualValue != null && actualValue.equals(exactMatchObj);
+ } else if ("OUTPUT_STRING".equals(type)) {
+ Double actualValue = outputValue.getDouble();
+ return actualValue != null && actualValue.equals(exactMatchValue);
}
+ return false;
+ }
- public boolean inRange(ToolOutputValue outputValue) {
- if ("OUTPUT_LONG".equals(type)) {
- Long startValueLong = startValue != null ? convertToLong(startValue) : null;
- Long endValueLong = endValue != null ? convertToLong(endValue) : null;
- Long actualValue = outputValue.getLong();
- return actualValue != null && (startValueLong == null || actualValue.compareTo(startValueLong) >= 0)
- && (endValueLong == null || actualValue.compareTo(endValueLong) <= 0);
- }
- else if ("OUTPUT_DOUBLE".equals(type)) {
- Double startValueDouble = startValue != null ? Double.parseDouble(startValue) : null;
- Double endValueDouble = endValue != null ? Double.parseDouble(endValue) : null;
- Double actualValue = outputValue.getDouble();
- return actualValue != null && (startValueDouble == null || actualValue.compareTo(startValueDouble) >= 0)
- && (endValueDouble == null || actualValue.compareTo(endValueDouble) <= 0);
- }
- else if ("OUTPUT_BOOLEAN".equals(type)) {
- // this is a nonsense, but we'll code it just in case. What order is a boolean? True greater than false?
- Boolean startValueBoolean = startValue != null ? Boolean.parseBoolean(startValue) : null;
- Boolean endValueBoolean = endValue != null ? Boolean.parseBoolean(endValue) : null;
- Boolean actualValue = outputValue.getBoolean();
- return actualValue != null && (startValueBoolean == null || actualValue.compareTo(startValueBoolean) >= 0)
- && (endValueBoolean == null || actualValue.compareTo(endValueBoolean) <= 0);
+ public boolean inRange(ToolOutputValue outputValue) {
+ if ("OUTPUT_LONG".equals(type)) {
+ Long startValueLong = startValue != null ? convertToLong(startValue) : null;
+ Long endValueLong = endValue != null ? convertToLong(endValue) : null;
+ Long actualValue = outputValue.getLong();
+ return actualValue != null && (startValueLong == null || actualValue.compareTo(startValueLong) >= 0)
+ && (endValueLong == null || actualValue.compareTo(endValueLong) <= 0);
+ } else if ("OUTPUT_DOUBLE".equals(type)) {
+ Double startValueDouble = startValue != null ? Double.parseDouble(startValue) : null;
+ Double endValueDouble = endValue != null ? Double.parseDouble(endValue) : null;
+ Double actualValue = outputValue.getDouble();
+ return actualValue != null && (startValueDouble == null || actualValue.compareTo(startValueDouble) >= 0)
+ && (endValueDouble == null || actualValue.compareTo(endValueDouble) <= 0);
+ } else if ("OUTPUT_BOOLEAN".equals(type)) {
+ // this is a nonsense, but we'll code it just in case. What order is a boolean? True greater than false?
+ Boolean startValueBoolean = startValue != null ? Boolean.parseBoolean(startValue) : null;
+ Boolean endValueBoolean = endValue != null ? Boolean.parseBoolean(endValue) : null;
+ Boolean actualValue = outputValue.getBoolean();
+ return actualValue != null && (startValueBoolean == null || actualValue.compareTo(startValueBoolean) >= 0)
+ && (endValueBoolean == null || actualValue.compareTo(endValueBoolean) <= 0);
- }
- else if ("OUTPUT_STRING".equals(type)) {
- String actualValue = outputValue.getString();
- return actualValue != null && (startValue == null || actualValue.compareTo(startValue) >= 0)
- && (endValue == null || actualValue.compareTo(endValue) <= 0);
- }
- return false;
+ } else if ("OUTPUT_STRING".equals(type)) {
+ String actualValue = outputValue.getString();
+ return actualValue != null && (startValue == null || actualValue.compareTo(startValue) >= 0)
+ && (endValue == null || actualValue.compareTo(endValue) <= 0);
}
+ return false;
+ }
- /** The data may have come in from WDDX and have .0 on the end of Longs, so eliminate that */
- private Long convertToLong(String textValue) {
- if (textValue.length() == 0) {
- return null;
- }
+ /** The data may have come in from WDDX and have .0 on the end of Longs, so eliminate that */
+ private Long convertToLong(String textValue) {
+ if (textValue.length() == 0) {
+ return null;
+ }
- int posPeriod = textValue.indexOf('.');
- if (posPeriod > 0) {
- textValue = textValue.substring(0, posPeriod);
- }
- return new Long(textValue);
+ int posPeriod = textValue.indexOf('.');
+ if (posPeriod > 0) {
+ textValue = textValue.substring(0, posPeriod);
}
+ return new Long(textValue);
+ }
- /** All conditions must have either (a) an exact match value or (b) a start value and no end value
- * or (c) start value and an end value and the end value must be >= start value.
- */
- protected boolean isValid() {
- if (exactMatchValue != null) {
- try {
- if (getTypedValue(exactMatchValue) != null) {
- return true;
- }
- }
- catch (Exception e) {
- }
- BranchCondition.log.error("Condition contains an unconvertible value for exactMatchValue. Type is " + type
- + " value " + exactMatchValue);
- return false;
+ /**
+ * All conditions must have either (a) an exact match value or (b) a start value and no end value or (c) start value
+ * and an end value and the end value must be >= start value.
+ */
+ protected boolean isValid() {
+ if (exactMatchValue != null) {
+ try {
+ if (getTypedValue(exactMatchValue) != null) {
+ return true;
}
- else {
- Comparable typedStartValue = null;
- Comparable typedEndValue = null;
+ } catch (Exception e) {
+ }
+ BranchCondition.log.error("Condition contains an unconvertible value for exactMatchValue. Type is " + type
+ + " value " + exactMatchValue);
+ return false;
+ } else {
+ Comparable typedStartValue = null;
+ Comparable typedEndValue = null;
- try {
- if (startValue != null) {
- typedStartValue = getTypedValue(startValue);
- }
- }
- catch (Exception e) {
- BranchCondition.log.error("Condition contains an unconvertible value for startValue. Type is " + type + " value "
- + startValue);
- return false;
- }
+ try {
+ if (startValue != null) {
+ typedStartValue = getTypedValue(startValue);
+ }
+ } catch (Exception e) {
+ BranchCondition.log.error("Condition contains an unconvertible value for startValue. Type is " + type
+ + " value " + startValue);
+ return false;
+ }
- try {
- if (endValue != null) {
- typedEndValue = getTypedValue(endValue);
- }
- }
- catch (Exception e) {
- BranchCondition.log.error("Condition contains an unconvertible value for endValue. Type is " + type + " value "
- + endValue);
- return false;
- }
-
- if (typedStartValue == null && typedEndValue != null) {
- return true;
- }
- else if (typedEndValue == null || typedEndValue.compareTo(typedStartValue) >= 0) {
- return true;
- }
+ try {
+ if (endValue != null) {
+ typedEndValue = getTypedValue(endValue);
}
+ } catch (Exception e) {
+ BranchCondition.log.error("Condition contains an unconvertible value for endValue. Type is " + type
+ + " value " + endValue);
return false;
+ }
+
+ if (typedStartValue == null && typedEndValue != null) {
+ return true;
+ } else if (typedEndValue == null || typedEndValue.compareTo(typedStartValue) >= 0) {
+ return true;
+ }
}
+ return false;
+ }
- private Comparable getTypedValue(String untypedValue) {
- if ("OUTPUT_LONG".equals(type)) {
- return convertToLong(untypedValue);
- }
- else if ("OUTPUT_DOUBLE".equals(type)) {
- return Double.parseDouble(untypedValue);
- }
- else if ("OUTPUT_BOOLEAN".equals(type)) {
- return Boolean.parseBoolean(untypedValue);
- }
- else if ("OUTPUT_STRING".equals(type)) {
- return untypedValue;
- }
- else {
- return null;
- }
+ private Comparable getTypedValue(String untypedValue) {
+ if ("OUTPUT_LONG".equals(type)) {
+ return convertToLong(untypedValue);
+ } else if ("OUTPUT_DOUBLE".equals(type)) {
+ return Double.parseDouble(untypedValue);
+ } else if ("OUTPUT_BOOLEAN".equals(type)) {
+ return Boolean.parseBoolean(untypedValue);
+ } else if ("OUTPUT_STRING".equals(type)) {
+ return untypedValue;
+ } else {
+ return null;
}
+ }
}
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/TextSearchCondition.java
===================================================================
diff -u
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/TextSearchCondition.java (revision 0)
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/TextSearchCondition.java (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -0,0 +1,330 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $$Id$$ */
+package org.lamsfoundation.lams.learningdesign;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.learningdesign.dto.BranchConditionDTO;
+import org.lamsfoundation.lams.tool.ToolOutput;
+import org.lamsfoundation.lams.web.TextSearchActionForm;
+
+/**
+ * Condition that is based on text search. Several properties set what needs to be found in a tool output. Based on the
+ * result of the text scan, the condition is safisfied or not.
+ *
+ * @author Marcin Cieslak
+ *
+ */
+public class TextSearchCondition extends BranchCondition implements Cloneable {
+
+ // ---- persistent fields -------
+ /**
+ * All the words from this string should be found in the tool output.
+ */
+ protected String allWords;
+ /**
+ * The whole phrase from this string should be found in the tool output.
+ */
+ protected String phrase;
+ /**
+ * At least one of the words from this string should be found in the tool output.
+ */
+ protected String anyWords;
+ /**
+ * None of the words from this string should be found in the tool output.
+ */
+ protected String excludedWords;
+
+ // ---- non-persistent fields ----------
+ /**
+ * Regular expression that divides a string into single words.
+ */
+ public static final String WORD_DELIMITER_REGEX = "\\s";
+ private static Logger log = Logger.getLogger(TextSearchCondition.class);
+ /**
+ * Were the strings provided by user parsed into practical collections of words.
+ */
+ protected boolean conditionsParsed = false;
+ /**
+ * Property {@link #allWords} divided into words.
+ */
+ protected List allWordsCondition = new ArrayList();
+ /**
+ * Same as {@link #phrase}. Created for
+ */
+ protected String phraseCondition;
+ /**
+ * Property {@link #anyWords} divided into words.
+ */
+ protected List anyWordsCondition = new ArrayList();
+ /**
+ * Property {@link #excludedWords} divided into words.
+ */
+ protected List excludedWordsCondition = new ArrayList();
+
+ public TextSearchCondition() {
+
+ }
+
+ /**
+ * Creates the condition based on a DTO.
+ *
+ * @param conditionDTO
+ */
+ public TextSearchCondition(BranchConditionDTO conditionDTO) {
+ super(conditionDTO);
+ allWords = conditionDTO.getAllWords();
+ phrase = conditionDTO.getPhrase();
+ anyWords = conditionDTO.getAnyWords();
+ excludedWords = conditionDTO.getExcludedWords();
+ }
+
+ /**
+ * Full constructor
+ */
+ public TextSearchCondition(Long conditionId, Integer conditionUIID, Integer orderId, String name,
+ String displayName, String type, String startValue, String endValue, String exactMatchValue,
+ String allWords, String phrase, String anyWords, String excludedWords) {
+ super(conditionId, conditionUIID, orderId, name, displayName, type, startValue, endValue, exactMatchValue);
+ this.allWords = allWords;
+ this.phrase = phrase;
+ this.anyWords = anyWords;
+ this.excludedWords = excludedWords;
+ }
+
+ @Override
+ public BranchCondition clone(int uiidOffset) {
+ Integer newConditionUIID = LearningDesign.addOffset(conditionUIID, uiidOffset);
+ return new TextSearchCondition(null, newConditionUIID, orderId, name, displayName, type, startValue, endValue,
+ exactMatchValue, allWords, phrase, anyWords, excludedWords);
+ }
+
+ @Override
+ public Object clone() {
+ return new TextSearchCondition(null, null, orderId, name, displayName, type, startValue, endValue,
+ exactMatchValue, allWords, phrase, anyWords, excludedWords);
+ }
+
+ public String getAllWords() {
+ return allWords;
+ }
+
+ public List getAllWordsCondition() {
+ return allWordsCondition;
+ }
+
+ public String getAnyWords() {
+ return anyWords;
+ }
+
+ public List getAnyWordsCondition() {
+ return anyWordsCondition;
+ }
+
+ public String getExcludedWords() {
+ return excludedWords;
+ }
+
+ public List getExcludedWordsCondition() {
+ return excludedWordsCondition;
+ }
+
+ public String getPhrase() {
+ return phrase;
+ }
+
+ public String getPhraseCondition() {
+ return phraseCondition;
+ }
+
+ @Override
+ public boolean isMet(ToolOutput output) {
+ return output != null && matches(output.getValue().getString());
+ }
+
+ /**
+ * Checks if the given text contain the words provided in the condition parameters. The search is done by using
+ * lower case both text and paramaters.
+ *
+ * @param text
+ * string to check
+ * @return true
if text satisfies this condition
+ */
+ public boolean matches(String text) {
+ if (text == null) {
+ return false;
+ }
+ if (!conditionsParsed) {
+ parseConditionStrings();
+ }
+ String lowerCaseText = text.toLowerCase();
+ if (getExcludedWordsCondition() != null) {
+ for (String excludedWord : getExcludedWordsCondition()) {
+ if (lowerCaseText.contains(excludedWord)) {
+ return false;
+ }
+ }
+ }
+ if (getAnyWordsCondition() != null) {
+ boolean wordFound = false;
+ for (String word : getAnyWordsCondition()) {
+ if (lowerCaseText.contains(word)) {
+ wordFound = true;
+ break;
+ }
+ }
+ if (!wordFound) {
+ return false;
+ }
+ }
+ if (getPhraseCondition() != null && !lowerCaseText.contains(getPhraseCondition())) {
+ return false;
+ }
+ if (getAllWordsCondition() != null) {
+ for (String word : getAllWordsCondition()) {
+ if (!lowerCaseText.contains(word)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Parser currently set condition string using {@link #parseConditionStrings(String, String, String, String)}.
+ */
+ public void parseConditionStrings() {
+ parseConditionStrings(getAllWords(), getPhrase(), getAnyWords(), getExcludedWords());
+ }
+
+ /**
+ * Splits condition parameters into lists of words for easier usage.
+ *
+ * @param allWordsString
+ * @param phraseString
+ * @param anyWordsString
+ * @param excludedWordsString
+ */
+ public void parseConditionStrings(String allWordsString, String phraseString, String anyWordsString,
+ String excludedWordsString) {
+
+ conditionsParsed = true;
+ String trimmed = null;
+ String[] splited = null;
+ if (allWordsString != null) {
+ trimmed = allWordsString.trim();
+ splited = trimmed.split(TextSearchCondition.WORD_DELIMITER_REGEX);
+ for (int index = 0; index < splited.length; index++) {
+ splited[index] = splited[index].toLowerCase();
+ }
+
+ setAllWordsCondition(Arrays.asList(splited));
+ } else {
+ setAllWordsCondition(null);
+ }
+ if (phraseString != null) {
+ trimmed = phraseString.trim();
+ setPhraseCondition(trimmed.toLowerCase());
+ }
+
+ if (anyWordsString != null) {
+ trimmed = anyWordsString.trim();
+ splited = trimmed.split(TextSearchCondition.WORD_DELIMITER_REGEX);
+ for (int index = 0; index < splited.length; index++) {
+ splited[index] = splited[index].toLowerCase();
+ }
+ setAnyWordsCondition(Arrays.asList(splited));
+ } else {
+ setAnyWordsCondition(null);
+ }
+ if (excludedWordsString != null) {
+ trimmed = excludedWordsString.trim();
+ splited = trimmed.split(TextSearchCondition.WORD_DELIMITER_REGEX);
+ for (int index = 0; index < splited.length; index++) {
+ splited[index] = splited[index].toLowerCase();
+ }
+ setExcludedWordsCondition(Arrays.asList(splited));
+ } else {
+ setExcludedWordsCondition(null);
+ }
+ }
+
+ /**
+ * Fills the condition parameters using strings provided by an user in the form.
+ *
+ * @param textSearchActionForm
+ * form to parse
+ */
+ public void parseConditionStrings(TextSearchActionForm textSearchActionForm) {
+ parseConditionStrings(textSearchActionForm.getAllWords(), textSearchActionForm.getPhrase(),
+ textSearchActionForm.getAnyWords(), textSearchActionForm.getExcludedWords());
+ }
+
+ public void setAllWords(String allWords) {
+ this.allWords = allWords;
+ conditionsParsed = false;
+ }
+
+ public void setAnyWords(String anyWords) {
+ this.anyWords = anyWords;
+ conditionsParsed = false;
+ }
+
+ public void setExcludedWords(String excludedWords) {
+ this.excludedWords = excludedWords;
+ conditionsParsed = false;
+ }
+
+ public void setPhrase(String phrase) {
+ this.phrase = phrase;
+ conditionsParsed = false;
+ }
+
+ public void setPhraseCondition(String phraseCondition) {
+ this.phraseCondition = phraseCondition;
+ }
+
+ /**
+ * No condition parameters must be set in order to make the condition valid.
+ */
+ @Override
+ protected boolean isValid() {
+ return true;
+ }
+
+ protected void setAllWordsCondition(List allWordsCondition) {
+ this.allWordsCondition = allWordsCondition;
+ }
+
+ protected void setAnyWordsCondition(List anyWordsCondition) {
+ this.anyWordsCondition = anyWordsCondition;
+ }
+
+ protected void setExcludedWordsCondition(List excludedWordsCondition) {
+ this.excludedWordsCondition = excludedWordsCondition;
+ }
+}
\ No newline at end of file
Index: lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/BranchConditionDTO.java
===================================================================
diff -u -r2927201b0bf594425125fac209db2815fb0f4412 -r3538b4ae424da479962e98b7528ad22b44cdd368
--- lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/BranchConditionDTO.java (.../BranchConditionDTO.java) (revision 2927201b0bf594425125fac209db2815fb0f4412)
+++ lams_common/src/java/org/lamsfoundation/lams/learningdesign/dto/BranchConditionDTO.java (.../BranchConditionDTO.java) (revision 3538b4ae424da479962e98b7528ad22b44cdd368)
@@ -25,129 +25,183 @@
import org.apache.commons.lang.builder.ToStringBuilder;
import org.lamsfoundation.lams.learningdesign.BranchCondition;
+import org.lamsfoundation.lams.learningdesign.TextSearchCondition;
-
/**
- * The BranchConditionDTO records the details of one particular condition, used for tool output based branching.
- * On one branching activity there will be one or more conditions, some with the same name. If the condition is a
- * range condition then startValue and endValue will be populated. If it is an exactMatchCondition (such as for a
- * boolean output definition) then the exactMatchValue will be true/false. Order id is used to ensure that the
- * conditions are always listed in the same order on the screen.
+ * The BranchConditionDTO records the details of one particular condition, used for tool output based branching. On one
+ * branching activity there will be one or more conditions, some with the same name. If the condition is a range
+ * condition then startValue and endValue will be populated. If it is an exactMatchCondition (such as for a boolean
+ * output definition) then the exactMatchValue will be true/false. Order id is used to ensure that the conditions are
+ * always listed in the same order on the screen.
*/
public class BranchConditionDTO {
- private Long conditionId;
- private Integer conditionUIID;
- private Integer orderID;
- private String name;
+ private Long conditionId;
+ private Integer conditionUIID;
+ private Integer orderID;
+ private String name;
private String displayName;
- private String type;
- private String startValue;
- private String endValue;
+ private String type;
+ private String startValue;
+ private String endValue;
private String exactMatchValue;
private Integer toolActivityUIID;
-
- public BranchConditionDTO( BranchCondition condition, Integer toolActivityUIID ) {
- this.conditionId = condition.getConditionId();
- this.conditionUIID = condition.getConditionUIID();
- this.orderID = condition.getOrderId();
- this.name = condition.getName();
- this.displayName = condition.getDisplayName();
- this.type = condition.getType();
- this.startValue = condition.getStartValue();
- this.endValue = condition.getEndValue();
+ private String allWords;
+ private String phrase;
+ private String anyWords;
+ private String excludedWords;
- this.exactMatchValue = condition.getExactMatchValue();
- this.toolActivityUIID = toolActivityUIID;
+ public BranchConditionDTO(BranchCondition condition, Integer toolActivityUIID) {
+ conditionId = condition.getConditionId();
+ conditionUIID = condition.getConditionUIID();
+ orderID = condition.getOrderId();
+ name = condition.getName();
+ displayName = condition.getDisplayName();
+ type = condition.getType();
+
+ startValue = condition.getStartValue();
+ endValue = condition.getEndValue();
+
+ exactMatchValue = condition.getExactMatchValue();
+ this.toolActivityUIID = toolActivityUIID;
+
+ if (condition instanceof TextSearchCondition) {
+ TextSearchCondition textSearchCondition = (TextSearchCondition) condition;
+ allWords = textSearchCondition.getAllWords();
+ phrase = textSearchCondition.getPhrase();
+ anyWords = textSearchCondition.getAnyWords();
+ excludedWords = textSearchCondition.getExcludedWords();
+ }
}
-
+
public Long getConditionId() {
- return conditionId;
- }
+ return conditionId;
+ }
- public void setConditionId(Long conditionId) {
- this.conditionId = conditionId;
- }
+ public void setConditionId(Long conditionId) {
+ this.conditionId = conditionId;
+ }
- public Integer getConditionUIID() {
- return conditionUIID;
- }
+ public Integer getConditionUIID() {
+ return conditionUIID;
+ }
- public void setConditionUIID(Integer conditionUIID) {
- this.conditionUIID = conditionUIID;
- }
+ public void setConditionUIID(Integer conditionUIID) {
+ this.conditionUIID = conditionUIID;
+ }
- public Integer getOrderID() {
- return orderID;
- }
- public void setOrderID(Integer orderId) {
- this.orderID = orderId;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getType() {
- return type;
- }
- public void setType(String type) {
- this.type = type;
- }
- public String getStartValue() {
- return startValue;
- }
- public void setStartValue(String startValue) {
- this.startValue = startValue;
- }
- public String getEndValue() {
- return endValue;
- }
- public void setEndValue(String endValue) {
- this.endValue = endValue;
- }
- public String getExactMatchValue() {
- return exactMatchValue;
- }
- public void setExactMatchValue(String exactMatchValue) {
- this.exactMatchValue = exactMatchValue;
- }
+ public Integer getOrderID() {
+ return orderID;
+ }
+ public void setOrderID(Integer orderId) {
+ orderID = orderId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getStartValue() {
+ return startValue;
+ }
+
+ public void setStartValue(String startValue) {
+ this.startValue = startValue;
+ }
+
+ public String getEndValue() {
+ return endValue;
+ }
+
+ public void setEndValue(String endValue) {
+ this.endValue = endValue;
+ }
+
+ public String getExactMatchValue() {
+ return exactMatchValue;
+ }
+
+ public void setExactMatchValue(String exactMatchValue) {
+ this.exactMatchValue = exactMatchValue;
+ }
+
+ @Override
public String toString() {
- return new ToStringBuilder(this)
- .append("conditionId", conditionId)
- .append("conditionUIID", conditionUIID)
- .append("orderId", orderID)
- .append("name", name)
- .append("type", type)
- .append("startValue", startValue)
- .append("endValue", endValue)
- .append("exactMatchValue", exactMatchValue)
- .toString();
+ return new ToStringBuilder(this).append("conditionId", conditionId).append("conditionUIID", conditionUIID)
+ .append("orderId", orderID).append("name", name).append("type", type).append("startValue", startValue)
+ .append("endValue", endValue).append("exactMatchValue", exactMatchValue).append("allWordsCondition",
+ allWords).append("phraseCondition", phrase).append("anyWordsCondition",
+ anyWords).append("excludedWordsCondition", excludedWords).toString();
}
- public String getDisplayName() {
- return displayName;
- }
+ public String getDisplayName() {
+ return displayName;
+ }
- public void setDisplayName(String displayName) {
- this.displayName = displayName;
- }
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
- /** The UIID of the tool activity that will be queried for the tool output. This should match the
- * output field in the appropriate branching activity. It is here to make life easier on the Flash side - so that
- * it has the UIID somewhere if the user changes from a tool based branch -> group/teacher based and
- * back to tool based without saving.
- * @return toolActivityUIID
- */
- public Integer getToolActivityUIID() {
- return toolActivityUIID;
- }
+ /**
+ * The UIID of the tool activity that will be queried for the tool output. This should match the output field in the
+ * appropriate branching activity. It is here to make life easier on the Flash side - so that it has the UIID
+ * somewhere if the user changes from a tool based branch -> group/teacher based and back to tool based without
+ * saving.
+ *
+ * @return toolActivityUIID
+ */
+ public Integer getToolActivityUIID() {
+ return toolActivityUIID;
+ }
- public void setToolActivityUIID(Integer toolActivityUIID) {
- this.toolActivityUIID = toolActivityUIID;
- }
-
-}
+ public void setToolActivityUIID(Integer toolActivityUIID) {
+ this.toolActivityUIID = toolActivityUIID;
+ }
+
+ public String getAllWords() {
+ return allWords;
+ }
+
+ public void setAllWords(String allWordsCondition) {
+ this.allWords = allWordsCondition;
+ }
+
+ public String getPhrase() {
+ return phrase;
+ }
+
+ public void setPhrase(String phraseCondition) {
+ this.phrase = phraseCondition;
+ }
+
+ public String getAnyWords() {
+ return anyWords;
+ }
+
+ public void setAnyWords(String anyWordsCondition) {
+ this.anyWords = anyWordsCondition;
+ }
+
+ public String getExcludedWords() {
+ return excludedWords;
+ }
+
+ public void setExcludedWords(String excludedWordsCondition) {
+ this.excludedWords = excludedWordsCondition;
+ }
+
+}
\ No newline at end of file