Skip to content

Commit

Permalink
Merge pull request #1067 from NASA-PDS/i1066
Browse files Browse the repository at this point in the history
Update context config generator for telescopes
  • Loading branch information
jordanpadams authored Nov 18, 2024
2 parents 79b76b5 + 6bf0045 commit b6f8538
Show file tree
Hide file tree
Showing 7 changed files with 11,472 additions and 75 deletions.
54 changes: 27 additions & 27 deletions src/main/java/gov/nasa/pds/validate/ValidateLauncher.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
import gov.nasa.pds.validate.report.XmlReport;
import gov.nasa.pds.validate.util.ToolInfo;
import gov.nasa.pds.validate.util.Utility;
import jdk.internal.org.jline.utils.Log;

/**
* Wrapper class for the Validate Tool. Class handles command-line parsing and querying, in addition
Expand Down Expand Up @@ -593,9 +594,9 @@ private String getSearchAfterFromDocument(Map<String, Object> document, String s
private void parseJsonObjectWriteTofile(List<Map<String, Object>> documents,
String contextJsonFilePath) {
final List<String> empty = Arrays.asList("N/A");
final List<String> fieldNames = Arrays.asList("pds:Airborne.pds", "pds:Facility.pds",
final List<String> fieldNames = Arrays.asList("pds:Facility.pds",
"pds:Instrument.pds", "pds:Instrument_Host.pds", "pds:Investigation.pds",
"pds:Resource.pds", "pds:Target.pds");
"pds:Resource.pds", "pds:Target.pds", "pds:Telescope.pds");
// backup old file
try {
if (registeredProductsFile.exists()) {
Expand All @@ -617,29 +618,32 @@ private void parseJsonObjectWriteTofile(List<Map<String, Object>> documents,
Map<String, Object> properties = (Map<String, Object>) document.get("properties");
@SuppressWarnings("unchecked")
String lidvid = ((List<String>) properties.get("lidvid")).get(0);
@SuppressWarnings("unchecked")
List<String> title = (List<String>) properties.get("title");
for (String fieldName : fieldNames) {
if (properties.containsKey(fieldName + ":name")
|| properties.containsKey(fieldName + ":type")) {
@SuppressWarnings("unchecked")
List<Object> names = (List<Object>) properties.getOrDefault(fieldName + ":name", empty);
@SuppressWarnings("unchecked")
List<Object> types = (List<Object>) properties.getOrDefault(fieldName + ":type", empty);
jsonWriter.beginObject(); // start a product
jsonWriter.name("name");
jsonWriter.beginArray();
for (Object n : names) {
jsonWriter.value((String) n);
}
jsonWriter.endArray();
jsonWriter.name("type");
jsonWriter.beginArray();
for (Object t : types) {
jsonWriter.value((String) t);
if (properties.containsKey(fieldName + ":name")
|| properties.containsKey(fieldName + ":type")
|| properties.containsKey(fieldName + ":aperture")) {
@SuppressWarnings("unchecked")
List<Object> names = (List<Object>) properties.getOrDefault(fieldName + ":name", title);
@SuppressWarnings("unchecked")
List<Object> types = (List<Object>) properties.getOrDefault(fieldName + ":type", empty);
jsonWriter.beginObject(); // start a product
jsonWriter.name("name");
jsonWriter.beginArray();
for (Object n : names) {
jsonWriter.value((String) n);
}
jsonWriter.endArray();
jsonWriter.name("type");
jsonWriter.beginArray();
for (Object t : types) {
jsonWriter.value((String) t);
}
jsonWriter.endArray();
jsonWriter.name("lidvid").value(lidvid);
jsonWriter.endObject(); // end a product
}
jsonWriter.endArray();
jsonWriter.name("lidvid").value(lidvid);
jsonWriter.endObject(); // end a product
}
}
}
jsonWriter.endArray();
Expand All @@ -648,10 +652,6 @@ private void parseJsonObjectWriteTofile(List<Map<String, Object>> documents,
} catch (IOException e) {
e.printStackTrace();
}

// System.out.println("New Registered Products File: " +
// registeredProductsFile);

}

private void copyFile(File source, File dest) throws IOException {
Expand Down
Loading

0 comments on commit b6f8538

Please sign in to comment.