From 8d92a72f542aa00604749f56da466ab09b9bb991 Mon Sep 17 00:00:00 2001
From: ?? ? <ulysseskao@ximple.com.tw>
Date: Thu, 12 Jun 2008 19:36:04 +0800
Subject: [PATCH] update for EOFM-118

---
 xdgnjobs/ximple-build/maven/jar-collector/src/main/java/com/ximple/eofms/maven/JarCollector.java                   |  177 +++++++++++++++++++++++++
 xdgnjobs/ximple-jobcarrier/pom.xml                                                                                 |   12 +
 xdgnjobs/pom.xml                                                                                                   |    9 
 xdgnjobs/ximple-build/pom.xml                                                                                      |   50 +++++++
 xdgnjobs/ximple-build/maven/pom.xml                                                                                |   70 ++++++++++
 .gitattributes                                                                                                     |    4 
 xdgnjobs/ximple-build/maven/jar-collector/pom.xml                                                                  |   46 ++++++
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java |   10 -
 xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java                    |   24 +--
 9 files changed, 374 insertions(+), 28 deletions(-)

diff --git a/.gitattributes b/.gitattributes
index f224d43..304111a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,5 +1,9 @@
 * text=auto !eol
 xdgnjobs/pom.xml svneol=native#text/xml
+xdgnjobs/ximple-build/maven/jar-collector/pom.xml svneol=native#text/xml
+xdgnjobs/ximple-build/maven/jar-collector/src/main/java/com/ximple/eofms/maven/JarCollector.java svneol=native#text/plain
+xdgnjobs/ximple-build/maven/pom.xml svneol=native#text/xml
+xdgnjobs/ximple-build/pom.xml svneol=native#text/xml
 xdgnjobs/ximple-dgnio/pom.xml svneol=native#text/xml
 xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ArcElement.java svneol=native#text/plain
 xdgnjobs/ximple-dgnio/src/main/java/com/ximple/io/dgn7/ComplexChainElement.java svneol=native#text/plain
diff --git a/xdgnjobs/pom.xml b/xdgnjobs/pom.xml
index cb4aa8e..73d417d 100644
--- a/xdgnjobs/pom.xml
+++ b/xdgnjobs/pom.xml
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!-- =======================================================================
   Maven Project Configuration File
-  
+
   The Ximple DgnIO Project
   http://www.ximple.com.tw/
-  
+
   Version: $Id$
   ======================================================================= -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
@@ -285,7 +285,7 @@
         <artifactId>postgis-driver</artifactId>
         <version>1.3.3</version>
       </dependency>
-        
+
       <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
@@ -523,7 +523,7 @@
       </extension>
     </extensions>
     -->
-    
+
     <plugins>
       <!-- ======================================================= -->
       <!--     Source reformat                                     -->
@@ -755,6 +755,7 @@
   <!--     Modules for the build in approximate dependency order   -->
   <!-- =========================================================== -->
   <modules>
+    <module>ximple-build</module>
     <module>ximple-dgnio</module>
     <module>ximple-spatialjob</module>
     <module>ximple-jobcarrier</module>
