+
+ public class PDBResponseSummary
+ {
+ private String pdbId;
+
+ private String summary;
+
+ private int width = 480;
+
+ public PDBResponseSummary(JSONObject doc, List<PDBDocField> diplayFields)
+ {
+ StringBuilder summaryBuilder = new StringBuilder();
+
+ for (PDBDocField field : diplayFields)
+ {
+ if (field.equals(PDBDocField.MOLECULE_TYPE)
+ && doc.get(PDBDocField.MOLECULE_TYPE.getCode()) != null)
+ {
+ String moleculeType = doc
+ .get(PDBDocField.MOLECULE_TYPE.getCode()).toString();
+ if (moleculeType.equalsIgnoreCase("protein"))
+ {
+ summaryBuilder.append("<img src=\""
+ + getClass().getResource("/images/protein.png")
+ .toString() + "\">");
+ }
+ if (moleculeType.equalsIgnoreCase("dna"))
+ {
+ summaryBuilder.append("<img src=\""
+ + getClass().getResource("/images/dna.png").toString()
+ + "\">");
+ }
+ if (moleculeType.equalsIgnoreCase("rna"))
+ {
+ summaryBuilder.append("<img src=\""
+ + getClass().getResource("/images/dna.png").toString()
+ + "\">");
+ }
+ if (moleculeType.equalsIgnoreCase("sugar"))
+ {
+ summaryBuilder.append("<img src=\""
+ + getClass().getResource("/images/sugar.png")
+ .toString() + "\">");
+ }
+ }
+ else if (field.equals(PDBDocField.PDB_ID)
+ && doc.get(PDBDocField.PDB_ID.getCode()) != null)
+ {
+ this.pdbId = doc.get(PDBDocField.PDB_ID.getCode()).toString();
+ }
+ else if (doc.get(field.getCode()) != null)
+ {
+ summaryBuilder.append(field.getName()).append(": ")
+ .append(doc.get(field.getCode())).append(" | ");
+ }
+ }
+ int endIndex = summaryBuilder.lastIndexOf(" | ");
+ String fSummary = summaryBuilder.toString().substring(0, endIndex);
+ this.summary = fSummary.trim();
+ summaryBuilder = null;
+ }
+
+ public String getPdbId()
+ {
+ return pdbId;
+ }
+
+ public void setPdbId(String pdbId)
+ {
+ this.pdbId = pdbId;
+ }
+
+ public String getSummary()
+ {
+ return summary;
+ }
+
+ public void setSummary(String summary)
+ {
+ this.summary = summary;
+ }
+
+ public String toString()
+ {
+ StringBuilder html = new StringBuilder();
+ html.append("<html><div style=\"width:" + width
+ + "; word-wrap: break-word; border-bottom-style: dotted;\"> ");
+ html.append(summary);
+ html.append("</div></html>");
+ return html.toString();
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(this.pdbId, this.summary);
+ }
+ }
+