CenterForDigitalHumanities / rerum_server

Java web service for a RERUM compliant digital object repository
http://rerum.io
Other
7 stars 2 forks source link

newTreePrime() isn't doing anything #216

Closed thehabes closed 3 years ago

thehabes commented 3 years ago
/**
     * An internal method to make all descendants of this JSONObject take on a new history.prime = this object's @id
     * This should only be fed a reliable object from mongo
     * @param obj A new prime object whose descendants must take on its id
     */
     private boolean newTreePrime(JSONObject obj){
         boolean success = true;
         String primeID = obj.getString("@id");
         JSONArray descendants = new JSONArray();
         for(int n=0; n< descendants.size(); n++){
             JSONObject descendantForUpdate = descendants.getJSONObject(n);
             JSONObject originalDescendant = descendants.getJSONObject(n);
             BasicDBObject objToUpdate = (BasicDBObject)JSON.parse(originalDescendant.toString());;
             descendantForUpdate.getJSONObject("__rerum").getJSONObject("history").element("prime", primeID);
             BasicDBObject objWithUpdate = (BasicDBObject)JSON.parse(descendantForUpdate.toString());
             mongoDBService.update(Constant.COLLECTION_ANNOTATION, objToUpdate, objWithUpdate);
         }
         return success;
     }

Maybe because you are looping a hard coded empty array? Yeesh.