JAL-1852 disable querying of unpublished PDB entries by default
[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.datamodel.SequenceI;
25 import jalview.ws.dbsources.PDBRestClient.PDBDocField;
26
27 import java.util.Collection;
28
29 /**
30  * Represents the PDB request to be consumed by the PDBRestClient
31  * 
32  * @author tcnofoegbu
33  *
34  */
35 public class PDBRestRequest
36 {
37   private String fieldToSearchBy;
38
39   private String searchTerm;
40
41   private String fieldToSortBy;
42
43   private SequenceI associatedSequence;
44
45   private boolean allowEmptySequence;
46
47   private boolean allowUnpublishedEntries;
48
49   private int responseSize;
50
51   private boolean isSortAscending;
52
53   private Collection<PDBDocField> wantedFields;// = new
54                                                // Collection<PDBDocField>();
55
56   public String getFieldToSearchBy()
57   {
58     return fieldToSearchBy;
59   }
60
61   public void setFieldToSearchBy(String fieldToSearchBy)
62   {
63     this.fieldToSearchBy = fieldToSearchBy;
64   }
65
66   public String getSearchTerm()
67   {
68     return searchTerm;
69   }
70
71   public void setSearchTerm(String searchTerm)
72   {
73     this.searchTerm = searchTerm;
74   }
75
76   public boolean isAllowEmptySeq()
77   {
78     return allowEmptySequence;
79   }
80
81   public void setAllowEmptySeq(boolean allowEmptySeq)
82   {
83     this.allowEmptySequence = allowEmptySeq;
84   }
85
86   public int getResponseSize()
87   {
88     return responseSize;
89   }
90
91   public void setResponseSize(int responseSize)
92   {
93     this.responseSize = responseSize;
94   }
95
96   public Collection<PDBDocField> getWantedFields()
97   {
98     return wantedFields;
99   }
100
101   public void setWantedFields(Collection<PDBDocField> wantedFields)
102   {
103     this.wantedFields = wantedFields;
104   }
105
106   public String getFieldToSortBy()
107   {
108     return fieldToSortBy;
109   }
110
111   public void setFieldToSortBy(String fieldToSortBy, boolean isSortAscending)
112   {
113     this.fieldToSortBy = fieldToSortBy;
114     this.isSortAscending = isSortAscending;
115   }
116
117   public boolean isAscending()
118   {
119     return isSortAscending;
120   }
121
122   public SequenceI getAssociatedSequence()
123   {
124     return associatedSequence;
125   }
126
127   public void setAssociatedSequence(SequenceI associatedSequence)
128   {
129     this.associatedSequence = associatedSequence;
130   }
131
132   public String getQuery()
133   {
134     return fieldToSearchBy + searchTerm
135             + (isAllowEmptySeq() ? "" : " AND molecule_sequence:['' TO *]")
136             + (isAllowUnpublishedEntries() ? "" : " AND status:REL");
137   }
138
139   public String toString()
140   {
141     return "Query : " + getQuery() + " sort field: " + fieldToSortBy
142             + " isAsc: " + isAscending() + " Associated Seq : "
143             + associatedSequence;
144   }
145
146   public boolean isAllowUnpublishedEntries()
147   {
148     return allowUnpublishedEntries;
149   }
150
151   public void setAllowUnpublishedEntries(boolean allowUnpublishedEntries)
152   {
153     this.allowUnpublishedEntries = allowUnpublishedEntries;
154   }
155 }