From 0ffbdf76fc7743979915204d41faf46cae69f7a1 Mon Sep 17 00:00:00 2001
From: ulysseskao <ulysseskao@ximple.com.tw>
Date: Mon, 06 Jan 2014 19:25:04 +0800
Subject: [PATCH] update for flow mark

---
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleTransformColorOwner2CSVJob.java |   20 ++++++++-
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java      |   44 ++++++++++++++++-----
 2 files changed, 50 insertions(+), 14 deletions(-)

diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java
index deaf389..71f89d3 100644
--- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java
+++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java
@@ -25,7 +25,7 @@
 import java.util.Map;
 import java.util.TreeMap;
 
-import com.ximple.eofms.util.DefaultColorTable;
+import com.ximple.eofms.util.*;
 import org.apache.commons.collections.OrderedMap;
 import org.apache.commons.collections.OrderedMapIterator;
 import org.apache.commons.collections.map.LinkedMap;
@@ -58,10 +58,6 @@
 import com.ximple.eofms.jobs.context.postgis.GeneralDgnConvertPostGISJobContext;
 import com.ximple.eofms.jobs.context.postgis.IndexDgnConvertPostGISJobContext;
 import com.ximple.eofms.jobs.context.postgis.OracleConvertPostGISJobContext;
-import com.ximple.eofms.util.BinConverter;
-import com.ximple.eofms.util.ByteArrayCompressor;
-import com.ximple.eofms.util.FileUtils;
-import com.ximple.eofms.util.StringUtils;
 import com.ximple.io.dgn7.ComplexElement;
 import com.ximple.io.dgn7.Dgn7fileException;
 import com.ximple.io.dgn7.Dgn7fileReader;
@@ -89,7 +85,7 @@
     private static final String INDEXPATHNAME = "index";
     private static final String OTHERPATHNAME = "other";
 
-    private static String FETCH_CONNFDR = "SELECT FSC, UFID, FDR1 FROM BASEDB.CONNECTIVITY ORDER BY FSC";
+    private static String FETCH_CONNFDR = "SELECT FSC, UFID, FDR1, DIR FROM BASEDB.CONNECTIVITY ORDER BY FSC";
     private static String FETCH_COLORTAB = "SELECT TAG_SFSC, TAG_LUFID, COLOR FROM OCSDB.COLOR ORDER BY TAG_SFSC";
 
     private static String CREATE_OWNERTABLE = "CREATE TABLE s (tid smallint not null, oid int not null, owner smallint not null)";
@@ -1622,11 +1618,11 @@
             rs.setFetchSize(50);
 
             createOrClearTargetTable(connectionPG, targetTableName,
-                "(tid smallint not null, oid int not null, fowner smallint not null)");
+                "(tid smallint not null, oid int not null, fowner smallint not null, flow varchar(20) not null)");
 
             pstmt = connectionPG.prepareStatement("INSERT INTO " +
                 encodeSchemaTableName(_pgSchema, targetTableName) +
-                " (tid, oid, fowner) VALUES (?, ?, ?)" );
+                " (tid, oid, fowner, flow) VALUES (?, ?, ?, ?)" );
 
             final int MAX_BATCHSIZE = 50;
             int count = 0;
@@ -1634,9 +1630,21 @@
                 int cid = rs.getInt(1);
                 long oid = rs.getLong(2);
                 int ownerId = rs.getInt(3);
+                short dirId = (short) rs.getInt(4);
                 pstmt.setShort(1, (short) cid);
                 pstmt.setInt(2, (int) oid);
                 pstmt.setShort(3, (short) ownerId);
