Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.

Commit 83dc3aa

Browse files
committed
Add derived auto configs, inaccuracy correction
1 parent 5d210cd commit 83dc3aa

5 files changed

Lines changed: 109 additions & 61 deletions

File tree

src/main/java/com/thebluealliance/api/v3/requests/DataRequest.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,36 +56,28 @@ private APIResponse getData(HttpURLConnection con){
5656
* @param urlDirectory URL subdirectory for the query (e.g. <code>/team/frc25</code>)
5757
* @return An {@link APIResponse} object with the API's response
5858
*/
59-
public APIResponse getDataTBA(String urlDirectory){
60-
61-
try {
59+
public APIResponse getDataTBA(String urlDirectory) throws IOException{
60+
6261
URL url;
6362
url = new URL(Constants.TBA_BASE_URL+urlDirectory);
6463
HttpURLConnection con = (HttpURLConnection) url.openConnection();
6564
con.addRequestProperty(Constants.HEADER_AUTH, AUTH_KEY);
6665
return getData(con);
67-
} catch (Exception e) {
68-
e.printStackTrace();
69-
}
70-
return null;
66+
7167
}
7268

7369
/** Retrieves data from TBA API using a URL and a <code>If-Modified-Since</code> header
7470
* @param urlDirectory URL subdirectory for the query (e.g. <code>/team/frc25</code>)
7571
* @param ifModifiedSince Value of the <code>Last-Modified</code> header in the most recently cached response by the client.
7672
* @return An {@link APIResponse} object with the API's response
7773
*/
78-
public APIResponse getDataTBA(String urlDirectory, String ifModifiedSince){
79-
try{
74+
public APIResponse getDataTBA(String urlDirectory, String ifModifiedSince) throws IOException{
8075
URL url = new URL(Constants.TBA_BASE_URL+urlDirectory);
8176
HttpURLConnection con = (HttpURLConnection) url.openConnection();
8277
con.addRequestProperty(Constants.HEADER_AUTH, AUTH_KEY);
8378
con.addRequestProperty(Constants.HEADER_MODIFIED, ifModifiedSince);
8479
return getData(con);
85-
}catch(Exception e){
86-
87-
}
88-
return null;
80+
8981

9082
}
9183

src/main/java/com/thebluealliance/api/v3/requests/DistrictRequest.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.thebluealliance.api.v3.requests;
22

3+
import java.io.IOException;
4+
35
import com.thebluealliance.api.v3.Deserializer;
46
import com.thebluealliance.api.v3.models.*;
57

@@ -20,8 +22,9 @@ public DistrictRequest(DataRequest tba){
2022
*
2123
* @param districtKey TBA District Key, e.g. <code>2016fim</code>
2224
* @return A list of {@link Team} objects in the given district
25+
* @throws IOException
2326
*/
24-
public Team[] getTeams(String districtKey){
27+
public Team[] getTeams(String districtKey) throws IOException{
2528
String directory = "/district/" + districtKey+"/teams";
2629
return Deserializer.toTeamArray(tba
2730
.getDataTBA(directory).getJson());
@@ -31,8 +34,9 @@ public Team[] getTeams(String districtKey){
3134
*
3235
* @param districtKey TBA District Key, e.g. <code>2016fim</code>
3336
* @return A list of {@link SimpleTeam} objects in the given district
37+
* @throws IOException
3438
*/
35-
public SimpleTeam[] getSimpleTeams(String districtKey){
39+
public SimpleTeam[] getSimpleTeams(String districtKey) throws IOException{
3640
String directory = "/district/" + districtKey+"/teams/simple";
3741
return Deserializer.toSimpleTeamArray(tba
3842
.getDataTBA(directory).getJson());
@@ -42,8 +46,9 @@ public SimpleTeam[] getSimpleTeams(String districtKey){
4246
*
4347
* @param districtKey TBA District Key, e.g. <code>2016fim</code>
4448
* @return A list of team keys in the given district
49+
* @throws IOException
4550
*/
46-
public String[] getTeamKeys(String districtKey){
51+
public String[] getTeamKeys(String districtKey) throws IOException{
4752
String directory = "/district/" + districtKey+"/teams/keys";
4853
return Deserializer.toStringArray(tba
4954
.getDataTBA(directory).getJson());
@@ -53,8 +58,9 @@ public String[] getTeamKeys(String districtKey){
5358
*
5459
* @param districtKey TBA District Key, e.g. <code>2016fim</code>
5560
* @return A list of team {@link DistrictRanking}s for the given district
61+
* @throws IOException
5662
*/
57-
public DistrictRanking[] getRankings(String districtKey){
63+
public DistrictRanking[] getRankings(String districtKey) throws IOException{
5864
String directory = "/district/" + districtKey+"/rankings";
5965
return Deserializer.toDistrictRankingArray(tba
6066
.getDataTBA(directory).getJson());
@@ -64,8 +70,9 @@ public DistrictRanking[] getRankings(String districtKey){
6470
*
6571
* @param districtKey TBA District Key, e.g. <code>2016fim</code>
6672
* @return A list of events in the given district
73+
* @throws IOException
6774
*/
68-
public Event[] getEvents(String districtKey){
75+
public Event[] getEvents(String districtKey) throws IOException{
6976
String directory = "/district/" + districtKey + "/events";
7077
return Deserializer.toEventArray(tba
7178
.getDataTBA(directory)
@@ -76,8 +83,9 @@ public Event[] getEvents(String districtKey){
7683
*
7784
* @param districtKey TBA District Key, e.g. <code>2016fim</code>
7885
* @return A short-form list of events in the given district
86+
* @throws IOException
7987
*/
80-
public SimpleEvent[] getSimpleEvents(String districtKey){
88+
public SimpleEvent[] getSimpleEvents(String districtKey) throws IOException{
8189
String directory = "/district/" + districtKey + "/events/simple";
8290
return Deserializer.toSimpleEventArray(tba
8391
.getDataTBA(directory)
@@ -88,8 +96,9 @@ public SimpleEvent[] getSimpleEvents(String districtKey){
8896
*
8997
* @param districtKey TBA District Key, e.g. <code>2016fim</code>
9098
* @return A list of event keys in the given district
99+
* @throws IOException
91100
*/
92-
public String[] getEventKeys(String districtKey){
101+
public String[] getEventKeys(String districtKey) throws IOException{
93102
String directory = "/district/" + districtKey + "/events/keys";
94103
return Deserializer.toStringArray(tba
95104
.getDataTBA(directory)

src/main/java/com/thebluealliance/api/v3/requests/EventRequest.java

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.thebluealliance.api.v3.requests;
22

3+
import java.io.IOException;
4+
35
import com.thebluealliance.api.v3.Deserializer;
46
import com.thebluealliance.api.v3.models.*;
57

@@ -20,8 +22,9 @@ public EventRequest(DataRequest tba){
2022
*
2123
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
2224
* @return The {@link Event} object referenced by the given key
25+
* @throws IOException
2326
*/
24-
public Event getEvent(String eventKey){
27+
public Event getEvent(String eventKey) throws IOException{
2528
String directory = "/event/" + eventKey;
2629
return Deserializer.toEvent(tba
2730
.getDataTBA(directory).getJson());
@@ -31,8 +34,9 @@ public Event getEvent(String eventKey){
3134
*
3235
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
3336
* @return The {@link SimpleEvent} object referenced by the given key
37+
* @throws IOException
3438
*/
35-
public SimpleEvent getSimpleEvent(String eventKey){
39+
public SimpleEvent getSimpleEvent(String eventKey) throws IOException{
3640
String directory = "/event/" + eventKey + "/simple";
3741
return Deserializer.toSimpleEvent(tba
3842
.getDataTBA(directory).getJson());
@@ -42,8 +46,9 @@ public SimpleEvent getSimpleEvent(String eventKey){
4246
*
4347
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
4448
* @return A list of {@link Team} objects that competed in the given event.
49+
* @throws IOException
4550
*/
46-
public Team[] getTeams(String eventKey){
51+
public Team[] getTeams(String eventKey) throws IOException{
4752
String directory = "/event/" + eventKey+"/teams";
4853
return Deserializer.toTeamArray(tba
4954
.getDataTBA(directory).getJson());
@@ -53,9 +58,10 @@ public Team[] getTeams(String eventKey){
5358
*
5459
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
5560
* @return A list of {@link SimpleTeam} objects that competed in the given event.
61+
* @throws IOException
5662
*/
5763

58-
public SimpleTeam[] getSimpleTeams(String eventKey){
64+
public SimpleTeam[] getSimpleTeams(String eventKey) throws IOException{
5965
String directory = "/event/" + eventKey+"/teams/simple";
6066
return Deserializer.toSimpleTeamArray(tba
6167
.getDataTBA(directory).getJson());
@@ -65,9 +71,10 @@ public SimpleTeam[] getSimpleTeams(String eventKey){
6571
*
6672
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
6773
* @return A list of {@link Team} keys that competed in the given event.
74+
* @throws IOException
6875
*/
6976

70-
public String[] getTeamKeys(String eventKey){
77+
public String[] getTeamKeys(String eventKey) throws IOException{
7178
String directory = "/event/" + eventKey+"/teams/keys";
7279
return Deserializer.toStringArray(tba
7380
.getDataTBA(directory).getJson());
@@ -77,9 +84,10 @@ public String[] getTeamKeys(String eventKey){
7784
*
7885
* @param year Competition year (or season). Must be four digits.
7986
* @return A list of {@link Event} objects that occurred in a given year
87+
* @throws IOException
8088
*/
8189

82-
public Event[] getEvents(int year){
90+
public Event[] getEvents(int year) throws IOException{
8391
String directory = "/events/" +year;
8492
return Deserializer.toEventArray(tba
8593
.getDataTBA(directory).getJson());
@@ -89,8 +97,9 @@ public Event[] getEvents(int year){
8997
*
9098
* @param year Competition year (or season). Must be four digits.
9199
* @return A list of {@link SimpleEvent} objects that occurred in a given year
100+
* @throws IOException
92101
*/
93-
public SimpleEvent[] getSimpleEvents(int year){
102+
public SimpleEvent[] getSimpleEvents(int year) throws IOException{
94103
String directory = "/events/" +year+"/simple";
95104
return Deserializer.toSimpleEventArray(tba
96105
.getDataTBA(directory).getJson());
@@ -100,8 +109,9 @@ public SimpleEvent[] getSimpleEvents(int year){
100109
*
101110
* @param year Competition year (or season). Must be four digits.
102111
* @return A list of {@link Event} keys that occurred in a given year
112+
* @throws IOException
103113
*/
104-
public String[] getEventKeys(int year){
114+
public String[] getEventKeys(int year) throws IOException{
105115
String directory = "/event/" +year+"/keys";
106116
return Deserializer.toStringArray(tba
107117
.getDataTBA(directory).getJson());
@@ -111,8 +121,9 @@ public String[] getEventKeys(int year){
111121
*
112122
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
113123
* @return A list of team rankings for the event
124+
* @throws IOException
114125
*/
115-
public EventDistrictPoints getDistrictPoints(String eventKey){
126+
public EventDistrictPoints getDistrictPoints(String eventKey) throws IOException{
116127
String directory = "/event/" +eventKey+"/district_points";
117128
return Deserializer.toEventDistrictPoints(tba
118129
.getDataTBA(directory).getJson());
@@ -122,8 +133,9 @@ public EventDistrictPoints getDistrictPoints(String eventKey){
122133
*
123134
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
124135
* @return A list of {@link EliminationAlliance}s for the event
136+
* @throws IOException
125137
*/
126-
public EliminationAlliance[] getAlliances(String eventKey){
138+
public EliminationAlliance[] getAlliances(String eventKey) throws IOException{
127139
String directory = "/event/" +eventKey+"/alliances";
128140
return Deserializer.toEliminationAllianceArray(tba
129141
.getDataTBA(directory).getJson());
@@ -133,8 +145,9 @@ public EliminationAlliance[] getAlliances(String eventKey){
133145
*
134146
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
135147
* @return A set of {@link OPRs} (includeing OPR, DPR, and CCWM) for the event
148+
* @throws IOException
136149
*/
137-
public OPRs getOPRs(String eventKey){
150+
public OPRs getOPRs(String eventKey) throws IOException{
138151
String directory = "/event/" +eventKey+"/oprs";
139152
return Deserializer.toOPRs(tba
140153
.getDataTBA(directory).getJson());
@@ -144,8 +157,9 @@ public OPRs getOPRs(String eventKey){
144157
*
145158
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
146159
* @return A list of team rankings for the event
160+
* @throws IOException
147161
*/
148-
public EventRankings getRankings(String eventKey){
162+
public EventRankings getRankings(String eventKey) throws IOException{
149163
String directory = "/event/" +eventKey+"/rankings";
150164
return Deserializer.toEventRankings(tba
151165
.getDataTBA(directory).getJson());
@@ -155,8 +169,9 @@ public EventRankings getRankings(String eventKey){
155169
*
156170
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
157171
* @return A list of {@link Match}es for the event
172+
* @throws IOException
158173
*/
159-
public Match[] getMatches(String eventKey){
174+
public Match[] getMatches(String eventKey) throws IOException{
160175
String directory = "/event/" + eventKey + "/matches";
161176
return Deserializer.toMatchArray(tba
162177
.getDataTBA(directory)
@@ -167,8 +182,9 @@ public Match[] getMatches(String eventKey){
167182
*
168183
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
169184
* @return A list of {@link SimpleMatch}es for the event
185+
* @throws IOException
170186
*/
171-
public SimpleMatch[] getSimpleMatches(String eventKey){
187+
public SimpleMatch[] getSimpleMatches(String eventKey) throws IOException{
172188
String directory = "/event/" + eventKey + "/matches/simple";
173189
return Deserializer.toSimpleMatchArray(tba
174190
.getDataTBA(directory)
@@ -179,8 +195,9 @@ public SimpleMatch[] getSimpleMatches(String eventKey){
179195
*
180196
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
181197
* @return A list of match keys for the event
198+
* @throws IOException
182199
*/
183-
public String[] getMatchKeys(String eventKey){
200+
public String[] getMatchKeys(String eventKey) throws IOException{
184201
String directory = "/event/" + eventKey+"/matches/keys";
185202
return Deserializer.toStringArray(tba
186203
.getDataTBA(directory)
@@ -191,8 +208,9 @@ public String[] getMatchKeys(String eventKey){
191208
*
192209
* @param eventKey TBA Event Key, e.g. <code>2016nytr</code>
193210
* @return A list of {@link Award}s from the given the event
211+
* @throws IOException
194212
*/
195-
public Award[] getAwards(String eventKey){
213+
public Award[] getAwards(String eventKey) throws IOException{
196214
String directory = "/event/" + eventKey+"/awards";
197215
return Deserializer.toAwardArray(tba
198216
.getDataTBA(directory)

src/main/java/com/thebluealliance/api/v3/requests/MatchRequest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.thebluealliance.api.v3.requests;
22

3+
import java.io.IOException;
4+
35
import com.thebluealliance.api.v3.Deserializer;
46
import com.thebluealliance.api.v3.models.Match;
57
import com.thebluealliance.api.v3.models.SimpleMatch;
@@ -21,8 +23,9 @@ public MatchRequest(DataRequest tba){
2123
*
2224
* @param matchKey TBA Match Key, e.g. <code>2016nytr_qm1</code>
2325
* @return A {@link Match} object for the given match key
26+
* @throws IOException
2427
*/
25-
public Match getMatch(String matchKey){
28+
public Match getMatch(String matchKey) throws IOException{
2629
String directory = "/match/" + matchKey;
2730
return Deserializer.toMatch(tba
2831
.getDataTBA(directory)
@@ -33,8 +36,9 @@ public Match getMatch(String matchKey){
3336
*
3437
* @param matchKey TBA Match Key, e.g. <code>2016nytr_qm1</code>
3538
* @return A {@link SimpleMatch} object for the given match key
39+
* @throws IOException
3640
*/
37-
public SimpleMatch getSimpleMatch(String matchKey){
41+
public SimpleMatch getSimpleMatch(String matchKey) throws IOException{
3842
String directory = "/match/" + matchKey + "/simple";
3943
return Deserializer.toSimpleMatch(tba
4044
.getDataTBA(directory)

0 commit comments

Comments
 (0)