From 2fae905a591201e3d4ee3d463d1d94a504171017 Mon Sep 17 00:00:00 2001 From: ?? ? <ulysseskao@ximple.com.tw> Date: Mon, 17 Mar 2008 19:31:27 +0800 Subject: [PATCH] update for EOFM-17 --- ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertJobContext.java | 76 ++++++++++++++++++++++++------------- 1 files changed, 49 insertions(+), 27 deletions(-) diff --git a/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertJobContext.java b/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertJobContext.java index 1b0a17a..fe44141 100644 --- a/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertJobContext.java +++ b/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertJobContext.java @@ -2,14 +2,16 @@ import java.sql.DriverManager; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.geotools.feature.AttributeTypeFactory; -import org.geotools.feature.FeatureCollection; -import org.geotools.feature.FeatureTypeBuilder; -import org.opengis.geometry.Geometry; +import org.apache.commons.transaction.memory.PessimisticMapWrapper; +import org.apache.commons.transaction.util.CommonsLoggingLogger; +import org.apache.commons.transaction.util.LoggerFacade; +import org.geotools.feature.Feature; import com.vividsolutions.jts.util.Assert; @@ -20,6 +22,7 @@ public class OracleConvertJobContext { static Log logger = LogFactory.getLog(OracleConvertJobContext.class); + static final LoggerFacade sLogger = new CommonsLoggingLogger(logger); private static final String ORACLE_URL = "jdbc:oracle:thin:@"; private static final String PROPUsrKey = "user"; @@ -208,6 +211,8 @@ protected static final String SMTM_GRANTOBJECTTYPE = "GRANT EXECUTE ANY TYPE TO \"" + UDT_SCHEMA + "\""; + protected static final long TIMEOUT = Long.MAX_VALUE; + static { try @@ -242,16 +247,21 @@ private ElementDispatcher elementDispatcher; + private HashMap featuresContext = new HashMap(); + private PessimisticMapWrapper txFeaturesContext; + public OracleConvertJobContext() { properties = new Properties(); elementDispatcher = createElementDispatcher(); + txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); + } private ElementDispatcher createElementDispatcher() { ElementDispatcher dispatcher = new ElementDispatcher(); - dispatcher.addRule(new TypeCompIdHandlerStrategy(106, 0)); + dispatcher.addRule(new TypeCompIdHandlerStrategy("Conductor", new CreateLineStringStrategy(), 106, 0)); return dispatcher; } @@ -305,34 +315,46 @@ _oraclePort = oraclePort; } - public FeatureCollection putFeatureCollection(Element element) + public void putFeatureCollection(Element element) { - return null; + Feature feature = elementDispatcher.execute(element); + if (feature == null) + return; + + if (!txFeaturesContext.containsKey(feature.getFeatureType())) + { + txFeaturesContext.put(feature.getFeatureType(), new ArrayList()); + } + ArrayList arrayList = (ArrayList) txFeaturesContext.get(feature.getFeatureType()); + arrayList.add(feature); } - public FeatureCollection createFeatureCollection(Element element) + public void startTransaction() { - FeatureTypeBuilder typeBuilder = FeatureTypeBuilder.newInstance("Line"); - - typeBuilder.addType(AttributeTypeFactory.newAttributeType("GEOM", Geometry.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("TID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("OID", Long.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("CID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LID", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("LEVEL", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMCOLOR", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMWEIGHT", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("SYMSTYLE", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("FONT", String.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("JUST", Integer.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("HEIGHT", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("WIDTH", Double.class)); - typeBuilder.addType(AttributeTypeFactory.newAttributeType("ANGLE", Double.class)); - return null; + txFeaturesContext.startTransaction(); } - public void commit() + public void commitTransaction() { - + txFeaturesContext.commitTransaction(); + if (!featuresContext.isEmpty()) + { + updateDataStore(); + } } + + public void rollbackTransaction() + { + txFeaturesContext.rollbackTransaction(); + if (!featuresContext.isEmpty()) + { + updateDataStore(); + } + } + + private void updateDataStore() + { + // todo: + } + } -- Gitblit v0.0.0-SNAPSHOT