Exemplo n.º 1
0
 public JSONObject asJSONTreeAux(ConcurrentHashMap<DomainConcept, DomainConcept> written) {
   JSONObject jsonObj = new JSONObject();
   try {
     jsonObj.put("class", "ClassModel");
     jsonObj.put("id", id);
     if (written.contains(this)) {
       return jsonObj;
     }
     written.put(this, this);
     if (getHasArcs() != null) {
       JSONArray jsonHasArcs = new JSONArray();
       for (Arc row : getHasArcs()) {
         jsonHasArcs.put(row.asJSONTreeAux(written));
       }
       jsonObj.put("hasArcs", jsonHasArcs);
     }
     if (getHasPropertySet() != null) {
       jsonObj.put("hasPropertySet", getHasPropertySet().asJSONTreeAux(written));
     }
     jsonObj.put("id", getId());
     if (getHasDomainNodes() != null) {
       jsonObj.put("hasDomainNodes", getHasDomainNodes().asJSONTreeAux(written));
     }
     written.remove(this);
   } catch (Exception e1) {
     logWriter.error("Error in marshalling to JSON ", e1);
   }
   return jsonObj;
 }
Exemplo n.º 2
0
 /** method to marshall data from caching layer object to JSON * */
 public JSONObject asJSON() {
   JSONObject jsonObj = new JSONObject();
   try {
     jsonObj.put("class", "ClassModel");
     jsonObj.put("id", id);
     if (getHasArcs() != null) {
       JSONArray jsonHasArcs = new JSONArray();
       for (Arc row : getHasArcs()) {
         jsonHasArcs.put(row.getId());
       }
       jsonObj.put("hasArcs", jsonHasArcs);
     }
     if (getHasPropertySet() != null) {
       jsonObj.put("hasPropertySet", getHasPropertySet().getId());
     }
     jsonObj.put("id", getId());
     if (getHasDomainNodes() != null) {
       jsonObj.put("hasDomainNodes", getHasDomainNodes().getId());
     }
   } catch (Exception e1) {
     logWriter.error("Error in marshalling to JSON ", e1);
   }
   return jsonObj;
 }