@@ -54,264 +54,266 @@ |
UpdateOptions opt = new UpdateOptions(); |
|
public MongoArchive(String uri) throws Exception { |
- // "mongodb://user:pass@host:port/db" |
- if (uri.contains("mongodb://")) { |
- MongoClientURI u = new MongoClientURI(uri); |
- dbname = u.getDatabase(); |
- if (dbname == null) { |
- dbname = "csip"; |
- } |
+ // "mongodb://user:pass@host:port/db" |
+ if (uri.contains("mongodb://")) { |
+ MongoClientURI u = new MongoClientURI(uri); |
+ dbname = u.getDatabase(); |
+ if (dbname == null) { |
+ dbname = "csip"; |
+ } |
|
- mongo = new MongoClient(u); |
- opt.upsert(true); |
- } else { |
- throw new Exception("No mongodb location specified"); |
- } |
+ mongo = new MongoClient(u); |
+ opt.upsert(true); |
+ } else { |
+ throw new Exception("No mongodb location specified"); |
+ } |
} // "mongodb://user:pass@host:port/db"// "mongodb://user:pass@host:port/db" |
|
@Override |
public synchronized ArrayList<ModelArchive> getArchiveByReqIP(String ip, String service) throws Exception { |
- ArrayList<ModelArchive> ret_val = new ArrayList<>(); |
- MongoDatabase db = mongo.getDatabase(dbname); |
- FindIterable<Document> r = db.getCollection(FS_COLL).find(eq("req_ip", ip)); |
+ ArrayList<ModelArchive> ret_val = new ArrayList<>(); |
+ MongoDatabase db = mongo.getDatabase(dbname); |
+ FindIterable<Document> r = db.getCollection(FS_COLL).find(eq("req_ip", ip)); |
|
- r.sort(new Document("ctime", 1)); |
- for (Document doc : r) { |
- if (doc != null) { |
- if (doc.getString("service").equalsIgnoreCase(service)) { |
- ret_val.add(new ModelArchive( |
- doc.getString("_id"), |
- doc.getString("ctime"), |
- doc.getString("etime"), |
- doc.getString("service"), |
- doc.getString("status"), |
- doc.getString("req_ip"), |
- doc.getString("filename") |
- ) |
- ); |
- } |
- } |
- } |
- return ret_val; |
+ r.sort(new Document("ctime", 1)); |
+ for (Document doc : r) { |
+ if (doc != null) { |
+ if (doc.getString("service").equalsIgnoreCase(service)) { |
+ ret_val.add(new ModelArchive( |
+ doc.getString("_id"), |
+ doc.getString("ctime"), |
+ doc.getString("etime"), |
+ doc.getString("service"), |
+ doc.getString("status"), |
+ doc.getString("req_ip"), |
+ doc.getString("filename") |
+ ) |
+ ); |
+ } |
+ } |
+ } |
+ return ret_val; |
} |
|
@Override |
public synchronized ModelArchive getArchiveBySUID(String suid) throws Exception { |
- MongoDatabase db = mongo.getDatabase(dbname); |
- FindIterable<Document> r = db.getCollection(FS_COLL).find(new Document("_id", suid)); |
- Document doc = r.first(); |
- if (doc != null) { |
- return new ModelArchive( |
- doc.getString("_id"), |
- doc.getString("ctime"), |
- doc.getString("etime"), |
- doc.getString("service"), |
- doc.getString("status"), |
- doc.getString("req_ip"), |
- doc.getString("filename") |
- ); |
- } |
- return null; |
+ MongoDatabase db = mongo.getDatabase(dbname); |
+ FindIterable<Document> r = db.getCollection(FS_COLL).find(new Document("_id", suid)); |
+ Document doc = r.first(); |
+ if (doc != null) { |
+ return new ModelArchive( |
+ doc.getString("_id"), |
+ doc.getString("ctime"), |
+ doc.getString("etime"), |
+ doc.getString("service"), |
+ doc.getString("status"), |
+ doc.getString("req_ip"), |
+ doc.getString("filename") |
+ ); |
+ } |
+ return null; |
} |
|
private synchronized byte[] getFile(String suid) throws Exception { |
- MongoDatabase db = mongo.getDatabase(dbname); |
- GridFSBucket gridFSBucket = GridFSBuckets.create(db); |
- try (GridFSDownloadStream stream = gridFSBucket.openDownloadStream(new BsonString(suid))) { |
- long fileLength = stream.getGridFSFile().getLength(); |
- // this should not happen, since it is capped at 1GB. |
- if (fileLength > Integer.MAX_VALUE) { |
- return ARCHIVE_TOO_BIG.getBytes(); |
- } |
- return IOUtils.toByteArray(stream, fileLength); |
- } |
+ MongoDatabase db = mongo.getDatabase(dbname); |
+ GridFSBucket gridFSBucket = GridFSBuckets.create(db); |
+ try (GridFSDownloadStream stream = gridFSBucket.openDownloadStream(new BsonString(suid))) { |
+ long fileLength = stream.getGridFSFile().getLength(); |
+ // this should not happen, since it is capped at 1GB. |
+ if (fileLength > Integer.MAX_VALUE) { |
+ return ARCHIVE_TOO_BIG.getBytes(); |
+ } |
+ return IOUtils.toByteArray(stream, fileLength); |
+ } |
} |
|
@Override |
public synchronized JSONObject getServiceRequest(String suid) throws Exception { |
- JSONObject requestData = null; |
+ JSONObject requestData = null; |
|
- byte[] zFile = getFile(suid); |
+ byte[] zFile = getFile(suid); |
|
- try (ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(zFile))) { |
- ZipEntry entry; |
+ try (ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(zFile))) { |
+ ZipEntry entry; |
|
- while ((entry = zin.getNextEntry()) != null) { |
- if (entry.getName().contains(".request")) { |
- BufferedReader bReader = new BufferedReader(new InputStreamReader(zin)); |
- StringBuilder fileContent = new StringBuilder(); |
- String inputStr; |
- while ((inputStr = bReader.readLine()) != null) { |
- fileContent.append(inputStr).append(System.lineSeparator()); |
- } |
- requestData = new JSONObject(fileContent.toString()); |
- break; |
- } |
- } |
- } |
+ while ((entry = zin.getNextEntry()) != null) { |
+ if (entry.getName().contains(".request")) { |
+ BufferedReader bReader = new BufferedReader(new InputStreamReader(zin)); |
+ StringBuilder fileContent = new StringBuilder(); |
+ String inputStr; |
+ while ((inputStr = bReader.readLine()) != null) { |
+ fileContent.append(inputStr).append(System.lineSeparator()); |
+ } |
+ requestData = new JSONObject(fileContent.toString()); |
+ break; |
+ } |
+ } |
+ } |
|
- return requestData; |
+ return requestData; |
} |
|
@Override |
public synchronized JSONObject getServiceResponse(String suid) throws Exception { |
- JSONObject requestData = null; |
+ JSONObject requestData = null; |
|
- byte[] zFile = getFile(suid); |
+ byte[] zFile = getFile(suid); |
|
- try (ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(zFile))) { |
- ZipEntry entry; |
+ try (ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(zFile))) { |
+ ZipEntry entry; |
|
- while ((entry = zin.getNextEntry()) != null) { |
- if (entry.getName().contains(".response")) { |
- BufferedReader bReader = new BufferedReader(new InputStreamReader(zin)); |
- StringBuilder fileContent = new StringBuilder(); |
- String inputStr; |
- while ((inputStr = bReader.readLine()) != null) { |
- fileContent.append(inputStr).append(System.lineSeparator()); |
- } |
- requestData = new JSONObject(fileContent.toString()); |
- break; |
- } |
- } |
- } |
+ while ((entry = zin.getNextEntry()) != null) { |
+ if (entry.getName().contains(".response")) { |
+ BufferedReader bReader = new BufferedReader(new InputStreamReader(zin)); |
+ StringBuilder fileContent = new StringBuilder(); |
+ String inputStr; |
+ while ((inputStr = bReader.readLine()) != null) { |
+ fileContent.append(inputStr).append(System.lineSeparator()); |
+ } |
+ requestData = new JSONObject(fileContent.toString()); |
+ break; |
+ } |
+ } |
+ } |
|
- return requestData; |
+ return requestData; |
} |
|
@Override |
public synchronized void shutdown() throws Exception { |
- mongo.close(); |
+ mongo.close(); |
} |
|
@Override |
public synchronized long getCount() { |
- MongoDatabase db = mongo.getDatabase(dbname); |
- return db.getCollection(FS_COLL).count(); |
+ MongoDatabase db = mongo.getDatabase(dbname); |
+ return db.getCollection(FS_COLL).count(); |
} |
|
// new keys implementation. |
@Override |
public synchronized Set<String> keys(int skip, int limit, String sortby, boolean sortAsc) { |
- if (sortby == null) { |
- sortby = "ctime"; |
- sortAsc = false; |
- } |
- Document sort = new Document(sortby, sortAsc ? 1 : -1); |
- Set<String> l = new LinkedHashSet<>(); |
- MongoDatabase db = mongo.getDatabase(dbname); |
- MongoCollection<Document> c = db.getCollection(FS_COLL); |
+ if (sortby == null) { |
+ sortby = "ctime"; |
+ sortAsc = false; |
+ } |
+ Document sort = new Document(sortby, sortAsc ? 1 : -1); |
+ Set<String> l = new LinkedHashSet<>(); |
+ MongoDatabase db = mongo.getDatabase(dbname); |
+ MongoCollection<Document> c = db.getCollection(FS_COLL); |
|
- for (Document doc : c.find().sort(sort).skip(skip).limit(limit)) { |
- l.add(doc.get("_id", String.class |
- )); |
- } |
- return l; |
+ for (Document doc : c.find().sort(sort).skip(skip).limit(limit)) { |
+ l.add(doc.get("_id", String.class |
+ )); |
+ } |
+ return l; |
} |
|
@Override |
public synchronized boolean hasArchive(String suid) throws Exception { |
- MongoDatabase db = mongo.getDatabase(dbname); |
- return db.getCollection(FS_COLL).count(new Document("_id", suid)) == 1; |
+ MongoDatabase db = mongo.getDatabase(dbname); |
+ return db.getCollection(FS_COLL).count(new Document("_id", suid)) == 1; |
|
} |
|
@Override |
public ArrayList<ModelArchive> getArchivesByFilters(Iterable<Bson> filters, int limit) throws Exception { |
- ArrayList<ModelArchive> ret_val = new ArrayList<>(); |
- MongoDatabase db = mongo.getDatabase(dbname); |
- FindIterable<Document> c = db.getCollection(FS_COLL).find(and(filters)).sort(new Document("ctime", -1)); |
+ ArrayList<ModelArchive> ret_val = new ArrayList<>(); |
+ MongoDatabase db = mongo.getDatabase(dbname); |
+ FindIterable<Document> c = db.getCollection(FS_COLL).find(and(filters)).sort(new Document("ctime", -1)); |
|
- MongoCursor<Document> cursor = c.iterator(); |
+ MongoCursor<Document> cursor = c.iterator(); |
|
- int count = 0; |
- while (cursor.hasNext()) { |
- Document doc = cursor.next(); |
- if (null != doc) { |
- ModelArchive model = null; |
- byte[] fileData = getFile(doc.getString("_id")); |
+ int count = 0; |
+ while (cursor.hasNext()) { |
+ Document doc = cursor.next(); |
+ if (null != doc) { |
+ ModelArchive model = null; |
+ byte[] fileData = getFile(doc.getString("_id")); |
|
- if (doc.getString("service").contains("weps/5.0")) { |
- model = new WEPSModelArchive(doc.getString("_id"), |
- doc.getString("ctime"), |
- doc.getString("etime"), |
- doc.getString("service"), |
- doc.getString("status"), |
- doc.getString("req_ip"), |
- doc.getString("filename"), |
- fileData |
- ); |
- } |
+ if (doc.getString("service").contains("weps/5.0")) { |
+ model = new WEPSModelArchive(doc.getString("_id"), |
+ doc.getString("ctime"), |
+ doc.getString("etime"), |
+ doc.getString("service"), |
+ doc.getString("status"), |
+ doc.getString("req_ip"), |
+ doc.getString("filename"), |
+ fileData |
+ ); |
+ model.saveFileData(fileData); |
+ } |
|
- fileData = null; // Allow garbage collection of the byte array. |
+ fileData = null; // Allow garbage collection of the byte array. |
|
- ret_val.add(model); |
- count++; |
+ ret_val.add(model); |
+ count++; |
|
- // Reached our limit yet? |
- if ((-1 != limit) && (count >= limit)) { |
- break; |
- } |
- } |
- } |
+ // Reached our limit yet? |
+ if ((-1 != limit) && (count >= limit)) { |
+ break; |
+ } |
+ } |
+ } |
|
- System.gc(); // We've read a lot of data and dynamically allocated a lot of space, some of which was returned...force some garbage collection. |
- return ret_val; |
+ System.gc(); // We've read a lot of data and dynamically allocated a lot of space, some of which was returned...force some garbage collection. |
+ return ret_val; |
} |
|
@Override |
public ArrayList<ModelArchive> getArchivesByFilter(String key, String value, int limit) throws Exception { |
- ArrayList<ModelArchive> ret_val = new ArrayList<>(); |
- MongoDatabase db = mongo.getDatabase(dbname); |
- FindIterable<Document> c = db.getCollection(FS_COLL).find(and(eq(key, value), eq("status", "Finished"))).sort(new Document("ctime", -1)); |
+ ArrayList<ModelArchive> ret_val = new ArrayList<>(); |
+ MongoDatabase db = mongo.getDatabase(dbname); |
+ FindIterable<Document> c = db.getCollection(FS_COLL).find(and(eq(key, value), eq("status", "Finished"))).sort(new Document("ctime", -1)); |
|
- MongoCursor<Document> cursor = c.iterator(); |
+ MongoCursor<Document> cursor = c.iterator(); |
|
- int count = 0; |
- while (cursor.hasNext()) { |
- Document doc = cursor.next(); |
- if ((null != doc) && (doc.getString(key).equalsIgnoreCase(value))) { |
- ModelArchive model = null; |
- byte[] fileData = null; |
- String serviceName = doc.getString("service"); |
+ int count = 0; |
+ while (cursor.hasNext()) { |
+ Document doc = cursor.next(); |
+ if ((null != doc) && (doc.getString(key).equalsIgnoreCase(value))) { |
+ ModelArchive model = null; |
+ byte[] fileData = null; |
+ String serviceName = doc.getString("service"); |
|
- model = ModelArchiveFactory.getModelArchive(serviceName, doc); |
- if (null != model) { |
- fileData = getFile(doc.getString("_id")); |
- model.setFileDataEx(fileData); |
- fileData = null; // Allow garbage collection of the byte array. |
+ model = ModelArchiveFactory.getModelArchive(serviceName, doc); |
+ if (null != model) { |
+ fileData = getFile(doc.getString("_id")); |
+ model.setFileDataEx(fileData); |
+ model.saveFileData(fileData); |
+ fileData = null; // Allow garbage collection of the byte array. |
|
- if (null != model) { |
- ret_val.add(model); |
- count++; |
- } |
- } |
- // Reached our limit yet? |
- if ((-1 != limit) && (count >= limit)) { |
- break; |
- } |
- } |
- } |
+ if (null != model) { |
+ ret_val.add(model); |
+ count++; |
+ } |
+ } |
+ // Reached our limit yet? |
+ if ((-1 != limit) && (count >= limit)) { |
+ break; |
+ } |
+ } |
+ } |
|
- System.gc(); // We've read a lot of data and dynamically allocated a lot of space, some of which was returned...force some garbage collection. |
- return ret_val; |
+ System.gc(); // We've read a lot of data and dynamically allocated a lot of space, some of which was returned...force some garbage collection. |
+ return ret_val; |
} |
|
@Override |
public ArrayList<String> getSUIDsByFilter(String key, String value |
) { |
- ArrayList<String> ret_val = new ArrayList<>(); |
- MongoDatabase db = mongo.getDatabase(dbname); |
- FindIterable<Document> c = db.getCollection(FS_COLL).find(eq(key, value)).sort(new Document("ctime", 1)); |
+ ArrayList<String> ret_val = new ArrayList<>(); |
+ MongoDatabase db = mongo.getDatabase(dbname); |
+ FindIterable<Document> c = db.getCollection(FS_COLL).find(eq(key, value)).sort(new Document("ctime", 1)); |
|
- MongoCursor<Document> cursor = c.iterator(); |
+ MongoCursor<Document> cursor = c.iterator(); |
|
- while (cursor.hasNext()) { |
- Document doc = cursor.next(); |
- if (null != doc) { |
- ret_val.add(doc.getString("_id")); |
- } |
- } |
- return ret_val; |
+ while (cursor.hasNext()) { |
+ Document doc = cursor.next(); |
+ if (null != doc) { |
+ ret_val.add(doc.getString("_id")); |
+ } |
+ } |
+ return ret_val; |
} |
} |
@@ -13,10 +13,12 @@ |
|
import java.io.BufferedReader; |
import java.io.ByteArrayInputStream; |
+import java.io.File; |
import java.io.IOException; |
import java.io.InputStreamReader; |
import java.util.zip.ZipEntry; |
import java.util.zip.ZipInputStream; |
+import org.apache.commons.io.FileUtils; |
import org.codehaus.jettison.json.JSONArray; |
import org.codehaus.jettison.json.JSONException; |
import org.codehaus.jettison.json.JSONObject; |
@@ -41,149 +43,180 @@ |
protected String logFile; |
|
public ModelArchive(String suid, String ctime, String etime, String service, String status, String req_ip, String filename) { |
- this.ctime = ctime; |
- this.etime = etime; |
- this.service = service; |
- this.status = status; |
- this.req_ip = req_ip; |
- this.suid = suid; |
- this.filename = filename; |
+ this.ctime = ctime; |
+ this.etime = etime; |
+ this.service = service; |
+ this.status = status; |
+ this.req_ip = req_ip; |
+ this.suid = suid; |
+ this.filename = filename; |
} |
|
public ModelArchive(String suid, String ctime, String etime, String service, String status, String req_ip, String filename, byte[] fileData) throws IOException, JSONException { |
- this.ctime = ctime; |
- this.etime = etime; |
- this.service = service; |
- this.status = status; |
- this.req_ip = req_ip; |
- this.suid = suid; |
- this.filename = filename; |
+ this.ctime = ctime; |
+ this.etime = etime; |
+ this.service = service; |
+ this.status = status; |
+ this.req_ip = req_ip; |
+ this.suid = suid; |
+ this.filename = filename; |
|
- setFileData(fileData); |
+ setFileData(fileData); |
} |
|
public ModelArchive(JSONObject inputData) throws JSONException { |
- suid = inputData.getString("_id"); |
- ctime = inputData.getString("ctime"); |
- etime = inputData.getString("etime"); |
- service = inputData.getString("service"); |
- status = inputData.getString("status"); |
- req_ip = inputData.getString("req_ip"); |
- filename = suid + ".zip"; |
+ suid = inputData.getString("_id"); |
+ ctime = inputData.getString("ctime"); |
+ etime = inputData.getString("etime"); |
+ service = inputData.getString("service"); |
+ status = inputData.getString("status"); |
+ req_ip = inputData.getString("req_ip"); |
+ filename = suid + ".zip"; |
} |
|
protected final void setFileData(byte[] fileData) throws IOException, JSONException { |
- originalRequest = getServiceRequest(fileData); |
- originalResponse = getServiceResponse(fileData); |
- logFile = getFileContents(fileData, ".log.txt"); |
+ originalRequest = getServiceRequest(fileData); |
+ originalResponse = getServiceResponse(fileData); |
+ logFile = getFileContents(fileData, ".log.txt"); |
} |
|
- public void setFileDataEx(byte[] fileData) throws IOException, JSONException{ |
- setFileData(fileData); |
+ public void setFileDataEx(byte[] fileData) throws IOException, JSONException { |
+ setFileData(fileData); |
} |
- |
+ |
public final String getFileContents(byte[] fileData, String fileName) throws IOException { |
- String fileString = null; |
+ String fileString = null; |
|
- try (ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(fileData))) { |
- ZipEntry entry; |
+ try (ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(fileData))) { |
+ ZipEntry entry; |
|
- while ((entry = zin.getNextEntry()) != null) { |
- if (entry.getName().contains(fileName)) { |
- BufferedReader bReader = new BufferedReader(new InputStreamReader(zin)); |
- StringBuilder fileContent = new StringBuilder(); |
- String inputStr; |
- while ((inputStr = bReader.readLine()) != null) { |
- fileContent.append(inputStr).append(System.lineSeparator()); |
- } |
- fileString = fileContent.toString(); |
- break; |
- } |
- } |
- } |
+ while ((entry = zin.getNextEntry()) != null) { |
+ if (entry.getName().contains(fileName)) { |
+ BufferedReader bReader = new BufferedReader(new InputStreamReader(zin)); |
+ StringBuilder fileContent = new StringBuilder(); |
+ String inputStr; |
+ while ((inputStr = bReader.readLine()) != null) { |
+ fileContent.append(inputStr).append(System.lineSeparator()); |
+ } |
+ fileString = fileContent.toString(); |
+ break; |
+ } |
+ } |
+ } |
|
- return fileString; |
+ return fileString; |
} |
|
protected JSONObject getServiceRequest(byte[] fileData) throws IOException, JSONException { |
- JSONObject requestData; |
- requestData = new JSONObject(getFileContents(fileData, ".request")); |
- return requestData; |
+ JSONObject requestData; |
+ requestData = new JSONObject(getFileContents(fileData, ".request")); |
+ return requestData; |
+ } |
+ |
+ public String getOriginalRequest(String lookup) { |
+ String ret_val = ((originalResponseFailed()) ? FAILED_MESSAGE : ""); |
+ |
+ JSONArray results = originalRequest.optJSONArray("parameter"); |
+ |
+ if (null != results) { |
+ for (int i = 0; i < results.length(); i++) { |
+ JSONObject jsonObject = results.optJSONObject(i); |
+ if (null != jsonObject) { |
+ if (jsonObject.optString("name") != null) { |
+ if (jsonObject.optString("name").equalsIgnoreCase(lookup)) { |
+ if (jsonObject.optString("value") != null) { |
+ ret_val = jsonObject.optString("value"); |
+ } |
+ } |
+ } |
+ } |
+ } |
+ } |
+ |
+ return ret_val; |
} |
|
protected JSONObject getServiceResponse(byte[] fileData) throws IOException, JSONException { |
- JSONObject requestData; |
- requestData = new JSONObject(getFileContents(fileData, ".response")); |
- return requestData; |
+ JSONObject requestData; |
+ requestData = new JSONObject(getFileContents(fileData, ".response")); |
+ return requestData; |
} |
|
public String getOriginalResponse(String lookup) { |
- String ret_val = ((originalResponseFailed()) ? FAILED_MESSAGE : ""); |
+ String ret_val = ((originalResponseFailed()) ? FAILED_MESSAGE : ""); |
|
- JSONArray results = originalResponse.optJSONArray("result"); |
+ JSONArray results = originalResponse.optJSONArray("result"); |
|
- if (null != results) { |
- for (int i = 0; i < results.length(); i++) { |
- JSONObject jsonObject = results.optJSONObject(i); |
- if (null != jsonObject) { |
- if (jsonObject.optString("name") != null) { |
- if (jsonObject.optString("name").equalsIgnoreCase(lookup)) { |
- if (jsonObject.optString("value") != null) { |
- ret_val = jsonObject.optString("value"); |
- } |
- } |
- } |
- } |
- } |
- } |
+ if (null != results) { |
+ for (int i = 0; i < results.length(); i++) { |
+ JSONObject jsonObject = results.optJSONObject(i); |
+ if (null != jsonObject) { |
+ if (jsonObject.optString("name") != null) { |
+ if (jsonObject.optString("name").equalsIgnoreCase(lookup)) { |
+ if (jsonObject.optString("value") != null) { |
+ ret_val = jsonObject.optString("value"); |
+ } |
+ } |
+ } |
+ } |
+ } |
+ } |
|
- return ret_val; |
+ return ret_val; |
} |
|
public boolean originalResponseFailed() { |
- boolean ret_val = true; |
- JSONObject metaInfo = originalResponse.optJSONObject("metainfo"); |
+ boolean ret_val = true; |
+ JSONObject metaInfo = originalResponse.optJSONObject("metainfo"); |
|
- if (null != metaInfo) { |
- String status = metaInfo.optString("status"); |
+ if (null != metaInfo) { |
+ String status = metaInfo.optString("status"); |
|
- if ((null != status) && (!status.isEmpty())) { |
- ret_val = !status.equalsIgnoreCase("finished"); |
- } |
- } |
+ if ((null != status) && (!status.isEmpty())) { |
+ ret_val = !status.equalsIgnoreCase("finished"); |
+ } |
+ } |
|
- return ret_val; |
+ return ret_val; |
} |
|
public JSONObject getOriginalRequest() { |
- return originalRequest; |
+ return originalRequest; |
} |
|
public JSONObject getOriginalResponse() { |
- return originalResponse; |
+ return originalResponse; |
} |
|
public String getReqIP() { |
- return req_ip; |
+ return req_ip; |
} |
|
public String getStatus() { |
- return status; |
+ return status; |
} |
|
public String getService() { |
- return service; |
+ return service; |
} |
|
public String getSUID() { |
- return suid; |
+ return suid; |
} |
|
public String getCtime() { |
- return ctime; |
+ return ctime; |
} |
|
public String getEtime() { |
- return etime; |
+ return etime; |
+ } |
+ |
+ public void saveFileData(byte[] fileData) throws IOException { |
+ if (null != fileData) { |
+ if (fileData.length > 0) { |
+ FileUtils.writeByteArrayToFile(new File(filename), fileData); |
+ } |
+ } |
} |
} |
@@ -45,38 +45,38 @@ |
private WEPSMetaData wepsMetaData; |
|
public WEPSModelArchive(String suid, String ctime, String etime, String service, String status, String req_ip, String filename) { |
- super(suid, ctime, etime, service, status, req_ip, filename); |
+ super(suid, ctime, etime, service, status, req_ip, filename); |
} |
|
public WEPSModelArchive(String suid, String ctime, String etime, String service, String status, String req_ip, String filename, byte[] fileData) throws IOException, JSONException { |
- super(suid, ctime, etime, service, status, req_ip, filename, fileData); |
- setFileDataEx(fileData); |
+ super(suid, ctime, etime, service, status, req_ip, filename, fileData); |
+ setFileDataEx(fileData); |
} |
|
@Override |
public final void setFileDataEx(byte[] fileData) throws IOException, JSONException { |
- super.setFileDataEx(fileData); |
+ super.setFileDataEx(fileData); |
|
- try { |
- stdErrorFile = getStdErrorFile(fileData); |
- } catch (IOException ex) { |
- badModelRun = true; |
- badModelMessage += "##\n"; |
- badModelMessage += ex.getMessage(); |
- } |
- if (null != stdErrorFile) { |
- possibleBadModelRun = stdErrorFile.contains("IEEE_UNDERFLOW_FLAG") || stdErrorFile.contains("IEEE_DENORMAL"); |
+ try { |
+ stdErrorFile = getStdErrorFile(fileData); |
+ } catch (IOException ex) { |
+ badModelRun = true; |
+ badModelMessage += "##\n"; |
+ badModelMessage += ex.getMessage(); |
+ } |
+ if (null != stdErrorFile) { |
+ possibleBadModelRun = stdErrorFile.contains("IEEE_UNDERFLOW_FLAG") || stdErrorFile.contains("IEEE_DENORMAL"); |
|
- if (possibleBadModelRun) { |
- badModelMessage += "##\nThe WEPS model executable stderr file contained: "; |
- badModelMessage += ((stdErrorFile.contains("IEEE_UNDERFLOW_FLAG")) ? "\nIEEE_UNDERFLOW_FLAG, Meaning that some values were rounded to zero because they were too small for the FORTRAN code to interpret." : ""); |
- if (badModelMessage.contains("IEEE")) { |
- badModelMessage += "\n AND "; |
- } |
- badModelMessage += ((stdErrorFile.contains("IEEE_DENORMAL")) ? "\nIEEE_DENORMAL, Meaning that there are denormal numbers generated when running the code." : ""); |
- badModelMessage += "\n This may be a hint about numerical problems in the model FORTRAN code, but it is not an error per se. Probably, the program finished successfully, but some result values may be suspect."; |
- } |
- } |
+ if (possibleBadModelRun) { |
+ badModelMessage += "##\nThe WEPS model executable stderr file contained: "; |
+ badModelMessage += ((stdErrorFile.contains("IEEE_UNDERFLOW_FLAG")) ? "\nIEEE_UNDERFLOW_FLAG, Meaning that some values were rounded to zero because they were too small for the FORTRAN code to interpret." : ""); |
+ if (badModelMessage.contains("IEEE")) { |
+ badModelMessage += "\n AND "; |
+ } |
+ badModelMessage += ((stdErrorFile.contains("IEEE_DENORMAL")) ? "\nIEEE_DENORMAL, Meaning that there are denormal numbers generated when running the code." : ""); |
+ badModelMessage += "\n This may be a hint about numerical problems in the model FORTRAN code, but it is not an error per se. Probably, the program finished successfully, but some result values may be suspect."; |
+ } |
+ } |
|
// try { |
// management = getManagementFile(fileData); |
@@ -85,365 +85,483 @@ |
// badModelMessage += "##\n"; |
// badModelMessage += ex.getMessage(); |
// } |
+ try { |
+ windData = getWindDataFile(fileData); |
+ } catch (IOException ex) { |
+ badModelRun = true; |
+ badModelMessage += "##\n"; |
+ badModelMessage += ex.getMessage(); |
+ } |
|
- try { |
- windData = getWindDataFile(fileData); |
- } catch (IOException ex) { |
- badModelRun = true; |
- badModelMessage += "##\n"; |
- badModelMessage += ex.getMessage(); |
- } |
+ if (windData.badWindData()) { |
+ badModelMessage += "##\nThe Wind data associated with this model run has some qualifying messages: \n" + windData.windDataMessages(); |
+ } |
|
- if (windData.badWindData()) { |
- badModelMessage += "##\nThe Wind data associated with this model run has some qualifying messages: \n" + windData.windDataMessages(); |
- } |
+ try { |
+ cligenData = getClimateDataFile(fileData); |
+ } catch (IOException ex) { |
+ badModelRun = true; |
+ badModelMessage += "##\n"; |
+ badModelMessage += ex.getMessage(); |
+ } |
|
- try { |
- cligenData = getClimateDataFile(fileData); |
- } catch (IOException ex) { |
- badModelRun = true; |
- badModelMessage += "##\n"; |
- badModelMessage += ex.getMessage(); |
- } |
+ if (cligenData.badClimateData()) { |
+ badModelMessage += "##\nThe Cligen data associated with this model run has some qualifying messages: \n" + cligenData.cligenDataMessages(); |
+ } |
|
- if (cligenData.badClimateData()) { |
- badModelMessage += "##\nThe Cligen data associated with this model run has some qualifying messages: \n" + cligenData.cligenDataMessages(); |
- } |
+ try { |
+ stdOutFile = getStdOutFile(fileData); |
+ } catch (IOException ex) { |
+ badModelRun = true; |
+ badModelMessage += "##\n"; |
+ badModelMessage += ex.getMessage(); |
+ } |
|
- try { |
- stdOutFile = getStdOutFile(fileData); |
- } catch (IOException ex) { |
- badModelRun = true; |
- badModelMessage += "##\n"; |
- badModelMessage += ex.getMessage(); |
- } |
+ try { |
+ ifcFile = getIFCFile(fileData); |
+ } catch (IOException ex) { |
+ badModelRun = true; |
+ badModelMessage += "##\n"; |
+ badModelMessage += ex.getMessage(); |
+ } |
|
- try { |
- ifcFile = getIFCFile(fileData); |
- } catch (IOException ex) { |
- badModelRun = true; |
- badModelMessage += "##\n"; |
- badModelMessage += ex.getMessage(); |
- } |
- |
- if (!badModelRun && badModelMessage.isEmpty()) { |
- calcWEPSMetaData(); |
- } |
+ if (!badModelRun && badModelMessage.isEmpty()) { |
+ calcWEPSMetaData(); |
+ } |
} |
|
public boolean questionableResults() { |
- return possibleBadModelRun; |
+ return possibleBadModelRun; |
} |
|
public boolean badModelRun() { |
- return badModelRun; |
+ return badModelRun; |
} |
|
public String badModelMessage() { |
- return badModelMessage; |
+ return badModelMessage; |
} |
|
public IFCFile iFCFile() { |
- return ifcFile; |
+ return ifcFile; |
} |
|
public WindGenData windData() { |
- return windData; |
+ return windData; |
} |
|
public CligenData cligenData() { |
- return cligenData; |
+ return cligenData; |
} |
|
public String stdErrorFile() { |
- return stdErrorFile; |
+ return stdErrorFile; |
} |
|
public String stdOutFile() { |
- return stdOutFile; |
+ return stdOutFile; |
} |
|
public WEPSMetaData getWEPSMetaData() { |
- return wepsMetaData; |
+ return wepsMetaData; |
} |
|
public void calcWEPSMetaData() { |
- if (null == wepsMetaData) { |
- wepsMetaData = new WEPSMetaData(); |
- } |
+ if (null == wepsMetaData) { |
+ wepsMetaData = new WEPSMetaData(); |
+ } |
|
- wepsMetaData.suid(this.suid); |
- wepsMetaData.annualPrecip(cligenData.annualAvgPrecip()); |
- wepsMetaData.windEnergy(windData.simulationAverage()); |
- wepsMetaData.crustStability(ifcFile.crustStability); |
- wepsMetaData.surfRockFrag(ifcFile.surfaceFragmentCover); |
+ wepsMetaData.suid(this.suid); |
+ wepsMetaData.cokey(getOriginalRequest("soil")); |
+ wepsMetaData.longitude(Double.parseDouble(getOriginalRequest("longitude"))); |
+ wepsMetaData.latitude(Double.parseDouble(getOriginalRequest("latitude"))); |
+ wepsMetaData.annualPrecip(cligenData.annualAvgPrecip()); |
+ wepsMetaData.windEnergy(windData.simulationAverage()); |
+ wepsMetaData.componentName(ifcFile.componentName); |
+ wepsMetaData.fractionSand(ifcFile.fractionSand); |
+ wepsMetaData.fractionSilt(ifcFile.fractionSilt); |
+ wepsMetaData.fractionClay(ifcFile.fractionClay); |
+ wepsMetaData.crustStability(ifcFile.crustStability); |
+ wepsMetaData.surfRockFrag(ifcFile.surfaceFragmentCover); |
+ wepsMetaData.albedo(ifcFile.surfaceAlbedo); |
+ wepsMetaData.num_layers(ifcFile.layerThickness.length); |
+ wepsMetaData.surface_thickness(((int) ifcFile.layerThickness[0])); |
+ wepsMetaData.slope_gradient(ifcFile.surfaceSlope); |
|
- //TODO: Do we need to measure the layers before setting these?? WEPSSoilInput already filters/sorts layers, etc... |
- wepsMetaData.aggStability(ifcFile.aggregateStability[0]); |
- wepsMetaData.soilWiltPoint(ifcFile.wiltingPointSWC[0]); |
+ //TODO: Do we need to measure the layers before setting these?? WEPSSoilInput already filters/sorts layers, etc... |
+ wepsMetaData.aggStability(ifcFile.aggregateStability[0]); |
+ wepsMetaData.soilWiltPoint(ifcFile.wiltingPointSWC[0]); |
|
- String biomass_avg = getOriginalResponse("average_biomass"); |
- if (!biomass_avg.isEmpty()) { |
- wepsMetaData.rotWeightResBiomass(Double.parseDouble(biomass_avg) * 2000); |
- } else { |
- badModelRun = true; |
- badModelMessage += "##\n"; |
- badModelMessage += "Missing biomass_avg result in WEPS output result file."; |
- } |
+ String biomass_avg = getOriginalResponse("average_biomass"); |
+ if (!biomass_avg.isEmpty()) { |
+ wepsMetaData.rotWeightResBiomass(Double.parseDouble(biomass_avg) * 2000); |
+ } else { |
+ badModelRun = true; |
+ badModelMessage += "##\n"; |
+ badModelMessage += "Missing biomass_avg result in WEPS output result file."; |
+ } |
|
- String stir_avg = getOriginalResponse("avg_all_stir"); |
- if (!stir_avg.isEmpty()) { |
- wepsMetaData.rotWeightSoilTillIntensity(Double.parseDouble(stir_avg)); |
- } else { |
- badModelRun = true; |
- badModelMessage += "##\n"; |
- badModelMessage += "Missing avg_all_stir result in WEPS output result file."; |
- } |
+ String stir_avg = getOriginalResponse("avg_all_stir"); |
+ if (!stir_avg.isEmpty()) { |
+ wepsMetaData.rotWeightSoilTillIntensity(Double.parseDouble(stir_avg)); |
+ } else { |
+ badModelRun = true; |
+ badModelMessage += "##\n"; |
+ badModelMessage += "Missing avg_all_stir result in WEPS output result file."; |
+ } |
|
- String wind_eros = getOriginalResponse("wind_eros"); |
- if (!wind_eros.isEmpty()) { |
- wepsMetaData.errosionRate(Double.parseDouble(wind_eros)); |
- } else { |
- badModelRun = true; |
- badModelMessage += "##\n"; |
- badModelMessage += "Missing wind_eros result in WEPS output result file."; |
- } |
- |
+ String wind_eros = getOriginalResponse("wind_eros"); |
+ if (!wind_eros.isEmpty()) { |
+ wepsMetaData.errosionRate(Double.parseDouble(wind_eros)); |
+ } else { |
+ badModelRun = true; |
+ badModelMessage += "##\n"; |
+ badModelMessage += "Missing wind_eros result in WEPS output result file."; |
+ } |
+ |
wepsMetaData.errorMessages(badModelMessage); |
|
} |
|
private WEPSManagement getManagementFile(byte[] fileData) throws IOException { |
- WEPSManagement wepsManagement = new WEPSManagement(new Urls()); |
+ WEPSManagement wepsManagement = new WEPSManagement(new Urls()); |
|
- File managementFile = new File("management.man"); |
- BufferedWriter bufferWriter = Files.newBufferedWriter(managementFile.toPath()); |
- String data = getFileContents(fileData, ".man"); |
- bufferWriter.write(data); |
- bufferWriter.flush(); |
- bufferWriter.close(); |
+ File managementFile = new File("management.man"); |
+ BufferedWriter bufferWriter = Files.newBufferedWriter(managementFile.toPath()); |
+ String data = getFileContents(fileData, ".man"); |
+ bufferWriter.write(data); |
+ bufferWriter.flush(); |
+ bufferWriter.close(); |
|
- try { |
- wepsManagement.readManData(managementFile); |
- } catch (ParserException | ServiceException ex) { |
- Logger.getLogger(WEPSModelArchive.class.getName()).log(Level.SEVERE, null, ex); |
- badModelRun = true; |
- badModelMessage += "##\n"; |
- badModelMessage += "Error parsing the WEPS management file: " + ex.getMessage(); |
- } |
+ try { |
+ wepsManagement.readManData(managementFile); |
+ } catch (ParserException | ServiceException ex) { |
+ Logger.getLogger(WEPSModelArchive.class.getName()).log(Level.SEVERE, null, ex); |
+ badModelRun = true; |
+ badModelMessage += "##\n"; |
+ badModelMessage += "Error parsing the WEPS management file: " + ex.getMessage(); |
+ } |
|
- return wepsManagement; |
+ return wepsManagement; |
} |
|
private WindGenData getWindDataFile(byte[] fileData) throws IOException { |
- WindGenData wind; |
+ WindGenData wind; |
|
- wind = new WindGenData(getFileContents(fileData, ".win")); |
+ wind = new WindGenData(getFileContents(fileData, ".win")); |
|
- return wind; |
+ return wind; |
} |
|
private CligenData getClimateDataFile(byte[] fileData) throws IOException { |
- CligenData climate; |
+ CligenData climate; |
|
- climate = new CligenData(getFileContents(fileData, ".cli")); |
+ climate = new CligenData(getFileContents(fileData, ".cli")); |
|
- return climate; |
+ return climate; |
} |
|
private IFCFile getIFCFile(byte[] fileData) throws IOException { |
- IFCFile requestData; |
+ IFCFile requestData; |
|
- requestData = new IFCFile(getFileContents(fileData, ".ifc")); |
+ requestData = new IFCFile(getFileContents(fileData, ".ifc")); |
|
- return requestData; |
+ return requestData; |
} |
|
private String getStdErrorFile(byte[] fileData) throws IOException { |
- String fileString = null; |
+ String fileString = null; |
|
- try (ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(fileData))) { |
- ZipEntry entry; |
+ try (ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(fileData))) { |
+ ZipEntry entry; |
|
- while ((entry = zin.getNextEntry()) != null) { |
- if (entry.getName().contains("weps.") && entry.getName().contains("stderr.txt")) { |
- BufferedReader bReader = new BufferedReader(new InputStreamReader(zin)); |
- StringBuilder fileContent = new StringBuilder(); |
- String inputStr; |
- while ((inputStr = bReader.readLine()) != null) { |
- fileContent.append(inputStr).append(System.lineSeparator()); |
- } |
- fileString = fileContent.toString(); |
- break; |
- } |
- } |
- } |
+ while ((entry = zin.getNextEntry()) != null) { |
+ if (entry.getName().contains("weps.") && entry.getName().contains("stderr.txt")) { |
+ BufferedReader bReader = new BufferedReader(new InputStreamReader(zin)); |
+ StringBuilder fileContent = new StringBuilder(); |
+ String inputStr; |
+ while ((inputStr = bReader.readLine()) != null) { |
+ fileContent.append(inputStr).append(System.lineSeparator()); |
+ } |
+ fileString = fileContent.toString(); |
+ break; |
+ } |
+ } |
+ } |
|
- return fileString; |
+ return fileString; |
} |
|
private String getStdOutFile(byte[] fileData) throws IOException { |
- String fileString = null; |
+ String fileString = null; |
|
- try (ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(fileData))) { |
- ZipEntry entry; |
+ try (ZipInputStream zin = new ZipInputStream(new ByteArrayInputStream(fileData))) { |
+ ZipEntry entry; |
|
- while ((entry = zin.getNextEntry()) != null) { |
- if (entry.getName().contains("weps.exe") && entry.getName().contains("stdout.txt")) { |
- BufferedReader bReader = new BufferedReader(new InputStreamReader(zin)); |
- StringBuilder fileContent = new StringBuilder(); |
- String inputStr; |
- while ((inputStr = bReader.readLine()) != null) { |
- fileContent.append(inputStr).append(System.lineSeparator()); |
- } |
- fileString = fileContent.toString(); |
- break; |
- } |
- } |
- } |
+ while ((entry = zin.getNextEntry()) != null) { |
+ if (entry.getName().contains("weps.exe") && entry.getName().contains("stdout.txt")) { |
+ BufferedReader bReader = new BufferedReader(new InputStreamReader(zin)); |
+ StringBuilder fileContent = new StringBuilder(); |
+ String inputStr; |
+ while ((inputStr = bReader.readLine()) != null) { |
+ fileContent.append(inputStr).append(System.lineSeparator()); |
+ } |
+ fileString = fileContent.toString(); |
+ break; |
+ } |
+ } |
+ } |
|
- return fileString; |
+ return fileString; |
} |
|
public class WEPSMetaData { |
|
- private double windEnergy; |
- private double annualPrecip; |
- private double rotIrrEffect; |
- private double soilWiltPoint; |
- private double rotWeightResBiomass; |
- private double rotWeightSoilTillIntensity; |
- private double rotWeightResAddition; |
- private double aggStability; |
- private double crustStability; |
- private double surfRockFrag; |
- private double errosionRate; |
- private String suid; |
+ private double latitude; |
+ private double longitude; |
+ private String cokey; |
+ private double windEnergy; |
+ private double annualPrecip; |
+ private double rotIrrEffect; |
+ private double soilWiltPoint; |
+ private double rotWeightResBiomass; |
+ private double rotWeightSoilTillIntensity; |
+ private double rotWeightResAddition; |
+ private double aggStability; |
+ private double crustStability; |
+ private double surfRockFrag; |
+ private double errosionRate; |
+ private String componentName; |
+ private double[] fractionSand; |
+ private double[] fractionSilt; |
+ private double[] fractionClay; |
+ private double albedo; |
+ private double slope_gradient; |
+ private int surface_thickness; |
+ private int num_layers; |
+ private String suid; |
private String errorMessages = ""; |
|
- public String errorMessages(){ |
+ public String errorMessages() { |
return errorMessages; |
} |
- |
- public void errorMessages(String value){ |
+ |
+ public void errorMessages(String value) { |
errorMessages = value; |
} |
- |
- public String suid() { |
- return suid; |
- } |
|
- public void suid(String value) { |
- suid = value; |
- } |
+ public String suid() { |
+ return suid; |
+ } |
|
- public double windEnergy() { |
- return windEnergy; |
- } |
+ public void suid(String value) { |
+ suid = value; |
+ } |
|
- public double annualPrecip() { |
- return annualPrecip; |
- } |
+ public double windEnergy() { |
+ return windEnergy; |
+ } |
|
- public double rotIrrEffect() { |
- return rotIrrEffect; |
- } |
+ public double annualPrecip() { |
+ return annualPrecip; |
+ } |
|
- public double soilWiltPoint() { |
- return rotIrrEffect; |
- } |
+ public double rotIrrEffect() { |
+ return rotIrrEffect; |
+ } |
|
- public double rotWeightResBiomass() { |
- return rotWeightResBiomass; |
- } |
+ public double soilWiltPoint() { |
+ return rotIrrEffect; |
+ } |
|
- public double rotWeightSoilTillIntensity() { |
- return rotWeightSoilTillIntensity; |
- } |
+ public double rotWeightResBiomass() { |
+ return rotWeightResBiomass; |
+ } |
|
- public double rotWeightResAddition() { |
- return rotWeightResAddition; |
- } |
+ public double rotWeightSoilTillIntensity() { |
+ return rotWeightSoilTillIntensity; |
+ } |
|
- public double aggStability() { |
- return aggStability; |
- } |
+ public double rotWeightResAddition() { |
+ return rotWeightResAddition; |
+ } |
|
- public double crustStability() { |
- return crustStability; |
- } |
+ public double aggStability() { |
+ return aggStability; |
+ } |
|
- public double surfRockFrag() { |
- return surfRockFrag; |
- } |
+ public double crustStability() { |
+ return crustStability; |
+ } |
|
- public double errosionRate() { |
- return errosionRate; |
- } |
+ public double surfRockFrag() { |
+ return surfRockFrag; |
+ } |
|
- public void windEnergy(double value) { |
- windEnergy = value; |
- } |
+ public double errosionRate() { |
+ return errosionRate; |
+ } |
|
- public void annualPrecip(double value) { |
- annualPrecip = value; |
- } |
+ public void windEnergy(double value) { |
+ windEnergy = value; |
+ } |
|
- public void rotIrrEffect(double value) { |
- rotIrrEffect = value; |
- } |
+ public void annualPrecip(double value) { |
+ annualPrecip = value; |
+ } |
|
- public void soilWiltPoint(double value) { |
- rotIrrEffect = value; |
- } |
+ public void rotIrrEffect(double value) { |
+ rotIrrEffect = value; |
+ } |
|
- public void rotWeightResBiomass(double value) { |
- rotWeightResBiomass = value; |
- } |
+ public void soilWiltPoint(double value) { |
+ rotIrrEffect = value; |
+ } |
|
- public void rotWeightSoilTillIntensity(double value) { |
- rotWeightSoilTillIntensity = value; |
- } |
+ public void rotWeightResBiomass(double value) { |
+ rotWeightResBiomass = value; |
+ } |
|
- public void rotWeightResAddition(double value) { |
- rotWeightResAddition = value; |
- } |
+ public void rotWeightSoilTillIntensity(double value) { |
+ rotWeightSoilTillIntensity = value; |
+ } |
|
- public void aggStability(double value) { |
- aggStability = value; |
- } |
+ public void rotWeightResAddition(double value) { |
+ rotWeightResAddition = value; |
+ } |
|
- public void crustStability(double value) { |
- crustStability = value; |
- } |
+ public void aggStability(double value) { |
+ aggStability = value; |
+ } |
|
- public void surfRockFrag(double value) { |
- surfRockFrag = value; |
- } |
+ public void crustStability(double value) { |
+ crustStability = value; |
+ } |
|
- public void errosionRate(double value) { |
- errosionRate = value; |
- } |
+ public void surfRockFrag(double value) { |
+ surfRockFrag = value; |
+ } |
|
- public JSONArray toJSON() throws JSONException { |
- JSONArray ret_val = new JSONArray(); |
- JSONObject results = new JSONObject(); |
+ public void errosionRate(double value) { |
+ errosionRate = value; |
+ } |
|
- results.put("weps_archive_suid", wepsMetaData.suid()); |
- results.put("annual_precipitation", wepsMetaData.annualPrecip()); |
- results.put("wind_energy", wepsMetaData.windEnergy()); |
- results.put("crust_stability", wepsMetaData.crustStability()); |
- results.put("surface_rock_fragments", wepsMetaData.surfRockFrag()); |
- results.put("aggregate_stability", wepsMetaData.aggStability()); |
- results.put("soil_wilting_poiont", wepsMetaData.soilWiltPoint()); |
- results.put("rotation_weighted_biomass", wepsMetaData.rotWeightResBiomass()); |
- results.put("annual_precipitation", wepsMetaData.annualPrecip()); |
+ public String componentName() { |
+ return componentName; |
+ } |
|
- results.put("rotation_weighted_soil_tillage_intensity", wepsMetaData.rotWeightSoilTillIntensity()); |
- results.put("erosion_rate", wepsMetaData.errosionRate()); |
+ public double fractionSand(int index) { |
+ if ((null != fractionSand) && (index < fractionSand.length)) { |
+ return fractionSand[index]; |
+ } |
+ return Double.NaN; |
+ } |
|
- ret_val.put(results); |
- return ret_val; |
- } |
+ public double fractionSilt(int index) { |
+ if ((null != fractionSand) && (index < fractionSilt.length)) { |
+ return fractionSilt[index]; |
+ } |
+ return Double.NaN; |
+ } |
+ |
+ public double fractionClay(int index) { |
+ if ((null != fractionSand) && (index < fractionClay.length)) { |
+ return fractionClay[index]; |
+ } |
+ return Double.NaN; |
+ } |
+ |
+ public void componentName(String value) { |
+ componentName = value; |
+ } |
+ |
+ public void fractionSand(double[] value) { |
+ fractionSand = value; |
+ } |
+ |
+ public void fractionSilt(double[] value) { |
+ fractionSilt = value; |
+ } |
+ |
+ public void fractionClay(double[] value) { |
+ fractionClay = value; |
+ } |
+ |
+ public void albedo(double value) { |
+ albedo = value; |
+ } |
+ |
+ public void slope_gradient(double value) { |
+ slope_gradient = value; |
+ } |
+ |
+ public void surface_thickness(int value) { |
+ surface_thickness = value; |
+ } |
+ |
+ public void num_layers(int value) { |
+ num_layers = value; |
+ } |
+ |
+ public double albedo() { |
+ return albedo; |
+ } |
+ |
+ public double slope_gradient() { |
+ return slope_gradient; |
+ } |
+ |
+ public int surface_thickness() { |
+ return surface_thickness; |
+ } |
+ |
+ public int num_layers() { |
+ return num_layers; |
+ } |
+ |
+ public double latitude() { |
+ return latitude; |
+ } |
+ |
+ public double longitude() { |
+ return longitude; |
+ } |
+ |
+ public String cokey() { |
+ return cokey; |
+ } |
+ |
+ public void latitude(double value) { |
+ latitude = value; |
+ } |
+ |
+ public void longitude(double value) { |
+ longitude = value; |
+ } |
+ |
+ public void cokey(String value) { |
+ cokey = value; |
+ } |
+ |
+ public JSONArray toJSON() throws JSONException { |
+ JSONArray ret_val = new JSONArray(); |
+ JSONObject results = new JSONObject(); |
+ |
+ results.put("weps_archive_suid", wepsMetaData.suid()); |
+ results.put("annual_precipitation", wepsMetaData.annualPrecip()); |
+ results.put("wind_energy", wepsMetaData.windEnergy()); |
+ results.put("crust_stability", wepsMetaData.crustStability()); |
+ results.put("surface_rock_fragments", wepsMetaData.surfRockFrag()); |
+ results.put("aggregate_stability", wepsMetaData.aggStability()); |
+ results.put("soil_wilting_poiont", wepsMetaData.soilWiltPoint()); |
+ results.put("rotation_weighted_biomass", wepsMetaData.rotWeightResBiomass()); |
+ results.put("annual_precipitation", wepsMetaData.annualPrecip()); |
+ |
+ results.put("rotation_weighted_soil_tillage_intensity", wepsMetaData.rotWeightSoilTillIntensity()); |
+ results.put("erosion_rate", wepsMetaData.errosionRate()); |
+ |
+ ret_val.put(results); |
+ return ret_val; |
+ } |
} |
} |