| | |
| | | |
| | | 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; |
| | | |
| | |
| | | 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"; |
| | |
| | | |
| | | protected static final String SMTM_GRANTOBJECTTYPE = "GRANT EXECUTE ANY TYPE TO \"" + UDT_SCHEMA + "\""; |
| | | |
| | | protected static final long TIMEOUT = Long.MAX_VALUE; |
| | | |
| | | static |
| | | { |
| | | try |
| | |
| | | |
| | | 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; |
| | | } |
| | | |
| | |
| | | _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: |
| | | } |
| | | |
| | | } |