Skip to content

Commit

Permalink
Updates to viewDataSet to support catalog tool updates
Browse files Browse the repository at this point in the history
* Update how the metadata is parsed from Solr
* Quiet logging

refs NASA-PDS/registry-pds3-catalog#16
  • Loading branch information
jordanpadams committed May 31, 2024
1 parent d17f60d commit b19d27f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 68 deletions.
82 changes: 42 additions & 40 deletions src/main/java/gov/nasa/pds/dsview/registry/PDS3Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.TimeZone;
import java.util.logging.Logger;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.impl.Http2SolrClient;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrDocument;
import org.apache.solr.common.SolrDocumentList;
Expand Down Expand Up @@ -58,10 +58,10 @@ public PDS3Search(String url) {
}

public SolrDocumentList getDataSetList() throws SolrServerException, IOException {
HttpSolrClient solr = null;
Http2SolrClient solr = null;

try {
solr = new HttpSolrClient.Builder(solrServerUrl).build();
solr = new Http2SolrClient.Builder(solrServerUrl).build();

ModifiableSolrParams params = new ModifiableSolrParams();

Expand All @@ -87,11 +87,11 @@ public SolrDocumentList getDataSetList() throws SolrServerException, IOException
int idx = 0;
while (itr.hasNext()) {
SolrDocument doc = itr.next();
log.info("***************** idx = " + (idx++));
log.fine("***************** idx = " + (idx++));
// log.info(doc.toString());

for (Map.Entry<String, Object> entry : doc.entrySet()) {
log.info("Key = " + entry.getKey()
log.fine("Key = " + entry.getKey()
+ " Value = " + entry.getValue());
}
}
Expand All @@ -102,10 +102,10 @@ public SolrDocumentList getDataSetList() throws SolrServerException, IOException
}

public SolrDocument getDataSet(String identifier) throws SolrServerException, IOException {
HttpSolrClient solr = null;
Http2SolrClient solr = null;

try {
solr = new HttpSolrClient.Builder(solrServerUrl).build();
solr = new Http2SolrClient.Builder(solrServerUrl).build();

ModifiableSolrParams params = new ModifiableSolrParams();

Expand All @@ -121,19 +121,20 @@ public SolrDocument getDataSet(String identifier) throws SolrServerException, IO
org.apache.solr.client.solrj.SolrRequest.METHOD.GET);

SolrDocumentList solrResults = response.getResults();
log.info("numFound = " + solrResults.getNumFound() + " maxScores = " + solrResults.getMaxScore());
log.fine("numFound = " + solrResults.getNumFound() + " maxScores = "
+ solrResults.getMaxScore());

Iterator<SolrDocument> itr = solrResults.iterator();
SolrDocument doc = null;
int idx = 0, returnIdx = 0;
List<SolrDocument> dsDocs = new ArrayList<SolrDocument>();
while (itr.hasNext()) {
doc = itr.next();
log.info("***************** idx = " + idx);
log.fine("***************** idx = " + idx);

for (Map.Entry<String, Object> entry : doc.entrySet()) {
String key = entry.getKey();
log.info("Key = " + key
log.fine("Key = " + key
+ " Value = " + entry.getValue());
String value = entry.getValue().toString();

Expand All @@ -157,10 +158,10 @@ public SolrDocument getDataSet(String identifier) throws SolrServerException, IO
}

public SolrDocument getMission(String identifier) throws SolrServerException, IOException {
HttpSolrClient solr = null;
Http2SolrClient solr = null;

try {
solr = new HttpSolrClient.Builder(solrServerUrl).build();
solr = new Http2SolrClient.Builder(solrServerUrl).build();

ModifiableSolrParams params = new ModifiableSolrParams();

Expand All @@ -175,19 +176,19 @@ public SolrDocument getMission(String identifier) throws SolrServerException, IO
org.apache.solr.client.solrj.SolrRequest.METHOD.GET);

SolrDocumentList solrResults = response.getResults();
log.info("numFound = " + solrResults.getNumFound());
log.fine("numFound = " + solrResults.getNumFound());

Iterator<SolrDocument> itr = solrResults.iterator();
SolrDocument doc = null;
int idx = 0;
List<SolrDocument> instDocs = new ArrayList<SolrDocument>();
while (itr.hasNext()) {
doc = itr.next();
log.info("***************** idx = " + (idx++));
log.fine("***************** idx = " + (idx++));
// log.info(doc.toString());

for (Map.Entry<String, Object> entry : doc.entrySet()) {
log.info("Key = " + entry.getKey()
log.fine("Key = " + entry.getKey()
+ " Value = " + entry.getValue());
}
instDocs.add(doc);
Expand All @@ -200,10 +201,10 @@ public SolrDocument getMission(String identifier) throws SolrServerException, IO
}

public SolrDocument getInstHost(String identifier) throws SolrServerException, IOException {
HttpSolrClient solr = null;
Http2SolrClient solr = null;

try {
solr = new HttpSolrClient.Builder(solrServerUrl).build();
solr = new Http2SolrClient.Builder(solrServerUrl).build();

ModifiableSolrParams params = new ModifiableSolrParams();

Expand All @@ -219,19 +220,19 @@ public SolrDocument getInstHost(String identifier) throws SolrServerException, I
org.apache.solr.client.solrj.SolrRequest.METHOD.GET);

SolrDocumentList solrResults = response.getResults();
log.info("numFound = " + solrResults.getNumFound());
log.fine("numFound = " + solrResults.getNumFound());

Iterator<SolrDocument> itr = solrResults.iterator();
SolrDocument doc = null;
int idx = 0;
List<SolrDocument> instDocs = new ArrayList<SolrDocument>();
while (itr.hasNext()) {
doc = itr.next();
log.info("***************** idx = " + (idx++));
log.fine("***************** idx = " + (idx++));
// log.info(doc.toString());

for (Map.Entry<String, Object> entry : doc.entrySet()) {
log.info("Key = " + entry.getKey()
log.fine("Key = " + entry.getKey()
+ " Value = " + entry.getValue());
}
instDocs.add(doc);
Expand All @@ -244,10 +245,10 @@ public SolrDocument getInstHost(String identifier) throws SolrServerException, I
}

public List<SolrDocument> getInst(String identifier) throws SolrServerException, IOException {
HttpSolrClient solr = null;
Http2SolrClient solr = null;

try {
solr = new HttpSolrClient.Builder(solrServerUrl).build();
solr = new Http2SolrClient.Builder(solrServerUrl).build();

ModifiableSolrParams params = new ModifiableSolrParams();

Expand All @@ -270,11 +271,11 @@ public List<SolrDocument> getInst(String identifier) throws SolrServerException,
int idx = 0;
while (itr.hasNext()) {
doc = itr.next();
log.info("***************** idx = " + (idx++));
log.fine("***************** idx = " + (idx++));
// log.info(doc.toString());

for (Map.Entry<String, Object> entry : doc.entrySet()) {
log.info("Key = " + entry.getKey()
log.fine("Key = " + entry.getKey()
+ " Value = " + entry.getValue());
}
instDocs.add(doc);
Expand All @@ -287,10 +288,10 @@ public List<SolrDocument> getInst(String identifier) throws SolrServerException,
}

public SolrDocument getInst(String instId, String instHostId) throws SolrServerException, IOException {
HttpSolrClient solr = null;
Http2SolrClient solr = null;

try {
solr = new HttpSolrClient.Builder(solrServerUrl).build();
solr = new Http2SolrClient.Builder(solrServerUrl).build();

ModifiableSolrParams params = new ModifiableSolrParams();

Expand All @@ -312,11 +313,11 @@ public SolrDocument getInst(String instId, String instHostId) throws SolrServerE
int idx = 0;
while (itr.hasNext()) {
doc = itr.next();
log.info("***************** idx = " + (idx++));
log.fine("***************** idx = " + (idx++));
// log.info(doc.toString());

for (Map.Entry<String, Object> entry : doc.entrySet()) {
log.info("Key = " + entry.getKey()
log.fine("Key = " + entry.getKey()
+ " Value = " + entry.getValue());
}
}
Expand All @@ -328,10 +329,10 @@ public SolrDocument getInst(String instId, String instHostId) throws SolrServerE
}

public SolrDocument getTarget(String identifier) throws SolrServerException, IOException {
HttpSolrClient solr = null;
Http2SolrClient solr = null;

try {
solr = new HttpSolrClient.Builder(solrServerUrl).build();
solr = new Http2SolrClient.Builder(solrServerUrl).build();

ModifiableSolrParams params = new ModifiableSolrParams();

Expand All @@ -345,19 +346,19 @@ public SolrDocument getTarget(String identifier) throws SolrServerException, IOE
org.apache.solr.client.solrj.SolrRequest.METHOD.GET);

SolrDocumentList solrResults = response.getResults();
log.info("numFound = " + solrResults.getNumFound());
log.fine("numFound = " + solrResults.getNumFound());

Iterator<SolrDocument> itr = solrResults.iterator();
SolrDocument doc = null;
int idx = 0;
List<SolrDocument> instDocs = new ArrayList<SolrDocument>();
while (itr.hasNext()) {
doc = itr.next();
log.info("***************** idx = " + (idx++));
log.fine("***************** idx = " + (idx++));
// log.info(doc.toString());

for (Map.Entry<String, Object> entry : doc.entrySet()) {
log.info("Key = " + entry.getKey()
log.fine("Key = " + entry.getKey()
+ " Value = " + entry.getValue());
}
instDocs.add(doc);
Expand All @@ -372,10 +373,10 @@ public SolrDocument getTarget(String identifier) throws SolrServerException, IOE
}

public SolrDocument getResource(String identifier) throws SolrServerException, IOException {
HttpSolrClient solr = null;
Http2SolrClient solr = null;

try {
solr = new HttpSolrClient.Builder(solrServerUrl).build();
solr = new Http2SolrClient.Builder(solrServerUrl).build();

ModifiableSolrParams params = new ModifiableSolrParams();

Expand All @@ -389,19 +390,19 @@ public SolrDocument getResource(String identifier) throws SolrServerException, I
org.apache.solr.client.solrj.SolrRequest.METHOD.GET);

SolrDocumentList solrResults = response.getResults();
log.info("numFound = " + solrResults.getNumFound());
log.fine("numFound = " + solrResults.getNumFound());

Iterator<SolrDocument> itr = solrResults.iterator();
SolrDocument doc = null;
int idx = 0;
//List<SolrDocument> instDocs = new ArrayList<SolrDocument>();
while (itr.hasNext()) {
doc = itr.next();
log.info("***************** idx = " + (idx++));
log.fine("***************** idx = " + (idx++));
// log.info(doc.toString());

for (Map.Entry<String, Object> entry : doc.entrySet()) {
log.info("Key = " + entry.getKey()
log.fine("Key = " + entry.getKey()
+ " Value = " + entry.getValue());
}
}
Expand Down Expand Up @@ -430,11 +431,12 @@ public List<String> getValues(SolrDocument doc, String key) {
} else {
results.add(dateValue);
}
log.info("key = " + key + " date = " + obj.toString() + " string date = " + dateValue);
log.fine("key = " + key + " date = " + obj.toString() + " string date = "
+ dateValue);
}
else {
results.add((String)obj);
log.info("key = " + key + " obj = " + (String)obj);
log.fine("key = " + key + " obj = " + (String) obj);
}
}
return results;
Expand Down
42 changes: 14 additions & 28 deletions src/main/webapp/pds/viewDataset.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -202,36 +202,22 @@ else {
<tr bgcolor="#E7EEF9">
<td>Search/Access Data</td>
<td>
<%
List<String> rvalues = pds3Search.getValues(doc, "resource_ref");
//List<String> rvalues = pds3Search.getValues(doc, "resource_id");
String resname="", reslink="";
String refLid = "";
if (rvalues !=null) {
for (int i=0; i<rvalues.size(); i++) {
//out.println(rvalues.get(i) + "<br>");
refLid = rvalues.get(i);
if (refLid!=null) {
if (refLid.indexOf("::")!=-1) {
refLid = refLid.substring(0, refLid.indexOf("::"));
}
//refLid = refLid.replace("context_pds3", "context");
SolrDocument refDoc = pds3Search.getResource(refLid);
if (refDoc!=null) {
resname = pds3Search.getValues(refDoc, "resource_name").get(0);
reslink = pds3Search.getValues(refDoc, "resource_url").get(0);
%>
<%
List<String> resnameList = pds3Search.getValues(doc, "resource_name");
List<String> reslinkList = pds3Search.getValues(doc, "resource_url");
String reslink = "";
String resname = "";
if (reslinkList !=null) {
for (int i = 0; i < reslinkList.size(); i++) {
reslink = reslinkList.get(i);
resname = resnameList.get(i);
%>
<li><a href="<%=reslink%>" target="_new"><%=resname%></a><br>
<%
}
else {
resname = refLid;
reslink = refLid;
}
} // end if (refLid!=null)
<%
} // end for
}%>
} // end if
%>
</td>
</tr>

Expand Down

0 comments on commit b19d27f

Please sign in to comment.