<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Geoprocessing issues in Java in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/geoprocessing-issues-in-java/m-p/554626#M3731</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm currently needing to make a tool that's inside another Java addin application which allows a user to update an existing&amp;nbsp;feature (parcels for example) in the database. &amp;nbsp;The user should be able to navigate to and select the shapefile or feature class they want to specify as the source. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of using full blown ArcObjects, I was trying to leverage the Geoprocessing processes available to expedite this (and make coding a little less bulky) since it's effectively using delete features and copy features and, as&amp;nbsp;a sanity check, I wanted to use the FeatureCompare as well to make sure the schemas of the source and target are the same before performing a delete on the existing features in the database. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While in the mapping application, the program has a live connection to the database, but even with that, I have been having some issues with NullPointerException errors when I try to run any of the processes and have also been trying to figure out the best way to get something returned from the FeatureCompare to let the program know whether or not to proceed with deleting and copying or stopping and letting the user know that it won't proceed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also been having a bit of a time getting Java to recognize a .gdb as anything besides a folder, but if I can get it to run for a .shp load, I'll tackle that later.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below are some snippets - the current setup I'm working with is 10.4.1, Java 1.8, Oracle 12c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;================================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;public void compareFeatures(String source, String target) throws IOException {&lt;BR /&gt; try {&lt;BR /&gt; // compare in and out feature schemas&lt;BR /&gt; FeatureCompare featComp = new FeatureCompare();&lt;BR /&gt; // set the target schema&lt;BR /&gt; featComp.setInBaseFeatures(source);&lt;BR /&gt; // set the test features schema&lt;BR /&gt; featComp.setInTestFeatures(target);&lt;BR /&gt; featComp.setSortField("AC_LAB");&lt;BR /&gt; // just compare the schemas&lt;BR /&gt; featComp.setCompareType("SCHEMA_ONLY");&lt;BR /&gt; // and omit these fields from comparison&lt;BR /&gt; featComp.setOmitField("Shape, Shape_Leng, Shape_Area, Shape_Length, AREA, LEN");&lt;BR /&gt; &lt;BR /&gt; // execute the compare&lt;BR /&gt; gp.execute(featComp, trackCancel);&lt;BR /&gt; int index = 0;&lt;BR /&gt; gp.getReturnCode(index);&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; catch(Exception cf) {&lt;BR /&gt; cf.printStackTrace();&lt;BR /&gt; setResultText("Error: " + cf.getMessage());&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; public void deleteFeatures(String target) throws IOException {&lt;BR /&gt; try {&lt;BR /&gt; // delete features in the database&lt;BR /&gt; DeleteFeatures delFeat = new DeleteFeatures();&lt;BR /&gt; delFeat.setInFeatures(target);&lt;BR /&gt; gp.execute(delFeat, trackCancel);&lt;BR /&gt; System.out.println("Features deleted ... ");&lt;BR /&gt; }&lt;BR /&gt; catch(Exception df) {&lt;BR /&gt; df.printStackTrace();&lt;BR /&gt; setResultText("Error: " + df.getMessage());&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Action&lt;BR /&gt; public void execute() {&lt;BR /&gt; System.out.println("I'm in the execute function");&lt;BR /&gt; try {&lt;BR /&gt; String sourceFile = inputFile.toString();&lt;BR /&gt; String targetFile = "comboBox.getSelectedItem()";&lt;BR /&gt; System.out.println("source file is: " + sourceFile + "\n");&lt;BR /&gt; System.out.println("target file is: " + targetFile + "\n");&lt;BR /&gt; System.out.println("Comparing schemas for " + targetFile + " and " + sourceFile + "\n");&lt;BR /&gt;compareFeatures(sourceFile, targetFile);&lt;/P&gt;&lt;P&gt;if (compareSucceeds) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("Deleting features from " + targetFile + "\n");&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;deleteFeatures(targetFile);&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println("Loading new features ... "\n");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; copyFeatures(sourceFile, targetFile);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Feb 2017 20:14:29 GMT</pubDate>
    <dc:creator>BartPittari</dc:creator>
    <dc:date>2017-02-15T20:14:29Z</dc:date>
    <item>
      <title>Geoprocessing issues in Java</title>
      <link>https://community.esri.com/t5/developers-questions/geoprocessing-issues-in-java/m-p/554626#M3731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm currently needing to make a tool that's inside another Java addin application which allows a user to update an existing&amp;nbsp;feature (parcels for example) in the database. &amp;nbsp;The user should be able to navigate to and select the shapefile or feature class they want to specify as the source. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of using full blown ArcObjects, I was trying to leverage the Geoprocessing processes available to expedite this (and make coding a little less bulky) since it's effectively using delete features and copy features and, as&amp;nbsp;a sanity check, I wanted to use the FeatureCompare as well to make sure the schemas of the source and target are the same before performing a delete on the existing features in the database. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While in the mapping application, the program has a live connection to the database, but even with that, I have been having some issues with NullPointerException errors when I try to run any of the processes and have also been trying to figure out the best way to get something returned from the FeatureCompare to let the program know whether or not to proceed with deleting and copying or stopping and letting the user know that it won't proceed.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also been having a bit of a time getting Java to recognize a .gdb as anything besides a folder, but if I can get it to run for a .shp load, I'll tackle that later.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below are some snippets - the current setup I'm working with is 10.4.1, Java 1.8, Oracle 12c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;================================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;public void compareFeatures(String source, String target) throws IOException {&lt;BR /&gt; try {&lt;BR /&gt; // compare in and out feature schemas&lt;BR /&gt; FeatureCompare featComp = new FeatureCompare();&lt;BR /&gt; // set the target schema&lt;BR /&gt; featComp.setInBaseFeatures(source);&lt;BR /&gt; // set the test features schema&lt;BR /&gt; featComp.setInTestFeatures(target);&lt;BR /&gt; featComp.setSortField("AC_LAB");&lt;BR /&gt; // just compare the schemas&lt;BR /&gt; featComp.setCompareType("SCHEMA_ONLY");&lt;BR /&gt; // and omit these fields from comparison&lt;BR /&gt; featComp.setOmitField("Shape, Shape_Leng, Shape_Area, Shape_Length, AREA, LEN");&lt;BR /&gt; &lt;BR /&gt; // execute the compare&lt;BR /&gt; gp.execute(featComp, trackCancel);&lt;BR /&gt; int index = 0;&lt;BR /&gt; gp.getReturnCode(index);&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; catch(Exception cf) {&lt;BR /&gt; cf.printStackTrace();&lt;BR /&gt; setResultText("Error: " + cf.getMessage());&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; &lt;BR /&gt; public void deleteFeatures(String target) throws IOException {&lt;BR /&gt; try {&lt;BR /&gt; // delete features in the database&lt;BR /&gt; DeleteFeatures delFeat = new DeleteFeatures();&lt;BR /&gt; delFeat.setInFeatures(target);&lt;BR /&gt; gp.execute(delFeat, trackCancel);&lt;BR /&gt; System.out.println("Features deleted ... ");&lt;BR /&gt; }&lt;BR /&gt; catch(Exception df) {&lt;BR /&gt; df.printStackTrace();&lt;BR /&gt; setResultText("Error: " + df.getMessage());&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@Action&lt;BR /&gt; public void execute() {&lt;BR /&gt; System.out.println("I'm in the execute function");&lt;BR /&gt; try {&lt;BR /&gt; String sourceFile = inputFile.toString();&lt;BR /&gt; String targetFile = "comboBox.getSelectedItem()";&lt;BR /&gt; System.out.println("source file is: " + sourceFile + "\n");&lt;BR /&gt; System.out.println("target file is: " + targetFile + "\n");&lt;BR /&gt; System.out.println("Comparing schemas for " + targetFile + " and " + sourceFile + "\n");&lt;BR /&gt;compareFeatures(sourceFile, targetFile);&lt;/P&gt;&lt;P&gt;if (compareSucceeds) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.out.println("Deleting features from " + targetFile + "\n");&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;deleteFeatures(targetFile);&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println("Loading new features ... "\n");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; copyFeatures(sourceFile, targetFile);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2017 20:14:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/geoprocessing-issues-in-java/m-p/554626#M3731</guid>
      <dc:creator>BartPittari</dc:creator>
      <dc:date>2017-02-15T20:14:29Z</dc:date>
    </item>
  </channel>
</rss>

