forked from geodmms/xdgnjobs

?? ?
2008-03-27 6de5086ab3e8e7fa852b1e5d9a31aabade25e017
9 files modified
264 ■■■■■ changed files
xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml 6 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java 6 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeCompIdDispatchableFilter.java 26 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeIdDispatchableFilter.java 2 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java 20 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertJobContext.java 40 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/filter/ElementDispatcherRules.xml 4 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/main/resources/conf/DefaultConvertShpFilter.xml 150 ●●●●● patch | view | raw | blame | history
xdgnjobs/ximple-spatialjob/src/test/java/com/ximple/eofms/filter/ElementDispatcherTest.java 10 ●●●● patch | view | raw | blame | history
xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml
@@ -26,11 +26,11 @@
        </entry>
        <entry>
          <key>ORAHOST</key>
          <value>192.168.11.119</value>
          <value>192.168.11.200</value>
        </entry>
        <entry>
          <key>ORAINST</key>
          <value>ORCL</value>
          <value>nntpc</value>
        </entry>
        <entry>
          <key>ORAPORT</key>
@@ -50,7 +50,7 @@
        </entry>
        <entry>
          <key>TESTMODE</key>
          <value>true</value>
          <value>FALSE</value>
        </entry>
        <entry>
          <key>TESTCOUNT</key>
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java
@@ -12,11 +12,7 @@
import com.vividsolutions.jts.geom.GeometryFactory;
import com.vividsolutions.jts.geom.Geometry;
import com.ximple.io.dgn7.Element;
import com.ximple.io.dgn7.FrammeAttributeData;
import com.ximple.io.dgn7.LineStringElement;
import com.ximple.io.dgn7.UserAttributeData;
import com.ximple.io.dgn7.ComplexChainElement;
import com.ximple.io.dgn7.*;
public class CreateLineStringStrategy implements CreateFeatureTypeStrategy
{
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeCompIdDispatchableFilter.java
@@ -8,11 +8,14 @@
import com.ximple.io.dgn7.Element;
import com.ximple.io.dgn7.FrammeAttributeData;
import java.util.ArrayList;
public class TypeCompIdDispatchableFilter extends AbstractFLinkageDispatchableFilter
{
    private int tid;
    private int cid;
    private CreateFeatureTypeStrategy createStrategy;
    private ArrayList<java.lang.Integer> elemtypeArray = new ArrayList<java.lang.Integer>();
    public TypeCompIdDispatchableFilter()
    {
@@ -48,6 +51,11 @@
        this.cid = cid;
    }
    public void setElemtypeArray(java.lang.Integer etype)
    {
        this.elemtypeArray.add(etype);
    }
    public CreateFeatureTypeStrategy getCreateStrategy()
    {
        return createStrategy;
@@ -58,11 +66,25 @@
        this.createStrategy = createStrategy;
    }
    //§PÂ_¬O§_²Å©M±ø¥ó
    public boolean isDispatchable(Element element)
    {
        FrammeAttributeData featureLinkage = getFeatureLinkage(element);
        return featureLinkage != null && tid == featureLinkage.getFsc() &&
                (cid == featureLinkage.getComponentID() && (getElmtype() == element.getElementType().id));
        if( featureLinkage != null && tid == featureLinkage.getFsc() && (cid == featureLinkage.getComponentID()))
        {
           for (Integer itype : this.elemtypeArray)
           {
               if(itype.intValue() == element.getElementType().id)
               {
                  return true ;
               }
           }
          return false ;
        }
        return false ;
    }
    public Feature execute(Element element)
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/TypeIdDispatchableFilter.java
@@ -8,6 +8,8 @@
import com.ximple.io.dgn7.Element;
import com.ximple.io.dgn7.FrammeAttributeData;
import java.util.ArrayList;
public class TypeIdDispatchableFilter extends AbstractFLinkageDispatchableFilter
{
    private int tid;
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2ShpJob.java
@@ -8,6 +8,7 @@
import java.sql.Statement;
import java.sql.Types;
import java.util.Date;
import java.io.IOException;
import org.apache.commons.collections.OrderedMap;
import org.apache.commons.collections.OrderedMapIterator;
@@ -106,10 +107,12 @@
                , null);
        logger.info("begin convert job:[" + map.size() + "]:testmode=" + _testMode);
        jobContext.startTransaction();
        int total = map.size();
        int total = map.size(); //spacenodes count
        int step = total / 100;
        int current = 0;
        //jobContext.startTransaction();
        jobContext.getExecutionContext().put("ConvertDgn2ShpJobProgress", 0);
        for (OrderedMapIterator it = map.orderedMapIterator(); it.hasNext();)
        {
@@ -134,6 +137,7 @@
                // OracleConnection connection = jobContext.getOracleConnection();
                // connection.commitTransaction();
                jobContext.commitTransaction();
                //jobContext.startTransaction();
                System.gc();
            }
@@ -142,11 +146,17 @@
            {
                current = now;
                jobContext.getExecutionContext().put("ConvertDgn2ShpJobProgress", current);
            }
        }
        jobContext.getExecutionContext().put("ConvertDgn2ShpJobProgress", 100);
        jobContext.commitTransaction();
        try {
            jobContext.closeFeatureWrite();
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        logger.info("end convert job:[" + order + "]");
        System.gc();
    }
@@ -268,6 +278,9 @@
                logger.warn("Dgn7Exception", e);
            }
        }
        rsSrc.close();
        stmtSrc.close();
    }
    protected void queryRawElement(OracleConvertJobContext jobContext,
@@ -312,6 +325,9 @@
                logger.warn("Dgn7Exception:" + e.getMessage(), e);
            }
        }
        rsDest.close();
        stmtDest.close();
    }
    private Element fetchBinaryElement(byte[] raws) throws Dgn7fileException
xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertJobContext.java
@@ -38,6 +38,7 @@
import com.ximple.io.dgn7.Element;
import com.ximple.io.dgn7.FrammeAttributeData;
public class OracleConvertJobContext extends AbstractOracleJobContext
{
    static Log logger = LogFactory.getLog(OracleConvertJobContext.class);
@@ -59,6 +60,7 @@
    private ElementDispatcher elementDispatcher;
    private HashMap featuresContext = new HashMap();
    private HashMap featuresWriterContext = new HashMap();
    private PessimisticMapWrapper txFeaturesContext;
    private JobExecutionContext executionContext;
@@ -137,7 +139,7 @@
    public void startTransaction()
    {
        txFeaturesContext.startTransaction();
       //txFeaturesContext.startTransaction();
    }
    public void commitTransaction()
@@ -145,9 +147,11 @@
        if (!txFeaturesContext.isEmpty())
        {
            logger.debug("Transaction size = " + txFeaturesContext.size());
            txFeaturesContext.commitTransaction();
           //txFeaturesContext.commitTransaction();
        } else
        {
            logger.debug("Transaction is empty.");
        }
        if (!featuresContext.isEmpty())
        {
@@ -157,7 +161,7 @@
    public void rollbackTransaction()
    {
        txFeaturesContext.rollbackTransaction();
       //txFeaturesContext.rollbackTransaction();
        if (!featuresContext.isEmpty())
        {
            updateDataStore();
@@ -177,9 +181,23 @@
                File sfile = new File(_dataPath + "\\" + featureType.getTypeName());
                logger.debug("Begin Save shapefile:" + sfile.toURI());
                FeatureWriter writer = null;
                if(featuresWriterContext.containsKey( featureType.getTypeName()))
                {
                    writer = (FeatureWriter) featuresWriterContext.get(featureType.getTypeName()) ;
                }
                else
                {
                ShapefileDataStore shapefileDataStore = new ShapefileDataStore(sfile.toURI().toURL());
                shapefileDataStore.createSchema(featureType);
                FeatureWriter writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                  writer = shapefileDataStore.getFeatureWriter(featureType.getTypeName(), Transaction.AUTO_COMMIT);
                  if(this.featuresWriterContext == null)
                  {
                     this.featuresWriterContext =  new HashMap();
                  }
                  featuresWriterContext.put(featureType.getTypeName() , writer);
                }
                ArrayList features = (ArrayList) featuresContext.get(featureType);
                Iterator itFeature = features.iterator();
                while (itFeature.hasNext())
@@ -187,7 +205,7 @@
                    Feature feature = (Feature) itFeature.next();
                    ((SimpleFeature) writer.next()).setAttributes(feature.getAttributes(null));
                }
                writer.close();
                //writer.close();
                logger.debug("End Save shapefile:" + sfile.toURI());
            }
            featuresContext.clear();
@@ -213,4 +231,16 @@
    {
        executionContext = context;
    }
    public void closeFeatureWrite() throws IOException {
       Iterator iter =   this.featuresWriterContext.values().iterator();
        while(iter.hasNext())
        {
           FeatureWriter writer = (FeatureWriter) iter.next();
           writer.close();
        }
        this.featuresWriterContext = null;
    }
}
xdgnjobs/ximple-spatialjob/src/main/resources/com/ximple/eofms/filter/ElementDispatcherRules.xml
@@ -32,6 +32,10 @@
      <bean-property-setter-rule pattern="elmtype"/>
      <bean-property-setter-rule pattern="tid"/>
      <bean-property-setter-rule pattern="cid"/>
        <pattern value="elmtype">
            <set-next-rule methodname="setElemtypeArray"  paramtype="java.lang.Integer"/>
            <set-properties-rule/>
        </pattern>
        <pattern value="LineCreateStrategy">
            <object-create-rule classname="com.ximple.eofms.filter.CreateLineStringStrategy"/>
            <set-next-rule methodname="setCreateStrategy" paramtype="com.ximple.eofms.filter.CreateFeatureTypeStrategy"/>
xdgnjobs/ximple-spatialjob/src/main/resources/conf/DefaultConvertShpFilter.xml
@@ -95,16 +95,31 @@
  <TypeCompFilter name="FSC-114.C-1">
    <tid>114</tid>
    <cid>1</cid>
    <description>¶}Ãöµù°O</description>
    <description>¶}Ãö°j¸ôµù°O</description>
    <elmtype>17</elmtype>
    <elmtype>7</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-114.C-2">
    <tid>114</tid>
    <cid>2</cid>
    <description>¶}Ãö¤p¬P¸¹</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-114.C-3">
    <tid>114</tid>
    <cid>3</cid>
    <description>¶}Ãö¤j¬P¸¹</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-122.C-0">
    <tid>122</tid>
    <cid>0</cid>
    <description>ª½±µ³s±µ</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
    <elmtype>4</elmtype>
    <LineCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-122.C-1">
    <tid>122</tid>
