[Tynstep-svn] r104 - in trunk/step-web-app/src/main: java/com/tyndalehouse/step/web/server/handler java/com/tyndalehouse/step/web/shared/common java/com/tyndalehouse/step/web/shared/common/maps java/com/tyndalehouse/step/web/shared/result resources/com/tyndalehouse/step/web/server/db/queries/maps

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Sun Mar 28 08:26:55 MST 2010


Author: ChrisBurrell
Date: 2010-03-28 08:26:54 -0700 (Sun, 28 Mar 2010)
New Revision: 104

Added:
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetLocationsHandler.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/GeoLocation.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/GeoLocationType.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/LatLong.java
   trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/result/GetLocationsResult.java
   trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/server/db/queries/maps/get_locations_for_passage.sql
Log:
documentation and warnings

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetLocationsHandler.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetLocationsHandler.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/server/handler/GetLocationsHandler.java	2010-03-28 15:26:54 UTC (rev 104)
@@ -0,0 +1,56 @@
+package com.tyndalehouse.step.web.server.handler;
+
+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.db.framework.StepQueryRunner;
+import com.tyndalehouse.step.web.shared.command.GetLocationsCommand;
+import com.tyndalehouse.step.web.shared.result.GetLocationsResult;
+
+/**
+ * The GetLocations command gets geographical locations from the server
+ * datasources and sends them back to the client
+ * 
+ * @author CJBurrell
+ * 
+ */
+public class GetLocationsHandler extends
+	AbstractStepHandler<GetLocationsCommand, GetLocationsResult> {
+	/**
+	 * The step query runner to run queries against the database
+	 */
+	private final StepQueryRunner queryRunner;
+
+	/**
+	 * Default constructor
+	 * 
+	 * @param queryRunner a query runner
+	 */
+	@Inject
+	public GetLocationsHandler(final StepQueryRunner queryRunner) {
+		this.queryRunner = queryRunner;
+	}
+
+	@Override
+	public GetLocationsResult execute(final GetLocationsCommand arg0, final ExecutionContext arg1)
+		throws ActionException {
+		// try {
+		// final List<GeoLoc> timelines = queryRunner.run(new
+		// TimelineSetupDataProcessor());
+		final GetLocationsResult r = new GetLocationsResult();
+		return r;
+		// } catch (final UnableToRunQueryException e) {
+		// getLogger().error("An error occured while loading the config for the query",
+		// e);
+		// throw new ActionException(e);
+		// }
+	}
+
+	@Override
+	public void rollback(final GetLocationsCommand arg0, final GetLocationsResult arg1,
+		final ExecutionContext arg2) throws ActionException {
+		getLogger().error("Get Locations Handler rolling back");
+	}
+}

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/GeoLocation.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/GeoLocation.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/GeoLocation.java	2010-03-28 15:26:54 UTC (rev 104)
@@ -0,0 +1,140 @@
+package com.tyndalehouse.step.web.shared.common.maps;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Serialisable POJO containing all the data pertaining to displaying the
+ * location on the screen
+ * 
+ * @author CJBurrell
+ * 
+ */
+public class GeoLocation implements Serializable {
+	/**
+	 * serial id
+	 */
+	private static final long serialVersionUID = -2429722523530262993L;
+
+	/**
+	 * description of the location
+	 */
+	private String description;
+
+	/**
+	 * value of the latitude
+	 */
+	private long latitude;
+
+	/**
+	 * List of lat longs
+	 */
+	private List<LatLong> latlongs;
+
+	/**
+	 * type of location, for e.g. a city, a memorial, a fountain, etc.
+	 */
+	private GeoLocationType locationType;
+
+	/**
+	 * value of the longitude
+	 */
+	private long longitude;
+
+	/**
+	 * Name of the place, for e.g. Golgotha
+	 */
+	private String placeName;
+
+	/**
+	 * default constructor
+	 */
+	public GeoLocation() {
+		latlongs = new ArrayList<LatLong>();
+	}
+
+	/**
+	 * @return the description
+	 */
+	public final String getDescription() {
+		return description;
+	}
+
+	/**
+	 * @return the latitude
+	 */
+	public final long getLatitude() {
+		return latitude;
+	}
+
+	/**
+	 * @return the latlongs
+	 */
+	public final List<LatLong> getLatlongs() {
+		return latlongs;
+	}
+
+	/**
+	 * @return the locationType
+	 */
+	public final GeoLocationType getLocationType() {
+		return locationType;
+	}
+
+	/**
+	 * @return the longitude
+	 */
+	public final long getLongitude() {
+		return longitude;
+	}
+
+	/**
+	 * @return the placeName
+	 */
+	public final String getPlaceName() {
+		return placeName;
+	}
+
+	/**
+	 * @param description the description to set
+	 */
+	public final void setDescription(final String description) {
+		this.description = description;
+	}
+
+	/**
+	 * @param latitude the latitude to set
+	 */
+	public final void setLatitude(final long latitude) {
+		this.latitude = latitude;
+	}
+
+	/**
+	 * @param latlongs the latlongs to set
+	 */
+	public final void setLatlongs(final List<LatLong> latlongs) {
+		this.latlongs = latlongs;
+	}
+
+	/**
+	 * @param locationType the locationType to set
+	 */
+	public final void setLocationType(final GeoLocationType locationType) {
+		this.locationType = locationType;
+	}
+
+	/**
+	 * @param longitude the longitude to set
+	 */
+	public final void setLongitude(final long longitude) {
+		this.longitude = longitude;
+	}
+
+	/**
+	 * @param placeName the placeName to set
+	 */
+	public final void setPlaceName(final String placeName) {
+		this.placeName = placeName;
+	}
+}

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/GeoLocationType.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/GeoLocationType.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/GeoLocationType.java	2010-03-28 15:26:54 UTC (rev 104)
@@ -0,0 +1,18 @@
+package com.tyndalehouse.step.web.shared.common.maps;
+
+/**
+ * Type of location, indicating whether the location is a city, a wall, a
+ * region, etc.
+ * 
+ * @author CJBurrell
+ * 
+ */
+public enum GeoLocationType {
+	/** CITY */
+	CITY,
+	/** A FOUNTAIN */
+	FOUNTAIN,
+	/** A REGION */
+	REGION,
+
+}

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/LatLong.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/LatLong.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/common/maps/LatLong.java	2010-03-28 15:26:54 UTC (rev 104)
@@ -0,0 +1,47 @@
+package com.tyndalehouse.step.web.shared.common.maps;
+
+/**
+ * LatLong POJO containg the latitude and longitude of a point on a map
+ * 
+ * @author CJBurrell
+ * 
+ */
+public class LatLong {
+	/**
+	 * latitude of the point
+	 */
+	private long latitude;
+
+	/**
+	 * longitude of the point
+	 */
+	private long longitude;
+
+	/**
+	 * @return the latitude
+	 */
+	public final long getLatitude() {
+		return latitude;
+	}
+
+	/**
+	 * @return the longitude
+	 */
+	public final long getLongitude() {
+		return longitude;
+	}
+
+	/**
+	 * @param latitude the latitude to set
+	 */
+	public final void setLatitude(final long latitude) {
+		this.latitude = latitude;
+	}
+
+	/**
+	 * @param longitude the longitude to set
+	 */
+	public final void setLongitude(final long longitude) {
+		this.longitude = longitude;
+	}
+}

