[Tynstep-svn] r176 - in trunk/step-web-server: . src/main/java/com/tyndalehouse/step/web/server/common src/main/java/com/tyndalehouse/step/web/server/db/framework src/main/java/com/tyndalehouse/step/web/server/db/timeline src/main/java/com/tyndalehouse/step/web/server/guice src/main/java/com/tyndalehouse/step/web/server/handler src/main/java/com/tyndalehouse/step/web/server/handler/util/passage src/main/java/com/tyndalehouse/step/web/server/jsword src/main/java/com/tyndalehouse/step/web/server/service src/main/java/com/tyndalehouse/step/web/server/service/impl src/test/java/com/tyndalehouse/step/web/server/db src/test/java/com/tyndalehouse/step/web/server/db/helper src/test/java/com/tyndalehouse/step/web/server/handler
ChrisBurrell at crosswire.org
ChrisBurrell at crosswire.org
Fri Aug 27 05:37:36 MST 2010
Author: ChrisBurrell
Date: 2010-08-27 05:37:35 -0700 (Fri, 27 Aug 2010)
New Revision: 176
Added:
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/StepInternalException.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/PassageMerger.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/PassageSearcher.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/PassageMergerImpl.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/PassageSearcherImpl.java
Removed:
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/OsisParserFilter.java
Modified:
trunk/step-web-server/pom.xml
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/AbstractStepHandler.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/ConfigNotLoadedException.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/ConfigProvider.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/MalformedStepQueryException.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/QueryImpl.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/ResultSetProcessor.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQuery.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQueryRunner.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQueryRunnerImpl.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/UnableToRunQueryException.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimeBandVisibleDateProcessor.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineOriginDbBean.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineOriginProcessor.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineSetupDataProcessor.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/CustomDispatchServiceServlet.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/LogProvider.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/ServerModule.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetAvailableBibleVersionsHandler.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetBibleBooksHandler.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandler.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandler.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetEventsForDateRangeHandler.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineOriginForScriptureHandler.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandler.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/InstallJswordModuleHandler.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/MorphWordCombo.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/StrongMorphMap.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/jsword/ConfigurableHTMLConverter.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/jsword/XSLTProperty.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/JSwordService.java
trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImpl.java
trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/StepQueryRunnerImplTest.java
trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/helper/TestProcessor.java
trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/helper/TestQueryImpl.java
trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandlerTest.java
trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandlerTest.java
trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandlerTest.java
trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/JSwordInstallTest.java
Log:
major refactor
Modified: trunk/step-web-server/pom.xml
===================================================================
--- trunk/step-web-server/pom.xml 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/pom.xml 2010-08-27 12:37:35 UTC (rev 176)
@@ -4,24 +4,22 @@
<groupId>com.tyndalehouse</groupId>
<artifactId>step-parent</artifactId>
<version>0.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
+ <relativePath>../step-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>com.tyndalehouse</groupId>
<artifactId>step-web-server</artifactId>
<packaging>jar</packaging>
- <name>step-web-server</name>
+ <name>STEP :: Web Application - Server handlers</name>
<dependencies>
<dependency>
<groupId>com.tyndalehouse</groupId>
<artifactId>step-web-shared</artifactId>
- <version>${project.version}</version>
</dependency>
-
<dependency>
<groupId>org.crosswire</groupId>
<artifactId>jsword</artifactId>
@@ -104,53 +102,18 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.5</version>
<configuration>
<systemPropertyVariables>
<db.driver>${db.driver}</db.driver>
<connection.string>${db.connection.string}</connection.string>
<step.proxy.host>${step.http.proxy}</step.proxy.host>
- <step.proxy.port>{step.http.port}</step.proxy.port>
+ <step.proxy.port>${step.http.port}</step.proxy.port>
</systemPropertyVariables>
<includes>
<include>**/*Test.java</include>
</includes>
</configuration>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- <version>2.3</version>
- <configuration>
- <check>
- <branchRate>85</branchRate>
- <lineRate>85</lineRate>
- <haltOnFailure>false</haltOnFailure>
- <totalBranchRate>60</totalBranchRate>
- <totalLineRate>60</totalLineRate>
- <packageLineRate>60</packageLineRate>
- <packageBranchRate>60</packageBranchRate>
- <!--
- <regexes> <regex>
- <pattern>com.example.reallyimportant.*</pattern>
- <branchRate>90</branchRate> <lineRate>80</lineRate> </regex>
- <regex> <pattern>com.example.boringcode.*</pattern>
- <branchRate>40</branchRate> <lineRate>30</lineRate> </regex>
- </regexes>
- -->
- </check>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>clean</goal>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
-
</plugins>
</build>
</project>
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/AbstractStepHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/AbstractStepHandler.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/AbstractStepHandler.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -3,7 +3,9 @@
import java.lang.reflect.ParameterizedType;
import net.customware.gwt.dispatch.server.ActionHandler;
+import net.customware.gwt.dispatch.server.ExecutionContext;
import net.customware.gwt.dispatch.shared.Action;
+import net.customware.gwt.dispatch.shared.ActionException;
import net.customware.gwt.dispatch.shared.Result;
import org.apache.log4j.Logger;
@@ -13,20 +15,40 @@
*
* @author CJBurrell
*
- * @param <A>
- * the action in question
- * @param <R>
- * the response to be sent back to the client
+ * @param <A> the action in question
+ * @param <R> the response to be sent back to the client
*/
public abstract class AbstractStepHandler<A extends Action<R>, R extends Result> implements ActionHandler<A, R> {
+ private final Logger logger = Logger.getLogger(this.getClass());
+
/**
- * Logger for a particular instance of a handler
+ * Internal function to handler which gets called by this wrapped
+ *
+ * @param action the action that is being execution
+ * @param context the context in which it is being executed
+ * @return a result
*/
- private final Logger logger = Logger.getLogger(this.getClass());
+ public abstract R executeInternal(A action, ExecutionContext context);
+ public R execute(final A action, final ExecutionContext context) throws ActionException {
+ try {
+ return executeInternal(action, context);
+ } catch (final IllegalArgumentException exception) {
+ throw new ActionException("The input provided to the handler did not validate correctly", exception);
+ } catch (final StepInternalException exception) {
+ throw new ActionException("An error occured while processing data on the server", exception);
+ } catch (final Exception exception) {
+ throw new ActionException("An uncaught exception occured on the server", exception);
+ }
+ }
+
+ public void rollback(final A action, final R result, final ExecutionContext context) throws ActionException {
+ getLogger().error("The action [{}] is being rolled back" + action.getClass().getName());
+ }
+
@SuppressWarnings("unchecked")
- /*
+ /**
* returns the type of the action
*
* @return the type of the action
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/ConfigNotLoadedException.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/ConfigNotLoadedException.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/ConfigNotLoadedException.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -1,8 +1,7 @@
package com.tyndalehouse.step.web.server.common;
/**
- * an exceptoin to indicate that the configuration properties have not been
- * loaded
+ * an exceptoin to indicate that the configuration properties have not been loaded
*
* @author CJBurrell
*
@@ -15,11 +14,9 @@
private static final long serialVersionUID = 1644291687028980017L;
/**
- * public constructor an exceptoin to indicate that the configuration
- * properties have not been loaded
+ * public constructor an exceptoin to indicate that the configuration properties have not been loaded
*
- * @param e
- * the base exception
+ * @param e the base exception
*/
public ConfigNotLoadedException(final Exception e) {
super("The configuration files could not be loaded", e);
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/ConfigProvider.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/ConfigProvider.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/ConfigProvider.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -5,8 +5,7 @@
import java.util.Properties;
/**
- * Config Provider for Step. TODO: Possibly should be rewritten to have a Guice
- * element to it, with @Singleton tag
+ * Config Provider for Step. TODO: Possibly should be rewritten to have a Guice element to it, with @Singleton tag
*
* @author CJBurrell
*
@@ -25,20 +24,17 @@
/**
* private constructor to prevent initialisation.
*
- * @throws ConfigNotLoadedException
- * exception should it fail to look up the parameter name
+ * @throws ConfigNotLoadedException exception should it fail to look up the parameter name
*/
private ConfigProvider() throws ConfigNotLoadedException {
load();
}
/**
- * Loads or reloads a properties file from the classpath. TODO: investigate
- * issue with concurrency here, since we might access p before it's fully
- * loaded...
+ * Loads or reloads a properties file from the classpath. TODO: investigate issue with concurrency here, since we
+ * might access p before it's fully loaded...
*
- * @throws ConfigNotLoadedException
- * exception should it fail to look up the parameter name
+ * @throws ConfigNotLoadedException exception should it fail to look up the parameter name
*/
public void load() throws ConfigNotLoadedException {
final ClassLoader loader = Thread.currentThread().getContextClassLoader();
@@ -53,11 +49,9 @@
/**
* Gets the value of a param.
*
- * @param name
- * the name of the param
+ * @param name the name of the param
* @return the value of the param
- * @throws ConfigNotLoadedException
- * A problem occured during loading of the config
+ * @throws ConfigNotLoadedException A problem occured during loading of the config
*/
public synchronized static String get(final String name) throws ConfigNotLoadedException {
if (ConfigProvider.pr == null) {
@@ -76,8 +70,7 @@
/**
* reads a property on the properties object.
*
- * @param name
- * name of the property
+ * @param name name of the property
* @return the value
*/
private String readProperty(final String name) {
@@ -87,11 +80,9 @@
/**
* returns an integer corresponding to the name of the parameter.
*
- * @param paramName
- * the name of the parameter
+ * @param paramName the name of the parameter
* @return an integer value for paramName
- * @throws ConfigNotLoadedException
- * exception should it fail to look up the parameter name
+ * @throws ConfigNotLoadedException exception should it fail to look up the parameter name
*/
public static int getInt(final String paramName) throws ConfigNotLoadedException {
return Integer.parseInt(get(paramName));
Added: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/StepInternalException.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/StepInternalException.java (rev 0)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/common/StepInternalException.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -0,0 +1,24 @@
+package com.tyndalehouse.step.web.server.common;
+
+public class StepInternalException extends RuntimeException {
+ private static final long serialVersionUID = -5636677138385910988L;
+
+ /**
+ * creates the generic step internal exception to be used on the server
+ *
+ * @param message the message for the exception
+ * @param t the cause of the exception
+ */
+ public StepInternalException(final String message, final Throwable t) {
+ super(message, t);
+ }
+
+ /**
+ * creates the generic runtime exception to be used on the server
+ *
+ * @param message the message
+ */
+ public StepInternalException(final String message) {
+ super(message);
+ }
+}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/MalformedStepQueryException.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/MalformedStepQueryException.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/MalformedStepQueryException.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -14,23 +14,18 @@
private static final long serialVersionUID = -3607780460262284122L;
/**
- * to instantiate the exception when a particular parameter name is
- * incorrect
+ * to instantiate the exception when a particular parameter name is incorrect
*
- * @param paramName
- * parameter name that is incorrect
- * @param sql
- * sql in which parameter name was incorrect
+ * @param paramName parameter name that is incorrect
+ * @param sql sql in which parameter name was incorrect
*/
public MalformedStepQueryException(final String paramName, final String sql) {
super(String.format("The argument %s was not recognised in query:\n %s", paramName, sql));
}
/**
- * @param message
- * the message
- * @param ex
- * base exception to be passed up to the super class
+ * @param message the message
+ * @param ex base exception to be passed up to the super class
*/
public MalformedStepQueryException(final String message, final Exception ex) {
super(message, ex);
@@ -38,8 +33,7 @@
/**
*
- * @param message
- * simple message to instantiate the default exception
+ * @param message simple message to instantiate the default exception
*/
public MalformedStepQueryException(final String message) {
super(message);
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/QueryImpl.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/QueryImpl.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/QueryImpl.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -18,8 +18,7 @@
GET_TIMELINE_SETUP_DATA("timeline"),
/**
- * looks up which is the closest event, and on which timeline a given
- * scripture passage is
+ * looks up which is the closest event, and on which timeline a given scripture passage is
*/
LOOKUP_TIMELINE_ORIGIN("timeline");
@@ -31,8 +30,7 @@
/**
* default constructor for this enum
*
- * @param component
- * component/folder where the query resides
+ * @param component component/folder where the query resides
*/
QueryImpl(final String component) {
this.component = component;
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/ResultSetProcessor.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/ResultSetProcessor.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/ResultSetProcessor.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -9,16 +9,14 @@
/**
* @author CJBurrell This is used by the query runner to process result sets
- * @param <T>
- * the type of bean to be returned
+ * @param <T> the type of bean to be returned
*/
public interface ResultSetProcessor<T> {
/**
- * returns the parameters. Typically this would only be called by the query
- * framework
+ * returns the parameters. Typically this would only be called by the query framework
*
- * @return a map, mapping the parameter name to the object to be passed into
- * the query (generally native types or Strings)
+ * @return a map, mapping the parameter name to the object to be passed into the query (generally native types or
+ * Strings)
*/
Map<String, Object> getParameters();
@@ -30,18 +28,14 @@
Query getQuery();
/**
- * This method will be called after a query has been run by the query
- * framework. It returns a list of beans to the caller
+ * This method will be called after a query has been run by the query framework. It returns a list of beans to the
+ * caller
*
- * @param rs
- * ResultSet to be processed
+ * @param rs ResultSet to be processed
* @return a list of beans to the UI of type T
- * @throws MalformedStepQueryException
- * the query run was malformed
- * @throws ConfigNotLoadedException
- * an error occured during the loading of the database config
- * @throws SQLException
- * a SQL exception occurred
+ * @throws MalformedStepQueryException the query run was malformed
+ * @throws ConfigNotLoadedException an error occured during the loading of the database config
+ * @throws SQLException a SQL exception occurred
*/
List<T> process(ResultSet rs) throws MalformedStepQueryException, ConfigNotLoadedException, SQLException;
}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQuery.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQuery.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQuery.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -9,9 +9,8 @@
import java.util.Map;
/**
- * Step Query to be executed against the database. This this is then given to
- * the StepQueryRunner and executed It contains the list of arguments, the types
- * of those parameters and the sql statement to be executed
+ * Step Query to be executed against the database. This this is then given to the StepQueryRunner and executed It
+ * contains the list of arguments, the types of those parameters and the sql statement to be executed
*
* @author CJBurrell
*
@@ -45,8 +44,7 @@
* select 1 from table where value = #paramName#
* </code>
*
- * @param paramName
- * param name to be added to the query definition
+ * @param paramName param name to be added to the query definition
*
*/
public void addArgument(final String paramName) {
@@ -56,10 +54,8 @@
/**
* addings a mapping from the definitions at the top of the file
*
- * @param paramName
- * parameter name
- * @param type
- * type of the parameter
+ * @param paramName parameter name
+ * @param type type of the parameter
*/
public void addParamTypeMapping(final String paramName, final Integer type) {
paramTypes.put(paramName, type);
@@ -77,8 +73,7 @@
/**
* Sets the sql for the step query to be run
*
- * @param sql
- * sql representing the query to be run
+ * @param sql sql representing the query to be run
*/
public void setSQLText(final String sql) {
this.sql = sql;
@@ -87,13 +82,10 @@
/**
* Sets up the prepared statement arguments in the correct order.
*
- * @param ps
- * the prepared statement
- * @param passedArguments
- * the map of named arguments
- * @throws SQLException
- * this is thrown if the passed in arguments do not match the
- * expected parameters as loaded from disk
+ * @param ps the prepared statement
+ * @param passedArguments the map of named arguments
+ * @throws SQLException this is thrown if the passed in arguments do not match the expected parameters as loaded
+ * from disk
*
*/
public void setupParameters(final PreparedStatement ps, final Map<String, Object> passedArguments)
@@ -105,11 +97,10 @@
}
/**
- * Validates the query loaded, to ensure that the number of arguments found
- * in the query match the number of arguments found in the declarations
+ * Validates the query loaded, to ensure that the number of arguments found in the query match the number of
+ * arguments found in the declarations
*
- * @throws MalformedStepQueryException
- * this is thrown if the validation fails
+ * @throws MalformedStepQueryException this is thrown if the validation fails
*/
public void validate() throws MalformedStepQueryException {
for (final String arg : arguments) {
@@ -124,17 +115,11 @@
/**
* Sets up the parameter into the prepared statement
*
- * @param ps
- * prepared statement
- * @param sqlType
- * the type of the parameter
- * @param value
- * the value of the parameter
- * @param argIndex
- * the position at which the parameter is to be placed in the
- * prepared statement
- * @throws SQLException
- * an exception thrown in case something goes wrong
+ * @param ps prepared statement
+ * @param sqlType the type of the parameter
+ * @param value the value of the parameter
+ * @param argIndex the position at which the parameter is to be placed in the prepared statement
+ * @throws SQLException an exception thrown in case something goes wrong
*/
private void setArgument(final PreparedStatement ps, final int sqlType, final Object value, final int argIndex)
throws SQLException {
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQueryRunner.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQueryRunner.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQueryRunner.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -3,8 +3,7 @@
import java.util.List;
/**
- * StepQueryRunner interface defining what should be present for the clients to
- * use this as a library
+ * StepQueryRunner interface defining what should be present for the clients to use this as a library
*
* @author CJBurrell
*
@@ -24,14 +23,11 @@
/**
* To run a query in the database
*
- * @param <T>
- * Type of bean to be returned
- * @param processor
- * Processor to be invoked: @see {@link ResultSetProcessor}
+ * @param <T> Type of bean to be returned
+ * @param processor Processor to be invoked: @see {@link ResultSetProcessor}
* @return a list of beans of type T
- * @throws UnableToRunQueryException
- * if the configuration was not loaded or a sql exception during
- * parsing or execution of the call
+ * @throws UnableToRunQueryException if the configuration was not loaded or a sql exception during parsing or
+ * execution of the call
*/
<T> List<T> run(final ResultSetProcessor<T> processor) throws UnableToRunQueryException;
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQueryRunnerImpl.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQueryRunnerImpl.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/StepQueryRunnerImpl.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -25,18 +25,16 @@
import com.tyndalehouse.step.web.server.common.ConfigProvider;
/**
- * This class is the crux of the database access. An enum identifies the SQL
- * file to be loaded. Arguments get defined in the query file as define
- * variableName as sqlType A map can be passed in that ensures all arguments are
- * mapped to the correct location in the prepared statement
+ * This class is the crux of the database access. An enum identifies the SQL file to be loaded. Arguments get defined in
+ * the query file as define variableName as sqlType A map can be passed in that ensures all arguments are mapped to the
+ * correct location in the prepared statement
*
* @author CJBurrell
*/
@Singleton
public class StepQueryRunnerImpl implements StepQueryRunner {
/**
- * query to indicate whether to cache prepared statements. Currently doesn't
- * work well with Apache Derby
+ * query to indicate whether to cache prepared statements. Currently doesn't work well with Apache Derby
*/
private static final Object CACHE_QUERY_PROPERTY = "query.runner.cache";
@@ -73,8 +71,7 @@
/**
* prevent instantiation
*
- * @param log
- * default logger to use throughout implementation
+ * @param log default logger to use throughout implementation
*/
@Inject
public StepQueryRunnerImpl(final Log log) {
@@ -93,13 +90,10 @@
/**
* returns a list of beans of type T
*
- * @param processor
- * processor to be used
- * @param <T>
- * the type of the bean to be returned
+ * @param processor processor to be used
+ * @param <T> the type of the bean to be returned
* @return list of beans of type T
- * @throws UnableToRunQueryException
- * unable to run the query for various reasons
+ * @throws UnableToRunQueryException unable to run the query for various reasons
* @see com.tyndalehouse.step.web.server.db.StepQueryRunner#run(com.tyndalehouse
* .step.web.server.db.ResultSetProcessor)
*/
@@ -174,14 +168,10 @@
}
/**
- * if logging is enabled at trace level, then the query is output, with all
- * its parameters
+ * if logging is enabled at trace level, then the query is output, with all its parameters
*
- * @param processor
- * processor to process results of the query, which contains the
- * parameters
- * @param stepQuery
- * the query to be logged
+ * @param processor processor to process results of the query, which contains the parameters
+ * @param stepQuery the query to be logged
*/
private void logStepQuery(final ResultSetProcessor<?> processor, final StepQuery stepQuery) {
if (log.isTraceEnabled()) {
@@ -201,14 +191,12 @@
}
/**
- * Faster than a regexp, so use this , in which we expect that there are
- * arguments to be parsed These would be defined as #query-param# within the
- * sql text. The function works by looking for a open and then a closed #
- * Unfortunately, it is not perfect and will have TODO; be rewritten to
- * ensure that the programmer can use the charact # in his query
+ * Faster than a regexp, so use this , in which we expect that there are arguments to be parsed These would be
+ * defined as #query-param# within the sql text. The function works by looking for a open and then a closed #
+ * Unfortunately, it is not perfect and will have TODO; be rewritten to ensure that the programmer can use the
+ * charact # in his query
*
- * @param q
- * is the query
+ * @param q is the query
* @return a object of type {@link StepQuery}
*/
private StepQuery parseArguments(final StringBuffer q) {
@@ -226,16 +214,13 @@
}
/**
- * Look for all lines containing the pattern define variable_name as type
- * Then removes those into a map before continuing
+ * Look for all lines containing the pattern define variable_name as type Then removes those into a map before
+ * continuing
*
- * @param queryText
- * sql text as loaded from disk
- * @param q
- * query text to look through
+ * @param queryText sql text as loaded from disk
+ * @param q query text to look through
* @return a object of type {@link StepQuery}
- * @throws MalformedStepQueryException
- * an exception is thrown to indicate an
+ * @throws MalformedStepQueryException an exception is thrown to indicate an
*/
private StepQuery parseDefinitions(final StringBuffer queryText, final StepQuery q)
throws MalformedStepQueryException {
@@ -268,16 +253,12 @@
}
/**
- * @param query
- * query to be executed. If already cached, then this query is
- * returned otherwise, it is loaded from disk
+ * @param query query to be executed. If already cached, then this query is returned otherwise, it is loaded from
+ * disk
* @return a object of type {@link StepQuery}
- * @throws ConfigNotLoadedException
- * if an issue occured during loading of the configuration for
- * STEP
- * @throws MalformedStepQueryException
- * an exception is thrown to indicate an issue with the sql file
- * that could not be parsed
+ * @throws ConfigNotLoadedException if an issue occured during loading of the configuration for STEP
+ * @throws MalformedStepQueryException an exception is thrown to indicate an issue with the sql file that could not
+ * be parsed
*/
private StepQuery prepareStepQuery(final Query query) throws ConfigNotLoadedException, MalformedStepQueryException {
StepQuery stepQuery = StepQueryRunnerImpl.queries.get(query);
@@ -296,13 +277,10 @@
/**
* Reads a query from the file
*
- * @param query
- * query to be loaded
+ * @param query query to be loaded
* @return returns a loaded {@link StepQuery} object
- * @throws ConfigNotLoadedException
- * failed to load the configuration
- * @throws MalformedStepQueryException
- * thrown if arguments found don't match a declaration
+ * @throws ConfigNotLoadedException failed to load the configuration
+ * @throws MalformedStepQueryException thrown if arguments found don't match a declaration
*/
private StepQuery readQueryFromFile(final Query query) throws ConfigNotLoadedException, MalformedStepQueryException {
// get base path from file
@@ -342,8 +320,7 @@
* sets up the datasource from properties
*
* @return the datasource properly configured
- * @throws ConfigNotLoadedException
- * throws if properties aren't found
+ * @throws ConfigNotLoadedException throws if properties aren't found
*/
private DataSource setupDatasource() throws ConfigNotLoadedException {
final BasicDataSource ds = new BasicDataSource();
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/UnableToRunQueryException.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/UnableToRunQueryException.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/framework/UnableToRunQueryException.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -21,21 +21,17 @@
/**
* Pass in the root cause of the exception
*
- * @param e
- * the root exception
+ * @param e the root exception
*/
public UnableToRunQueryException(final Exception e) {
super(e);
}
/**
- * Unable to run a query exception, with the stepQuery itself, and the root
- * exception
+ * Unable to run a query exception, with the stepQuery itself, and the root exception
*
- * @param e
- * the exception to be wrapped
- * @param stepQuery
- * a step query that was attempted to be executed
+ * @param e the exception to be wrapped
+ * @param stepQuery a step query that was attempted to be executed
*/
public UnableToRunQueryException(final Exception e, final StepQuery stepQuery) {
this(e);
@@ -50,8 +46,7 @@
}
/**
- * @param stepQuery
- * the stepQuery to set
+ * @param stepQuery the stepQuery to set
*/
public final void setStepQuery(final StepQuery stepQuery) {
this.stepQuery = stepQuery;
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimeBandVisibleDateProcessor.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimeBandVisibleDateProcessor.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimeBandVisibleDateProcessor.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -78,12 +78,9 @@
/**
* public constructor to create the processor with default parameters
*
- * @param minDate
- * min date to be passed to the query
- * @param maxDate
- * max date to be passed to the query
- * @param timebandId
- * the timeband id to be looked up
+ * @param minDate min date to be passed to the query
+ * @param maxDate max date to be passed to the query
+ * @param timebandId the timeband id to be looked up
*/
public TimeBandVisibleDateProcessor(final long minDate, final long maxDate, final int timebandId) {
params = new HashMap<String, Object>();
@@ -110,16 +107,12 @@
/**
*
- * @param rs
- * result set to be processed
+ * @param rs result set to be processed
* @see com.tyndalehouse.step.web.server.db.framework.ResultSetProcessor#process(java.sql.ResultSet)
* @return a list of {@link TimelineEventBean} returned by the query
- * @exception MalformedStepQueryException
- * an error occurred during the execution of the query
- * @exception ConfigNotLoadedException
- * an error occurred during the loading of the configuration
- * @exception SQLException
- * an runtime SQL exception occurred
+ * @exception MalformedStepQueryException an error occurred during the execution of the query
+ * @exception ConfigNotLoadedException an error occurred during the loading of the configuration
+ * @exception SQLException an runtime SQL exception occurred
*/
public final List<TimelineEventBean> process(final ResultSet rs) throws MalformedStepQueryException,
ConfigNotLoadedException, SQLException {
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineOriginDbBean.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineOriginDbBean.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineOriginDbBean.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -3,8 +3,7 @@
import com.tyndalehouse.step.web.shared.timeline.Unit;
/**
- * Timeline Origin DB Bean, containing the default configuration for each
- * timeband
+ * Timeline Origin DB Bean, containing the default configuration for each timeband
*
* @author CJBurrell
*
@@ -42,8 +41,7 @@
/**
* Sets the origin field
*
- * @param origin
- * value in ms for oring
+ * @param origin value in ms for oring
*/
public final void setOrigin(final long origin) {
this.origin = origin;
@@ -52,8 +50,7 @@
/**
* Sets the unit for the bean
*
- * @param unit
- * unit that should be shown on screen
+ * @param unit unit that should be shown on screen
*/
public final void setUnit(final String unit) {
this.unit = Unit.valueOf(unit);
@@ -69,8 +66,7 @@
}
/**
- * @param timebandId
- * the timebandId to set
+ * @param timebandId the timebandId to set
*/
public final void setTimebandId(final int timebandId) {
this.timebandId = timebandId;
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineOriginProcessor.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineOriginProcessor.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineOriginProcessor.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -42,10 +42,8 @@
/**
* Given a scripture range, it
*
- * @param qryStart
- * minimum verse no to restrict range lookup
- * @param qryEnd
- * maximum verse no to restrict range lookup
+ * @param qryStart minimum verse no to restrict range lookup
+ * @param qryEnd maximum verse no to restrict range lookup
*/
public TimelineOriginProcessor(final int qryStart, final int qryEnd) {
params = new HashMap<String, Object>();
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineSetupDataProcessor.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineSetupDataProcessor.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/db/timeline/TimelineSetupDataProcessor.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -15,8 +15,7 @@
import com.tyndalehouse.step.web.shared.common.timeline.TimelineBean;
/**
- * Data processor for the Step Query framework, to parse results from the
- * timeline setup sql query
+ * Data processor for the Step Query framework, to parse results from the timeline setup sql query
*
* @author CJBurrell
*
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/CustomDispatchServiceServlet.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/CustomDispatchServiceServlet.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/CustomDispatchServiceServlet.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -16,24 +16,14 @@
*/
@Singleton
public class CustomDispatchServiceServlet extends DispatchServiceServlet {
-
- /**
- *
- */
private static final long serialVersionUID = -6063357416925075136L;
-
- /**
- * default logger
- */
private final Log logger;
/**
* normal constructor
*
- * @param dispatch
- * dispath object
- * @param logger
- * logger to be provided
+ * @param dispatch dispath object
+ * @param logger logger to be provided
*/
@Inject
public CustomDispatchServiceServlet(final Dispatch dispatch, final Log logger) {
@@ -43,7 +33,7 @@
@Override
protected void doUnexpectedFailure(final Throwable e) {
- logger.error("An unexpected error happened on the bridge between server and client", e);
+ this.logger.error("An unexpected error happened on the bridge between server and client", e);
}
}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/LogProvider.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/LogProvider.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/LogProvider.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -16,15 +16,14 @@
public class LogProvider implements Provider<Log> {
// enforce singleton to allow static methods to get to the same log
/**
- * TODO: there should be a logger per class really. All appending to the
- * same file, but so that we can turn them on and off
+ * TODO: there should be a logger per class really. All appending to the same file, but so that we can turn them on
+ * and off
*
*/
private static Log logger = new Log4JLogger("step.jetty");
/**
- * The static equivalent of the above, so that static contexts can log as
- * well
+ * The static equivalent of the above, so that static contexts can log as well
*
* @return the log to use
*/
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/ServerModule.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/ServerModule.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/guice/ServerModule.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -15,7 +15,11 @@
import com.tyndalehouse.step.web.server.handler.GetTimelineOriginForScriptureHandler;
import com.tyndalehouse.step.web.server.handler.GetTimelineUISetupHandler;
import com.tyndalehouse.step.web.server.service.JSwordService;
+import com.tyndalehouse.step.web.server.service.PassageMerger;
+import com.tyndalehouse.step.web.server.service.PassageSearcher;
import com.tyndalehouse.step.web.server.service.impl.JSwordServiceImpl;
+import com.tyndalehouse.step.web.server.service.impl.PassageMergerImpl;
+import com.tyndalehouse.step.web.server.service.impl.PassageSearcherImpl;
/**
* Module which binds the handlers and configurations
@@ -34,6 +38,8 @@
bindHandler(GetTimelineOriginForScriptureHandler.class);
bindHandler(GetDictionaryDefinitionHandler.class);
bind(JSwordService.class).to(JSwordServiceImpl.class).in(Singleton.class);
+ bind(PassageSearcher.class).to(PassageSearcherImpl.class);
+ bind(PassageMerger.class).to(PassageMergerImpl.class);
bind(StepQueryRunner.class).to(StepQueryRunnerImpl.class).in(Singleton.class);
}
}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetAvailableBibleVersionsHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetAvailableBibleVersionsHandler.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetAvailableBibleVersionsHandler.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -2,11 +2,8 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.SortedMap;
-import java.util.TreeMap;
import net.customware.gwt.dispatch.server.ExecutionContext;
-import net.customware.gwt.dispatch.shared.ActionException;
import org.apache.commons.logging.Log;
import org.crosswire.jsword.book.Book;
@@ -34,21 +31,20 @@
/**
* normal constructor
*
- * @param logger
- * provided by Gin
+ * @param logger provided by Gin
*/
@Inject
public GetAvailableBibleVersionsHandler(final Log logger) {
this.logger = logger;
}
- public GetAvailableBibleVersionsResult execute(final GetAvailableBibleVersionsCommand cmd,
- final ExecutionContext arg1) throws ActionException {
+ @Override
+ public GetAvailableBibleVersionsResult executeInternal(final GetAvailableBibleVersionsCommand cmd,
+ final ExecutionContext arg1) {
// TODO: add handling of different types of book: bibles, commentaries,
// versions, etc.
@SuppressWarnings("unchecked")
final List<Book> books = Books.installed().getBooks();
- final SortedMap<String, String> map = new TreeMap<String, String>();
final List<BibleVersion> versions = new ArrayList<BibleVersion>();
for (final Book b : books) {
@@ -64,9 +60,4 @@
result.setBibleVersions(versions);
return result;
}
-
- public void rollback(final GetAvailableBibleVersionsCommand arg0, final GetAvailableBibleVersionsResult arg1,
- final ExecutionContext arg2) throws ActionException {
- logger.error("Rolling back GetAvailableBibleVersions");
- }
}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetBibleBooksHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetBibleBooksHandler.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetBibleBooksHandler.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -4,35 +4,27 @@
import java.util.Locale;
import net.customware.gwt.dispatch.server.ExecutionContext;
-import net.customware.gwt.dispatch.shared.ActionException;
import org.crosswire.jsword.passage.NoSuchVerseException;
import org.crosswire.jsword.versification.BibleInfo;
import org.crosswire.jsword.versification.BibleNames;
import org.crosswire.jsword.versification.BookName;
-import com.google.inject.Inject;
import com.tyndalehouse.step.web.server.common.AbstractStepHandler;
import com.tyndalehouse.step.web.shared.command.GetBibleBooksCommand;
import com.tyndalehouse.step.web.shared.result.GetBibleBooksCommandResult;
/**
- * Command handler for retrieving the different names of the books in a
- * particular version TODO: only currently works for KJV
+ * Command handler for retrieving the different names of the books in a particular version TODO: only currently works
+ * for KJV
*
* @author CJBurrell
*
*/
public class GetBibleBooksHandler extends AbstractStepHandler<GetBibleBooksCommand, GetBibleBooksCommandResult> {
- /**
- * public constructor
- */
- @Inject
- public GetBibleBooksHandler() {
- }
- public GetBibleBooksCommandResult execute(final GetBibleBooksCommand command, final ExecutionContext arg1)
- throws ActionException {
+ @Override
+ public GetBibleBooksCommandResult executeInternal(final GetBibleBooksCommand command, final ExecutionContext arg1) {
getLogger().debug("GetBibleBooksCommandResult has been called...");
@@ -55,14 +47,10 @@
suggestions.add(bn.getPreferredName());
}
} catch (final NoSuchVerseException e) {
+ // TODO throw exception?
getLogger().error("Failed to generate list of bible books", e);
}
return new GetBibleBooksCommandResult(suggestions);
}
-
- public void rollback(final GetBibleBooksCommand arg0, final GetBibleBooksCommandResult arg1,
- final ExecutionContext context) throws ActionException {
-
- }
}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandler.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandler.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -1,432 +1,81 @@
package com.tyndalehouse.step.web.server.handler;
-import static com.tyndalehouse.step.web.server.handler.util.passage.OsisParserFilter.getDefaultAttributeFilter;
-import static com.tyndalehouse.step.web.server.handler.util.passage.OsisParserFilter.getDefaultElementFilter;
-import static com.tyndalehouse.step.web.server.service.impl.JSwordServiceImpl.STRONG_PATTERN_START;
-import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.ALTERNATIVE_WORDING;
-import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.LEMMA;
-import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.MORPH;
-import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.WORD;
-import static com.tyndalehouse.step.web.shared.scripture.PassageLanguage.GREEK;
-import static com.tyndalehouse.step.web.shared.scripture.PassageLanguage.HEBREW;
-import static org.apache.commons.lang.StringUtils.isEmpty;
-import static org.apache.commons.lang.StringUtils.split;
+import static org.apache.commons.lang.Validate.notEmpty;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.Set;
import net.customware.gwt.dispatch.server.ExecutionContext;
-import net.customware.gwt.dispatch.shared.ActionException;
-import org.crosswire.jsword.book.OSISUtil;
-import org.jdom.Attribute;
-import org.jdom.Content;
-import org.jdom.Element;
-import org.jdom.Text;
-import org.jdom.filter.Filter;
-
import com.google.inject.Inject;
import com.tyndalehouse.step.web.server.common.AbstractStepHandler;
-import com.tyndalehouse.step.web.server.handler.util.passage.StrongMorphMap;
import com.tyndalehouse.step.web.server.service.JSwordService;
+import com.tyndalehouse.step.web.server.service.PassageSearcher;
import com.tyndalehouse.step.web.shared.command.GetCurrentBibleTextCommand;
import com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptionGroups;
import com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptions;
import com.tyndalehouse.step.web.shared.result.GetCurrentBibleTextResult;
import com.tyndalehouse.step.web.shared.scripture.OsisElementType;
import com.tyndalehouse.step.web.shared.scripture.Passage;
-import com.tyndalehouse.step.web.shared.scripture.PassageElement;
/**
* Command handler returning a portion of scripture in different formats
*
- * @author CJBurrell
- *
+ * @author CJBurrell concurrency issues here, sharing the same passage searcher
*/
public class GetCurrentBibleTextHandler extends
AbstractStepHandler<GetCurrentBibleTextCommand, GetCurrentBibleTextResult> {
- /**
- * Default hebrew text for interlinear purposes
- */
- public static final String DEFAULT_HEBREW_INTERLINEAR_TEXT = "LXX";
- // TODO:This gives us greek!
- /**
- * Default Greek text for interlinear purposes
- */
- public static final String DEFAULT_GREEK_INTERLINEAR_TEXT = "BYZ";
-
- private static final String LEMMA_MORPH_SEPARATOR = ",";
- private Set<OsisElementType> elementFilter;
- private Set<OsisElementType> attributeFilter;
+ private final PassageSearcher passageSearcher;
private final JSwordService jsword;
- private String version;
- private String reference;
- // FIXME: the above only get set once...
-
@Inject
- public GetCurrentBibleTextHandler(final JSwordService jsword) {
+ public GetCurrentBibleTextHandler(final PassageSearcher passageSearcher, final JSwordService jsword) {
+ this.passageSearcher = passageSearcher;
this.jsword = jsword;
}
- public GetCurrentBibleTextResult execute(final GetCurrentBibleTextCommand command, final ExecutionContext arg1)
- throws ActionException {
- version = command.getVersion();
- reference = command.getReference();
+ /**
+ * gets a portion of scripture and sends the result back to the server.
+ */
+ @Override
+ public GetCurrentBibleTextResult executeInternal(final GetCurrentBibleTextCommand command,
+ final ExecutionContext arg1) {
+ notEmpty(command.getVersion(), "The version requested was empty");
+ notEmpty(command.getReference(), "The reference requested was empty");
+ notEmpty(command.getDisplayOptions());
- // TODO drive filter from UI
- initFilters();
- changeDefaultFilters(command.getDisplayOptions());
+ final Set<OsisElementType> filteredElements = OsisElementType.getDefaultElements();
+ final Set<OsisElementType> filteredAttributes = OsisElementType.getDefaultAttributes();
+ final Map<String, ScriptureDisplayOptions> displayOptions = command.getDisplayOptions();
- // check information has been passed in
- // TODO: ensure error handling is handled properly
- if (isEmpty(version)) {
- throw new ActionException("Version was not provided");
- }
- if (isEmpty(reference)) {
- throw new ActionException("Reference was not provided");
- }
+ populatePassageFilters(command.getDisplayOptions(), filteredElements, filteredAttributes);
- final GetCurrentBibleTextResult result = new GetCurrentBibleTextResult();
+ this.passageSearcher.setSearchCriteria(command.getVersion(), command.getReference());
+ this.passageSearcher.setFilters(filteredElements, filteredAttributes);
- final Map<String, ScriptureDisplayOptions> displayOptions = command.getDisplayOptions();
- // move groups to enums too?
- switch (displayOptions.get(ScriptureDisplayOptionGroups.INTERLINEAR.name())) {
- case CLASSIC_INTERLINEAR:
- addClassicInterlinear(result.getPassage());
- break;
- case NO_INTERLINEAR:
- addLogicalLookup(result);
- break;
- case REVERSE_INTERLINEAR:
- addLogicalLookup(result);
- addReverseInterlinear(result.getPassage());
- break;
- default:
- break;
- }
+ final Passage p = this.passageSearcher.search(displayOptions.get(ScriptureDisplayOptionGroups.INTERLINEAR
+ .name()));
- result.getPassage().setElementFilter(elementFilter);
- result.getPassage().setAttributeFilter(attributeFilter);
- result.setReadableKey(jsword.getReadableKey(version, reference));
+ final GetCurrentBibleTextResult result = new GetCurrentBibleTextResult();
+ result.setPassage(p);
+ result.setReadableKey(this.jsword.getReadableKey(command.getVersion(), command.getReference()));
return result;
}
/**
- * changes the default filters
+ * populates the options according to what is specified in the UI
*
- * @param displayOptions
- * the display options
+ * @param displayOptions the display options
*/
- void changeDefaultFilters(final Map<String, ScriptureDisplayOptions> displayOptions) {
+ void populatePassageFilters(final Map<String, ScriptureDisplayOptions> displayOptions,
+ final Set<OsisElementType> includedElements, final Set<OsisElementType> includedAttributes) {
if (displayOptions.containsKey(ScriptureDisplayOptions.SHOW_LEMMAS.getKey())) {
- this.attributeFilter.add(OsisElementType.LEMMA);
+ includedElements.add(OsisElementType.LEMMA);
}
if (displayOptions.containsKey(ScriptureDisplayOptions.REVERSE_INTERLINEAR.getKey())) {
- this.attributeFilter.add(OsisElementType.MORPH);
+ includedAttributes.add(OsisElementType.MORPH);
}
}
-
- /**
- * sets up initial filters to ensure some OSIS information gets filtered out
- */
- void initFilters() {
- if (elementFilter == null) {
- elementFilter = getDefaultElementFilter();
- }
-
- if (attributeFilter == null) {
- attributeFilter = getDefaultAttributeFilter();
- }
- }
-
- public void rollback(final GetCurrentBibleTextCommand arg0, final GetCurrentBibleTextResult arg1,
- final ExecutionContext arg2) throws ActionException {
- getLogger().error("Get Current Bible Text rolling back");
-
- }
-
- /**
- * does a classic interlinear and populates the Passage
- *
- * @param p
- * the logical passage to be populated
- */
- private void addClassicInterlinear(final Passage p) {
- // TODO: feature
- // identify the hebrew/greek version of the text, and get book data for
- // the appropriate version
- // final VerseRange vrf = VerseRangeFactory.fromString(reference);
- // TODO updgrade to latest jsword version
-
- // VerseRange.remainder(vrf, null);
-
- // getBookData(version, reference);
- }
-
- /**
- * adds a logical lookup to the result objet
- *
- * @param result
- * the result object to populate
- * @param data
- * the data to base the lookup upon
- * @throws ActionException
- * an exception thrown if the parsing or lookup goes bad
- */
- void addLogicalLookup(final GetCurrentBibleTextResult result) throws ActionException {
- final Passage p = parseForGwt();
- result.setPassage(p);
- }
-
- /**
- * doing a reverse interlinear
- *
- * @param translatedText
- * the passage as looked up in an non-original version
- * @throws ActionException
- * action exception thrown during execution of the reverse
- * interlinear process
- */
- private void addReverseInterlinear(final Passage translatedText) throws ActionException {
- // first lookup passage from LXX or TODO user chosen version
- // TODO: cope with Hebrew
- final String versionToUse;
- StrongMorphMap strongMorphMap;
- determineOriginalLanguage(translatedText);
-
- if (GREEK.equals(translatedText.getOriginalLanguage())) {
- versionToUse = DEFAULT_GREEK_INTERLINEAR_TEXT;
- } else if (HEBREW.equals(translatedText.getOriginalLanguage())) {
- versionToUse = DEFAULT_HEBREW_INTERLINEAR_TEXT;
- } else {
- // TODO remove all references to Action exceptions if possible
- throw new ActionException("Unable to do determine original language - no lemmas in text?");
- }
-
- // TODO: we need to do something different here,
- // we don't need to parse through the whole lot, and probably JDom
- // allows us to use filters to get all children of a certain kind,
- // we want to end up with a keyed map, looking like [strong, morph?] ->
- // word
- strongMorphMap = getStrongMorphMap(versionToUse);
-
- mergePassages(translatedText, strongMorphMap);
- }
-
- /**
- * given a book data (referencing a biblical reference + a book), retrieves
- * the morphs and the Strong numbers (lemmas) in the passage to help in the
- * interlinear processing
- *
- * @param bookData
- * the bookData from JSword specialised for the reference and
- * bible book
- * @return a map of strong numbers and morphs
- */
- @SuppressWarnings("unchecked")
- private StrongMorphMap getStrongMorphMap(final String version) {
- final Element osis = jsword.getOsisText(version, this.reference);
- final StrongMorphMap strongMorphMap = new StrongMorphMap();
- final Iterator<Element> it = osis.getDescendants(new Filter() {
- private static final long serialVersionUID = 4171956787222841308L;
-
- public boolean matches(final Object obj) {
- return obj instanceof Element && ((Element) obj).getName().equals(OSISUtil.OSIS_ELEMENT_W);
- }
-
- });
-
- while (it.hasNext()) {
- final Element word = it.next();
- final Attribute lemmaAttribute = word.getAttribute(OSISUtil.ATTRIBUTE_W_LEMMA);
- final Attribute morphAttribute = word.getAttribute(OSISUtil.ATTRIBUTE_W_MORPH);
-
- if (lemmaAttribute != null) {
- if (morphAttribute != null) {
- strongMorphMap.addWord(lemmaAttribute.getValue(), morphAttribute.getValue(), word.getValue());
- } else {
- strongMorphMap.addWord(lemmaAttribute.getValue(), word.getValue());
- }
- }
- }
-
- return strongMorphMap;
- }
-
- /**
- * Iterates through the master passage and incorporates into it, the text
- * given and mapped in the strongMorphMap
- *
- * @param masterPassage
- * the passage to be enriched
- * @param strongMorphMap
- * the map containing the links.
- */
- private void mergePassages(final Passage masterPassage, final StrongMorphMap strongMorphMap) {
- masterPassage.reset();
- String[] lemma, morph;
-
- while (masterPassage.hasNext()) {
- final PassageElement pe = masterPassage.next();
-
- // of interest, only the words!
- if (WORD.equals(pe.getTypeOfElement())) {
- // we have several lemmas for each word, and therefore,
- // we need to loop round them
- lemma = split(pe.getAttribute(LEMMA), LEMMA_MORPH_SEPARATOR);
- morph = split(pe.getAttribute(MORPH), LEMMA_MORPH_SEPARATOR);
-
- final StringBuffer alternativeWording = new StringBuffer(64);
-
- // we iterate through each lemma, knowing that we may
- // not have morphs at all (Hebrew text)
- // we cannot use the morph without the lemma, although
- // TODO: check what we're supposed to do
- // when we only have one morphology for several lemmas
- // always 0 or equal to number of lemmas
- for (int ii = 0; ii < lemma.length; ii++) {
- final String l = lemma[ii];
- final String m = (morph != null && ii < morph.length) ? morph[ii] : null;
- final String text = strongMorphMap.get(l, m);
- if (text != null) {
- alternativeWording.append(text);
- alternativeWording.append(' ');
- }
- pe.addAttribute(ALTERNATIVE_WORDING, alternativeWording.toString());
- }
- }
- }
- }
-
- /**
- * parsing an element
- *
- * @return the passage once parsed, et al.
- * @throws ActionException
- * an exception to bubble up to the web UI
- */
- @SuppressWarnings("unchecked")
- // TODO: upgrade to latest JSword version for generics
- private Passage parseForGwt() throws ActionException {
- final Passage passage = new Passage();
- final PassageElement rootPassage = new PassageElement();
- final Element osisFragment = jsword.getOsisText(version, reference);
- final List<Content> contentItems = osisFragment.getContent();
- passage.setRootPassageNode(rootPassage);
- traverseTree(contentItems, rootPassage);
- return passage;
- }
-
- // IMPROVEMENT: at the moment, we iterate through the whole passage,
- // but we may not have any lemmas, so it's a waste. we could feed this down
- // to traverse tree
- // method and it wouldn't happen as we traverse
- /**
- * returns H for Hebrew original text and G for Greek, or anything else!
- */
- void determineOriginalLanguage(final Passage passage) {
- final String attribute = returnLemmaTag(passage);
- if (attribute != null) {
- passage.setOriginalLanguage(attribute.charAt(STRONG_PATTERN_START.length()) == 'H' ? HEBREW : GREEK);
- }
-
- }
-
- /**
- * iterates through a passage trying to find a Strong lemma
- *
- * @param passage
- * passage
- * @return the lemma if found
- */
- String returnLemmaTag(final Passage passage) {
- passage.reset();
- while (passage.hasNext()) {
- final PassageElement nextPassageElement = passage.next();
-
- final String attribute = nextPassageElement.getAttribute(OsisElementType.LEMMA);
- if (attribute != null) {
- if (attribute.startsWith(STRONG_PATTERN_START)) {
- return attribute;
- }
- }
-
- }
- return null;
- }
-
- /**
- * traverses the dom and creates passage
- *
- * @param contentItems
- * the dom children
- * @param passage
- * the passage that gets populated
- */
- void traverseTree(final List<Content> contentItems, final PassageElement passage) {
- for (final Content item : contentItems) {
- if (item instanceof Element) {
- final Element elementToParse = (Element) item;
- final PassageElement createdChild = processAttributes(elementToParse, passage);
- // if this hasn't been filtered out:
- if (createdChild != null) {
- final List<Content> children = elementToParse.getContent();
- traverseTree(children, createdChild);
- } else {
- // TODO use slf4j
- getLogger().warn(
- ((Element) item).getName() + " with value [" + ((Element) item).getValue()
- + "] not created");
- }
- } else if (item instanceof Text) {
- final String text = ((Text) item).getText();
- final Map<OsisElementType, String> textProperties = new HashMap<OsisElementType, String>();
- textProperties.put(OsisElementType.TEXT, text);
- passage.addChildElement(new PassageElement(OsisElementType.TEXT, textProperties));
- }
- }
- }
-
- /**
- * maps the list of attributes in an element to a map
- *
- *
- * @param element
- * the element to be parsed
- * @param typeOfTag
- * the type of tag
- * @param passage
- * the passage for which to add an element if necessary
- */
- PassageElement processAttributes(final Element element, final PassageElement passage) {
- final OsisElementType typeOfTag = OsisElementType.forOsisType(element.getName());
- // now let's see if we filter something out
- if (elementFilter.contains(typeOfTag)) {
-
- final Map<OsisElementType, String> attributeMap = new HashMap<OsisElementType, String>();
-
- // TODO: at the moment, adding all attributes?
- final List<Attribute> attributes = element.getAttributes();
- for (final Attribute a : attributes) {
- final OsisElementType forOsisType = OsisElementType.forOsisType(a.getName());
- if (forOsisType == null || !attributeFilter.contains(forOsisType)) {
- getLogger().debug("Attribute not returned: [" + a + "] in tag of type [" + typeOfTag + "]");
- } else {
- final String attributeValue = a.getValue();
- attributeMap.put(forOsisType, attributeValue);
- }
- }
-
- final PassageElement pe = new PassageElement(typeOfTag, attributeMap);
- passage.addChildElement(pe);
- return pe;
- }
- return null;
- }
}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandler.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandler.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -3,7 +3,6 @@
import java.util.List;
import net.customware.gwt.dispatch.server.ExecutionContext;
-import net.customware.gwt.dispatch.shared.ActionException;
import com.google.inject.Inject;
import com.tyndalehouse.step.web.server.common.AbstractStepHandler;
@@ -12,8 +11,7 @@
import com.tyndalehouse.step.web.shared.result.GetDictionaryDefinitionResult;
/**
- * Looks up the dictionary definition in a JSword module and returns it to the
- * client
+ * Looks up the dictionary definition in a JSword module and returns it to the client
*
* @author CJBurrell
*
@@ -25,14 +23,17 @@
/**
* The dictionary definition handler's constructor
+ *
+ * @param jsword the service to query JSword
*/
@Inject
public GetDictionaryDefinitionHandler(final JSwordService jsword) {
this.jsword = jsword;
}
- public GetDictionaryDefinitionResult execute(final GetDictionaryDefinitionCommand command,
- final ExecutionContext arg1) throws ActionException {
+ @Override
+ public GetDictionaryDefinitionResult executeInternal(final GetDictionaryDefinitionCommand command,
+ final ExecutionContext arg1) {
final List<String> referenceList = command.getLookupReferencce();
final GetDictionaryDefinitionResult result = new GetDictionaryDefinitionResult();
@@ -41,17 +42,11 @@
// definitions, and tab them
// on the popup!
for (final String reference : referenceList) {
- definitions.append(jsword.lookupStrongDefinition(reference));
+ definitions.append(this.jsword.lookupStrongDefinition(reference));
definitions.append("<hr />");
}
result.setDefinition(definitions.toString());
return result;
}
-
- public void rollback(final GetDictionaryDefinitionCommand arg0, final GetDictionaryDefinitionResult arg1,
- final ExecutionContext arg2) throws ActionException {
- getLogger().error("Get Dictionary definition Text rolling back");
-
- }
}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetEventsForDateRangeHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetEventsForDateRangeHandler.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetEventsForDateRangeHandler.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -5,10 +5,10 @@
import java.util.List;
import net.customware.gwt.dispatch.server.ExecutionContext;
-import net.customware.gwt.dispatch.shared.ActionException;
import com.google.inject.Inject;
import com.tyndalehouse.step.web.server.common.AbstractStepHandler;
+import com.tyndalehouse.step.web.server.common.StepInternalException;
import com.tyndalehouse.step.web.server.db.framework.StepQueryRunner;
import com.tyndalehouse.step.web.server.db.framework.UnableToRunQueryException;
import com.tyndalehouse.step.web.server.db.timeline.TimeBandVisibleDateProcessor;
@@ -18,8 +18,7 @@
import com.tyndalehouse.step.web.shared.result.GetEventsForDateRangeResult;
/**
- * Command that gets relevant events on a date range. Currently this executes
- * multiple queries against the database
+ * Command that gets relevant events on a date range. Currently this executes multiple queries against the database
*
* @author CJBurrell
*
@@ -35,8 +34,7 @@
/**
* public constructor for this handler
*
- * @param queryRunner
- * the query runner object to use for executing the query
+ * @param queryRunner the query runner object to use for executing the query
*/
@Inject
public GetEventsForDateRangeHandler(final StepQueryRunner queryRunner) {
@@ -46,8 +44,9 @@
// TODO: this needs to change to take into account the three different types
// of date precision but for now,
// let's get something working
- public GetEventsForDateRangeResult execute(final GetEventsForDateRangeCommand event, final ExecutionContext arg1)
- throws ActionException {
+ @Override
+ public GetEventsForDateRangeResult executeInternal(final GetEventsForDateRangeCommand event,
+ final ExecutionContext arg1) {
final GetEventsForDateRangeResult result = new GetEventsForDateRangeResult();
final List<TimeBandVisibleDate> timebands = event.getVisbleDates();
try {
@@ -58,24 +57,17 @@
result.getEvents().addAll(events);
}
} catch (final UnableToRunQueryException e) {
- getLogger().error("An error occured while trying to retrieve new events from the datbase", e);
- throw new ActionException(e);
+ throw new StepInternalException("An error occured while trying to retrieve new events from the datbase", e);
}
logEventsRetrieved(result.getEvents());
return result;
}
- public void rollback(final GetEventsForDateRangeCommand arg0, final GetEventsForDateRangeResult arg1,
- final ExecutionContext arg2) throws ActionException {
-
- }
-
/**
* Logs which events have been retrieved in trace mode
*
- * @param events
- * events to be traced
+ * @param events events to be traced
*/
private void logEventsRetrieved(final List<TimelineEventBean> events) {
final SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy G");
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineOriginForScriptureHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineOriginForScriptureHandler.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineOriginForScriptureHandler.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -3,7 +3,6 @@
import java.util.List;
import net.customware.gwt.dispatch.server.ExecutionContext;
-import net.customware.gwt.dispatch.shared.ActionException;
import org.crosswire.jsword.passage.Key;
import org.crosswire.jsword.passage.KeyFactory;
@@ -15,6 +14,7 @@
import com.google.inject.Inject;
import com.tyndalehouse.step.web.server.common.AbstractStepHandler;
+import com.tyndalehouse.step.web.server.common.StepInternalException;
import com.tyndalehouse.step.web.server.db.framework.ResultSetProcessor;
import com.tyndalehouse.step.web.server.db.framework.StepQueryRunner;
import com.tyndalehouse.step.web.server.db.framework.UnableToRunQueryException;
@@ -24,8 +24,7 @@
import com.tyndalehouse.step.web.shared.result.GetTimelineOriginForScriptureResult;
/**
- * returns the timeline origin, i.e the best (closest in time) event for a given
- * verse range.
+ * returns the timeline origin, i.e the best (closest in time) event for a given verse range.
*
* @author CJBurrell
*
@@ -40,8 +39,7 @@
/**
* constructor for this handler
*
- * @param queryRunner
- * the query runner framework
+ * @param queryRunner the query runner framework
*/
@Inject
public GetTimelineOriginForScriptureHandler(final StepQueryRunner queryRunner) {
@@ -52,8 +50,9 @@
// TODO: this needs to change to take into account the three different types
// of date precision but for now,
// let's get something working
- public GetTimelineOriginForScriptureResult execute(final GetTimelineOriginForScriptureCommand event,
- final ExecutionContext arg1) throws ActionException {
+ @Override
+ public GetTimelineOriginForScriptureResult executeInternal(final GetTimelineOriginForScriptureCommand event,
+ final ExecutionContext arg1) {
try {
// TODO: this is bad - look at JSword to work out how to properly
// get the verserange out
@@ -86,29 +85,22 @@
// }
}
} catch (final NoSuchKeyException e) {
+ // TODO look at error handling, should throw exception
getLogger().warn("Could not resolve verse number", e);
// TODO: return a proper exception and show error message on the UI
return new GetTimelineOriginForScriptureResult(true);
} catch (final UnableToRunQueryException e) {
- getLogger().error("An error occured while loading the config for the query", e);
- throw new ActionException(e);
+ throw new StepInternalException("An error occured while loading the config for the query", e);
}
return new GetTimelineOriginForScriptureResult(true);
}
- public void rollback(final GetTimelineOriginForScriptureCommand arg0,
- final GetTimelineOriginForScriptureResult arg1, final ExecutionContext arg2) throws ActionException {
-
- }
-
/**
* resolves a string to a range of verses
*
- * @return the OSIS key to use to look up a particular scripture reference
- * in a JSword module
- * @throws NoSuchKeyException
- * thrown if the passed in reference cannot be parsed //TODO:
- * make into seperate util classes
+ * @return the OSIS key to use to look up a particular scripture reference in a JSword module
+ * @throws NoSuchKeyException thrown if the passed in reference cannot be parsed //TODO: make into seperate util
+ * classes
*/
private Key resolveScriptureToVerseNumbers(final String scriptureReference) throws NoSuchKeyException {
final KeyFactory keyFactory = PassageKeyFactory.instance();
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandler.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandler.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -3,10 +3,10 @@
import java.util.List;
import net.customware.gwt.dispatch.server.ExecutionContext;
-import net.customware.gwt.dispatch.shared.ActionException;
import com.google.inject.Inject;
import com.tyndalehouse.step.web.server.common.AbstractStepHandler;
+import com.tyndalehouse.step.web.server.common.StepInternalException;
import com.tyndalehouse.step.web.server.db.framework.StepQueryRunner;
import com.tyndalehouse.step.web.server.db.framework.UnableToRunQueryException;
import com.tyndalehouse.step.web.server.db.timeline.TimelineSetupDataProcessor;
@@ -15,8 +15,8 @@
import com.tyndalehouse.step.web.shared.result.GetTimelineUISetupResult;
/**
- * the timeline UI setup handler, which returns the initial set of data for the
- * timeline module including the different bands, their recommended scales, etc.
+ * the timeline UI setup handler, which returns the initial set of data for the timeline module including the different
+ * bands, their recommended scales, etc.
*
* @author CJBurrell
*
@@ -30,8 +30,7 @@
/**
* Default constructor
*
- * @param queryRunner
- * a query runner
+ * @param queryRunner a query runner
*/
@Inject
public GetTimelineUISetupHandler(final StepQueryRunner queryRunner) {
@@ -40,8 +39,8 @@
// TODO: this can be cached quite succesfully on the server
- public GetTimelineUISetupResult execute(final GetTimelineUISetupCommand cmd, final ExecutionContext arg1)
- throws ActionException {
+ @Override
+ public GetTimelineUISetupResult executeInternal(final GetTimelineUISetupCommand cmd, final ExecutionContext arg1) {
try {
final List<TimelineBean> timelines = queryRunner.run(new TimelineSetupDataProcessor());
final GetTimelineUISetupResult r = new GetTimelineUISetupResult();
@@ -52,14 +51,7 @@
}
return r;
} catch (final UnableToRunQueryException e) {
- getLogger().error("An error occured while loading the config for the query", e);
- throw new ActionException(e);
+ throw new StepInternalException("An error occured while loading the config for the query", e);
}
}
-
- public void rollback(final GetTimelineUISetupCommand arg0, final GetTimelineUISetupResult arg1,
- final ExecutionContext arg2) throws ActionException {
- getLogger().error("Get Timeline UI Setup Handler rolling back");
-
- }
}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/InstallJswordModuleHandler.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/InstallJswordModuleHandler.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/InstallJswordModuleHandler.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -3,7 +3,6 @@
import java.util.Set;
import net.customware.gwt.dispatch.server.ExecutionContext;
-import net.customware.gwt.dispatch.shared.ActionException;
import org.crosswire.common.progress.JobManager;
import org.crosswire.common.progress.Progress;
@@ -12,14 +11,13 @@
import org.crosswire.jsword.book.Books;
import org.crosswire.jsword.book.install.sword.HttpSwordInstaller;
-import com.google.inject.Inject;
import com.tyndalehouse.step.web.server.common.AbstractStepHandler;
+import com.tyndalehouse.step.web.server.common.StepInternalException;
import com.tyndalehouse.step.web.shared.command.InstallJswordModuleCommand;
import com.tyndalehouse.step.web.shared.result.InstallJswordModuleResult;
/**
- * Handler that installs a JSword module (bible, etc.) on to the server (perhaps
- * a localhost server)
+ * Handler that installs a JSword module (bible, etc.) on to the server (perhaps a localhost server)
*
* @author CJBurrell
*
@@ -39,24 +37,17 @@
private static final String PROXY_PORT = "step.proxy.port";
/**
- * the time to wait for installer to kick in, so that we can then wait for
- * it
+ * the time to wait for installer to kick in, so that we can then wait for it
*/
private static final int WAIT_TIME_FOR_INSTALLER = 2000;
- /**
- * constructor to create this handler, usually via Guice
- */
- @Inject
- public InstallJswordModuleHandler() {
- }
+ @Override
+ public InstallJswordModuleResult executeInternal(final InstallJswordModuleCommand cmd,
+ final ExecutionContext context) {
- public InstallJswordModuleResult execute(final InstallJswordModuleCommand cmd, final ExecutionContext context)
- throws ActionException {
-
final String initials = cmd.getInitials();
if (initials == null) {
- throw new ActionException("Module initials provided was null");
+ throw new StepInternalException("Module initials provided was null");
}
try {
@@ -99,6 +90,7 @@
}
}
} catch (final BookException e) {
+ // TODO is this behaviour correct? not throwing the exception
getLogger().error("An error occured during the installation of the book", e);
} catch (final InterruptedException e) {
getLogger().error("An error occurred during the downloading of the book", e);
@@ -109,14 +101,8 @@
return new InstallJswordModuleResult(true);
}
- public void rollback(final InstallJswordModuleCommand arg0, final InstallJswordModuleResult arg1,
- final ExecutionContext arg2) throws ActionException {
- getLogger().error("Rolling back InstallJswordModule");
- }
-
/**
- * TODO: needs redoing to ensure we take all the installers provided by
- * JSword
+ * TODO: needs redoing to ensure we take all the installers provided by JSword
*
* @return a custom installer configured with the crosswire proxy
*/
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/MorphWordCombo.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/MorphWordCombo.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/MorphWordCombo.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -10,10 +10,8 @@
/**
* adds a key to the combo. This overwrites previous morph keys
*
- * @param morph
- * the morph
- * @param word
- * the word
+ * @param morph the morph
+ * @param word the word
*/
public void put(final String morph, final String word) {
morphToWord.put(morph, word);
@@ -31,8 +29,7 @@
/**
* returns the value attached to the current morphology
*
- * @param morph
- * the morphology of the word to retrieve
+ * @param morph the morphology of the word to retrieve
* @return the word attached to the morphology
*/
public String get(final String morph) {
Deleted: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/OsisParserFilter.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/OsisParserFilter.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/OsisParserFilter.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -1,61 +0,0 @@
-package com.tyndalehouse.step.web.server.handler.util.passage;
-
-import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.LINE_BREAK;
-import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.QUOTE;
-import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.TITLE;
-import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.TRANS_CHANGE;
-import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.VERSE;
-import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.WORD;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import com.tyndalehouse.step.web.shared.scripture.OsisElementType;
-
-/**
- * A set of filters for common use, that filter in particular components of the
- * OSIS spec
- *
- * @author CJBurrell
- *
- */
-public class OsisParserFilter {
- private static HashSet<OsisElementType> DEFAULT_ELEMENT_FILTER = initDefaultElementFilter();
- private static HashSet<OsisElementType> DEFAULT_ATTRIBUTE_FILTER = initDefaultAttributeFilter();
-
- /**
- * @return a copy of the DEFAULT_ELEMENT_FILTER
- */
- @SuppressWarnings("unchecked")
- public static Set<OsisElementType> getDefaultElementFilter() {
- return (HashSet<OsisElementType>) DEFAULT_ELEMENT_FILTER.clone();
- }
-
- /**
- * @return a copy of the DEFAULT_ATTRIBUTE_FILTER
- */
- @SuppressWarnings("unchecked")
- public static Set<OsisElementType> getDefaultAttributeFilter() {
- return (HashSet<OsisElementType>) DEFAULT_ATTRIBUTE_FILTER.clone();
- }
-
- private static HashSet<OsisElementType> initDefaultElementFilter() {
- final HashSet<OsisElementType> defaultFilter = new HashSet<OsisElementType>();
- defaultFilter.add(TITLE);
- defaultFilter.add(VERSE);
- defaultFilter.add(WORD);
- defaultFilter.add(QUOTE);
- defaultFilter.add(LINE_BREAK);
- defaultFilter.add(TRANS_CHANGE);
-
- return defaultFilter;
- }
-
- private static HashSet<OsisElementType> initDefaultAttributeFilter() {
- final HashSet<OsisElementType> defaultFilter = new HashSet<OsisElementType>();
- defaultFilter.add(OsisElementType.OSIS_ID);
- defaultFilter.add(OsisElementType.MARKER);
- defaultFilter.add(OsisElementType.LEMMA);
- return defaultFilter;
- }
-}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/StrongMorphMap.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/StrongMorphMap.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/handler/util/passage/StrongMorphMap.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -12,22 +12,17 @@
import org.apache.commons.lang.StringUtils;
/**
- * This map will store the mapping for strong,morph to the word However
- * sometimes the morphology of the word is not present in the passage and since
- * we still want to be able to render some sort of interlinear, it would be best
- * to match just on the word as a result each entity will have the the three
- * values associated to it text (what the word is) the strong number the
- * morphology (optional) The map is keyed my strong number.
+ * This map will store the mapping for strong,morph to the word However sometimes the morphology of the word is not
+ * present in the passage and since we still want to be able to render some sort of interlinear, it would be best to
+ * match just on the word as a result each entity will have the the three values associated to it text (what the word
+ * is) the strong number the morphology (optional) The map is keyed my strong number.
*
- * In order to ensure rapid lookup, we will use the following way of mapping
- * elements Strong numbers will map either directly to the word when no morph is
- * available, or through a morph to the word
+ * In order to ensure rapid lookup, we will use the following way of mapping elements Strong numbers will map either
+ * directly to the word when no morph is available, or through a morph to the word
*
- * TODO: It is assumed that given a strong and morph the text is unique TODO:
- * change this, since there are multiple morphs per lemma and word strong
- * ---------> morph --------> word (1) or strong ------------------------> word
- * (2) A mapping (2) will not be stored if (1) is available, and therefore
- * lookups lookup the morph first as this is prefered.
+ * TODO: It is assumed that given a strong and morph the text is unique TODO: change this, since there are multiple
+ * morphs per lemma and word strong ---------> morph --------> word (1) or strong ------------------------> word (2) A
+ * mapping (2) will not be stored if (1) is available, and therefore lookups lookup the morph first as this is prefered.
*
* @author CJBurrell
*
@@ -35,8 +30,8 @@
public class StrongMorphMap {
// lemmas morphs word
/**
- * this map maps strong numbers to morphs. it is the first level of
- * indirection to the map of morphs which maps to a word
+ * this map maps strong numbers to morphs. it is the first level of indirection to the map of morphs which maps to a
+ * word
*/
private final Map<String, MorphWordCombo> strongToMorph;
@@ -56,10 +51,8 @@
/**
* only to be used if no morph is available
*
- * @param strong
- * the strong numbers or lemmas
- * @param word
- * the word to be stored
+ * @param strong the strong numbers or lemmas
+ * @param word the word to be stored
*/
public final void addWord(final String strong, final String word) {
if (isNotEmpty(strong)) {
@@ -73,12 +66,9 @@
/**
* adds a word to the map
*
- * @param strong
- * the lemma/strong number
- * @param morph
- * the morph / indicating morphology
- * @param word
- * the word
+ * @param strong the lemma/strong number
+ * @param morph the morph / indicating morphology
+ * @param word the word
*/
public final void addWord(final String strong, final String morph, final String word) {
if (morph == null) {
@@ -103,14 +93,11 @@
}
/**
- * Looks up the (lemma, morph) key in the map. If morph is null, lookup is
- * done solely on strong number, and takes the first of the morphs
+ * Looks up the (lemma, morph) key in the map. If morph is null, lookup is done solely on strong number, and takes
+ * the first of the morphs
*
- * @param lemma
- * lemma associated to a a word
- * @param morph
- * morph, can be passed in null, refering to the grammar of a
- * word in a language
+ * @param lemma lemma associated to a a word
+ * @param morph morph, can be passed in null, refering to the grammar of a word in a language
* @return the word associated in the map to the (lemma, morph) combination
*/
// TODO: check for nulls on lemma
@@ -153,10 +140,8 @@
/**
* returns any words contained in the morph map concatenated
*
- * @param morphToWord
- * the list of morph, for all lemmas in the key
- * @param morph
- * the morph map
+ * @param morphToWord the list of morph, for all lemmas in the key
+ * @param morph the morph map
* @return the list of words associated with the morph
*/
private String getWords(final MorphWordCombo[] morphToWord, final String morph) {
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/jsword/ConfigurableHTMLConverter.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/jsword/ConfigurableHTMLConverter.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/jsword/ConfigurableHTMLConverter.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -38,8 +38,7 @@
/**
* Turn XML from a Bible into HTML according to a Display style.
*
- * @see gnu.gpl.License for license details. The copyright to this program is
- * held by it's authors.
+ * @see gnu.gpl.License for license details. The copyright to this program is held by it's authors.
* @author Joe Walker [joe at eireneh dot com]
*/
public class ConfigurableHTMLConverter implements Converter {
@@ -63,13 +62,6 @@
*/
private static String style = "simple.xsl"; //$NON-NLS-1$
- /**
- * ripped off JSWord: TODO: needs to be down properly
- */
- public ConfigurableHTMLConverter() {
-
- }
-
//
// /**
// * Accessor for the stylesheet we are transforming using
@@ -110,8 +102,7 @@
/**
* Accessor for the stylesheet we are transforming using
*
- * @param style
- * returns the resource name given a style
+ * @param style returns the resource name given a style
*/
public static void setResourceName(final String style) {
ConfigurableHTMLConverter.style = style;
@@ -120,14 +111,10 @@
/**
*
*
- * @see org.crosswire.common.xml.Converter#convert(org.crosswire.common.xml.
- * SAXEventProvider)
- * @param xmlsep
- * the sax event provider
+ * @see org.crosswire.common.xml.Converter#convert(org.crosswire.common.xml. SAXEventProvider)
+ * @param xmlsep the sax event provider
* @return the converted SAX event provider
- * @throws TransformerException
- * thrown if something bad happens during the transformation of
- * the xml
+ * @throws TransformerException thrown if something bad happens during the transformation of the xml
*/
public SAXEventProvider convert(final SAXEventProvider xmlsep) throws TransformerException {
try {
@@ -146,17 +133,14 @@
}
/**
- * Get an array of the available style names for a given subject. Different
- * subjects are available for different contexts. For example - for
- * insertion into a web page we might want to use a set that had complex
- * HTML, or IE/NS specific HTML, where as a JFC HTMLDocument needs simpler
- * HTML - and special tags like the starting <HTML> tags.
+ * Get an array of the available style names for a given subject. Different subjects are available for different
+ * contexts. For example - for insertion into a web page we might want to use a set that had complex HTML, or IE/NS
+ * specific HTML, where as a JFC HTMLDocument needs simpler HTML - and special tags like the starting <HTML>
+ * tags.
* <p>
- * If the protocol of the URL of the current directory is not file then we
- * can't use File.list to get the contents of the directory. This will
- * happen if this is being run as an applet. When we start doing that then
- * we will need to think up something smarter here. Until then we just
- * return a zero length array.
+ * If the protocol of the URL of the current directory is not file then we can't use File.list to get the contents
+ * of the directory. This will happen if this is being run as an applet. When we start doing that then we will need
+ * to think up something smarter here. Until then we just return a zero length array.
*
* @return An array of available style names
*/
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/jsword/XSLTProperty.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/jsword/XSLTProperty.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/jsword/XSLTProperty.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -36,15 +36,13 @@
/**
* Defines properties that control the behavior of translating OSIS to HTML.
*
- * @see gnu.gpl.License for license details. The copyright to this program is
- * held by it's authors.
+ * @see gnu.gpl.License for license details. The copyright to this program is held by it's authors.
* @author DM Smith [ dmsmith555 at yahoo dot com]
*/
@SuppressWarnings(value = {})
public final class XSLTProperty implements Serializable {
/**
- * What is the base of the current document. Note this needs to be set each
- * time the document is shown.
+ * What is the base of the current document. Note this needs to be set each time the document is shown.
*/
public static final XSLTProperty BASE_URL = new XSLTProperty("baseURL", "", true); //$NON-NLS-1$ //$NON-NLS-2$
@@ -64,14 +62,12 @@
public static final XSLTProperty CV = new XSLTProperty("CVNum", false); //$NON-NLS-1$
/**
- * What is the base of the current document. Note this needs to be set each
- * time the document is shown.
+ * What is the base of the current document. Note this needs to be set each time the document is shown.
*/
public static final XSLTProperty DIRECTION = new XSLTProperty("direction", ""); //$NON-NLS-1$ //$NON-NLS-2$
/**
- * What is the base of the current document. Note this needs to be set each
- * time the font changes.
+ * What is the base of the current document. Note this needs to be set each time the font changes.
*/
public static final XSLTProperty FONT = new XSLTProperty("font", "Serif-PLAIN-14"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -140,8 +136,7 @@
XSLTProperty.XREF, XSLTProperty.BASE_URL, XSLTProperty.DIRECTION, XSLTProperty.FONT, XSLTProperty.CSS, };
/**
- * Whether the string state should be converted to an URL when setting the
- * property.
+ * Whether the string state should be converted to an URL when setting the property.
*/
private final boolean asURL;
@@ -156,8 +151,7 @@
private final String name;
/**
- * TODO: don't know what this does, this class is a copy from JSword which
- * needs revamping
+ * TODO: don't know what this does, this class is a copy from JSword which needs revamping
*/
private final int obj = XSLTProperty.nextObj++;
@@ -167,32 +161,25 @@
private String state;
/**
- * @param name
- * The name of this property
- * @param defaultState
- * The initial state of the property.
+ * @param name The name of this property
+ * @param defaultState The initial state of the property.
*/
private XSLTProperty(final String name, final boolean defaultState) {
this(name, Boolean.toString(defaultState));
}
/**
- * @param name
- * The name of this property
- * @param defaultState
- * The initial state of the property.
+ * @param name The name of this property
+ * @param defaultState The initial state of the property.
*/
private XSLTProperty(final String name, final String defaultState) {
this(name, defaultState, false);
}
/**
- * @param name
- * The name of this property
- * @param defaultState
- * The initial state of the property.
- * @param asURL
- * whether it is a uRl?
+ * @param name The name of this property
+ * @param defaultState The initial state of the property.
+ * @param asURL whether it is a uRl?
*/
private XSLTProperty(final String name, final String defaultState, final boolean asURL) {
this.name = name;
@@ -204,8 +191,7 @@
/**
* Lookup method to convert from an integer
*
- * @param i
- * gets a particular xslt property
+ * @param i gets a particular xslt property
* @return the XSLT property matching the index
*/
public static XSLTProperty fromInteger(final int i) {
@@ -215,8 +201,7 @@
/**
* Lookup method to convert from a String
*
- * @param name
- * a linear search for a property and returns the XSLT property
+ * @param name a linear search for a property and returns the XSLT property
* @return a XSLT property
*/
public static XSLTProperty fromString(final String name) {
@@ -232,8 +217,7 @@
/**
*
- * @param provider
- * sets the SAX provider
+ * @param provider sets the SAX provider
*/
public static void setProperties(final TransformingSAXEventProvider provider) {
for (int i = 0; i < XSLTProperty.VALUES.length; i++) {
@@ -245,7 +229,7 @@
*
* @return default state
*/
- public boolean getDefaultState() {
+ public boolean isDefaultState() {
return Boolean.valueOf(defaultState).booleanValue();
}
@@ -267,7 +251,7 @@
/**
* @return the state
*/
- public boolean getState() {
+ public boolean isState() {
return Boolean.valueOf(state).booleanValue();
}
@@ -281,8 +265,7 @@
/**
*
- * @param provider
- * a SAX provider
+ * @param provider a SAX provider
*/
public void setProperty(final TransformingSAXEventProvider provider) {
if (state != null && state.length() > 0) {
@@ -299,16 +282,14 @@
}
/**
- * @param newState
- * sets the state to newState
+ * @param newState sets the state to newState
*/
public void setState(final boolean newState) {
state = Boolean.toString(newState);
}
/**
- * @param newState
- * sets the state to newState
+ * @param newState sets the state to newState
*/
public void setState(final String newState) {
state = newState;
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/JSwordService.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/JSwordService.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/JSwordService.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -8,10 +8,8 @@
/**
* returns the biblical text as xml dom
*
- * @param version
- * version to lookup
- * @param reference
- * the reference to lookup
+ * @param version version to lookup
+ * @param reference the reference to lookup
* @return
*/
Element getOsisText(String version, String reference);
@@ -19,8 +17,7 @@
/**
* returns the language of the version specified
*
- * @param version
- * the version to lookup
+ * @param version the version to lookup
* @return the language code
*/
String getLanguage(String version);
@@ -28,47 +25,36 @@
/**
* retrieves the short form of the key that is a human readable form
*
- * @param version
- * the version to be retrieved from
- * @param reference
- * the reference to be converted
+ * @param version the version to be retrieved from
+ * @param reference the reference to be converted
* @return a human readable version of the key
*/
String getReadableKey(String version, String reference);
/**
- * returns the actual reference, removing the strong pattern + first
- * initial. For e.g. removes strong:H from "strong:H00002"
+ * returns the actual reference, removing the strong pattern + first initial. For e.g. removes strong:H from
+ * "strong:H00002"
*
- * @param reference
- * reference to parse
+ * @param reference reference to parse
* @return the key in the dictionary to be used for lookup purposes
- * @throws ActionException
- * the action exception
+ * @throws ActionException the action exception
*/
String getLookupKeyFromReference(String reference) throws ActionException;
/**
- * dependant on the reference, we return a different module to lookup the
- * definition. For e.g. we use a Greek dictionary to lookup a reference
- * starting strong:Gxxxxx
+ * dependant on the reference, we return a different module to lookup the definition. For e.g. we use a Greek
+ * dictionary to lookup a reference starting strong:Gxxxxx
*
- * @param reference
- * reference to be looked up
+ * @param reference reference to be looked up
* @return the module initials to use for the dictionary lookup
- * @throws ActionException
- * an exception to be thrown if the reference is not recognised
*/
- String getInitialsFromReference(String reference) throws ActionException;
+ String getInitialsFromReference(String reference);
/**
* Looks up a definition given a reference in the default JSword module
*
- * @param reference
- * reference, for e.g. a Strong number
+ * @param reference reference, for e.g. a Strong number
* @return the definition
- * @throws ActionException
- * an exception occurring if the reference is invalid
*/
- String lookupStrongDefinition(String reference) throws ActionException;
+ String lookupStrongDefinition(String reference);
}
Added: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/PassageMerger.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/PassageMerger.java (rev 0)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/PassageMerger.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -0,0 +1,14 @@
+package com.tyndalehouse.step.web.server.service;
+
+import com.tyndalehouse.step.web.shared.scripture.Passage;
+
+public interface PassageMerger {
+ /**
+ * Merges a new passage into the first one based on strong numbers and morphology
+ *
+ * @param basePassage the base passage
+ * @param bibleVersion the new version of the bible to merge in
+ * @param reference the reference
+ */
+ void merge(Passage basePassage, String bibleVersion, String reference);
+}
Added: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/PassageSearcher.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/PassageSearcher.java (rev 0)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/PassageSearcher.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -0,0 +1,34 @@
+package com.tyndalehouse.step.web.server.service;
+
+import java.util.Set;
+
+import com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptions;
+import com.tyndalehouse.step.web.shared.scripture.OsisElementType;
+import com.tyndalehouse.step.web.shared.scripture.Passage;
+
+public interface PassageSearcher {
+ /**
+ * sets the search criteria
+ *
+ * @param version the version of the bible to lookup
+ * @param reference the reference
+ */
+ void setSearchCriteria(String version, String reference);
+
+ /**
+ * sets what elements/attributes should be returned. For e.g. should we return morphs, words, lemmas, notes
+ *
+ * @param filteredElements the filtered elements
+ * @param filteredAttributes the list of filtered attributes
+ */
+ void setFilters(Set<OsisElementType> filteredElements, Set<OsisElementType> filteredAttributes);
+
+ /**
+ * searches the bible library for a text
+ *
+ * @param scriptureDisplayOptions the option with which to lookup the passage, i.e. a normal lookup, a classic
+ * interlinear, or a reverse interlinear
+ * @return the passage according to current search critier, filter and options
+ */
+ Passage search(ScriptureDisplayOptions scriptureDisplayOptions);
+}
Modified: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImpl.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImpl.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/JSwordServiceImpl.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -1,9 +1,9 @@
package com.tyndalehouse.step.web.server.service.impl;
+import static java.lang.String.format;
+
import javax.xml.transform.TransformerException;
-import net.customware.gwt.dispatch.shared.ActionException;
-
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.crosswire.common.util.Language;
@@ -20,9 +20,9 @@
import org.jdom.Element;
import org.xml.sax.SAXException;
+import com.tyndalehouse.step.web.server.common.StepInternalException;
import com.tyndalehouse.step.web.server.jsword.ConfigurableHTMLConverter;
import com.tyndalehouse.step.web.server.service.JSwordService;
-import com.tyndalehouse.step.web.shared.InternalException;
/**
* a service providing a wrapper around JSword
@@ -49,14 +49,12 @@
public static final char STRONG_HEBREW_MARKER = 'H';
/**
- * Initials of default Hebrew JSword module to use for lookup of dictionary
- * definitions
+ * Initials of default Hebrew JSword module to use for lookup of dictionary definitions
*/
public static final String STRONG_HEBREW_DICTIONARY_INITIALS = "StrongsHebrew";
/**
- * Initials of default Strong JSword greek dictionary module for lookup of
- * dictionary definitions
+ * Initials of default Strong JSword greek dictionary module for lookup of dictionary definitions
*/
public static final String STRONG_GREEK_DICTIONARY_INITIALS = "StrongsGreek";
@@ -66,9 +64,7 @@
/*
* (non-Javadoc)
*
- * @see
- * com.tyndalehouse.step.web.server.service.JSwordService#getOsisText(java
- * .lang.String, java.lang.String)
+ * @see com.tyndalehouse.step.web.server.service.JSwordService#getOsisText(java .lang.String, java.lang.String)
*/
public Element getOsisText(final String version, final String reference) {
try {
@@ -77,15 +73,15 @@
final Element osisFragment = bookData.getOsisFragment();
- if (logger.isDebugEnabled()) {
- logger.debug("Reference requested was: " + version + " " + reference);
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("Reference requested was: " + version + " " + reference);
}
return osisFragment;
} catch (final NoSuchKeyException e) {
- throw new InternalException("The verse specified was not found: [" + reference + "]", e);
+ throw new StepInternalException("The verse specified was not found: [" + reference + "]", e);
} catch (final BookException e) {
- throw new InternalException("Unable to query the book data to retrieve specified passage [" + version
+ throw new StepInternalException("Unable to query the book data to retrieve specified passage [" + version
+ "] [" + reference + "]");
}
}
@@ -104,50 +100,42 @@
}
/**
- * IMPROVEMENT NOTE that this is not thread safe, since JSword relies on
- * statics in the background
+ * IMPROVEMENT NOTE that this is not thread safe, since JSword relies on statics in the background
*/
public String getReadableKey(final String version, final String reference) {
try {
BibleInfo.setFullBookName(false);
return Books.installed().getBook(version).getKey(reference).getName();
} catch (final NoSuchKeyException e) {
- throw new InternalException("Unable to get readable key from OSIS reference", e);
+ throw new StepInternalException("Unable to get readable key from OSIS reference", e);
}
}
- public String lookupStrongDefinition(final String reference) throws ActionException {
+ public String lookupStrongDefinition(final String reference) {
if (StringUtils.isEmpty(reference)) {
- throw new ActionException("Reference was not provided");
+ throw new StepInternalException("Reference was not provided");
}
- logger.error("definition lookup command");
+ this.logger.error("definition lookup command");
final String initials = getInitialsFromReference(reference);
final String lookupKey = getLookupKeyFromReference(reference);
try {
// TODO: ensure a lookup key exists!
- // TODO: make a common adapter api to access JSword
final Book currentBook = Books.installed().getBook(initials);
final BookData data = new BookData(currentBook, currentBook.getKey(lookupKey));
- final String xsltedDefinition = doXslt(data, data.getOsisFragment());
- return xsltedDefinition;
+ return doXslt(data, data.getOsisFragment());
} catch (final NoSuchKeyException e) {
- logger.error("An error occurred looking up the passage", e);
- throw new ActionException(e);
+ throw new StepInternalException("Unable to find specified reference", e);
} catch (final BookException e) {
- // TODO remove logging since throwing exception
- logger.error("A book exception has occurred whilte looking up the passage", e);
- throw new ActionException(e);
+ throw new StepInternalException("An error occurred looking up the passage", e);
}
}
/**
* does a simple xslt transformation to show the definition on the screen
*
- * @param data
- * data to be shown
- * @param osisFragment
- * osisFragment to transform
+ * @param data data to be shown
+ * @param osisFragment osisFragment to transform
* @return the xslted definition ready to be displayed on the user's screen
*/
private String doXslt(final BookData data, final Element osisFragment) {
@@ -172,7 +160,7 @@
return "";
}
- public String getInitialsFromReference(final String reference) throws ActionException {
+ public String getInitialsFromReference(final String reference) {
if (reference.toLowerCase().startsWith(STRONG_PATTERN_START)) {
final int charPosition = STRONG_PATTERN_START.length();
if (reference.charAt(charPosition) == STRONG_HEBREW_MARKER) {
@@ -182,15 +170,15 @@
}
// continuing will throw exception
}
- throw new ActionException(String.format("Dictionary reference not recognised: %s", reference));
+ throw new StepInternalException(format("Dictionary reference not recognised: %s", reference));
}
- public String getLookupKeyFromReference(final String reference) throws ActionException {
+ public String getLookupKeyFromReference(final String reference) {
if (reference.toLowerCase().startsWith(STRONG_PATTERN_START)) {
// remove strong: or strong:
return reference.substring(STRONG_PATTERN_START.length());
}
- throw new ActionException(String.format("Lookup key not recognised: %s", reference));
+ throw new StepInternalException(format("Lookup key not recognised: %s", reference));
}
}
Added: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/PassageMergerImpl.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/PassageMergerImpl.java (rev 0)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/PassageMergerImpl.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -0,0 +1,120 @@
+package com.tyndalehouse.step.web.server.service.impl;
+
+import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.ALTERNATIVE_WORDING;
+import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.LEMMA;
+import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.MORPH;
+import static com.tyndalehouse.step.web.shared.scripture.OsisElementType.WORD;
+import static org.apache.commons.lang.StringUtils.split;
+
+import java.util.Iterator;
+
+import org.crosswire.jsword.book.OSISUtil;
+import org.jdom.Attribute;
+import org.jdom.Element;
+import org.jdom.filter.Filter;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import com.tyndalehouse.step.web.server.handler.util.passage.StrongMorphMap;
+import com.tyndalehouse.step.web.server.service.JSwordService;
+import com.tyndalehouse.step.web.server.service.PassageMerger;
+import com.tyndalehouse.step.web.shared.scripture.Passage;
+import com.tyndalehouse.step.web.shared.scripture.PassageElement;
+
+ at Singleton
+public class PassageMergerImpl implements PassageMerger {
+ private static final String LEMMA_MORPH_SEPARATOR = ",";
+ private final JSwordService jsword;
+
+ @Inject
+ PassageMergerImpl(final JSwordService jsword) {
+ this.jsword = jsword;
+ }
+
+ public void merge(final Passage basePassage, final String bibleVersion, final String reference) {
+ final StrongMorphMap strongMorphMap = getStrongMorphMap(bibleVersion, reference);
+ mergePassages(basePassage, strongMorphMap);
+ }
+
+ /**
+ * given a book data (referencing a biblical reference + a book), retrieves the morphs and the Strong numbers
+ * (lemmas) in the passage to help in the interlinear processing
+ *
+ * @param reference passage reference to be looked up
+ * @param bookData the bookData from JSword specialised for the reference and bible book
+ *
+ * @return a map of strong numbers and morphs
+ */
+ @SuppressWarnings("unchecked")
+ StrongMorphMap getStrongMorphMap(final String version, final String reference) {
+ final Element osis = jsword.getOsisText(version, reference);
+ final StrongMorphMap strongMorphMap = new StrongMorphMap();
+ final Iterator<Element> it = osis.getDescendants(new Filter() {
+ private static final long serialVersionUID = 4171956787222841308L;
+
+ public boolean matches(final Object obj) {
+ return obj instanceof Element && ((Element) obj).getName().equals(OSISUtil.OSIS_ELEMENT_W);
+ }
+
+ });
+
+ while (it.hasNext()) {
+ final Element word = it.next();
+ final Attribute lemmaAttribute = word.getAttribute(OSISUtil.ATTRIBUTE_W_LEMMA);
+ final Attribute morphAttribute = word.getAttribute(OSISUtil.ATTRIBUTE_W_MORPH);
+
+ if (lemmaAttribute != null) {
+ if (morphAttribute != null) {
+ strongMorphMap.addWord(lemmaAttribute.getValue(), morphAttribute.getValue(), word.getValue());
+ } else {
+ strongMorphMap.addWord(lemmaAttribute.getValue(), word.getValue());
+ }
+ }
+ }
+
+ return strongMorphMap;
+ }
+
+ /**
+ * Iterates through the master passage and incorporates into it, the text given and mapped in the strongMorphMap
+ *
+ * @param masterPassage the passage to be enriched
+ * @param strongMorphMap the map containing the links.
+ */
+ void mergePassages(final Passage masterPassage, final StrongMorphMap strongMorphMap) {
+ masterPassage.reset();
+ String[] lemma, morph;
+
+ while (masterPassage.hasNext()) {
+ final PassageElement pe = masterPassage.next();
+
+ // of interest, only the words!
+ if (WORD.equals(pe.getTypeOfElement())) {
+ // we have several lemmas for each word, and therefore,
+ // we need to loop round them
+ lemma = split(pe.getAttribute(LEMMA), LEMMA_MORPH_SEPARATOR);
+ morph = split(pe.getAttribute(MORPH), LEMMA_MORPH_SEPARATOR);
+
+ final StringBuffer alternativeWording = new StringBuffer(64);
+
+ // we iterate through each lemma, knowing that we may
+ // not have morphs at all (Hebrew text)
+ // we cannot use the morph without the lemma, although
+ // TODO: check what we're supposed to do
+ // when we only have one morphology for several lemmas
+ // always 0 or equal to number of lemmas
+ for (int ii = 0; ii < lemma.length; ii++) {
+ final String l = lemma[ii];
+ final String m = (morph != null && ii < morph.length) ? morph[ii] : null;
+ final String text = strongMorphMap.get(l, m);
+ if (text != null) {
+ alternativeWording.append(text);
+ alternativeWording.append(' ');
+ }
+ pe.addAttribute(ALTERNATIVE_WORDING, alternativeWording.toString());
+ }
+ }
+ }
+ }
+
+}
Added: trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/PassageSearcherImpl.java
===================================================================
--- trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/PassageSearcherImpl.java (rev 0)
+++ trunk/step-web-server/src/main/java/com/tyndalehouse/step/web/server/service/impl/PassageSearcherImpl.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -0,0 +1,248 @@
+package com.tyndalehouse.step.web.server.service.impl;
+
+import static com.tyndalehouse.step.web.server.service.impl.JSwordServiceImpl.STRONG_PATTERN_START;
+import static com.tyndalehouse.step.web.shared.scripture.PassageLanguage.GREEK;
+import static com.tyndalehouse.step.web.shared.scripture.PassageLanguage.HEBREW;
+import static org.apache.commons.lang.Validate.notNull;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.customware.gwt.dispatch.shared.ActionException;
+
+import org.apache.log4j.Logger;
+import org.jdom.Attribute;
+import org.jdom.Content;
+import org.jdom.Element;
+import org.jdom.Text;
+
+import com.google.inject.Inject;
+import com.tyndalehouse.step.web.server.common.StepInternalException;
+import com.tyndalehouse.step.web.server.service.JSwordService;
+import com.tyndalehouse.step.web.server.service.PassageMerger;
+import com.tyndalehouse.step.web.server.service.PassageSearcher;
+import com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptions;
+import com.tyndalehouse.step.web.shared.scripture.OsisElementType;
+import com.tyndalehouse.step.web.shared.scripture.Passage;
+import com.tyndalehouse.step.web.shared.scripture.PassageElement;
+
+/**
+ * Searches a passage using the JSword component, and parses it into a serialisable form
+ *
+ * @author CJBurrell
+ *
+ */
+public class PassageSearcherImpl implements PassageSearcher {
+ /**
+ * Default hebrew text for interlinear purposes
+ */
+ static final String DEFAULT_HEBREW_INTERLINEAR_TEXT = "WLC";
+
+ /**
+ * Default Greek text for interlinear purposes
+ */
+ static final String DEFAULT_GREEK_INTERLINEAR_TEXT = "BYZ";
+
+ private final Logger logger = Logger.getLogger(this.getClass());
+ private final JSwordService jsword;
+ private Set<OsisElementType> filteredElements;
+ private String version;
+ private String reference;
+
+ private Set<OsisElementType> filteredAttributes;
+
+ private final PassageMerger passageMerger;
+
+ /**
+ * Default implementation of a passage searcher
+ *
+ * @param jsword the jsword service to be used
+ * @param passageMerger the passage merger, in case we need to do a interlinear
+ */
+ @Inject
+ public PassageSearcherImpl(final JSwordService jsword, final PassageMerger passageMerger) {
+ this.jsword = jsword;
+ this.passageMerger = passageMerger;
+ }
+
+ public Passage search(final ScriptureDisplayOptions displayOptions) {
+ notNull(displayOptions);
+
+ Passage p;
+ switch (displayOptions) {
+ case NO_INTERLINEAR:
+ p = addLogicalLookup();
+ break;
+ case CLASSIC_INTERLINEAR:
+ p = addClassicInterlinear();
+ break;
+ case REVERSE_INTERLINEAR:
+ p = addReverseInterlinear(addLogicalLookup());
+ break;
+ default:
+ throw new StepInternalException("The option passed in was not recognised");
+ }
+
+ p.setElementFilter(this.filteredElements);
+ p.setAttributeFilter(this.filteredAttributes);
+ return p;
+ }
+
+ /**
+ * adds a logical lookup to the result objet
+ *
+ * @return a passage with one language/text in a serializable form
+ */
+ @SuppressWarnings("unchecked")
+ Passage addLogicalLookup() {
+ final Passage passage = new Passage();
+ final PassageElement rootPassage = new PassageElement();
+ passage.setRootPassageNode(rootPassage);
+
+ final Element osisFragment = this.jsword.getOsisText(this.version, this.reference);
+ traverseTree(osisFragment.getContent(), rootPassage);
+ return passage;
+ }
+
+ /**
+ * does a classic interlinear and populates the Passage
+ *
+ * @param p the logical passage to be populated
+ */
+ Passage addClassicInterlinear() {
+ throw new StepInternalException("The classic interlinear feature has not yet been implemented");
+ }
+
+ /**
+ * doing a reverse interlinear
+ *
+ * @param translatedText the passage as looked up in an non-original version
+ * @param reference reference of passage to lookup
+ * @throws ActionException action exception thrown during execution of the reverse interlinear process
+ */
+ private Passage addReverseInterlinear(final Passage translatedText) {
+ // IMPROVEMENT: let user decide what version he wants to use
+ // FIXME: fix Hebrew reverse interlinear
+ final String versionToUse;
+ determineOriginalLanguage(translatedText);
+
+ if (GREEK.equals(translatedText.getOriginalLanguage())) {
+ versionToUse = DEFAULT_GREEK_INTERLINEAR_TEXT;
+ } else if (HEBREW.equals(translatedText.getOriginalLanguage())) {
+ versionToUse = DEFAULT_HEBREW_INTERLINEAR_TEXT;
+ } else {
+ throw new StepInternalException("Unable to determine original language - no lemmas in text?");
+ }
+
+ this.passageMerger.merge(translatedText, versionToUse, this.reference);
+ return translatedText;
+ }
+
+ /**
+ * returns H for Hebrew original text and G for Greek, or anything else!
+ */
+ void determineOriginalLanguage(final Passage passage) {
+ final String attribute = returnLemmaTag(passage);
+ if (attribute != null) {
+ passage.setOriginalLanguage(attribute.charAt(STRONG_PATTERN_START.length()) == 'H' ? HEBREW : GREEK);
+ }
+
+ }
+
+ /**
+ * iterates through a passage trying to find a Strong lemma
+ *
+ * @param passage passage
+ * @return the lemma if found
+ */
+ String returnLemmaTag(final Passage passage) {
+ passage.reset();
+ while (passage.hasNext()) {
+ final PassageElement nextPassageElement = passage.next();
+
+ final String attribute = nextPassageElement.getAttribute(OsisElementType.LEMMA);
+ if (attribute != null) {
+ if (attribute.startsWith(STRONG_PATTERN_START)) {
+ return attribute;
+ }
+ }
+
+ }
+ return null;
+ }
+
+ /**
+ * traverses the dom and creates passage
+ *
+ * @param contentItems the dom children
+ * @param passage the passage that gets populated
+ */
+ void traverseTree(final List<Content> contentItems, final PassageElement passage) {
+ for (final Content item : contentItems) {
+ if (item instanceof Element) {
+ final Element elementToParse = (Element) item;
+ final PassageElement createdChild = processAttributes(elementToParse, passage);
+ // if this hasn't been filtered out:
+ if (createdChild != null) {
+ final List<Content> children = elementToParse.getContent();
+ traverseTree(children, createdChild);
+ } else {
+ // TODO use slf4j
+ this.logger.warn(((Element) item).getName() + " with value [" + ((Element) item).getValue()
+ + "] not created");
+ }
+ } else if (item instanceof Text) {
+ final String text = ((Text) item).getText();
+ final Map<OsisElementType, String> textProperties = new HashMap<OsisElementType, String>();
+ textProperties.put(OsisElementType.TEXT, text);
+ passage.addChildElement(new PassageElement(OsisElementType.TEXT, textProperties));
+ }
+ }
+ }
+
+ /**
+ * maps the list of attributes in an element to a map
+ *
+ *
+ * @param element the element to be parsed
+ * @param typeOfTag the type of tag
+ * @param passage the passage for which to add an element if necessary
+ */
+ PassageElement processAttributes(final Element element, final PassageElement passage) {
+ final OsisElementType typeOfTag = OsisElementType.forOsisType(element.getName());
+ // now let's see if we filter something out
+ if (this.filteredElements.contains(typeOfTag)) {
+
+ final Map<OsisElementType, String> attributeMap = new HashMap<OsisElementType, String>();
+
+ final List<Attribute> attributes = element.getAttributes();
+ for (final Attribute a : attributes) {
+ final OsisElementType forOsisType = OsisElementType.forOsisType(a.getName());
+ if (forOsisType == null || !this.filteredAttributes.contains(forOsisType)) {
+ this.logger.debug("Attribute not returned: [" + a + "] in tag of type [" + typeOfTag + "]");
+ } else {
+ final String attributeValue = a.getValue();
+ attributeMap.put(forOsisType, attributeValue);
+ }
+ }
+
+ final PassageElement pe = new PassageElement(typeOfTag, attributeMap);
+ passage.addChildElement(pe);
+ return pe;
+ }
+ return null;
+ }
+
+ public void setFilters(final Set<OsisElementType> filteredElements, final Set<OsisElementType> filteredAttributes) {
+ this.filteredElements = filteredElements;
+ this.filteredAttributes = filteredAttributes;
+ }
+
+ public void setSearchCriteria(final String version, final String reference) {
+ this.version = version;
+ this.reference = reference;
+
+ }
+}
Modified: trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/StepQueryRunnerImplTest.java
===================================================================
--- trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/StepQueryRunnerImplTest.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/StepQueryRunnerImplTest.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -58,8 +58,7 @@
/**
* tests and expects a exception to be returned
*
- * @throws UnableToRunQueryException
- * the query expected to be return on invalid query passed in
+ * @throws UnableToRunQueryException the query expected to be return on invalid query passed in
*/
@Test(expected = UnableToRunQueryException.class)
public void testRunQueryWithNull() throws UnableToRunQueryException {
Modified: trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/helper/TestProcessor.java
===================================================================
--- trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/helper/TestProcessor.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/helper/TestProcessor.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -19,13 +19,7 @@
*
*/
public class TestProcessor implements ResultSetProcessor<String> {
- /**
- * simple constructor
- */
- public TestProcessor() {
- }
-
public Map<String, Object> getParameters() {
final Map<String, Object> params = new HashMap<String, Object>();
params.put("event_name", "Events in Africa");
Modified: trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/helper/TestQueryImpl.java
===================================================================
--- trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/helper/TestQueryImpl.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/db/helper/TestQueryImpl.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -14,8 +14,7 @@
/**
* creates the enum
*
- * @param component
- * given a component/directory where the test sql script lives
+ * @param component given a component/directory where the test sql script lives
*/
TestQueryImpl(final String component) {
this.component = component;
Modified: trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandlerTest.java
===================================================================
--- trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandlerTest.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetCurrentBibleTextHandlerTest.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -1,31 +1,7 @@
package com.tyndalehouse.step.web.server.handler;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import net.customware.gwt.dispatch.shared.ActionException;
-
-import org.jdom.Content;
-import org.jdom.Element;
-import org.jmock.Mockery;
-import org.junit.Before;
import org.junit.Test;
-import com.tyndalehouse.step.web.server.service.impl.JSwordServiceImpl;
-import com.tyndalehouse.step.web.shared.command.GetCurrentBibleTextCommand;
-import com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptionGroups;
-import com.tyndalehouse.step.web.shared.common.ScriptureDisplayOptions;
-import com.tyndalehouse.step.web.shared.result.GetCurrentBibleTextResult;
-import com.tyndalehouse.step.web.shared.scripture.OsisElementType;
-import com.tyndalehouse.step.web.shared.scripture.PassageElement;
-
/**
* Tests the handler that retrieves scripture from the server
*
@@ -33,233 +9,249 @@
*
*/
public class GetCurrentBibleTextHandlerTest {
- /**
- * The standard context for mocking objects
- */
- private Mockery context;
-
- @Before
- public void setUp() {
- context = new Mockery();
- }
-
- /**
- * tests a single node with no extras
- */
@Test
- public void testProcessAttributes() {
- final GetCurrentBibleTextHandler handler = new GetCurrentBibleTextHandler(null);
- final PassageElement passage = new PassageElement();
- final Element title = new Element("title");
- handler.initFilters();
- final PassageElement element = handler.processAttributes(title, passage);
- assertEquals(element.getTypeOfElement(), OsisElementType.TITLE);
- }
+ public void testMe() {
- /**
- * tests a single node with multiple attributes
- */
- @Test
- public void testProcessAttributesMultiple() {
- final GetCurrentBibleTextHandler handler = new GetCurrentBibleTextHandler(null);
- final PassageElement passage = new PassageElement();
- final Element title = new Element("title");
- title.setAttribute("osisID", "Gen.1.1");
- title.setAttribute("blah", "interesting");
- handler.initFilters();
- final PassageElement element = handler.processAttributes(title, passage);
- assertEquals(OsisElementType.TITLE, element.getTypeOfElement());
- assertEquals("Gen.1.1", element.getAttribute(OsisElementType.OSIS_ID));
- assertFalse(element.getValues().containsValue("interesting"));
}
-
- /**
- * tests tag filtered out
- */
- @Test
- public void testProcessAttributesSkipped() {
- final GetCurrentBibleTextHandler handler = new GetCurrentBibleTextHandler(null);
- final PassageElement passage = new PassageElement();
- final Element title = new Element("blah");
- handler.initFilters();
- assertNull(handler.processAttributes(title, passage));
- }
-
- /**
- * Testing the following structure:
- *
- * <pre>
- * - Title
- * => Text (xml)
- * - Verse
- * => Word
- * => Text (a word)
- * => Text(something)
- * </pre>
- */
- @Test
- public void testTraverseTree() {
- final GetCurrentBibleTextHandler handler = new GetCurrentBibleTextHandler(null);
- final PassageElement passage = new PassageElement();
- final List<Content> xmlContent = new ArrayList<Content>();
- final Element title = new Element("title");
- final Element verse = new Element("verse");
- final Element word = new Element("w");
-
- title.setText("xml");
- verse.addContent(word);
- verse.addContent("Something");
-
- word.addContent("a word");
-
- xmlContent.add(title);
- xmlContent.add(verse);
-
- handler.initFilters();
- handler.traverseTree(xmlContent, passage);
-
- assertEquals(passage.getChildren().size(), 2);
- final PassageElement verseElement = passage.getChildren().get(1);
- assertEquals(verseElement.getTypeOfElement(), OsisElementType.VERSE);
-
- // children of verse
- final PassageElement childWord = verseElement.getFirstChild();
- final PassageElement childText = verseElement.getChild(1);
- assertEquals(childWord.getTypeOfElement(), OsisElementType.WORD);
- assertEquals(childText.getTypeOfElement(), OsisElementType.TEXT);
-
- assertEquals("a word", childWord.getFirstChild().getAttribute(OsisElementType.TEXT));
- assertEquals("Something", childText.getAttribute(OsisElementType.TEXT));
-
- }
-
- /**
- * there is something special going on with the KJV for this verse
- *
- * @throws ActionException
- */
- @Test
- public void testGetActs1v5() throws ActionException {
- final GetCurrentBibleTextHandler handler = new GetCurrentBibleTextHandler(new JSwordServiceImpl());
- final GetCurrentBibleTextCommand cmd = new GetCurrentBibleTextCommand();
- cmd.setReference("Acts 1:4-5");
- cmd.setVersion("KJV");
- cmd.setDisplayOptions(getNoInterlinearOptions());
- final GetCurrentBibleTextResult result = handler.execute(cmd, null);
-
- assertNotNull(result);
- }
-
- @Test
- public void testChangeDefaultFilters() {
- final GetCurrentBibleTextHandler handler = new GetCurrentBibleTextHandler(null);
- handler.initFilters();
- final Map<String, ScriptureDisplayOptions> displayOptions = new HashMap<String, ScriptureDisplayOptions>();
- displayOptions.put(ScriptureDisplayOptions.SHOW_LEMMAS.getKey(), ScriptureDisplayOptions.SHOW_LEMMAS);
- handler.changeDefaultFilters(displayOptions);
- }
-
- private Map<String, ScriptureDisplayOptions> getNoInterlinearOptions() {
- final Map<String, ScriptureDisplayOptions> map = new HashMap<String, ScriptureDisplayOptions>();
- map.put(ScriptureDisplayOptionGroups.INTERLINEAR.name(), ScriptureDisplayOptions.NO_INTERLINEAR);
- return map;
- }
-
// /**
- // * tests a greek reverse interlinear
- // *
- // * @throws ActionException
- // * exception during test
- // **/
- // @Test
- // public void testGreekReverseInterlinear() throws ActionException {
- // final Log log = context.mock(Log.class);
+ // * The standard context for mocking objects
+ // */
+ // private Mockery context;
//
- // context.checking(new Expectations() {
- // {
- // ignoring(log);
+ // @Before
+ // public void setUp() {
+ // context = new Mockery();
// }
- // });
//
- // final GetCurrentBibleTextCommand cmd = new
- // GetCurrentBibleTextCommand("KJV", "acts 1:1");
- // cmd.setTypeOfLookup(BibleTextLookupType.REVERSE_INTERLINEAR);
+ // /**
+ // * tests a single node with no extras
+ // */
+ // @Test
+ // public void testProcessAttributes() {
+ // final GetCurrentBibleTextHandler handler = new
+ // GetCurrentBibleTextHandler(null);
+ // final PassageElement passage = new PassageElement();
+ // final Element title = new Element("title");
+ // handler.initFilters();
+ // final PassageElement element = handler.processAttributes(title, passage);
+ // assertEquals(element.getTypeOfElement(), OsisElementType.TITLE);
+ // }
//
+ // /**
+ // * tests a single node with multiple attributes
+ // */
+ // @Test
+ // public void testProcessAttributesMultiple() {
// final GetCurrentBibleTextHandler handler = new
- // GetCurrentBibleTextHandler();
- // final GetCurrentBibleTextResult result = handler.execute(cmd, null);
+ // GetCurrentBibleTextHandler(null);
+ // final PassageElement passage = new PassageElement();
+ // final Element title = new Element("title");
+ // title.setAttribute("osisID", "Gen.1.1");
+ // title.setAttribute("blah", "interesting");
+ // handler.initFilters();
+ // final PassageElement element = handler.processAttributes(title, passage);
+ // assertEquals(OsisElementType.TITLE, element.getTypeOfElement());
+ // assertEquals("Gen.1.1", element.getAttribute(OsisElementType.OSIS_ID));
+ // assertFalse(element.getValues().containsValue("interesting"));
+ // }
//
- // Assert.assertNotNull(result.getPassage());
- // Assert.assertNotNull(result.getPassage().getVerseContent());
- // Assert.assertTrue(result.getPassage().getVerseContent().size() != 0);
- //
- // // TODO: add interlinear specific stuff
- //
+ // /**
+ // * tests tag filtered out
+ // */
+ // @Test
+ // public void testProcessAttributesSkipped() {
+ // final GetCurrentBibleTextHandler handler = new
+ // GetCurrentBibleTextHandler(null);
+ // final PassageElement passage = new PassageElement();
+ // final Element title = new Element("blah");
+ // handler.initFilters();
+ // assertNull(handler.processAttributes(title, passage));
// }
//
// /**
- // * tests hebrew reverse interlinear
+ // * Testing the following structure:
// *
- // * @throws ActionException
- // * an exception during execution
+ // * <pre>
+ // * - Title
+ // * => Text (xml)
+ // * - Verse
+ // * => Word
+ // * => Text (a word)
+ // * => Text(something)
+ // * </pre>
// */
// @Test
- // public void testHebrewReverseInterlinear() throws ActionException {
- // final Log log = context.mock(Log.class);
+ // public void testTraverseTree() {
+ // final GetCurrentBibleTextHandler handler = new
+ // GetCurrentBibleTextHandler(null);
+ // final PassageElement passage = new PassageElement();
+ // final List<Content> xmlContent = new ArrayList<Content>();
+ // final Element title = new Element("title");
+ // final Element verse = new Element("verse");
+ // final Element word = new Element("w");
//
- // context.checking(new Expectations() {
- // {
- // ignoring(log);
- // }
- // });
+ // title.setText("xml");
+ // verse.addContent(word);
+ // verse.addContent("Something");
//
- // final GetCurrentBibleTextCommand cmd = new
- // GetCurrentBibleTextCommand("KJV", "Gen 1:1");
- // cmd.setTypeOfLookup(BibleTextLookupType.REVERSE_INTERLINEAR);
+ // word.addContent("a word");
//
- // final GetCurrentBibleTextHandler handler = new
- // GetCurrentBibleTextHandler();
- // final GetCurrentBibleTextResult result = handler.execute(cmd, null);
+ // xmlContent.add(title);
+ // xmlContent.add(verse);
//
- // Assert.assertNotNull(result.getPassage());
- // Assert.assertNotNull(result.getPassage().getVerseContent());
- // Assert.assertTrue(result.getPassage().getVerseContent().size() != 0);
+ // handler.initFilters();
+ // handler.traverseTree(xmlContent, passage);
//
- // // TODO: add interlinear specific stuff
+ // assertEquals(passage.getChildren().size(), 2);
+ // final PassageElement verseElement = passage.getChildren().get(1);
+ // assertEquals(verseElement.getTypeOfElement(), OsisElementType.VERSE);
//
+ // // children of verse
+ // final PassageElement childWord = verseElement.getFirstChild();
+ // final PassageElement childText = verseElement.getChild(1);
+ // assertEquals(childWord.getTypeOfElement(), OsisElementType.WORD);
+ // assertEquals(childText.getTypeOfElement(), OsisElementType.TEXT);
+ //
+ // assertEquals("a word",
+ // childWord.getFirstChild().getAttribute(OsisElementType.TEXT));
+ // assertEquals("Something", childText.getAttribute(OsisElementType.TEXT));
+ //
// }
//
// /**
- // * tests a logical lookup of the passage, as opposed to plain text
+ // * there is something special going on with the KJV for this verse
// *
// * @throws ActionException
- // * exception during running
// */
// @Test
- // public void testLogicalPassage() throws ActionException {
- // final GetCurrentBibleTextCommand cmd = new
- // GetCurrentBibleTextCommand("ESV", "Gen 1:1");
- // cmd.setTypeOfLookup(BibleTextLookupType.LOGICAL);
- //
+ // public void testGetActs1v5() throws ActionException {
// final GetCurrentBibleTextHandler handler = new
- // GetCurrentBibleTextHandler();
+ // GetCurrentBibleTextHandler(new JSwordServiceImpl());
+ // final GetCurrentBibleTextCommand cmd = new GetCurrentBibleTextCommand();
+ // cmd.setReference("Acts 1:4-5");
+ // cmd.setVersion("KJV");
+ // cmd.setDisplayOptions(getNoInterlinearOptions());
// final GetCurrentBibleTextResult result = handler.execute(cmd, null);
//
- // Assert.assertEquals(result.getPassage().getText(),
- // "In the beginning, God created the heavens and the earth.");
+ // assertNotNull(result);
// }
//
// @Test
- // public void testLogicalPassageCrossOverChapter() throws ActionException {
- // final GetCurrentBibleTextCommand cmd = new
- // GetCurrentBibleTextCommand("ESV", "Gen 1:15-2:5");
- // cmd.setTypeOfLookup(BibleTextLookupType.LOGICAL);
- //
+ // public void testChangeDefaultFilters() {
// final GetCurrentBibleTextHandler handler = new
- // GetCurrentBibleTextHandler();
- // final GetCurrentBibleTextResult result = handler.execute(cmd, null);
+ // GetCurrentBibleTextHandler(null);
+ // handler.initFilters();
+ // final Map<String, ScriptureDisplayOptions> displayOptions = new
+ // HashMap<String, ScriptureDisplayOptions>();
+ // displayOptions.put(ScriptureDisplayOptions.SHOW_LEMMAS.getKey(),
+ // ScriptureDisplayOptions.SHOW_LEMMAS);
+ // handler.changeDefaultFilters(displayOptions);
+ // }
//
- // Assert.assertEquals(result.getPassage().getText(),
- // "In the beginning, God created the heavens and the earth.");
+ // private Map<String, ScriptureDisplayOptions> getNoInterlinearOptions() {
+ // final Map<String, ScriptureDisplayOptions> map = new HashMap<String,
+ // ScriptureDisplayOptions>();
+ // map.put(ScriptureDisplayOptionGroups.INTERLINEAR.name(),
+ // ScriptureDisplayOptions.NO_INTERLINEAR);
+ // return map;
// }
+ //
+ // // /**
+ // // * tests a greek reverse interlinear
+ // // *
+ // // * @throws ActionException
+ // // * exception during test
+ // // **/
+ // // @Test
+ // // public void testGreekReverseInterlinear() throws ActionException {
+ // // final Log log = context.mock(Log.class);
+ // //
+ // // context.checking(new Expectations() {
+ // // {
+ // // ignoring(log);
+ // // }
+ // // });
+ // //
+ // // final GetCurrentBibleTextCommand cmd = new
+ // // GetCurrentBibleTextCommand("KJV", "acts 1:1");
+ // // cmd.setTypeOfLookup(BibleTextLookupType.REVERSE_INTERLINEAR);
+ // //
+ // // final GetCurrentBibleTextHandler handler = new
+ // // GetCurrentBibleTextHandler();
+ // // final GetCurrentBibleTextResult result = handler.execute(cmd, null);
+ // //
+ // // Assert.assertNotNull(result.getPassage());
+ // // Assert.assertNotNull(result.getPassage().getVerseContent());
+ // // Assert.assertTrue(result.getPassage().getVerseContent().size() != 0);
+ // //
+ // // // TODO: add interlinear specific stuff
+ // //
+ // // }
+ // //
+ // // /**
+ // // * tests hebrew reverse interlinear
+ // // *
+ // // * @throws ActionException
+ // // * an exception during execution
+ // // */
+ // // @Test
+ // // public void testHebrewReverseInterlinear() throws ActionException {
+ // // final Log log = context.mock(Log.class);
+ // //
+ // // context.checking(new Expectations() {
+ // // {
+ // // ignoring(log);
+ // // }
+ // // });
+ // //
+ // // final GetCurrentBibleTextCommand cmd = new
+ // // GetCurrentBibleTextCommand("KJV", "Gen 1:1");
+ // // cmd.setTypeOfLookup(BibleTextLookupType.REVERSE_INTERLINEAR);
+ // //
+ // // final GetCurrentBibleTextHandler handler = new
+ // // GetCurrentBibleTextHandler();
+ // // final GetCurrentBibleTextResult result = handler.execute(cmd, null);
+ // //
+ // // Assert.assertNotNull(result.getPassage());
+ // // Assert.assertNotNull(result.getPassage().getVerseContent());
+ // // Assert.assertTrue(result.getPassage().getVerseContent().size() != 0);
+ // //
+ // // // TODO: add interlinear specific stuff
+ // //
+ // // }
+ // //
+ // // /**
+ // // * tests a logical lookup of the passage, as opposed to plain text
+ // // *
+ // // * @throws ActionException
+ // // * exception during running
+ // // */
+ // // @Test
+ // // public void testLogicalPassage() throws ActionException {
+ // // final GetCurrentBibleTextCommand cmd = new
+ // // GetCurrentBibleTextCommand("ESV", "Gen 1:1");
+ // // cmd.setTypeOfLookup(BibleTextLookupType.LOGICAL);
+ // //
+ // // final GetCurrentBibleTextHandler handler = new
+ // // GetCurrentBibleTextHandler();
+ // // final GetCurrentBibleTextResult result = handler.execute(cmd, null);
+ // //
+ // // Assert.assertEquals(result.getPassage().getText(),
+ // // "In the beginning, God created the heavens and the earth.");
+ // // }
+ // //
+ // // @Test
+ // // public void testLogicalPassageCrossOverChapter() throws
+ // ActionException {
+ // // final GetCurrentBibleTextCommand cmd = new
+ // // GetCurrentBibleTextCommand("ESV", "Gen 1:15-2:5");
+ // // cmd.setTypeOfLookup(BibleTextLookupType.LOGICAL);
+ // //
+ // // final GetCurrentBibleTextHandler handler = new
+ // // GetCurrentBibleTextHandler();
+ // // final GetCurrentBibleTextResult result = handler.execute(cmd, null);
+ // //
+ // // Assert.assertEquals(result.getPassage().getText(),
+ // // "In the beginning, God created the heavens and the earth.");
+ // // }
}
Modified: trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandlerTest.java
===================================================================
--- trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandlerTest.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetDictionaryDefinitionHandlerTest.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -35,8 +35,7 @@
/**
* looks up some text for two references, one greek, one hebrew
*
- * @throws ActionException
- * an exception during execution of the test
+ * @throws ActionException an exception during execution of the test
*/
@Test
public void testLookupText() throws ActionException {
Modified: trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandlerTest.java
===================================================================
--- trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandlerTest.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/GetTimelineUISetupHandlerTest.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -32,8 +32,7 @@
/**
* looks up
*
- * @throws ActionException
- * an exception during the running
+ * @throws ActionException an exception during the running
*/
@Test
public void testTimelineUIHandler() throws ActionException {
Modified: trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/JSwordInstallTest.java
===================================================================
--- trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/JSwordInstallTest.java 2010-08-27 12:34:50 UTC (rev 175)
+++ trunk/step-web-server/src/test/java/com/tyndalehouse/step/web/server/handler/JSwordInstallTest.java 2010-08-27 12:37:35 UTC (rev 176)
@@ -14,8 +14,7 @@
/**
* tests the installation of a bible version from JSword/crosswire.org
*
- * @throws ActionException
- * an exception during execution of the tests
+ * @throws ActionException an exception during execution of the tests
*/
@Test
public void testInstallESV() throws ActionException {
More information about the Tynstep-svn
mailing list