.gitattributes
@@ -44,6 +44,8 @@ xdgnjobs/ximple-jobcarrier/pom.xml svneol=native#text/xml xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobCarrier.java svneol=native#text/plain xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobWizard.java svneol=native#text/plain xdgnjobs/ximple-jobcarrier/src/main/resources/com/ximple/eofms/XQuartzJobWizard.properties svneol=native#text/plain xdgnjobs/ximple-jobcarrier/src/main/resources/com/ximple/eofms/XQuartzJobWizard_zh_TW.properties svneol=native#text/plain xdgnjobs/ximple-jobcarrier/src/main/resources/log4j.properties svneol=native#text/plain xdgnjobs/ximple-jobcarrier/src/main/resources/quartz.properties svneol=native#text/plain xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml svneol=native#text/xml xdgnjobs/pom.xml
@@ -161,6 +161,11 @@ <version>1.2</version> </dependency> <dependency> <groupId>commons-cli</groupId> <artifactId>commons-cli</artifactId> <version>1.1</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.15</version> xdgnjobs/ximple-jobcarrier/pom.xml
@@ -118,8 +118,13 @@ </dependency> <dependency> <artifactId>velocity</artifactId> <groupId>org.apache.velocity</groupId> <artifactId>velocity</artifactId> </dependency> <dependency> <groupId>commons-cli</groupId> <artifactId>commons-cli</artifactId> </dependency> <!-- ORACLE --> @@ -215,10 +220,10 @@ </executions> --> <configuration> <!-- <mainClass>com.ximple.eofms.XQuartzJobCarrier</mainClass> <!-- <commandlineArgs>-wizard</commandlineArgs> --> <mainClass>com.ximple.eofms.XQuartzJobWizard</mainClass> </configuration> <!-- <dependencies> @@ -243,8 +248,52 @@ </execution> </executions> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>native2ascii-maven-plugin</artifactId> <version>1.0-alpha-1</version> <configuration> <dest>target/classes/com/ximple/eofms</dest> <src>src/main/resources/com/ximple/eofms</src> </configuration> <executions> <execution> <id>native2ascii-utf8</id> <goals> <goal>native2ascii</goal> </goals> <configuration> <encoding>UTF8</encoding> <includes>XQuartzJobWizard_zh*.properties</includes> </configuration> </execution> </executions> </plugin> </plugins> <resources> <resource> <directory>src/main/resources/com/ximple/eofms</directory> <excludes> <exclude>XQuartzJobWizard_zh*.properties</exclude> </excludes> <filtering>true</filtering> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>log4j.properties</include> <include>quartz.properties</include> <include>quartz_jobs.xml</include> </includes> <!-- <excludes> <exclude>XQuartzJobWizard*.properties</exclude> <exclude>quartz_jobs.xml</exclude> <exclude>quartz_jobs_shapefiles.xml</exclude> </excludes> --> <filtering>false</filtering> </resource> </resources> </build> xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobCarrier.java
@@ -1,9 +1,20 @@ package com.ximple.eofms; import java.util.Date; import javax.swing.JFrame; import javax.swing.SwingUtilities; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.CommandLineParser; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Option; import org.apache.commons.cli.OptionBuilder; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.apache.commons.cli.PosixParser; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.awl.Wizard; import org.quartz.JobDetail; import org.quartz.Scheduler; import org.quartz.SchedulerException; @@ -19,11 +30,111 @@ public class XQuartzJobCarrier { static Log logger = LogFactory.getLog(XQuartzJobCarrier.class); static Options options = new Options(); private static final String VERSION = "0.8.0"; public static void main(String[] args) { XQuartzJobCarrier instance = new XQuartzJobCarrier(); instance.startScheduler(); instance.initializeOption(); instance.execute(args); } private void initializeOption() { Option option; option = OptionBuilder.create("help"); option.setDescription("print this message"); options.addOption(option); option = OptionBuilder.create("version"); option.setDescription("print the version information and exit"); options.addOption(option); option = OptionBuilder.create("wizard"); option.setDescription("start wizard mode"); options.addOption(option); option = OptionBuilder.create("verbose"); option.setDescription("be extra verbose"); options.addOption(option); option = OptionBuilder.create("debug"); option.setDescription("print debugging information"); options.addOption(option); option = OptionBuilder.create("jobfile"); option.setDescription("use given jobfile"); option.setArgName("file"); options.addOption(option); } private void execute(String[] args) { // CommandLineParser parser = new GnuParser(); CommandLineParser parser = new PosixParser(); CommandLine commandLine = null; try { // parse the command commandLine arguments commandLine = parser.parse(options, args); } catch (ParseException exp) { // oops, something went wrong System.err.println("Parsing failed. Reason: " + exp.getMessage()); } if ((commandLine != null) && (commandLine.getOptions().length > 0)) { if (commandLine.hasOption("help")) { printHelpMessage(); } else if (commandLine.hasOption("version")) { printVersionMessage(); } else if (commandLine.hasOption("wizard")) { startWizardMode(); } return; } startScheduler(); } private void printHelpMessage() { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("XQuartzJobCarrier", options); } private void printVersionMessage() { System.out.println("XQuartzJobCarrier - " + VERSION); } public void startWizardMode() { Runnable runnable = new Runnable() { public void run() { Wizard wizard = new XQuartzJobWizard((JFrame) null); wizard.pack(); wizard.setVisibleOnCenterOfScreen(); } }; try { SwingUtilities.invokeLater(runnable); } catch (Exception ex) { ex.printStackTrace(); } } public void startScheduler() xdgnjobs/ximple-jobcarrier/src/main/java/com/ximple/eofms/XQuartzJobWizard.java
@@ -1,48 +1,454 @@ package com.ximple.eofms; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.ResourceBundle; import javax.swing.AbstractAction; import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JEditorPane; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.WindowConstants; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.JRadioButton; import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.JToolBar; import javax.swing.SwingConstants; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.awl.Wizard; import org.awl.DefaultWizard; import org.awl.DefaultWizardPageDescriptor; import org.awl.WizardConstants; import org.awl.NavigationAuthorization; import org.awl.Wizard; import org.awl.WizardPageDescriptor; import org.awl.demo.AwlDemo; import org.awl.header.AbstractWizardHeader; import org.awl.header.EclipseWizardHeader; import org.awl.message.MessageLevel; public class XQuartzJobWizard public class XQuartzJobWizard extends DefaultWizard { static Log logger = LogFactory.getLog(XQuartzJobWizard.class); public static void main(String[] args) { Wizard wizard = new DefaultWizard((JFrame)null); initializeWizardComponent(wizard); /** * header type none */ private static final String HEADER_NONE = "none"; wizard.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); wizard.setTitle("Read a bad book..."); wizard.setSize(new Dimension(430, 300)); wizard.setVisible(true); /** * header type classic */ private static final String HEADER_CLASSIC = "classic"; /** * header type eclipse */ private static final String HEADER_ECLIPSE = "eclipse"; /** * first page */ private WizardPageDescriptor firstPage = null; /** * second page */ private WizardPageDescriptor secondPage = null; /** * third page */ private WizardPageDescriptor thirdPage = null; /** * forth page */ private WizardPageDescriptor fourthPage = null; /** * Creates a new instance of AwlDemo */ public XQuartzJobWizard(JFrame frame) { super(frame); AbstractWizardHeader header = new EclipseWizardHeader(); header.getIconLabel().setIcon(new ImageIcon(AwlDemo.class.getResource("/org/awl/rc/install.png"))); this.setHeader(header); final ResourceBundle rb = ResourceBundle.getBundle(XQuartzJobWizard.class.getName()); this.setTitle(rb.getString("title")); /** first page */ this.firstPage = new DefaultWizardPageDescriptor(); firstPage.setTitle(rb.getString("first.title")); firstPage.setDescription(rb.getString("first.description")); JLabel firstLabel = new JLabel(rb.getString("first.label.text")); firstLabel.setVerticalAlignment(SwingConstants.TOP); firstLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); firstPage.setComponent(firstLabel); firstPage.setNextDescriptorId("2"); /** second page */ this.secondPage = new DefaultWizardPageDescriptor(); secondPage.setTitle(rb.getString("second.title")); secondPage.setDescription(rb.getString("second.description")); secondPage.setMessage(rb.getString("second.messageContent"), MessageLevel.INFO); URL licenseUrl = null; try { licenseUrl = new URL("http://www.gnu.org/licenses/lgpl-2.1.txt"); } catch (MalformedURLException e) { e.printStackTrace(); } private static void initializeWizardComponent(Wizard wizard) JEditorPane licensePane = null; if (licenseUrl == null) { DefaultWizardPageDescriptor page1 = new DefaultWizardPageDescriptor(); page1.setComponent(new JLabel("this is my first page")); page1.setDescription("my first page"); licensePane = new JEditorPane(); licensePane.setText("license LGPL 2.1"); } else { try { licensePane = new JEditorPane(licenseUrl); } catch (IOException e) { licensePane = new JEditorPane(); licensePane.setText("license LGPL 2.1"); } } DefaultWizardPageDescriptor page2 = new DefaultWizardPageDescriptor(); page2.setComponent(new JLabel("this is my second page")); page2.setDescription("my second page"); licensePane.setPreferredSize(new Dimension(630, 350)); page1.setNextDescriptorId("2"); page2.setPreviousDescriptorId("1"); page1.setPreviousDescriptorId(WizardConstants.STARTING_DESCRIPTOR_ID); page2.setNextDescriptorId(WizardConstants.TERMINAL_DESCRIPTOR_ID); final JRadioButton radioAcceptLicense = new JRadioButton(rb.getString("second.licenseAccepted")); final JRadioButton radioRefuseLicense = new JRadioButton(rb.getString("second.licenseRefused")); wizard.addPage(page1, "1"); wizard.addPage(page2, "2"); ButtonGroup licenseButtonGroup = new ButtonGroup(); licenseButtonGroup.add(radioAcceptLicense); licenseButtonGroup.add(radioRefuseLicense); ChangeListener changeListener = new ChangeListener() { public void stateChanged(ChangeEvent e) { secondPage.setNextPageAuthorization( radioAcceptLicense.isSelected() ? NavigationAuthorization.DEFAULT : NavigationAuthorization.FORBIDDEN); } }; radioAcceptLicense.addChangeListener(changeListener); radioRefuseLicense.addChangeListener(changeListener); radioRefuseLicense.setSelected(true); JPanel secondPageComponent = new JPanel(); GridBagLayout secondPageLayout = new GridBagLayout(); secondPageComponent.setLayout(secondPageLayout); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0f; gbc.weighty = 1.0f; JScrollPane scrollLicense = new JScrollPane(licensePane); scrollLicense.setBorder(BorderFactory.createLoweredBevelBorder()); secondPageComponent.add(scrollLicense, gbc); gbc.gridx = 1; gbc.gridy = 2; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0f; gbc.weighty = 0.0f; secondPageComponent.add(new JToolBar.Separator(new Dimension(10, 10)), gbc); gbc.gridx = 1; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; secondPageComponent.add(radioAcceptLicense, gbc); gbc.gridx = 1; gbc.gridy = 4; secondPageComponent.add(radioRefuseLicense, gbc); secondPageComponent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); secondPage.setComponent(secondPageComponent); secondPage.setPreviousDescriptorId("1"); secondPage.setNextDescriptorId("3"); /** third page */ final JTextField locationField = new JTextField(20); final Action chooseLocation = new AbstractAction() { public void actionPerformed(ActionEvent e) { File current = null; String text = locationField.getText(); if (text != null && text.trim().length() > 0) { try { current = new File(text); if (!current.exists()) { current = null; } } catch (Exception ex) { } } JFileChooser chooser = new JFileChooser(current); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setFileFilter(new javax.swing.filechooser.FileFilter() { public boolean accept(File f) { boolean result = false; if (f != null && f.isDirectory()) { result = true; } return result; } public String getDescription() { return rb.getString("third.fileChooser.description"); } }); chooser.setMultiSelectionEnabled(false); int answer = chooser.showDialog(XQuartzJobWizard.this, rb.getString("third.fileChooser.selectLabel")); if (answer == JFileChooser.CANCEL_OPTION) { locationField.setText(""); thirdPage.setMessage(rb.getString("third.messageContent"), MessageLevel.WARN); } else // aprove { locationField.setText(chooser.getSelectedFile().getPath()); } } }; this.thirdPage = new DefaultWizardPageDescriptor() { public void displayingPanel(Wizard wizard) { /** open file dialog box */ if (locationField.getText().trim().length() == 0) { chooseLocation.actionPerformed(null); } } }; chooseLocation.putValue(Action.SMALL_ICON, new ImageIcon(AwlDemo.class.getResource("/org/awl/rc/folder.png"))); thirdPage.setNextPageAuthorization(NavigationAuthorization.FORBIDDEN); locationField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { } public void insertUpdate(DocumentEvent e) { this.changeNavigation(); } public void removeUpdate(DocumentEvent e) { this.changeNavigation(); } private void changeNavigation() { thirdPage.setNextPageAuthorization(locationField.getText().trim().length() > 0 ? NavigationAuthorization.DEFAULT : NavigationAuthorization.FORBIDDEN); } }); thirdPage.setTitle(rb.getString("third.title")); thirdPage.setDescription(rb.getString("third.description")); JPanel thirdSubPanel = new JPanel(); JPanel thirdPanel = new JPanel(); JLabel installLocationLabel = new JLabel(rb.getString("third.label.text")); installLocationLabel.setHorizontalAlignment(SwingConstants.LEFT); thirdSubPanel.add(installLocationLabel); locationField.setEnabled(false); locationField.setHorizontalAlignment(SwingConstants.LEFT); thirdSubPanel.add(locationField); JButton locationButton = new JButton(chooseLocation); locationButton.setHorizontalAlignment(SwingConstants.LEFT); Dimension buttonPrefSize = new Dimension(locationButton.getPreferredSize()); buttonPrefSize.height = locationField.getPreferredSize().height; // buttonPrefSize.width = ((Icon)chooseLocation.getValue(Action.SMALL_ICON)).getIconWidth() + 4; locationButton.setPreferredSize(buttonPrefSize); thirdSubPanel.add(locationButton); thirdSubPanel.setAlignmentX(0.0f); thirdPanel.setAlignmentX(0.0f); thirdPanel.setLayout(new GridBagLayout()); gbc.gridx = 1; gbc.gridy = 1; gbc.weightx = 0.0f; gbc.weighty = 0.0f; gbc.fill = GridBagConstraints.NONE; thirdPanel.add(thirdSubPanel, gbc); gbc.gridx = 2; gbc.gridy = 2; gbc.weightx = 1.0f; gbc.weighty = 1.0f; gbc.fill = GridBagConstraints.BOTH; thirdPanel.add(new JToolBar.Separator(new Dimension(5, 5)), gbc); thirdPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); thirdPage.setComponent(thirdPanel); thirdPage.setPreviousDescriptorId("2"); thirdPage.setNextDescriptorId("4"); /** fourth page */ final JProgressBar installProgressBar = new JProgressBar(); final JLabel progressLabel = new JLabel(rb.getString("fourth.inProgress.text")); this.fourthPage = new DefaultWizardPageDescriptor() { public void displayingPanel(Wizard wizard) { /* begin installation */ this.setPreviousPageAuthorization(NavigationAuthorization.FORBIDDEN); this.setFinishAuthorization(NavigationAuthorization.FORBIDDEN); /* begin new thread */ Runnable runnable = new Runnable() { public void run() { while (installProgressBar.getValue() < installProgressBar.getMaximum()) { Runnable r = new Runnable() { public void run() { installProgressBar.setValue(installProgressBar.getValue() + 1); } }; SwingUtilities.invokeLater(r); try { Thread.sleep(50); } catch (InterruptedException e) { Runnable r1 = new Runnable() { public void run() { installProgressBar.setValue(installProgressBar.getMaximum()); } }; SwingUtilities.invokeLater(r1); break; } } Runnable r2 = new Runnable() { public void run() { progressLabel.setText(rb.getString("fourth.finished.text")); } }; SwingUtilities.invokeLater(r2); setFinishAuthorization(NavigationAuthorization.DEFAULT); setCancelAuthorization(NavigationAuthorization.FORBIDDEN); } }; new Thread(runnable).start(); } }; fourthPage.setTitle(rb.getString("fourth.title")); fourthPage.setDescription(rb.getString("fourth.description")); JPanel fourthPanel = new JPanel(); BoxLayout fourthLayout = new BoxLayout(fourthPanel, BoxLayout.PAGE_AXIS); fourthPanel.setLayout(fourthLayout); fourthPanel.add(installProgressBar); fourthPanel.add(progressLabel); fourthPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); fourthPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); fourthPage.setComponent(fourthPanel); fourthPage.setPreviousDescriptorId("3"); /** register */ this.addPage(firstPage, "1"); this.addPage(secondPage, "2"); this.addPage(thirdPage, "3"); this.addPage(fourthPage, "4"); } public static void main(String[] args) { Runnable runnable = new Runnable() { public void run() { Wizard wizard = new XQuartzJobWizard((JFrame) null); wizard.pack(); wizard.setVisibleOnCenterOfScreen(); } }; try { SwingUtilities.invokeLater(runnable); } catch (Exception ex) { ex.printStackTrace(); } } } xdgnjobs/ximple-jobcarrier/src/main/resources/com/ximple/eofms/XQuartzJobWizard.properties
New file @@ -0,0 +1,23 @@ title=Ximple Quartz Job Wizard first.title=Convert first.description=Installation introduction first.label.text=<html>This wizard will not install anything on your computer.<br/>It only demonstrates <b>Awl</b> functionnalities.</html> second.title=License agreement second.description=Accept the license of this software second.licenseAccepted=I accept the terms of this license agreement second.licenseRefused=I do not accept the terms of this license agreement second.messageContent=Accept the terms of the license third.title=Install location third.description=Select the location where to install this software third.label.text=Install location third.fileChooser.selectLabel=Select third.fileChooser.description=Select third.messageContent=You must choose a valid location fourth.title=Installation... fourth.description=Installation progress fourth.inProgress.text=Installation in progress... fourth.finished.text=Installation finished xdgnjobs/ximple-jobcarrier/src/main/resources/com/ximple/eofms/XQuartzJobWizard_zh_TW.properties
New file @@ -0,0 +1,23 @@ title=Ximple Quartz Job Wizard first.title=ªÅ¶¡¸ê®ÆÂà´« first.description=ªÅ¶¡¸ê®ÆÂà´«±N·|Ū¨ú OMS/CMMS ªÅ¶¡¸ê®Æ®w¤º®eÂà´«¦Ü PostGIS ªÅ¶¡¸ê®Æ®w first.label.text=<html>This wizard will not install anything on your computer.<br/>It only demonstrates <b>Awl</b> functionnalities.</html> second.title=ª©ÅvÁn©ú second.description=Accept the license of this software second.licenseAccepted=I accept the terms of this license agreement second.licenseRefused=I do not accept the terms of this license agreement second.messageContent=Accept the terms of the license third.title=²ÕºA³]©w¦ì¸m third.description=Select the location where to install this software third.label.text=Install location third.fileChooser.selectLabel=Select third.fileChooser.description=Select third.messageContent=You must choose a valid location fourth.title=¶}©lÂàÀÉ... fourth.description=Installation progress fourth.inProgress.text=Installation in progress... fourth.finished.text=Installation finished xdgnjobs/ximple-jobcarrier/src/main/resources/quartz_jobs.xml
@@ -18,7 +18,7 @@ <job-data-map allows-transient-data="true"> <entry> <key>JOBDATA_DIR</key> <value>g:\temp\data</value> <value>g:\temp\JobData</value> </entry> <!-- <entry> @@ -28,11 +28,11 @@ --> <entry> <key>PGHOST</key> <value>192.168.11.200</value> <value>192.168.11.119</value> </entry> <entry> <key>PGDDATBASE</key> <value>tctpc</value> <value>xtpcgis</value> </entry> <entry> <key>PGPORT</key> @@ -40,7 +40,7 @@ </entry> <entry> <key>PGSCHEMA</key> <value>public</value> <value>gisrepo1</value> </entry> <entry> <key>PGUSER</key> @@ -56,7 +56,7 @@ </entry> <entry> <key>ORAINST</key> <value>tctpc</value> <value>nntpc</value> </entry> <entry> <key>ORAPORT</key> @@ -108,7 +108,7 @@ </entry> <entry> <key>COPYCONNECTIVITYMODE</key> <value>true</value> <value>false</value> </entry> </job-data-map> </job-detail> xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/filter/CreateLineStringStrategy.java
@@ -103,12 +103,9 @@ { MultiLineString mline = (MultiLineString) gobj; CoordinateList coordinateList = new CoordinateList(); if (mline.getNumGeometries() == 1) { for (int i = 0; i < mline.getNumGeometries(); i++) { coordinateList.add(mline.getGeometryN(i).getCoordinates(), true); } } gobj = geometryFactory.createLineString(coordinateList.toCoordinateArray()); xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/OracleConvertDgn2PostGISJob.java
@@ -114,7 +114,7 @@ } return oracleJobContext; */ return new OracleConvertPostGISJobContext(getDataPath(), getTargetDataStore(), filterPath); return new OracleConvertPostGISJobContext(getDataPath(), getTargetDataStore(), _pgSchema, filterPath); } protected void extractJobConfiguration(JobDetail jobDetail) throws JobExecutionException @@ -623,7 +623,7 @@ for (File dgnFile : dgnFiles) { IndexDgnConvertPostGISJobContext convertContext = new IndexDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore()); new IndexDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), _pgSchema); logger.debug("--- start dgnfile-" + dgnFile.toString() + " ---"); try { @@ -763,7 +763,7 @@ for (File dgnFile : dgnFiles) { GeneralDgnConvertPostGISJobContext convertContext = new GeneralDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore()); new GeneralDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), _pgSchema); logger.info("--- start dgnfile-" + dgnFile.toString() + " ---"); try { @@ -946,7 +946,7 @@ for (File dgnFile : dgnFiles) { FeatureDgnConvertPostGISJobContext convertContext = new FeatureDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), _filterPath); new FeatureDgnConvertPostGISJobContext(getDataPath(), getTargetDataStore(), _pgSchema, _filterPath); logger.info("--- start dgnfile-" + dgnFile.toString() + " ---"); try { xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractDgnToPostGISJobContext.java
@@ -126,14 +126,23 @@ protected static JtsBinaryWriter binaryWriter = new JtsBinaryWriter(); protected PostgisDataStore targetDataStore; protected String targetSchema = "public"; private Connection connection; protected boolean schemaEnabled = true; public AbstractDgnToPostGISJobContext(String dataPath, DataStore targetDataStore) public AbstractDgnToPostGISJobContext(String dataPath, DataStore targetDataStore, String targetSchema) { super(dataPath); this.targetDataStore = (PostgisDataStore) targetDataStore; this.connection = null; if ((targetDataStore != null) && (targetDataStore instanceof PostgisDataStore)) { this.targetDataStore = (PostgisDataStore) targetDataStore; } else { getLogger().info("targetDataStore has wrong."); } setTargetSchema(targetSchema); } public PostgisDataStore getTargetDataStore() @@ -144,6 +153,16 @@ public void setTargetDataStore(PostgisDataStore targetDataStore) { this.targetDataStore = targetDataStore; } public String getTargetSchema() { return targetSchema; } public void setTargetSchema(String schemaName) { targetSchema = schemaName; } public Connection getConnection() @@ -194,7 +213,7 @@ Statement stmt = conn.createStatement(); StringBuilder sb = new StringBuilder(); sb.append("DELETE FROM \""); sb.append(targetDataStore.getDatabaseSchemaName()); sb.append(getTargetSchema()); sb.append("\".\""); sb.append(tableName); sb.append('\"'); @@ -209,7 +228,7 @@ Statement stmt = conn.createStatement(); StringBuilder sb = new StringBuilder(); sb.append("DROP TABLE \""); sb.append(targetDataStore.getDatabaseSchemaName()); sb.append(getTargetSchema()); sb.append("\".\""); sb.append(tableName); sb.append("\" CASCADE"); @@ -223,7 +242,7 @@ { Statement stmt = conn.createStatement(); StringBuilder sb = new StringBuilder(); sb.append("SELECT DropGeometryColumn('','"); sb.append("SELECT \"public\".DropGeometryColumn('','"); sb.append(tableName); sb.append("','"); sb.append(geomField); @@ -237,7 +256,7 @@ protected String dropGeometryColumn(String dbSchema, String tableName, String geomField) { StringBuilder sb = new StringBuilder(); sb.append("SELECT DropGeometryColumn('"); sb.append("SELECT \"public\".DropGeometryColumn('"); sb.append(dbSchema); sb.append("','"); sb.append(tableName); @@ -258,7 +277,7 @@ throw new RuntimeException("Error: " + geometryAttribute.getLocalName() + " unknown type!!!"); } sql = new StringBuilder("SELECT AddGeometryColumn('"); sql = new StringBuilder("SELECT \"public\".AddGeometryColumn('"); sql.append(dbSchema); sql.append("','"); sql.append(tableName); @@ -282,7 +301,6 @@ ArrayList<String> result = new ArrayList<String>(); AttributeType[] attributeType = featureType.getAttributeTypes(); // String dbSchema = targetDataStore.getDatabaseSchemaName(); Connection con = getConnection(); @@ -691,7 +709,7 @@ public String encodeSchemaTableName(String tableName) { return schemaEnabled ? ("\"" + targetDataStore.getDatabaseSchemaName() + "\".\"" + tableName + "\"") return schemaEnabled ? ("\"" + getTargetSchema() + "\".\"" + tableName + "\"") : ("\"" + tableName + "\""); } xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/AbstractOracleToPostGISJobContext.java
@@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.Set; import java.util.ArrayList; import java.util.Queue; import java.math.BigDecimal; import org.geotools.data.DataStore; @@ -125,10 +126,12 @@ protected static JtsBinaryWriter binaryWriter = new JtsBinaryWriter(); protected PostgisDataStore targetDataStore; protected String targetSchema = "public"; private Connection connection; protected boolean schemaEnabled = true; public AbstractOracleToPostGISJobContext(String dataPath, DataStore targetDataStore) public AbstractOracleToPostGISJobContext(String dataPath, DataStore targetDataStore, String targetSchema) { if ((targetDataStore != null) && (targetDataStore instanceof PostgisDataStore)) { @@ -138,6 +141,7 @@ getLogger().info("targetDataStore has wrong."); } setDataPath(dataPath); setTargetSchema(targetSchema); } public PostgisDataStore getTargetDataStore() @@ -148,6 +152,16 @@ public void setTargetDataStore(PostgisDataStore targetDataStore) { this.targetDataStore = targetDataStore; } public String getTargetSchema() { return targetSchema; } public void setTargetSchema(String schemaName) { targetSchema = schemaName; } public Connection getConnection() @@ -193,12 +207,12 @@ } } protected void deleteTable(Connection conn, String tableName) throws SQLException protected void deleteTable(Connection conn, String schemaName, String tableName) throws SQLException { Statement stmt = conn.createStatement(); StringBuilder sb = new StringBuilder(); sb.append("DELETE FROM \""); sb.append(targetDataStore.getDatabaseSchemaName()); sb.append(schemaName); sb.append("\".\""); sb.append(tableName); sb.append('\"'); @@ -208,12 +222,12 @@ conn.commit(); } protected void dropTable(Connection conn, String tableName) throws SQLException protected void dropTable(Connection conn, String schemaName, String tableName) throws SQLException { Statement stmt = conn.createStatement(); StringBuilder sb = new StringBuilder(); sb.append("DROP TABLE \""); sb.append(targetDataStore.getDatabaseSchemaName()); sb.append(schemaName); sb.append("\".\""); sb.append(tableName); sb.append("\" CASCADE"); @@ -223,11 +237,13 @@ conn.commit(); } protected void dropGeometryColumn(Connection conn, String tableName, String geomField) throws SQLException protected void dropGeometryColumn(Connection conn, String dbSchema, String tableName, String geomField) throws SQLException { Statement stmt = conn.createStatement(); StringBuilder sb = new StringBuilder(); sb.append("SELECT DropGeometryColumn('','"); sb.append("SELECT \"public\".DropGeometryColumn('"); sb.append(dbSchema); sb.append("','"); sb.append(tableName); sb.append("','"); sb.append(geomField); @@ -241,14 +257,13 @@ protected String dropGeometryColumn(String dbSchema, String tableName, String geomField) { StringBuilder sb = new StringBuilder(); sb.append("SELECT DropGeometryColumn('"); sb.append("SELECT \"public\".DropGeometryColumn('"); sb.append(dbSchema); sb.append("','"); sb.append(tableName); sb.append("','"); sb.append(geomField); sb.append("')"); getLogger().info("Execute-" + sb.toString()); return sb.toString(); } @@ -262,7 +277,7 @@ throw new RuntimeException("Error: " + geometryAttribute.getLocalName() + " unknown type!!!"); } sql = new StringBuilder("SELECT AddGeometryColumn('"); sql = new StringBuilder("SELECT \"public\".AddGeometryColumn('"); sql.append(dbSchema); sql.append("','"); sql.append(tableName); @@ -290,10 +305,22 @@ Connection con = getConnection(); boolean shouldDrop = tablePresent(tableName, con); boolean shouldDrop = tablePresent(getTargetSchema(), tableName, con); if (shouldDrop) { String sqlStr = "DROP TABLE " + encodeSchemaTableName(tableName) + ";"; String sqlStr; for (AttributeType anAttributeType : attributeType) { if (!(anAttributeType instanceof GeometryAttributeType)) { continue; } GeometryAttributeType geomAttribute = (GeometryAttributeType) anAttributeType; sqlStr = dropGeometryColumn(getTargetSchema(), tableName, geomAttribute.getLocalName()); getLogger().info(sqlStr); result.add(sqlStr); } sqlStr = "DROP TABLE " + encodeSchemaTableName(tableName) + ";"; getLogger().info(sqlStr); result.add(sqlStr); } @@ -315,13 +342,6 @@ continue; } GeometryAttributeType geomAttribute = (GeometryAttributeType) anAttributeType; if (shouldDrop) { sqlStr = dropGeometryColumn("", tableName, geomAttribute.getLocalName()); getLogger().info(sqlStr); result.add(sqlStr); } CoordinateReferenceSystem refSys = geomAttribute.getCoordinateSystem(); int SRID; @@ -349,18 +369,19 @@ SRID = -1; } sqlStr = addGeometryColumn("", tableName, geomAttribute, SRID); sqlStr = addGeometryColumn(getTargetSchema(), tableName, geomAttribute, SRID); getLogger().info(sqlStr); result.add(sqlStr); String indexName = tableName.replace('-', '_'); //also build a spatial index on each geometry column. sql = new StringBuffer("CREATE INDEX spatial_"); sql = new StringBuffer("CREATE INDEX \""); sql.append("spatial_"); sql.append(indexName); sql.append("_"); sql.append(anAttributeType.getLocalName().toLowerCase()); sql.append(" ON "); sql.append("\" ON "); sql.append(encodeSchemaTableName(tableName)); sql.append(" USING GIST ("); sql.append(encodeSchemaColumnName(anAttributeType.getLocalName())); @@ -375,7 +396,7 @@ return result; } private boolean tablePresent(String table, Connection conn) throws IOException private boolean tablePresent(String schema, String table, Connection conn) throws IOException { final int TABLE_NAME_COL = 3; @@ -386,7 +407,7 @@ DatabaseMetaData meta = conn.getMetaData(); String[] tableType = {"TABLE"}; ResultSet tables = meta.getTables(null, targetDataStore.getDatabaseSchemaName(), "%", tableType); schema, "%", tableType); while (tables.next()) { @@ -695,7 +716,7 @@ } public String encodeSchemaTableName(String tableName) { return schemaEnabled ? ("\"" + targetDataStore.getDatabaseSchemaName() + "\".\"" + tableName + "\"") return schemaEnabled ? ("\"" + getTargetSchema() + "\".\"" + tableName + "\"") : ("\"" + tableName + "\""); } xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/DummyFeatureConvertPostGISJobContext.java
@@ -57,9 +57,9 @@ private String _filterConfig; private boolean withIndex = false; public DummyFeatureConvertPostGISJobContext(String dataPath, DataStore targetDataStore, String filterConfig) public DummyFeatureConvertPostGISJobContext(String dataPath, DataStore targetDataStore, String targetSchema, String filterConfig) { super(dataPath, targetDataStore); super(dataPath, targetDataStore, targetSchema); txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); _filterConfig = filterConfig; elementDispatcher = createElementDispatcher(); xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/FeatureDgnConvertPostGISJobContext.java
@@ -51,9 +51,9 @@ private String _filterConfig; private boolean withIndex = false; public FeatureDgnConvertPostGISJobContext(String dataPath, DataStore targetDataStore, String filterConfig) public FeatureDgnConvertPostGISJobContext(String dataPath, DataStore targetDataStore, String targetSchema, String filterConfig) { super(dataPath, targetDataStore); super(dataPath, targetDataStore, targetSchema); txFeaturesContext = new PessimisticMapWrapper(featuresContext, sLogger); _filterConfig = filterConfig; elementDispatcher = createElementDispatcher(); xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/GeneralDgnConvertPostGISJobContext.java
@@ -61,9 +61,9 @@ private int accumulate = 0; public GeneralDgnConvertPostGISJobContext(String dataPath, DataStore targetDataStore) public GeneralDgnConvertPostGISJobContext(String dataPath, DataStore targetDataStore, String targetSchema) { super(dataPath, targetDataStore); super(dataPath, targetDataStore, targetSchema); convertDecorator = new TWD97GeometryConverterDecorator(); } xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/IndexDgnConvertPostGISJobContext.java
@@ -57,9 +57,9 @@ private boolean dropTableMode = true; private int accumulate = 0; public IndexDgnConvertPostGISJobContext(String dataPath, DataStore targetDataStore) public IndexDgnConvertPostGISJobContext(String dataPath, DataStore targetDataStore, String targetSchema) { super(dataPath, targetDataStore); super(dataPath, targetDataStore, targetSchema); } public void putFeatureCollection(Element element) throws IllegalAttributeException, SchemaException xdgnjobs/ximple-spatialjob/src/main/java/com/ximple/eofms/jobs/context/postgis/OracleConvertPostGISJobContext.java
@@ -31,6 +31,8 @@ import org.xml.sax.SAXException; import com.vividsolutions.jts.util.Assert; import com.vividsolutions.jts.geom.GeometryFactory; import com.vividsolutions.jts.geom.Geometry; import com.ximple.eofms.filter.AbstractFLinkageDispatchableFilter; import com.ximple.eofms.filter.CreateFeatureTypeEventListener; @@ -40,6 +42,7 @@ import com.ximple.io.dgn7.ComplexElement; import com.ximple.io.dgn7.Element; import com.ximple.io.dgn7.FrammeAttributeData; import com.ximple.io.dgn7.ComplexChainElement; public class OracleConvertPostGISJobContext extends AbstractOracleToPostGISJobContext implements CreateFeatureTypeEventListener @@ -75,9 +78,9 @@ private boolean dropTableMode = true; private int accumulate = 0; public OracleConvertPostGISJobContext(String dataPath, DataStore pgDS, String filterConfig) public OracleConvertPostGISJobContext(String dataPath, DataStore pgDS, String targetSchema, String filterConfig) { super(dataPath, pgDS); super(dataPath, pgDS, targetSchema); _filterConfig = filterConfig; elementDispatcher = createElementDispatcher(); elementDispatcher.addCreateFeatureTypeEventListener(this); @@ -146,6 +149,32 @@ ComplexElement complex = (ComplexElement) element; logger.warn("----Complex Element size=" + complex.size() + ":" + (linkage == null ? "NULL" : (linkage.getUfid()))); if (complex.size() == 0) isEmptySize = true; } if (getElementLogging() && (!isEmptySize)) { getElementLogger().logElement(element, getCurrentSchema()); } return; } if (feature.getDefaultGeometry().isEmpty()) { boolean isEmptySize = false; FrammeAttributeData linkage = AbstractFLinkageDispatchableFilter.getFeatureLinkage(element); logger.warn("Empty Geom Element:" + element.getElementType().toString() + ":type=" + element.getType() + ":lv=" + element.getLevelIndex() + ":id=" + (linkage == null ? "NULL" : (linkage.getFsc() + "|" + linkage.getComponentID()))); if (element instanceof ComplexElement) { ComplexElement complex = (ComplexElement) element; logger.warn("----Complex Element size=" + complex.size() + ":" + (linkage == null ? "NULL" : (linkage.getUfid()))); if (complex.size() == 0) isEmptySize = true; } @@ -337,9 +366,9 @@ Connection conn = targetDataStore.getConnection(Transaction.AUTO_COMMIT); if (dropTableMode) { dropGeometryColumn(conn, featureName, dropGeometryColumn(conn, getTargetSchema(), featureName, featureType.getDefaultGeometry().getLocalName()); dropTable(conn, featureName); dropTable(conn, getTargetSchema(), featureName); ArrayList<String> schemaTexts = createNewSchemaTexts(featureType); for (String stmtText : schemaTexts) @@ -350,7 +379,7 @@ } } else { deleteTable(conn, featureName); deleteTable(conn, getTargetSchema(), featureName); } conn.close(); } catch (IOException e) @@ -362,6 +391,7 @@ } } else { String tempStmt = null; try { Connection conn = targetDataStore.getConnection(Transaction.AUTO_COMMIT); @@ -369,15 +399,18 @@ for (String stmtText : schemaTexts) { Statement stmt = conn.createStatement(); tempStmt = stmtText; stmt.execute(stmtText); stmt.close(); } conn.close(); } catch (IOException e) { logger.warn("RUN--" + tempStmt); logger.warn(e.getMessage(), e); } catch (SQLException e) { logger.warn("RUN--" + tempStmt); logger.warn(e.getMessage(), e); } } xdgnjobs/ximple-spatialjob/src/test/resources/com/ximple/eofms/filter/test-data/testElementFilter.xml
@@ -813,7 +813,10 @@ <tid>210</tid> <cid>0</cid> <description>§CÀ£¦a¤U¾É½u</description> <elmtype>12</elmtype> <elementCriterion> <elementType>4</elementType> <elementType>12</elementType> </elementCriterion> <LineCreateStrategy/> </TypeCompFilter> <TypeCompFilter name="FSC-210.C-1">