diff --git a/xdgnjobs/ximple-build/maven/jar-collector/pom.xml b/xdgnjobs/ximple-build/maven/jar-collector/pom.xml
new file mode 100644
index 0000000..ca14767
--- /dev/null
+++ b/xdgnjobs/ximple-build/maven/jar-collector/pom.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>com.ximple.eofms.maven</groupId>
+    <artifactId>ximple-maven</artifactId>
+    <version>0.6.0</version>
+  </parent>
+
+
+  <!-- =========================================================== -->
+  <!--     Module Description                                      -->
+  <!-- =========================================================== -->
+  <groupId>com.ximple.eofms.maven</groupId>
+  <artifactId>ximple-jar-collector</artifactId>
+  <packaging>maven-plugin</packaging>
+  <name>JAR files collector</name>
+
+  <scm>
+    <connection>
+      scm:svn:http://www.ximple.com.tw/svn/xeofms/xdgnio/truck/
+    </connection>
+    <url>http://www.ximple.com.tw/svn/xeofms/xdgnio/truck/</url>
+  </scm>
+
+  <description>
+    Copy all JAR files (including dependencies) in the target directory
+    of the parent project descriptor.
+  </description>
+
+  <licenses>
+    <license>
+      <name>Lesser General Public License (LGPL)</name>
+      <url>http://www.gnu.org/copyleft/lesser.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+
+  <!-- =========================================================== -->
+  <!--     Developers and Contributors                             -->
+  <!-- =========================================================== -->
+
+</project>
diff --git a/xdgnjobs/ximple-build/maven/jar-collector/src/main/java/com/ximple/eofms/maven/JarCollector.java b/xdgnjobs/ximple-build/maven/jar-collector/src/main/java/com/ximple/eofms/maven/JarCollector.java
new file mode 100644
index 0000000..c76d6ae
--- /dev/null
+++ b/xdgnjobs/ximple-build/maven/jar-collector/src/main/java/com/ximple/eofms/maven/JarCollector.java
@@ -0,0 +1,177 @@
+package org.ximple.eofms.maven;
+
+import org.apache.maven.artifact.Artifact;
+
+// Maven and Plexus dependencies
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.FileUtils;
+
+// J2SE dependencies
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Set;
+
+
+// Note: javadoc in class and fields descriptions must be XHTML.
+/**
+ * Copies <code>.jar</code> files in a single directory. Dependencies are copied as well,
+ * except if already presents.
+ *
+ * @goal collect
+ * @phase package
+ * @source $URL$
+ * @version $Id$
+ * @author Martin Desruisseaux
+ */
+public class JarCollector extends AbstractMojo {
+    /**
+     * The sub directory to create inside the "target" directory.
+     */
+    private static final String SUB_DIRECTORY = "binaries";
+
+    /**
+     * The directory where JARs are to be copied. It should
+     * be the "target" directory of the parent {@code pom.xml}.
+     */
+    private String collectDirectory;
+
+    /**
+     * Directory containing the generated JAR.
+     *
+     * @parameter expression="${project.build.directory}"
+     * @required
+     */
+    private String outputDirectory;
+
+    /**
+     * Name of the generated JAR.
+     *
+     * @parameter expression="${project.build.finalName}"
+     * @required
+     */
+    private String jarName;
+
+    /**
+     * Project dependencies.
+     *
+     * @parameter expression="${project.artifacts}"
+     * @required
+     */
+    private Set /*<Artifact>*/ dependencies;
+
+    /**
+     * The Maven project running this plugin.
+     *
+     * @parameter expression="${project}"
+     * @required
+     */
+    private MavenProject project;
+
+    /**
+     * Copies the {@code .jar} files to the collect directory.
+     *
+     * @throws MojoExecutionException if the plugin execution failed.
+     */
+    public void execute() throws MojoExecutionException {
+        /*
+         * Gets the parent "target" directory.
+         */
+        MavenProject parent = project;
+
+        while (parent.hasParent()) {
+            parent = parent.getParent();
+        }
+
+        collectDirectory = parent.getBuild().getDirectory();
+
+        /*
+         * Now collects the JARs.
+         */
+        try {
+            collect();
+        } catch (IOException e) {
+            throw new MojoExecutionException("Error collecting the JAR file.", e);
+        }
+    }
+
+    /**
+     * Implementation of the {@link #execute} method.
+     */
+    private void collect() throws MojoExecutionException, IOException {
+        /*
+         * Make sure that we are collecting the JAR file from a module which produced
+         * such file. Some modules use pom packaging, which do not produce any JAR file.
+         */
+        final File jarFile = new File(outputDirectory, jarName + ".jar");
+
+        if (!jarFile.isFile()) {
+            return;
+        }
+
+        /*
+         * Get the "target" directory of the parent pom.xml and make sure it exists.
+         */
+        File collect = new File(collectDirectory);
+
+        if (!collect.exists()) {
+            if (!collect.mkdir()) {
+                throw new MojoExecutionException("Failed to create target directory.");
+            }
+        }
+
+        if (collect.getCanonicalFile().equals(jarFile.getParentFile().getCanonicalFile())) {
+            /*
+             * The parent's directory is the same one than this module's directory.
+             * In other words, this plugin is not executed from the parent POM. Do
+             * not copy anything, since this is not the place where we want to
+             * collect the JAR files.
+             */
+            return;
+        }
+
+        /*
+         * Creates a "binaries" subdirectory inside the "target" directory.
+         */
+        collect = new File(collect, SUB_DIRECTORY);
+
+        if (!collect.exists()) {
+            if (!collect.mkdir()) {
+                throw new MojoExecutionException("Failed to create binaries directory.");
+            }
+        }
+
+        int count = 1;
+        FileUtils.copyFileToDirectory(jarFile, collect);
+
+        if (dependencies != null) {
+            for (final Iterator it = dependencies.iterator(); it.hasNext();) {
+                final Artifact artifact = (Artifact) it.next();
+                final String scope = artifact.getScope();
+
+                if ((scope != null) // Maven 2.0.6 bug?
+                        && (scope.equalsIgnoreCase(Artifact.SCOPE_COMPILE)
+                        || scope.equalsIgnoreCase(Artifact.SCOPE_RUNTIME))) {
+                    final File file = artifact.getFile();
+                    final File copy = new File(collect, file.getName());
+
+                    if (!copy.exists()) {
+                        /*
+                         * Copies the dependency only if it was not already copied. Note that
+                         * the module's JAR was copied inconditionnaly above (because it may
+                         * be the result of a new compilation). If a Geotools JAR from the
+                         * dependencies list changed, it will be copied inconditionnaly when
+                         * the module for this JAR will be processed by Maven.
+                         */
+                        FileUtils.copyFileToDirectory(file, collect);
+                        count++;
+                    }
+                }
+            }
+        }
+
+        getLog().info("Copied " + count + " JAR to parent directory.");
+    }
+}
diff --git a/xdgnjobs/ximple-build/maven/pom.xml b/xdgnjobs/ximple-build/maven/pom.xml
new file mode 100644
index 0000000..af14632
--- /dev/null
+++ b/xdgnjobs/ximple-build/maven/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>com.ximple.eofms.maven</groupId>
+    <artifactId>ximple-build</artifactId>
+    <version>0.6.0</version>
+  </parent>
+
+
+  <!-- =========================================================== -->
+  <!--     Module Description                                      -->
+  <!-- =========================================================== -->
+  <groupId>com.ximple.eofms.maven</groupId>
+  <artifactId>ximple-maven</artifactId>
+  <packaging>pom</packaging>
+  <name>Maven plugins for Ximple</name>
+
+  <scm>
+    <connection>
+      scm:svn:http://www.ximple.com.tw/svn/xeofms/xdgnio/truck/
+    </connection>
+    <url>http://www.ximple.com.tw/svn/xeofms/xdgnio/truck/</url>
+  </scm>
+
+  <description>
+    Maven plugins specific to the the Ximple Dgn IO Library.
+  </description>
+
+  <licenses>
+    <license>
+      <name>Lesser General Public License (LGPL)</name>
+      <url>http://www.gnu.org/copyleft/lesser.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+
+
+  <!-- =========================================================== -->
+  <!--     Dependency Management                                   -->
+  <!-- =========================================================== -->
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-plugin-api</artifactId>
+      <version>2.0.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.2</version>
+    </dependency>
+  </dependencies>
+
+
+  <!-- =========================================================== -->
+  <!--     Modules included in the build                           -->
+  <!-- =========================================================== -->
+  <modules>
+    <module>jar-collector</module>
+  </modules>
+</project>
diff --git a/xdgnjobs/ximple-build/pom.xml b/xdgnjobs/ximple-build/pom.xml
new file mode 100644
index 0000000..8208e70
--- /dev/null
+++ b/xdgnjobs/ximple-build/pom.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>com.ximple.eofms</groupId>
+    <artifactId>ximple-dgnjobs</artifactId>
+    <version>0.6.0</version>
+  </parent>
+
+
+  <!-- =========================================================== -->
+  <!--     Module Description                                      -->
+  <!-- =========================================================== -->
+  <groupId>com.ximple.eofms.maven</groupId>
+  <artifactId>ximple-build</artifactId>
+  <packaging>pom</packaging>
+  <name>Build tools for Ximple DgnJobs</name>
+
+  <scm>
+    <connection>
+      scm:svn:http://www.ximple.com.tw/svn/xeofms/xdgnio/truck/
+    </connection>
+    <url>http://www.ximple.com.tw/svn/xeofms/xdgnio/truck/</url>
+  </scm>
+
+  <description>
+    Build tools for the the Ximple Dgn IO Library.
+  </description>
+
+  <licenses>
+    <license>
+      <name>Lesser General Public License (LGPL)</name>
+      <url>http://www.gnu.org/copyleft/lesser.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+
+
+  <!-- =========================================================== -->
+  <!--     Modules included in the build                           -->
+  <!-- =========================================================== -->
+  <modules>
+    <module>maven</module>
+  </modules>
+
+
+</project>
diff --git a/xdgnjobs/ximple-jobcarrier/pom.xml b/xdgnjobs/ximple-jobcarrier/pom.xml
index dd497ec..ae21fcb 100644
--- a/xdgnjobs/ximple-jobcarrier/pom.xml
+++ b/xdgnjobs/ximple-jobcarrier/pom.xml
@@ -222,6 +222,18 @@
         </dependencies>
         -->
       </plugin>
