EditScratch.java [src/edit] Revision: default Date:
/*
* $Id$
*
* This file is part of the Cloud Services Integration Platform (CSIP),
* a Model-as-a-Service framework, API, and application suite.
*
* 2012-2021, OMSLab, Colorado State University.
*
* OMSLab licenses this file to you under the MIT license.
* See the LICENSE file in the project root for more information.
*/
package edit;
import com.jayway.jsonpath.ReadContext;
import csip.SessionLogger;
import edit.EditConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
/**
* Rest service access to EditQueries (Ecological Dynamics Interpretive Tool).
* (https://edit.jornada.nmsu.edu/resources/esd)
*
* @author od
*/
public class EditScratch {
static void t1() throws Exception {
EditConnection s = new EditConnection(new SessionLogger());
String es_id = "R053CY004SD";
// String edit_es_name = getEcoClassNameFor(s.fetchEcoClassList(es_id), es_id);
ReadContext f = s.fetchAnnualProd(es_id);
// System.out.println(new JSONObject(f).toString(2));
List l = EditQueries.getAnnualProd(f, 1, 1, 1);
System.out.println(l);
System.out.println(l.size());
}
static List<List> grs = new ArrayList<>();
static void add(Map<String, Object> o) throws JSONException {
int index = (int) o.get("group") - 1;
List gr;
if (index >= grs.size())
grs.add(index, gr = new ArrayList());
else
gr = (List) grs.get(index);
gr.add(o);
}
static void t12() throws Exception {
EditConnection s = new EditConnection(new SessionLogger());
String es_id = "R042XC244TX";
ReadContext f = s.fetchPlantComposition(es_id);
// System.out.println(f.jsonString());
List<List<Map<String, Object>>> cg = EditQueries.getCompositionGroups(f);
for (List<Map<String, Object>> comps : cg) {
for (Map<String, Object> comp : comps) {
add(comp);
}
}
for (List gr : grs) {
System.out.println("----");
for (Object object : gr) {
System.out.println(object);
}
}
System.out.println(grs);
// System.out.println(cg);
// System.out.println(cg.size());
// System.out.println(cg.get(0).get(0).getClass());
}
public static void syn() throws Exception {
EditConnection s = new EditConnection(new SessionLogger());
// List<Map<String, String>> l = EditQueries.getSynonyms(s.fetchAllSynonyms(), "R011BY001ID");
List<Map<String, String>> l = EditQueries.getSynonyms(s.fetchAllSynonyms(), "R042XC241TX");
System.out.println(l);
System.out.println(l.get(l.size() - 1).get("legacyId"));
// String s1 = EditQueries.getSynonymFor(s.fetchAllSynonyms(), "R011BY001ID");
// System.out.println(s1);
}
public static void main(String[] args) throws Exception {
// t12();
syn();
// JSONArray r = gras_fisprodesd("R053CY010SD", 0.2, 0, "name", new SessionLogger());
// System.out.println(r.toString(4));
// System.out.println(l.get(0));
// String edit_es_name = getEcoClassNameFor(s.fetchEcoClassList(es_id), es_id);
// System.out.println(edit_es_name);
}
}