@@ -152,7 +167,7 @@
    <tid>101</tid>
    <cid>0</cid>
    <description>¶×¬y±Æ</description>
    <elmtype>3</elmtype>
    <elmtype>4</elmtype>
    <LineCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-120.C-0">
@@ -208,7 +223,7 @@
    <tid>108</tid>
    <cid>1</cid>
    <description>Â_¸ô¾¹µù°O</description>
    <elmtype>7</elmtype>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-119.C-0">
@@ -373,6 +388,131 @@
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-210.C-0">
    <tid>210</tid>
    <cid>0</cid>
    <description>§CÀ£¦a¤U¾É½u</description>
    <elmtype>12</elmtype>
    <LineCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-210.C-1">
    <tid>210</tid>
    <cid>1</cid>
    <description>§CÀ£¦a¤U¾É½u¥´ÂI²Å¸¹</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
   <TypeCompFilter name="FSC-210.C-2">
    <tid>210</tid>
    <cid>2</cid>
    <description>§CÀ£¦a¤U¾É½uªø«×µù°O</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-210.C-3">
    <tid>210</tid>
    <cid>3</cid>
    <description>§CÀ£¦a¤U¾É½u²Å¸¹</description>
    <elmtype>4</elmtype>
    <LineCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-210.C-4">
    <tid>210</tid>
    <cid>4</cid>
    <description>§CÀ£¦a¤U¾É½uµù°O</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-211.C-0">
    <tid>211</tid>
    <cid>0</cid>
    <description>§CÀ£¬[ªÅ±µ¤á½u</description>
    <elmtype>4</elmtype>
    <LineCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-211.C-1">
    <tid>211</tid>
    <cid>1</cid>
    <description>§CÀ£¬[ªÅ±µ¤á½u</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-211.C-2">
    <tid>211</tid>
    <cid>2</cid>
    <description>§CÀ£¬[ªÅ±µ¤á½uªø«×µù°O</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-212.C-0">
    <tid>212</tid>
    <cid>0</cid>
    <description>§CÀ£¬[ªÅ³s±µ±µ¤á½u</description>
    <elmtype>4</elmtype>
    <LineCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-212.C-1">
    <tid>212</tid>
    <cid>1</cid>
    <description>§CÀ£¬[ªÅ³s±µ±µ¤á½uµù°O</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-212.C-2">
    <tid>212</tid>
    <cid>2</cid>
    <description>§CÀ£¬[ªÅ³s±µ±µ¤á½uªø«×µù°O</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-213.C-0">
    <tid>213</tid>
    <cid>0</cid>
    <description>§CÀ£¦a¤U³s±µ±µ¤á½u</description>
    <elmtype>4</elmtype>
    <LineCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-213.C-1">
    <tid>213</tid>
    <cid>1</cid>
    <description>§CÀ£¦a¤U³s±µ±µ¤á½uµù°O</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-213.C-2">
    <tid>213</tid>
    <cid>2</cid>
    <description>§CÀ£¦a¤U³s±µ±µ¤á½uªø«×µù°O</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-215.C-0">
    <tid>215</tid>
    <cid>0</cid>
    <description>§CÀ£¦Û°Ê­t¸ü¤Á´«¶}Ãö</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-216.C-0">
    <tid>216</tid>
    <cid>0</cid>
    <description>¦a¤U§CÀ£ºÊµø¾¹</description>
    <elmtype>17</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <TypeCompFilter name="FSC-999.C-0">
    <tid>999</tid>
    <cid>0</cid>
    <description>µù°O</description>
    <elmtype>4</elmtype>
    <TextCreateStrategy/>
  </TypeCompFilter>
  <!-- Dummy
  <TypeCompLevelFilter name="DemoFeature3">
xdgnjobs/ximple-spatialjob/src/test/java/com/ximple/eofms/filter/ElementDispatcherTest.java
@@ -33,9 +33,11 @@
        File config = TestData.file(this, TestConfigName);
        ElementDispatcher ed = (ElementDispatcher) digester.parse(config);
        Assert.assertNotNull(ed);
        Assert.assertEquals(ed.getRules().size(), 3);
       // Assert.assertEquals(ed.getRules().size(), 3);
        ElementDispatchableFilter filter = ed.getRules().get(0);
        /*
        Assert.assertTrue(filter instanceof TypeIdDispatchableFilter);
        TypeIdDispatchableFilter tFilter = (TypeIdDispatchableFilter) filter;
        Assert.assertEquals(tFilter.getName(), "DemoFeature1");
@@ -43,8 +45,9 @@
        Assert.assertEquals(tFilter.getElmtype(), 7);
        Assert.assertNotNull(tFilter.getCreateStrategy());
        Assert.assertTrue(tFilter.getCreateStrategy() instanceof CreateLineStringStrategy);
        */
        filter = ed.getRules().get(1);
        filter = ed.getRules().get(0);
        Assert.assertTrue(filter instanceof TypeCompIdDispatchableFilter);
        TypeCompIdDispatchableFilter tcFilter = (TypeCompIdDispatchableFilter) filter;
        Assert.assertEquals(tcFilter.getName(), "DemoFeature2");
@@ -52,7 +55,7 @@
        Assert.assertEquals(tcFilter.getCid(), 11);
        Assert.assertNotNull(tcFilter.getCreateStrategy());
        Assert.assertTrue(tcFilter.getCreateStrategy() instanceof CreateTextStrategy);
        /*
        filter = ed.getRules().get(2);
        Assert.assertTrue(filter instanceof TypeCompLevelIdDispatchableFilter);
        TypeCompLevelIdDispatchableFilter tclFilter = (TypeCompLevelIdDispatchableFilter) filter;
@@ -61,5 +64,6 @@
        Assert.assertEquals(tclFilter.getCid(), 2);
        Assert.assertEquals(tclFilter.getLid(), 34);
        Assert.assertNull(tclFilter.getCreateStrategy());
        */
    }
}