+                ConnectivityDirectionEnum dir = ConnectivityDirectionEnum.convertShort(dirId);
+                if ((ConnectivityDirectionEnum.ForwardflowON == dir) ||
+                        (ConnectivityDirectionEnum.ForwardFixflowON == dir)) {
+                    pstmt.setString(4, "shape://ccarrow");
+
+                } else if ((ConnectivityDirectionEnum.BackflowON == dir) ||
+                        (ConnectivityDirectionEnum.BackFixflowON == dir)) {
+                    pstmt.setString(4, "shape://rccarrow");
+                } else {
+                    pstmt.setString(4, "shape://backslash");
+                }
                 pstmt.addBatch();
 
                 if (count % MAX_BATCHSIZE == 0) {
@@ -1735,7 +1743,7 @@
                 String colorText = colorTable.getColorCode(colorId);
 
                 sb.append(cid).append(',');
-                sb.append(oid).append(",");
+                sb.append(oid).append(',');
                 sb.append(colorText).append("\n");
 
                 if (count % MAX_BATCHSIZE == 0) {
@@ -1791,7 +1799,7 @@
             rs.setFetchSize(MAX_BATCHSIZE);
 
             createOrClearTempTargetTable(connectionPG, targetTempName,
-                "(tid smallint not null, oid int not null, fowner smallint not null)");
+                "(tid smallint not null, oid int not null, fowner smallint not null, flow varchar(20) not null)");
 
             StringBuilder sb = new StringBuilder();
 
@@ -1803,10 +1811,24 @@
                 int cid = rs.getInt(1);
                 long oid = rs.getLong(2);
                 int ownerId = rs.getInt(3);
+                short dirId = (short) rs.getInt(4);
+                String flowMark = null;
+                ConnectivityDirectionEnum dir = ConnectivityDirectionEnum.convertShort(dirId);
+                if ((ConnectivityDirectionEnum.ForwardflowON == dir) ||
+                        (ConnectivityDirectionEnum.ForwardFixflowON == dir)) {
+                    flowMark = "shape://ccarrow";
+
+                } else if ((ConnectivityDirectionEnum.BackflowON == dir) ||
+                        (ConnectivityDirectionEnum.BackFixflowON == dir)) {
+                    flowMark = "shape://rccarrow";
+                } else {
+                    flowMark = "shape://backslash";
+                }
 
                 sb.append(cid).append(',');
                 sb.append(oid).append(',');
-                sb.append(ownerId).append('\n');
+                sb.append(ownerId).append(',');
+                sb.append(flowMark).append('\n');
 
                 if (count % MAX_BATCHSIZE == 0) {
                     reader.unread(sb.toString().toCharArray());
diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleTransformColorOwner2CSVJob.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleTransformColorOwner2CSVJob.java
index 87d2441..c54723d 100644
--- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleTransformColorOwner2CSVJob.java
+++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleTransformColorOwner2CSVJob.java
@@ -17,6 +17,7 @@
 import au.com.bytecode.opencsv.ResultSetHelperService;
 import com.ximple.eofms.jobs.context.AbstractOracleJobContext;
 import com.ximple.eofms.jobs.context.postgis.OracleConvertPostGISJobContext;
+import com.ximple.eofms.util.ConnectivityDirectionEnum;
 import com.ximple.eofms.util.DefaultColorTable;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -34,7 +35,7 @@
     final static Log logger = LogFactory.getLog(OracleTransformColorOwner2CSVJob.class);
 
     public static String FETCH_TPDATA = "SELECT TPID, TPNAME FROM BASEDB.TPDATA";
-    public static String FETCH_CONNFDR = "SELECT FSC, UFID, FDR1 FROM BASEDB.CONNECTIVITY ORDER BY FSC";
+    public static String FETCH_CONNFDR = "SELECT FSC, UFID, FDR1, DIR FROM BASEDB.CONNECTIVITY ORDER BY FSC";
     public static String FETCH_FDRCOLOR = "SELECT FRREDERID, COLOR FROM BASEDB.FEEDER";
     public static String FETCH_COLORTAB = "SELECT TAG_SFSC, TAG_LUFID, COLOR FROM OCSDB.COLOR ORDER BY TAG_SFSC";
 
@@ -246,11 +247,24 @@
             rs.setFetchSize(FETCHSIZE);
 
             ResultSetHelper resultService = new ResultSetHelperService();
-            final String[] header = new String[] { "tid", "oid", "owner" };
+            final String[] header = new String[] { "tid", "oid", "owner", "flow" };
             CSVWriter writer = new CSVWriter(new FileWriter("featureowner.csv"), ',');
             writer.writeNext(header);
             while (rs.next()) {
-                writer.writeNext(resultService.getColumnValues(rs));
+                short dirId = (short) rs.getInt(4);
+                String[] values = resultService.getColumnValues(rs);
+                ConnectivityDirectionEnum dir = ConnectivityDirectionEnum.convertShort(dirId);
+                if ((ConnectivityDirectionEnum.ForwardflowON == dir) ||
+                    (ConnectivityDirectionEnum.ForwardFixflowON == dir)) {
+                    values[3] = "shape://ccarrow";
+
+                } else if ((ConnectivityDirectionEnum.BackflowON == dir) ||
+                        (ConnectivityDirectionEnum.BackFixflowON == dir)) {
+                    values[3] = "shape://rccarrow";
+                } else {
+                    values[3] = "shape://backslash";
+                }
+                writer.writeNext(values);
             }
             writer.flush();
             writer.close();

--
Gitblit v0.0.0-SNAPSHOT