+      <plugin>
+        <groupId>com.ximple.eofms.maven</groupId>
+        <artifactId>ximple-jar-collector</artifactId>
+        <version>${project.version}</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>collect</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
     <resources>
     </resources>
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 8b679f9..e73e9f7 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
@@ -72,7 +72,7 @@
     private static final String USEWKB = "USEWKB";
 
     private static final int FETCHSIZE = 30;
-    private static final int COMMITSIZE = 20;
+    private static final int COMMITSIZE = 100;
 
     class Pair
     {
@@ -214,25 +214,21 @@
         {
             logger.info("-- step:clearOutputDatabase --");
             clearOutputDatabase();
-            boolean bFirst = isCopyConnectivityMode();
             if (checkConvertDB())
             {
                 logger.info("-- step:convertOracleDB --");
 
+                OracleConvertPostGISJobContext jobContext =
+                        (OracleConvertPostGISJobContext) prepareJobContext(_filterPath);
+                jobContext.setSourceDataStore(getSourceDataStore());
+                // jobContext.setConvertElementIn(_convertElementIn);
+                jobContext.setElementLogging(checkElementLogging());
+                jobContext.setExecutionContext(context);
+                if (isCopyConnectivityMode())
+                    copyConnectivity(jobContext);
+
                 for (String orgSchema : _orgSchema)
                 {
-                    OracleConvertPostGISJobContext jobContext =
-                            (OracleConvertPostGISJobContext) prepareJobContext(_filterPath);
-                    jobContext.setSourceDataStore(getSourceDataStore());
-                    // jobContext.setConvertElementIn(_convertElementIn);
-                    jobContext.setElementLogging(checkElementLogging());
-                    jobContext.setExecutionContext(context);
-
-                    if (bFirst)
-                        copyConnectivity(jobContext);
-                    else
-                        bFirst = false;
-
                     logger.info("----- start schema:" + orgSchema + " -----");
                     exetcuteConvert(jobContext, orgSchema, _dataPath);
 
diff --git a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java
index 964f19e..8240963 100644
--- a/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java
+++ b/xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java
@@ -242,16 +242,6 @@
                     } finally {
                         stmt.close();
                     }
-                    /*
-                    if ((i % BATCHSIZE) != 0)
-                    {
-                        stmt.addBatch(stmtText);
-                    } else {
-                        stmt.addBatch(stmtText);
-                        stmt.executeBatch();
-                    }
-                    i++;
-                    */
                 }
 
                 stmtTexts.clear();

--
Gitblit v0.0.0-SNAPSHOT