Commit 42afbb42 authored by Daniel Eggert's avatar Daniel Eggert
Browse files

added implementation for scene status update

parent 9184850b
......@@ -83,7 +83,72 @@ public class DbUtils {
dstDb.commit();
}
private static void transferSceneState() throws IOException {
private static void transferSceneState() throws IOException, SQLException {
// establish connections
Connection srcDb = getSrcDb();
Connection dstDb = getDstDb();
// reset proc_level to metadata for all scenes in dst db
dstDb.prepareStatement("update scenes set proc_level='METADATA'::proc_level;").executeUpdate();
PreparedStatement updateScene = dstDb.prepareStatement("update scenes set proc_level='DOWNLOADED'::proc_level, filename=? where entityid=? and datasetid=?;");
PreparedStatement updateSentinelScene = dstDb.prepareStatement("update scenes set proc_level='DOWNLOADED'::proc_level, entityid=? where filename=? and datasetid=?;");
// get list of downloaded scenes from src database
ResultSet rs = srcDb.prepareStatement("select filename, entityid, datasetid from scenes where proc_level='DOWNLOADED'::proc_level;").executeQuery();
int count = 0;
while (rs.next()) {
String filename = rs.getString(1);
String entityid = rs.getString(2);
short datasetid = rs.getShort(3);
// transform datasetids
datasetid = transformDatasetid(datasetid);
if (datasetid == 249) {
// sentinel scene update
updateSentinelScene.setString(1, entityid);
updateSentinelScene.setString(2, filename);
updateSentinelScene.setShort(3, datasetid);
updateSentinelScene.executeUpdate();
} else {
updateScene.setString(1, filename);
updateScene.setString(2, entityid);
updateScene.setShort(3, datasetid);
updateScene.executeUpdate();
}
if (++count % 100 == 0) {
System.out.print("updated " + count + " scenes \r");
dstDb.commit();
}
}
System.out.print("done. updated " + count + " scenes ");
}
/**
* @param datasetid
* @return
*/
private static short transformDatasetid(short datasetid) {
switch (datasetid) {
case 104:
// L8
return 250;
case 112:
case 113:
// L7 etm
return 251;
case 108:
// l4-5 tm
return 252;
default:
return datasetid;
}
}
private static final String SRC_DB_PROPS_KEY_PREFIX = "src_db_";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment