[Tynstep-svn] r72 - in trunk/StepDataLoader: . data sql/com/tyndalehouse/step/dataloader/sql sql/com/tyndalehouse/step/dataloader/sql/create sql/com/tyndalehouse/step/dataloader/sql/data src/com/tyndalehouse/step/dataloader/loaders src/com/tyndalehouse/step/dataloader/utils

ChrisBurrell at crosswire.org ChrisBurrell at crosswire.org
Tue Feb 9 13:42:08 MST 2010


Author: ChrisBurrell
Date: 2010-02-09 13:42:08 -0700 (Tue, 09 Feb 2010)
New Revision: 72

Added:
   trunk/StepDataLoader/data/timeline_reference_corrections.csv
   trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/
   trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/1.timeband_units.sql
   trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/2.timeband_setup.sql
   trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/3.sub_timeband_units.sql
   trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java
Removed:
   trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/create/options for scripture.txt
   trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java
Modified:
   trunk/StepDataLoader/.project
   trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/TimelineLoader.java
Log:
commiting new version of dataloader

Modified: trunk/StepDataLoader/.project
===================================================================
--- trunk/StepDataLoader/.project	2010-02-09 20:37:50 UTC (rev 71)
+++ trunk/StepDataLoader/.project	2010-02-09 20:42:08 UTC (rev 72)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <projectDescription>
-	<name>StepDataLoader</name>
+	<name>step-dataloader</name>
 	<comment></comment>
 	<projects>
 	</projects>

Added: trunk/StepDataLoader/data/timeline_reference_corrections.csv
===================================================================
--- trunk/StepDataLoader/data/timeline_reference_corrections.csv	                        (rev 0)
+++ trunk/StepDataLoader/data/timeline_reference_corrections.csv	2010-02-09 20:42:08 UTC (rev 72)
@@ -0,0 +1,76 @@
+SUB_TIMEBAND_CODE,
+T_EgyptD12,CENTURY
+,#DELETE#
+T_BirthOfTheNation,CENTURY
+T_ArchCult,CENTURY
+T_Ezekiel,DECADE
+T_LifeOfJesus,YEAR
+T_Europe,CENTURY
+T_EgyptD19,CENTURY
+T_PaulToRome,YEAR
+T_China,CENTURY
+T_ACModern,CENTURY
+T_All,MILLENIUM
+T_EgyptD18,CENTURY
+T_Abraham,YEAR
+T_Bible,MILLENIUM
+T_PaulMJ1,MONTH
+T_Isaac,YEAR
+T_NewTestament,DECADE
+T_PaulMJ3,MONTH
+T_PaulMJ2,MONTH
+T_Babylon,MILLENIUM
+T_JesusGalilee,MONTH
+T_Monarchy,DECADE
+T_JesusPerea,MONTH
+T_ACBronzeAge,MILLENIUM
+T_JudahMonarchy,DECADE
+T_Patriarchs,YEAR
+T_Syria,MILLENIUM
+T_Wilderness,DECADE
+T_ACIronAge,MILLENIUM
+T_Herodians,CENTURY
+T_Africa,MILLENIUM
+-,#DELETE#
+T_Rome,CENTURY
+T_Assyria,CENTURY
+T_PassionWeek,DAY
+T_JesusEarly,YEAR
+T_EgyptPtolemaic,MILLENIUM
+T_Judges,DECADE
+T_Solomon,DECADE
+T_JesusResurrected,WEEK
+T_Jacob,YEAR
+T_ExileAndReturn,YEAR
+T_UnitedMonarchy,YEAR
+T_Persia,CENTURY
+T_Isaiah,CENTURY
+T_ACBabylonPersia,CENTURY
+T_Saul,YEAR
+T_Americas,MILLENIUM
+T_ACRomeByzantium,MILLENIUM
+T_Mesopotamia,MILLENIUM
+T_David,DECADE
+T_EarlyChurch,YEAR
+T_India,CENTURY
+T_Hasmonean,CENTURY
+T_AdamToAbraham,MILLENIUM
+T_NTChurch,YEAR
+T_Conquest,YEAR
+T_Greece,CENTURY
+T_JesusJudea,MONTH
+T_RomanRepublic,CENTURY
+T_Jeremiah,DECADE
+T_IsraelMonarchy,DECADE
+T_ACJewishPeriod,CENTURY
+T_Esther,YEAR
+T_Return,YEAR
+T_JesusJohn,MONTH
+T_Exile,YEAR
+T_Asia,CENTURY
+T_Exodus,YEAR
+T_Intertestamental,DECADE
+T_JesusGalileeArea,MONTH
+T_RomanEmpire,CENTURY
+T_Egypt,MILLENIUM
+T_HagZech,YEAR