Added: trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/result/GetLocationsResult.java
===================================================================
--- trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/result/GetLocationsResult.java	                        (rev 0)
+++ trunk/step-web-app/src/main/java/com/tyndalehouse/step/web/shared/result/GetLocationsResult.java	2010-03-28 15:26:54 UTC (rev 104)
@@ -0,0 +1,50 @@
+package com.tyndalehouse.step.web.shared.result;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import net.customware.gwt.dispatch.shared.Result;
+
+import com.tyndalehouse.step.web.shared.common.maps.GeoLocation;
+
+/**
+ * This object contains the result from a geographical location, containing
+ * enough data to display a marker on the screen, and a hover over.
+ * 
+ * @author CJBurrell
+ * 
+ */
+public class GetLocationsResult implements Result {
+
+	/**
+	 * serial id for serialisation
+	 */
+	private static final long serialVersionUID = 1516648078862839012L;
+
+	/**
+	 * list of locations
+	 */
+	private List<GeoLocation> locations;
+
+	/**
+	 * default constructor
+	 */
+	public GetLocationsResult() {
+		locations = new ArrayList<GeoLocation>();
+	}
+
+	/**
+	 * @return the locations
+	 */
+	public final List<GeoLocation> getLocations() {
+		return locations;
+	}
+
+	/**
+	 * @param locations the locations to set
+	 */
+	public final void setLocations(final List<GeoLocation> locations) {
+		this.locations = locations;
+	}
+
+}

Added: trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/server/db/queries/maps/get_locations_for_passage.sql
===================================================================
--- trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/server/db/queries/maps/get_locations_for_passage.sql	                        (rev 0)
+++ trunk/step-web-app/src/main/resources/com/tyndalehouse/step/web/server/db/queries/maps/get_locations_for_passage.sql	2010-03-28 15:26:54 UTC (rev 104)
@@ -0,0 +1,22 @@
+--------------------------------------------------------
+-- Gets all the location for a given passage (qry_start, qry_end)
+--------------------------------------------------------
+define qry_start as integer
+define qry_end as integer
+
+select 
+	location_name,
+	lat,
+	long
+from 
+                   step.scripture_reference sr 
+        inner join step.location loc on sr.TARGET_ID = loc.location_id 
+		inner join step.lat_long ll on loc.location_id = ll.location_id
+where target_type = 2 
+  and 
+		((#qry_start# between start_verse_id and end_verse_id)    -- the query start is between the event range
+		or (#qry_end# between start_verse_id and end_verse_id)  -- the query end is between the event range
+		or (#qry_start# <= start_verse_id and #qry_end# >= start_verse_id)  -- the query start is before the event start, but the end is after the event start
+		or (#qry_end# >= end_verse_id and #qry_start# <= end_verse_id))     -- the end of the range is greater than event end, but the start is before the end
+  order by (end_verse_id - start_verse_id) asc
+ fetch first row only




More information about the Tynstep-svn mailing list