/**
* 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.
Maybe because you are looping a hard coded empty array? Yeesh.