Deleted: trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/create/options for scripture.txt
===================================================================
--- trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/create/options for scripture.txt	2010-02-09 20:37:50 UTC (rev 71)
+++ trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/create/options for scripture.txt	2010-02-09 20:42:08 UTC (rev 72)
@@ -1,79 +0,0 @@
-set schema step;
-
-call dropIfExists('scripture_reference_map');
-call dropIfExists('scripture_reference');
-
---/** This table contains all the verse numbers in a passage...
--- * If a passage contains 10 verses, there will 10 rows in the database representing
--- * this.
--- * If a passage contains 100 verses (fairly unlikely) then it will contain
--- * 100 rows in the database...
--- * TODO: write performance tests for querying...
--- */
---create table scripture_reference (
---	target_id						int,
---	target_type						int,
---	verse_id						int
---
---)
---
----- finally create indexes
---create unique index target_type_target_id_verse_id_uind 
---on scripture_reference (target_id, target_type, verse_id)
---
---
-
-/*
- * we have several options here, 1st to basically store each verse references as a single
- * row and then when doing a query we can either
- *    A- lookup 
- * 	            select * from scripture where verse_id in (a,b,c,d,e,f,g,h)
- *    B- given we are probably only looking at one passage at a time, we can lookup as follows:
- *              select * from scripture where verse_id between a and h
- * 
- * Second option is store ranges, and do more complicated logic around the beginning of verses
- * and end of verses.
- *             select * from scripture where a between (verse_start_id and verse_end_id)
- *                                       or b between (verse_start_id and verse_end_id)
-  
- *   but of course, it is not quite so simple as this, since we d be wanting to key by chapter too
- *   so in the end we'd be looking at verse/chapter overlaps.
- * 
- * Third option is to store with verse_numbers and verse ranges...
- *            so as above but without the book/chapter mapping which makes it much easier, or does it?
- * we'd probaly have to end up doing the same thing several times, if the passage that is looked at
- * is non contiguous... 
- *
- * 
- */
-
-/**
- * This tables defines the reference. An event may have several references
- * For eg. Exodus 3:1-5,9-10 would be represented twice here...
- TODO: check the performance of this
- */
-create table scripture_reference (
-	scripture_reference_id		int PRIMARY KEY,
-	book_id						int NOT NULL,
-	start_chapter				int NOT NULL,		-- for philemon and short books, we can store this as -1? 
-	end_chapter					int NOT NULL,       -- so we can benefit from index or make nullable.
-	start_verse					int NOT NULL,
-	end_verse					int				-- this may be a single verse so can be null here 
-												-- or should we put the start verse and have a neat non-nullable field? 
-);
-
-/** need to define standards and whether we want to include seperate creates in each file
- * or one file per area
- */
-create table scripture_reference_map (
-	scripture_reference_id		int NOT NULL 
-								CONSTRAINT scripture_reference_id_fk REFERENCES scripture_reference (scripture_reference_id),
-	target_id  					int NOT NULL, -- could be for eg. a timeline event, or an article, etc. no referential integrity here
-    target_type					int  NOT NULL -- description of the event, defined in enum in java code...
-);
-
-
----- finally create indexes
---create index target_type_target_id_scripture_reference_id_ind 
---on scripture_reference_map (target_id, target_type, scripture_reference_id);
-

