diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fd0ec54
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+
+*.class
diff --git a/.idea/libraries/libs.xml b/.idea/libraries/libs.xml
new file mode 100644
index 0000000..8faa3ad
--- /dev/null
+++ b/.idea/libraries/libs.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/TBA-API-V3.iml b/.idea/modules/TBA-API-V3.iml
index 6e9f014..df3ef78 100644
--- a/.idea/modules/TBA-API-V3.iml
+++ b/.idea/modules/TBA-API-V3.iml
@@ -1,5 +1,5 @@
-
+
@@ -8,5 +8,6 @@
+
\ No newline at end of file
diff --git a/.idea/modules/TBA-API-V3_main.iml b/.idea/modules/TBA-API-V3_main.iml
index cb28de3..25eab92 100644
--- a/.idea/modules/TBA-API-V3_main.iml
+++ b/.idea/modules/TBA-API-V3_main.iml
@@ -1,5 +1,5 @@
-
+
@@ -9,16 +9,11 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules/TBA-API-V3_test.iml b/.idea/modules/TBA-API-V3_test.iml
index fa8f454..9f22f7e 100644
--- a/.idea/modules/TBA-API-V3_test.iml
+++ b/.idea/modules/TBA-API-V3_test.iml
@@ -1,5 +1,5 @@
-
+
@@ -10,19 +10,12 @@
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..8f2955c
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,420 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1521233293351
+
+
+ 1521233293351
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ TBA-API-V3:jar
+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ TBA-API-V3
+
+
+
+
+
+
+
+
+
+
+
+ libs
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/out/artifacts/TBA_API_V3_jar/TBA-API-V3.jar b/out/artifacts/TBA_API_V3_jar/TBA-API-V3.jar
new file mode 100644
index 0000000..3c2022e
Binary files /dev/null and b/out/artifacts/TBA_API_V3_jar/TBA-API-V3.jar differ
diff --git a/src/main/java/main/TBA.java b/src/main/java/main/TBA.java
index fe4bfd4..744a7ff 100644
--- a/src/main/java/main/TBA.java
+++ b/src/main/java/main/TBA.java
@@ -6,6 +6,7 @@
import models.other.Media;
import models.other.events.EventOPR;
import models.other.teams.Robot;
+import models.other.teams.status.TeamEventStatus;
import models.simple.SEvent;
import models.simple.SMatch;
import models.simple.STeam;
@@ -492,6 +493,18 @@ public String[] getTeamEventKeys(int number) {
return tr.getTeamEventKeys(number);
}
+ /**
+ * Mirror of: /team/{team_key}/event/{event_key}/status
+ *
+ * Gets a list of the event keys for all events this team has competed at.
+ * @param number the team's frc number
+ * @param eventKey TBA Event Key, eg 2016nytr
+ * @return TeamEventStatus[] that gets the competition rank and status of the team at the given event.
+ */
+ public TeamEventStatus getTeamEventStatus(int number, String eventKey){
+ return tr.getTeamEventStatus(number, eventKey);
+ }
+
/**
* Mirror of: /team/{team_key}/events/{year}
*
diff --git a/src/main/java/models/other/Media.java b/src/main/java/models/other/Media.java
index f96bad4..1da0b98 100644
--- a/src/main/java/models/other/Media.java
+++ b/src/main/java/models/other/Media.java
@@ -17,7 +17,7 @@ public class Media implements Serializable {
/**
* String type of the media element.
*/
- private String type;
+ private String[] type;
/**
* The key used to identify this media on the media site.
*/
diff --git a/src/main/java/models/other/Ranking.java b/src/main/java/models/other/Ranking.java
index 0fd1c45..37543b8 100644
--- a/src/main/java/models/other/Ranking.java
+++ b/src/main/java/models/other/Ranking.java
@@ -20,7 +20,7 @@ public class Ranking implements Serializable {
/**
* The average match score during qualifications. Year specific. May be null if not relevant for a given year.
*/
- private long qualAverage;
+ private double qualAverage;
/**
* The team’s rank at the event as provided by FIRST.
*/
@@ -38,7 +38,7 @@ public class Ranking implements Serializable {
/**
* Additional year-specific information, may be null. See parent `sort_order_info` for details.
*/
- private long[] sortOrders;
+ private double[] sortOrders;
/**
* The team with this rank.
*/
diff --git a/src/main/java/models/other/teams/status/TeamEventStatusAlliance.java b/src/main/java/models/other/teams/status/TeamEventStatusAlliance.java
index 5f3a546..e385149 100644
--- a/src/main/java/models/other/teams/status/TeamEventStatusAlliance.java
+++ b/src/main/java/models/other/teams/status/TeamEventStatusAlliance.java
@@ -15,7 +15,7 @@ public class TeamEventStatusAlliance {
/**
* Alliance number.
*/
- private int number;
+ private long number;
/**
* Backup status, may be null.
*/
@@ -23,5 +23,5 @@ public class TeamEventStatusAlliance {
/**
* Order the team was picked in the alliance from 0-2, with 0 being alliance captain.
*/
- private int pick;
+ private long pick;
}
diff --git a/src/main/java/models/other/teams/status/TeamEventStatusPlayoff.java b/src/main/java/models/other/teams/status/TeamEventStatusPlayoff.java
index c09c7f1..522f759 100644
--- a/src/main/java/models/other/teams/status/TeamEventStatusPlayoff.java
+++ b/src/main/java/models/other/teams/status/TeamEventStatusPlayoff.java
@@ -1,6 +1,7 @@
package models.other.teams.status;
import lombok.Data;
+import models.other.WLTRecord;
/**
* @since 1.0.0
@@ -15,9 +16,17 @@ public class TeamEventStatusPlayoff {
/**
* Record in playoffs as a string in the format WINS-LOSSES-TIES.
*/
- private String record;
+ private WLTRecord record;
+ /**
+ * Record in current level of competition (e.g. QF, SF, F) as a string in the format WINS-LOSSES-TIES.
+ */
+ private WLTRecord currentLevelRecord;
/**
* Current competition status for the playoffs.
*/
- private String[] status;
+ private String status;
+ /**
+ * The average match score during playoffs. Year specific. May be null if not relevant for a given year.
+ */
+ private Long playoffAverage;
}
diff --git a/src/main/java/models/other/teams/status/TeamEventStatusRank.java b/src/main/java/models/other/teams/status/TeamEventStatusRank.java
index 8645300..68d5104 100644
--- a/src/main/java/models/other/teams/status/TeamEventStatusRank.java
+++ b/src/main/java/models/other/teams/status/TeamEventStatusRank.java
@@ -12,8 +12,8 @@ public class TeamEventStatusRank {
/**
* Number of teams ranked.
*/
- private int numTeams;
- private Ranking[] ranking;
+ private Long numTeams;
+ private Ranking ranking;
/**
* Ordered list of names corresponding to the elements of the `sort_orders` array.
*/
diff --git a/src/main/java/requests/TeamRequest.java b/src/main/java/requests/TeamRequest.java
index a1af702..c0075e2 100644
--- a/src/main/java/requests/TeamRequest.java
+++ b/src/main/java/requests/TeamRequest.java
@@ -4,6 +4,7 @@
import models.other.Media;
import models.other.District;
import models.other.teams.Robot;
+import models.other.teams.status.TeamEventStatus;
import models.simple.SEvent;
import models.simple.SMatch;
import models.simple.STeam;
@@ -11,6 +12,7 @@
import models.standard.Match;
import models.standard.Team;
import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
import utils.IO;
import utils.Parser;
import utils.Utils;
@@ -233,6 +235,20 @@ public String[] getTeamEventKeys(int number) {
return Utils.jsonArrayToStringArray(keys);
}
+ /**
+ * Mirror of: /team/{team_key}/event/{event_key}/status
+ *
+ * Gets a list of the event keys for all events this team has competed at.
+ * @param number the team's frc number
+ * @param eventKey TBA Event Key, eg 2016nytr
+ * @return TeamEventStatus[] that gets the competition rank and status of the team at the given event.
+ */
+ public TeamEventStatus getTeamEventStatus(int number, String eventKey){
+ JSONObject status = (JSONObject) IO.doRequest("team/frc"+number+"/event/"+eventKey+"/status");
+ if(status == null) throw new DataNotFoundException("Couldn't find any event status for team with number: frc"+number+" at event "+eventKey);
+ return parseTeamEventStatus(status);
+ }
+
/**
* Mirror of: /team/{team_key}/events/{year}
*
diff --git a/src/main/java/utils/Parser.java b/src/main/java/utils/Parser.java
index caadcfd..53f33a7 100644
--- a/src/main/java/utils/Parser.java
+++ b/src/main/java/utils/Parser.java
@@ -1,14 +1,11 @@
package utils;
-import models.other.APIStatus;
-import models.other.Award;
-import models.other.AwardRecipient;
-import models.other.Media;
+import models.other.*;
import models.other.events.EventOPR;
import models.other.events.Webcast;
import models.other.matches.MatchAlliance;
-import models.other.District;
import models.other.teams.Robot;
+import models.other.teams.status.*;
import models.simple.SEvent;
import models.simple.SMatch;
import models.simple.STeam;
@@ -167,11 +164,104 @@ protected SEvent parseSEvent(Object object) {
return e;
}
+ protected TeamEventStatus parseTeamEventStatus(Object object){
+ TeamEventStatus t = new TeamEventStatus();
+ HashMap hash = (HashMap) object;
+ t.setQual(parseTeamEventStatusRank(hash.get("qual")));
+ t.setAlliance(new TeamEventStatusAlliance());
+ if(hash.get("alliance") != null){
+ t.setAlliance(parseTeamEventStatusAlliance(hash.get("alliance")));
+ }
+
+ t.setPlayoff(parseTeamEventStatusPlayoff(hash.get("playoff")));
+ t.setAllianceStatus((String)hash.get("alliance_status_str"));
+ t.setPlayoffStatus((String)hash.get("playoff_status_str"));
+ t.setOverallStatus((String)hash.get("overall_status_str"));
+ return t;
+ }
+
+ protected TeamEventStatusRank parseTeamEventStatusRank(Object object){
+ TeamEventStatusRank t = new TeamEventStatusRank();
+ HashMap hash = (HashMap) object;
+ t.setNumTeams(Utils.cleanLong(hash.get("num_teams")));
+ t.setRanking(parseRanking(hash.get("ranking")));
+ JSONArray sortOrderList = (JSONArray)hash.get("sort_order_info");
+ SortInfo[] si = new SortInfo[sortOrderList.size()];
+ for(int i = 0; i < sortOrderList.size(); i++) {
+ si[i] = parseSortInfo(sortOrderList.get(i));
+ }
+ t.setSortOrderInfo(si);
+ return t;
+ }
+
+ protected Ranking parseRanking(Object object){
+ Ranking r = new Ranking();
+ HashMap hash = (HashMap) object;
+ r.setDq(Utils.cleanLong(hash.get("dq")));
+ r.setMatchesPlayed(Utils.cleanLong(hash.get("matches_played")));
+ r.setQualAverage(Utils.cleanDouble(hash.get("qual_average")));
+ r.setRank(Utils.cleanLong(hash.get("rank")));
+ r.setQualificationsRecord(parseWLTRecord(hash.get("record")));
+ r.setOverallRecord(null);
+ JSONArray sortOrders = (JSONArray)hash.get("sort_orders");
+ r.setSortOrders(Utils.jsonArrayToDoublesArray(sortOrders));
+ r.setTeamKey((String)hash.get("team_key"));
+ return r;
+ }
+
+ protected WLTRecord parseWLTRecord(Object object){
+ WLTRecord w = new WLTRecord();
+ HashMap hash = (HashMap) object;
+ w.setLosses(Utils.cleanLong(hash.get("losses")));
+ w.setWins(Utils.cleanLong(hash.get("wins")));
+ w.setTies(Utils.cleanLong(hash.get("ties")));
+ return w;
+ }
+
+ protected SortInfo parseSortInfo(Object object){
+ SortInfo s = new SortInfo();
+ HashMap hash = (HashMap) object;
+ s.setName((String)hash.get("name"));
+ s.setPrecision(Utils.cleanLong(hash.get("precision")));
+ return s;
+ }
+
+ protected TeamEventStatusAlliance parseTeamEventStatusAlliance(Object object){
+ TeamEventStatusAlliance t = new TeamEventStatusAlliance();
+ HashMap hash = (HashMap) object;
+ t.setName((String)hash.get("name"));
+ t.setNumber(Utils.cleanLong(hash.get("number")));
+ t.setBackup(parseTeamEventStatusAllianceBackup(hash.get("backup")));
+ t.setPick(Utils.cleanLong(hash.get("pick")));
+ return t;
+ }
+
+ protected TeamEventStatusAllianceBackup parseTeamEventStatusAllianceBackup(Object object){
+ TeamEventStatusAllianceBackup t = new TeamEventStatusAllianceBackup();
+ HashMap hash = (HashMap) object;
+ if(hash == null)return null;
+ t.setOut((String)hash.get("out"));
+ t.setIn((String)hash.get("in"));
+ return t;
+ }
+
+ protected TeamEventStatusPlayoff parseTeamEventStatusPlayoff(Object object){
+ TeamEventStatusPlayoff t = new TeamEventStatusPlayoff();
+ HashMap hash = (HashMap) object;
+ if(hash == null) return null;
+ t.setLevel((String)hash.get("level"));
+ t.setCurrentLevelRecord(parseWLTRecord(hash.get("current_level_record")));
+ t.setRecord(parseWLTRecord(hash.get("record")));
+ t.setStatus((String)hash.get("status"));
+ t.setPlayoffAverage(Utils.cleanLong(hash.get("playoff_average")));
+ return t;
+ }
+
protected Media parseMedia(Object object) {
Media media = new Media();
HashMap hash = (HashMap)object;
media.setKey((String)hash.get("key"));
- media.setType((String)hash.get("type"));
+ media.setType(Utils.jsonArrayToStringArray((JSONArray)hash.get("type")));
media.setForeignKey((String)hash.get("foreign_key"));
media.setDetails((String)hash.get("details"));
media.setPreferred(Utils.cleanBoolean(hash.get("preferred")));
diff --git a/src/main/java/utils/Utils.java b/src/main/java/utils/Utils.java
index ae17661..5ea831b 100644
--- a/src/main/java/utils/Utils.java
+++ b/src/main/java/utils/Utils.java
@@ -29,4 +29,18 @@ public static String[] jsonArrayToStringArray(JSONArray jsonArray) {
return toReturn;
}
+ public static long[] jsonArrayToLongArray(JSONArray jsonArray){
+ if(jsonArray == null) return null;
+ long[] toReturn = new long[jsonArray.size()];
+ for(int i = 0; i < jsonArray.size(); i++) toReturn[i] = cleanLong(jsonArray.get(i));
+ return toReturn;
+ }
+
+ public static double[] jsonArrayToDoublesArray(JSONArray jsonArray){
+ if(jsonArray == null) return null;
+ double[] toReturn = new double[jsonArray.size()];
+ for(int i = 0; i < jsonArray.size(); i++) toReturn[i] = cleanDouble(jsonArray.get(i));
+ return toReturn;
+ }
+
}