Displaying differences for changeset
 
display as  

src/java/d/bamert_01/edit_soils_properties/V1_0.java

@@ -15,6 +15,8 @@
 import csip.annotations.Resource;
 import csip.annotations.VersionInfo;
 import csip.utils.JSONUtils;
+import csip.utils.Parallel;
+import csip.utils.Parallel.Run;
 import static db.DBResources.GIS_DB;
 import edit.EditConnection;
 import edit.EditQueries;
@@ -162,21 +164,30 @@
       }
     }
 
+    private void queryEdit(Coecoclass coEcoClass, EditConnection editConn) throws Exception {
+      String ecId = coEcoClass.ecoclassid();
+      String edit_es_name = EditQueries.getEcoClassNameFor(editConn.fetchEcoClassList(ecId), ecId);
+      if ((null != edit_es_name) && (!edit_es_name.isEmpty())) {
+        coEcoClass.ecoclassname(edit_es_name);
+        coEcoClass.setEDITPath("https://edit.jornada.nmsu.edu/catalogs/esd/" + ecId.substring(1, 5) + "/" + ecId);
+      }
+    }
+
     private void getEDITEcoclassNames() throws ServiceException, Exception {
       if (null != map_units) {
         for (MapUnit mapUnit : map_units.values()) {
           for (Component component : mapUnit.components().values()) {
+            ArrayList<Run> runs = new ArrayList<>();
+            EditConnection editConn = new EditConnection(LOG);            
             for (Coecoclass coEcoClass : component.ecoClasses().values()) {
               String ecId = coEcoClass.ecoclassid();
               if (ecId.length() == 11 && ((ecId.charAt(0) == 'R' || ecId.charAt(0) == 'F'))) {
-                EditConnection editConn = new EditConnection(LOG);
-                String edit_es_name = EditQueries.getEcoClassNameFor(editConn.fetchEcoClassList(ecId), ecId);
-                if ((null != edit_es_name) && (!edit_es_name.isEmpty())) {
-                  coEcoClass.ecoclassname(edit_es_name);
-                  coEcoClass.setEDITPath("https://edit.jornada.nmsu.edu/catalogs/esd/" + ecId.substring(1, 5) + "/" + ecId);
-                }
+                runs.add(() -> queryEdit(coEcoClass, editConn ));
               }
             }
+            if ( runs.size() > 0 ){
+              Parallel.run(runs);
+            }
           }
         }
       } else {
@@ -229,7 +240,7 @@
               component.setHorizonOutputColumnOrdering(new ArrayList<>(Arrays.asList(TableHorizon.CHKEY_NAME, TableHorizonCalculations.DEPT_R_IN,
                   TableHorizonCalculations.DEPB_R_IN)));
               component.setTextureGroupOutputColumnOrdering(new ArrayList<>(Arrays.asList(TableTextureGroup.DESCRIPTION)));
-              
+
               componentObject = component.toJSON(false);
 
               JSONArray ecoClassArray = new JSONArray();
@@ -238,7 +249,7 @@
                     TableCoecoclass.ECOCLASSNAME, TableCoecoclassCalculations.ES_EDIT_URL)));
                 ecoClassArray.put(ecoClass.toJSON());
               }
-              
+
               componentObject.put(JSONUtils.data("EcoClassList", ecoClassArray));
               componentArray.put(componentObject);