Skip to content

v0.2.50..v0.2.51 changeset DbUtils.java

Garret Voltz edited this page Jan 15, 2020 · 1 revision
diff --git a/hoot-services/src/main/java/hoot/services/utils/DbUtils.java b/hoot-services/src/main/java/hoot/services/utils/DbUtils.java
index 142cd5f..ea974c4 100644
--- a/hoot-services/src/main/java/hoot/services/utils/DbUtils.java
+++ b/hoot-services/src/main/java/hoot/services/utils/DbUtils.java
@@ -342,9 +342,9 @@ public class DbUtils {
 
     public static boolean grailEligible(long inputId) {
         Map<String, String> tags = getMapsTableTags(inputId);
-        String sourceInfo = tags.get("source");
+        String grailReference = tags.get("grailReference");
 
-        return sourceInfo != null && sourceInfo.equals("rails");
+        return grailReference != null && grailReference.equals("true");
     }
 
     public static String getConflationType(long inputId) {
@@ -377,9 +377,9 @@ public class DbUtils {
      */
     public static String getMapBbox(long mapId) {
         Map<String, String> tags = getMapsTableTags(mapId);
-        String sourceInfo = tags.get("bbox");
+        String bbox = tags.get("bbox");
 
-        return sourceInfo;
+        return bbox;
     }
 
     /**
@@ -640,13 +640,29 @@ public class DbUtils {
         return -1;
     }
 
-    // Returns the parentId for the specified jobId job
-    public static String getParentId(String jobId) {
-        return createQuery()
-                .select(jobStatus.parentId)
+    // Gets tags column from job status table for specified job id row
+    public static Map<String, String> getJobTags(String jobId) {
+        Map<String, String> tags = new HashMap<>();
+
+        List<Object> results = createQuery()
+                .select(jobStatus.tags)
                 .from(jobStatus)
                 .where(jobStatus.jobId.eq(jobId))
-                .fetchFirst();
+                .fetch();
+
+        if (!results.isEmpty()) {
+            Object oTag = results.get(0);
+            tags = PostgresUtils.postgresObjToHStore(oTag);
+        }
+
+        return tags;
+    }
+
+    // Returns the parentId for the specified jobId job
+    public static String getParentId(String jobId) {
+        Map<String, String> tags = getJobTags(jobId);
+
+        return tags.get("parentId");
     }
 
     // Sets the specified job to a status detail of stale and recurses up to the parent jobs to do the same
@@ -665,9 +681,10 @@ public class DbUtils {
                 .set(jobStatus.statusDetail, "STALE")
                 .execute();
 
+            String parentId = getParentId(jobId);
             // If it has a parent, make the parent stale too
-            if(job.getParentId() != null && !job.getParentId().equals("")) {
-                setStale(job.getParentId());
+            if(parentId != null) {
+                setStale(parentId);
             }
         }
     }
Clone this wiki locally