JAL-1720 JAL-2002 improvement for 'uniprot coverage' filter using facet pivot query
[jalview.git] / src / jalview / ws / uimodel / PDBRestRequest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3  * Copyright (C) 2014 The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
7  * Jalview is free software: you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License 
9  * as published by the Free Software Foundation, either version 3
10  * of the License, or (at your option) any later version.
11  *  
12  * Jalview is distributed in the hope that it will be useful, but 
13  * WITHOUT ANY WARRANTY; without even the implied warranty 
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
15  * PURPOSE.  See the GNU General Public License for more details.
16  * 
17  * You should have received a copy of the GNU General Public License
18  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
19  * The Jalview Authors are detailed in the 'AUTHORS' file.
20  */
21
22 package jalview.ws.uimodel;
23
24 import jalview.bin.Cache;
25 import jalview.datamodel.SequenceI;
26 import jalview.ws.dbsources.PDBRestClient.PDBDocField;
27
28 import java.util.Collection;
29
30 /**
31  * Represents the PDB request to be consumed by the PDBRestClient
32  * 
33  * @author tcnofoegbu
34  *
35  */
36 public class PDBRestRequest
37 {
38   private String fieldToSearchBy;
39
40   private String searchTerm;
41
42   private String fieldToSortBy;
43
44   private SequenceI associatedSequence;
45
46   private boolean allowEmptySequence;
47
48   private boolean allowUnpublishedEntries = Cache.getDefault(
49           "ALLOW_UNPUBLISHED_PDB_QUERYING", false);
50
51   private boolean facet;
52
53   private String facetPivot;
54
55   private int facetPivotMinCount;
56
57   private int responseSize;
58
59   private boolean isSortAscending;
60
61   private Collection<PDBDocField> wantedFields;
62
63   public String getFieldToSearchBy()
64   {
65     return fieldToSearchBy;
66   }
67
68   public void setFieldToSearchBy(String fieldToSearchBy)
69   {
70     this.fieldToSearchBy = fieldToSearchBy;
71   }
72
73   public String getSearchTerm()
74   {
75     return searchTerm;
76   }
77
78   public void setSearchTerm(String searchTerm)
79   {
80     this.searchTerm = searchTerm;
81   }
82
83   public boolean isAllowEmptySeq()
84   {
85     return allowEmptySequence;
86   }
87
88   public void setAllowEmptySeq(boolean allowEmptySeq)
89   {
90     this.allowEmptySequence = allowEmptySeq;
91   }
92
93   public int getResponseSize()
94   {
95     return responseSize;
96   }
97
98   public void setResponseSize(int responseSize)
99   {
100     this.responseSize = responseSize;
101   }
102
103   public Collection<PDBDocField> getWantedFields()
104   {
105     return wantedFields;
106   }
107
108   public void setWantedFields(Collection<PDBDocField> wantedFields)
109   {
110     this.wantedFields = wantedFields;
111   }
112
113   public String getFieldToSortBy()
114   {
115     return fieldToSortBy;
116   }
117
118   public void setFieldToSortBy(String fieldToSortBy, boolean isSortAscending)
119   {
120     this.fieldToSortBy = fieldToSortBy;
121     this.isSortAscending = isSortAscending;
122   }
123
124   public boolean isAscending()
125   {
126     return isSortAscending;
127   }
128
129   public SequenceI getAssociatedSequence()
130   {
131     return associatedSequence;
132   }
133
134   public void setAssociatedSequence(SequenceI associatedSequence)
135   {
136     this.associatedSequence = associatedSequence;
137   }
138
139   public String getQuery()
140   {
141     return fieldToSearchBy + searchTerm
142             + (isAllowEmptySeq() ? "" : " AND molecule_sequence:['' TO *]")
143             + (isAllowUnpublishedEntries() ? "" : " AND status:REL");
144   }
145
146   @Override
147   public String toString()
148   {
149     return "Query : " + getQuery() + " sort field: " + fieldToSortBy
150             + " isAsc: " + isAscending() + " Associated Seq : "
151             + associatedSequence;
152   }
153
154   public boolean isAllowUnpublishedEntries()
155   {
156     return allowUnpublishedEntries;
157   }
158
159   public void setAllowUnpublishedEntries(boolean allowUnpublishedEntries)
160   {
161     this.allowUnpublishedEntries = allowUnpublishedEntries;
162   }
163
164   public boolean isFacet()
165   {
166     return facet;
167   }
168
169   public void setFacet(boolean facet)
170   {
171     this.facet = facet;
172   }
173
174   public String getFacetPivot()
175   {
176     return facetPivot;
177   }
178
179   public void setFacetPivot(String facetPivot)
180   {
181     this.facetPivot = facetPivot;
182   }
183
184   public int getFacetPivotMinCount()
185   {
186     return facetPivotMinCount;
187   }
188
189   public void setFacetPivotMinCount(int facetPivotMinCount)
190   {
191     this.facetPivotMinCount = facetPivotMinCount;
192   }
193 }