Added: trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/1.timeband_units.sql
===================================================================
--- trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/1.timeband_units.sql	                        (rev 0)
+++ trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/1.timeband_units.sql	2010-02-09 20:42:08 UTC (rev 72)
@@ -0,0 +1,21 @@
+set schema step;
+
+-- updating the timeband units 
+update step.timeband set timeband_unit = 'YEAR' 		where timeband_code = 'TL_Jesus';
+update step.timeband set timeband_unit = 'YEAR' 		where timeband_code = 'TL_NTChurch';
+update step.timeband set timeband_unit = 'DECADE' 		where timeband_code = 'TL_PatriarchsToJudges';
+update step.timeband set timeband_unit = 'DECADE' 		where timeband_code = 'TL_Rome';
+update step.timeband set timeband_unit = 'DECADE' 		where timeband_code = 'TL_Egypt';
+update step.timeband set timeband_unit = 'DECADE' 		where timeband_code = 'TL_Monarchy';
+update step.timeband set timeband_unit = 'DECADE' 		where timeband_code = 'TL_EarlyChurch';
+update step.timeband set timeband_unit = 'CENTURY' 		where timeband_code = 'TL_ArchCult';
+update step.timeband set timeband_unit = 'DECADE' 		where timeband_code = 'TL_OTNeighbours';
+update step.timeband set timeband_unit = 'CENTURY'		where timeband_code = 'TL_Global';
+update step.timeband set timeband_unit = 'YEAR' 		where timeband_code = 'TL_ExileAndReturn';
+update step.timeband set timeband_unit = 'CENTURY' 		where timeband_code = 'TL_Intertestamental';
+update step.timeband set timeband_unit = 'MILLENIUM' 	where timeband_code = 'TL_Africa';
+update step.timeband set timeband_unit = 'CENTURY'		where timeband_code = 'TL_Asia';
+update step.timeband set timeband_unit = 'DECADE' 		where timeband_code = 'TL_Europe';
+update step.timeband set timeband_unit = 'MILLENIUM' 	where timeband_code = 'TL_Americas';
+
+

Added: trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/2.timeband_setup.sql
===================================================================
--- trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/2.timeband_setup.sql	                        (rev 0)
+++ trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/2.timeband_setup.sql	2010-02-09 20:42:08 UTC (rev 72)
@@ -0,0 +1,11 @@
+set schema step;
+
+update timeband 
+set is_biblical = 'Y'
+where timeband_id in ( 
+    select timeband_id from scripture_reference, event
+    where target_type = 1
+      and target_id = event_id
+    group by timeband_id
+);
+

Added: trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/3.sub_timeband_units.sql
===================================================================
--- trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/3.sub_timeband_units.sql	                        (rev 0)
+++ trunk/StepDataLoader/sql/com/tyndalehouse/step/dataloader/sql/data/3.sub_timeband_units.sql	2010-02-09 20:42:08 UTC (rev 72)
@@ -0,0 +1,77 @@
+set schema step;
+
+-- updating the sub timeband units
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_EgyptD12';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_BirthOfTheNation';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_ArchCult';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_Europe';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_EgyptD19';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_China';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_ACModern';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_EgyptD18';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_Herodians';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_Rome';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_Assyria';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_Persia';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_Isaiah';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_ACBabylonPersia';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_India';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_Hasmonean';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_Greece';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_RomanRepublic';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_ACJewishPeriod';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_Asia';
+update step.sub_timeband set sub_timeband_unit = 'CENTURY' where sub_timeband_code = 'T_RomanEmpire';
+update step.sub_timeband set sub_timeband_unit = 'DAY' where sub_timeband_code = 'T_PassionWeek';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_Ezekiel';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_NewTestament';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_Monarchy';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_JudahMonarchy';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_Wilderness';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_Judges';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_Solomon';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_David';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_Jeremiah';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_IsraelMonarchy';
+update step.sub_timeband set sub_timeband_unit = 'DECADE' where sub_timeband_code = 'T_Intertestamental';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_All';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_Bible';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_Babylon';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_ACBronzeAge';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_Syria';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_ACIronAge';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_Africa';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_EgyptPtolemaic';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_Americas';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_ACRomeByzantium';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_Mesopotamia';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_AdamToAbraham';
+update step.sub_timeband set sub_timeband_unit = 'MILLENIUM' where sub_timeband_code = 'T_Egypt';
+update step.sub_timeband set sub_timeband_unit = 'MONTH' where sub_timeband_code = 'T_PaulMJ1';
+update step.sub_timeband set sub_timeband_unit = 'MONTH' where sub_timeband_code = 'T_PaulMJ3';
+update step.sub_timeband set sub_timeband_unit = 'MONTH' where sub_timeband_code = 'T_PaulMJ2';
+update step.sub_timeband set sub_timeband_unit = 'MONTH' where sub_timeband_code = 'T_JesusGalilee';
+update step.sub_timeband set sub_timeband_unit = 'MONTH' where sub_timeband_code = 'T_JesusPerea';
+update step.sub_timeband set sub_timeband_unit = 'MONTH' where sub_timeband_code = 'T_JesusJudea';
+update step.sub_timeband set sub_timeband_unit = 'MONTH' where sub_timeband_code = 'T_JesusJohn';
+update step.sub_timeband set sub_timeband_unit = 'MONTH' where sub_timeband_code = 'T_JesusGalileeArea';
+update step.sub_timeband set sub_timeband_unit = 'WEEK' where sub_timeband_code = 'T_JesusResurrected';
+update step.sub_timeband set sub_timeband_unit = 'WEEK' where sub_timeband_code = 'T_Exodus';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_LifeOfJesus';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_PaulToRome';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_Abraham';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_Isaac';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_Patriarchs';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_JesusEarly';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_Jacob';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_ExileAndReturn';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_UnitedMonarchy';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_Saul';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_EarlyChurch';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_NTChurch';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_Conquest';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_Esther';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_Return';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_Exile';
+update step.sub_timeband set sub_timeband_unit = 'YEAR' where sub_timeband_code = 'T_HagZech';
+

