JAL-1720 JAL-2002 improvement for 'uniprot coverage' filter using facet pivot query
[jalview.git] / src / jalview / ws / uimodel / PDBRestRequest.java
index 70dae0b..7bfc226 100644 (file)
@@ -21,7 +21,8 @@
 
 package jalview.ws.uimodel;
 
-
+import jalview.bin.Cache;
+import jalview.datamodel.SequenceI;
 import jalview.ws.dbsources.PDBRestClient.PDBDocField;
 
 import java.util.Collection;
@@ -40,16 +41,24 @@ public class PDBRestRequest
 
   private String fieldToSortBy;
 
-  private String associatedSequence;
+  private SequenceI associatedSequence;
 
   private boolean allowEmptySequence;
 
+  private boolean allowUnpublishedEntries = Cache.getDefault(
+          "ALLOW_UNPUBLISHED_PDB_QUERYING", false);
+
+  private boolean facet;
+
+  private String facetPivot;
+
+  private int facetPivotMinCount;
+
   private int responseSize;
 
   private boolean isSortAscending;
 
-  private Collection<PDBDocField> wantedFields;// = new
-                                               // Collection<PDBDocField>();
+  private Collection<PDBDocField> wantedFields;
 
   public String getFieldToSearchBy()
   {
@@ -117,12 +126,12 @@ public class PDBRestRequest
     return isSortAscending;
   }
 
-  public String getAssociatedSequence()
+  public SequenceI getAssociatedSequence()
   {
     return associatedSequence;
   }
 
-  public void setAssociatedSequence(String associatedSequence)
+  public void setAssociatedSequence(SequenceI associatedSequence)
   {
     this.associatedSequence = associatedSequence;
   }
@@ -130,6 +139,55 @@ public class PDBRestRequest
   public String getQuery()
   {
     return fieldToSearchBy + searchTerm
-            + (isAllowEmptySeq() ? "" : " AND molecule_sequence:['' TO *]");
+            + (isAllowEmptySeq() ? "" : " AND molecule_sequence:['' TO *]")
+            + (isAllowUnpublishedEntries() ? "" : " AND status:REL");
+  }
+
+  @Override
+  public String toString()
+  {
+    return "Query : " + getQuery() + " sort field: " + fieldToSortBy
+            + " isAsc: " + isAscending() + " Associated Seq : "
+            + associatedSequence;
+  }
+
+  public boolean isAllowUnpublishedEntries()
+  {
+    return allowUnpublishedEntries;
+  }
+
+  public void setAllowUnpublishedEntries(boolean allowUnpublishedEntries)
+  {
+    this.allowUnpublishedEntries = allowUnpublishedEntries;
+  }
+
+  public boolean isFacet()
+  {
+    return facet;
+  }
+
+  public void setFacet(boolean facet)
+  {
+    this.facet = facet;
+  }
+
+  public String getFacetPivot()
+  {
+    return facetPivot;
+  }
+
+  public void setFacetPivot(String facetPivot)
+  {
+    this.facetPivot = facetPivot;
+  }
+
+  public int getFacetPivotMinCount()
+  {
+    return facetPivotMinCount;
+  }
+
+  public void setFacetPivotMinCount(int facetPivotMinCount)
+  {
+    this.facetPivotMinCount = facetPivotMinCount;
   }
 }