Modified: trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/TimelineLoader.java
===================================================================
--- trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/TimelineLoader.java	2010-02-09 20:37:50 UTC (rev 71)
+++ trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/loaders/TimelineLoader.java	2010-02-09 20:42:08 UTC (rev 72)
@@ -100,6 +100,11 @@
 	 * @param subTimebandCode
 	 */
 	public void addSubTimebandIfNotExists(final String subTimebandCode) {
+		if(subTimebandCode == null) {
+			//do nothing, it is not attached to a subtimeband or an importance
+			return;
+		}
+		
 		if (!subTimebands.containsKey(subTimebandCode)) {
 			// debatable as to whether or not we want to set the id here...
 			TimelineBean tb = new TimelineBean(subTimebands.size() + 1, subTimebandCode, subTimebandCode);
@@ -147,14 +152,43 @@
 
 		// first parse - get all the different timeline and populate timeline
 		// table  also add what's in the importance field in case it's not there already		
-		//TODO: actually there is a hierarchy between timebands and sub_timebands that is not modelled
-		//although would need to check whether the hierarchy is true
+		cleanupInputFile(events);
+		
 		populateTimebandTable(events);
 		populateSubTimebandTable(events);
 		populateEventTypeTable(events);
 		populateEventsTable(events);
+		executeTimebandUnitUpdates();
 	}
 
+	/** 
+	 * If the importance field or subtimeband field are empty, then set to null
+	 * @param events
+	 */
+	private void cleanupInputFile(List<TimelineEventBean> events) {
+		for(int ii = 0; ii < events.size(); ii++) {
+			TimelineEventBean teb = events.get(ii);
+			if(teb.getTimeline() != null && 
+					(teb.getTimeline().equals("-") ||
+					teb.getTimeline().equals(" "))) {
+				events.remove(ii);
+			
+				//readjust ii, so that we're looking at the next event
+				ii--;
+			} else if(teb.getTimeline() != null && teb.getTimeline().length() == 0) {
+				teb.setTimeline(null);
+			} else if(teb.getImportance() != null && teb.getImportance().length() == 0) {
+				teb.setImportance(null);
+			}
+		}
+	}
+
+	private void executeTimebandUnitUpdates() throws IOException, SQLException {
+		executeFile("sql/com/tyndalehouse/step/dataloader/sql/data/1.timeband_units.sql");
+		executeFile("sql/com/tyndalehouse/step/dataloader/sql/data/2.timeband_setup.sql");
+		executeFile("sql/com/tyndalehouse/step/dataloader/sql/data/3.sub_timeband_units.sql");
+	}
+
 	private void setDate(PreparedStatement ps, int index, PartialDate d) throws SQLException {
 		if (d == null || d.getDate() == null) {
 			ps.setNull(index, Types.BIGINT);
@@ -171,6 +205,21 @@
 		}
 	}
 
+	/**
+	 * sets a nullable integer
+	 * @param ps prepared statement
+	 * @param index, the index of the parameter
+	 * @param value the value
+	 * @throws SQLException
+	 */
+	private void setInt(PreparedStatement ps, int index, Integer value) throws SQLException {
+		if (value == null) {
+			ps.setNull(index, Types.INTEGER);
+		} else {
+			ps.setInt(index, value);
+		}
+	}
+
 	// TODO: all foreign key constraint, indexes and checks
 	// TODO: Rewrite to get rid of all the parameter indexes. It should be
 	// feasible to give a bunch
@@ -204,7 +253,7 @@
 				setString(timelineInsert, timelineParameterIndex++, "" + to.getPrecision().getShortCode()); // to_precision
 				timelineInsert.setInt(timelineParameterIndex++, timebands.get(event.getTimebandId()).getTimelineId()); // timeband_id
 				timelineInsert.setInt(timelineParameterIndex++, subTimebands.get(event.getTimeline()).getTimelineId()); // timeband_id
-				timelineInsert.setInt(timelineParameterIndex++, subTimebands.get(event.getImportance()).getTimelineId()); // importance_id
+				setInt(timelineInsert, timelineParameterIndex++, event.getImportance() == null ? null : subTimebands.get(event.getImportance()).getTimelineId()); // importance_id
 				setString(timelineInsert, timelineParameterIndex++, event.getCertainty()); // certainty
 				setString(timelineInsert, timelineParameterIndex++, event.getFlags()); // flags
 				timelineInsert.setInt(timelineParameterIndex++, eventTypes.get(event.getType()).getEventTypeId()); // event_type_id

Deleted: trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java
===================================================================
--- trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java	2010-02-09 20:37:50 UTC (rev 71)
+++ trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java	2010-02-09 20:42:08 UTC (rev 72)
@@ -1,30 +0,0 @@
-package com.tyndalehouse.step.dataloader.utils;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-
-import com.tyndalehouse.step.dataloader.ClientDbProvider;
-
-public class DerbyUtils {
-	
-	//TODO: optimize: creating a new connection each time sounds like a waste of time...
-	public static void dropIfExists(String tableName) throws SQLException {
-		//Connection conn = DriverManager.getConnection("jdbc:default:connection");
-		Connection conn = ClientDbProvider.getConnection();
-		
-		PreparedStatement exists = conn.prepareStatement("select count(*) from sys.systables where tablename = upper('" + tableName + "')");
-		ResultSet exRs = exists.executeQuery();
-		
-		exRs.next();
-		//get count out:
-		int count = exRs.getInt(1);
-		if(count > 0) {
-			//System.out.println("Dropping table " + tableName);
-			PreparedStatement s = conn.prepareStatement("drop table " + tableName);	
-			s.executeUpdate();
-		}		
-		//conn.close();
-	}
-}

Added: trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java
===================================================================
--- trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java	                        (rev 0)
+++ trunk/StepDataLoader/src/com/tyndalehouse/step/dataloader/utils/DerbyUtils.java	2010-02-09 20:42:08 UTC (rev 72)
@@ -0,0 +1,31 @@
+package com.tyndalehouse.step.dataloader.utils;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import com.tyndalehouse.step.dataloader.ClientDbProvider;
+
+
+public class DerbyUtils {
+	
+	//TODO: optimize: creating a new connection each time sounds like a waste of time...
+	public static void dropIfExists(String tableName) throws SQLException {
+		//Connection conn = DriverManager.getConnection("jdbc:default:connection");
+		Connection conn = ClientDbProvider.getConnection();
+		
+		PreparedStatement exists = conn.prepareStatement("select count(*) from sys.systables where tablename = upper('" + tableName + "')");
+		ResultSet exRs = exists.executeQuery();
+		
+		exRs.next();
+		//get count out:
+		int count = exRs.getInt(1);
+		if(count > 0) {
+			//System.out.println("Dropping table " + tableName);
+			PreparedStatement s = conn.prepareStatement("drop table " + tableName);	
+			s.executeUpdate();
+		}		
+		//conn.close();
+	}
+}




More information about the Tynstep-svn mailing list