smmdbapi part 1
working so far, until the api returns null as result
|
@ -18,5 +18,6 @@
|
|||
<classpathentry kind="lib" path="src/libraries/commons-codec-1.10.jar"/>
|
||||
<classpathentry kind="lib" path="src/libraries/jfoenix-1.4.0.jar"/>
|
||||
<classpathentry kind="lib" path="src/libraries/sqlite-jdbc-3.18.0.jar"/>
|
||||
<classpathentry kind="lib" path="src/libraries/minimal-json-0.9.4.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
/application/
|
||||
/cloudControllerInstances/
|
||||
/resources/
|
||||
/dataTypes/
|
||||
/datatypes/
|
||||
|
|
After Width: | Height: | Size: 222 B |
After Width: | Height: | Size: 233 B |
After Width: | Height: | Size: 235 B |
After Width: | Height: | Size: 245 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 116 B |
After Width: | Height: | Size: 222 B |
After Width: | Height: | Size: 232 B |
After Width: | Height: | Size: 322 B |
After Width: | Height: | Size: 326 B |
|
@ -25,6 +25,7 @@ import java.math.BigInteger;
|
|||
import java.sql.SQLException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -39,6 +40,7 @@ import com.jfoenix.controls.JFXTextField;
|
|||
import com.jfoenix.controls.JFXToggleButton;
|
||||
import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition;
|
||||
|
||||
import datatypes.SmmdbApiDataType;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
|
@ -140,6 +142,7 @@ public class MainWindowController {
|
|||
|
||||
Main main;
|
||||
dbController dbController;
|
||||
SmmdbApiQuery smmdbApiQuery;
|
||||
playGame playGame;
|
||||
private boolean menuTrue = false;
|
||||
private boolean settingsTrue = false;
|
||||
|
@ -191,6 +194,7 @@ public class MainWindowController {
|
|||
public void setMain(Main main) {
|
||||
this.main = main;
|
||||
dbController = new dbController(this);
|
||||
smmdbApiQuery = new SmmdbApiQuery();
|
||||
}
|
||||
|
||||
void initUI(){
|
||||
|
@ -200,7 +204,7 @@ public class MainWindowController {
|
|||
fullscreenToggleBtn.setSelected(isFullscreen());
|
||||
cloudSyncToggleBtn.setSelected(isCloudSync());
|
||||
edit.setDisable(true);
|
||||
smmdbBtn.setDisable(true);
|
||||
smmdbBtn.setDisable(true); //TODO
|
||||
applyColor();
|
||||
}
|
||||
|
||||
|
@ -470,9 +474,13 @@ public class MainWindowController {
|
|||
|
||||
@FXML
|
||||
void smmdbBtnAction() {
|
||||
System.out.println("yeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeehaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
//TODO show TODO smmdbAnchorPane
|
||||
|
||||
//TODO start query
|
||||
ArrayList<SmmdbApiDataType> courses = new ArrayList<>(smmdbApiQuery.startQuery());
|
||||
System.out.println(courses.size());
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
void playBtnAction(ActionEvent event) throws InterruptedException, IOException{
|
||||
dbController.setLastPlayed(selectedGameTitleID);
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* smmdbapi query
|
||||
* start query and return all courses as ArrayList
|
||||
*/
|
||||
package application;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import com.eclipsesource.json.Json;
|
||||
import com.eclipsesource.json.JsonArray;
|
||||
import com.eclipsesource.json.JsonObject;
|
||||
import com.eclipsesource.json.JsonValue;
|
||||
|
||||
import datatypes.SmmdbApiDataType;
|
||||
|
||||
public class SmmdbApiQuery {
|
||||
|
||||
private String url = "http://smmdb.ddns.net/api/getcourses?";
|
||||
|
||||
public SmmdbApiQuery() {
|
||||
//Auto-generated constructor stub
|
||||
}
|
||||
|
||||
//TODO needs to be tested
|
||||
public ArrayList<SmmdbApiDataType> startQuery() {
|
||||
ArrayList<Integer> courseIDs = new ArrayList<>();
|
||||
ArrayList<SmmdbApiDataType> course = new ArrayList<>();
|
||||
String output = "";
|
||||
|
||||
|
||||
try {
|
||||
URL apiUrl = new URL(url);
|
||||
BufferedReader ina = new BufferedReader(new InputStreamReader(apiUrl.openStream()));
|
||||
output = ina.readLine();
|
||||
ina.close();
|
||||
} catch (IOException e) {
|
||||
//Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
JsonObject mainObject = Json.parse(output).asObject().get("courses").asObject();
|
||||
System.out.println(mainObject);
|
||||
|
||||
|
||||
JsonArray objectAssets = Json.parse(output).asObject().get("order").asArray();
|
||||
for (JsonValue asset : objectAssets) {
|
||||
courseIDs.add(asset.asInt());
|
||||
}
|
||||
|
||||
//FIXME if parameter = null query will stop
|
||||
for (int i = 0; i < courseIDs.size(); i++) {
|
||||
System.out.println(i);
|
||||
JsonObject singleObject = mainObject.get(courseIDs.get(i).toString()).asObject();
|
||||
int id = singleObject.getInt("id", 0);
|
||||
int owner = singleObject.getInt("owner", 0);
|
||||
int coursetype = singleObject.getInt("coursetype", 0);
|
||||
int leveltype = singleObject.getInt("leveltype", 0);
|
||||
int difficulty = singleObject.getInt("difficulty", 0);
|
||||
int lastmodified = singleObject.getInt("lastmodified", 0);
|
||||
int uploaded = singleObject.getInt("uploaded", 0);
|
||||
int downloads = singleObject.getInt("downloads", 0);
|
||||
int stars = singleObject.getInt("stars", 0);
|
||||
int ispackage = singleObject.getInt("ispackage", 0);
|
||||
int updatereq = singleObject.getInt("updatereq", 0);
|
||||
// String nintendoid = singleObject.getString("nintendoid", "");
|
||||
String title = singleObject.getString("title", "");
|
||||
|
||||
course.add(new SmmdbApiDataType(id, owner, coursetype, leveltype, difficulty, lastmodified, uploaded, downloads,
|
||||
stars, ispackage, updatereq, title));
|
||||
}
|
||||
|
||||
return course;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,200 @@
|
|||
package datatypes;
|
||||
|
||||
import javafx.beans.property.BooleanProperty;
|
||||
import javafx.beans.property.IntegerProperty;
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
||||
public class SmmdbApiDataType {
|
||||
|
||||
private final IntegerProperty id = new SimpleIntegerProperty();
|
||||
private final IntegerProperty owner = new SimpleIntegerProperty();
|
||||
private final IntegerProperty coursetype = new SimpleIntegerProperty();
|
||||
private final IntegerProperty leveltype = new SimpleIntegerProperty();
|
||||
private final IntegerProperty difficulty = new SimpleIntegerProperty();
|
||||
private final IntegerProperty lastmodified = new SimpleIntegerProperty();
|
||||
private final IntegerProperty uploaded = new SimpleIntegerProperty();
|
||||
private final IntegerProperty downloads = new SimpleIntegerProperty();
|
||||
private final IntegerProperty stars = new SimpleIntegerProperty();
|
||||
private final IntegerProperty ispackage = new SimpleIntegerProperty();
|
||||
private final IntegerProperty updatereq = new SimpleIntegerProperty();
|
||||
// private final StringProperty nintendoid = new SimpleStringProperty();
|
||||
private final StringProperty title = new SimpleStringProperty();
|
||||
|
||||
public SmmdbApiDataType(final int id, final int owner, final int coursetype, final int leveltype, final int difficulty,
|
||||
final int lastmodified, final int uploaded, final int downloads, final int stars, final int ispackage,
|
||||
final int updatereq, final String title) {
|
||||
this.id.set(id);
|
||||
this.owner.set(owner);
|
||||
this.coursetype.set(coursetype);
|
||||
// this.nintendoid.set(nintendoid);
|
||||
this.leveltype.set(leveltype);
|
||||
this.difficulty.set(difficulty);
|
||||
this.lastmodified.set(lastmodified);
|
||||
this.uploaded.set(uploaded);
|
||||
this.downloads.set(downloads);
|
||||
this.stars.set(stars);
|
||||
this.title.set(title);
|
||||
this.ispackage.set(ispackage);
|
||||
this.updatereq.set(updatereq);
|
||||
}
|
||||
|
||||
public IntegerProperty idProperty(){
|
||||
return id;
|
||||
}
|
||||
|
||||
public IntegerProperty ownerProperty(){
|
||||
return owner;
|
||||
}
|
||||
|
||||
public IntegerProperty coursetypeProperty(){
|
||||
return coursetype;
|
||||
}
|
||||
|
||||
// public StringProperty nintendoidProperty(){
|
||||
// return nintendoid;
|
||||
// }
|
||||
|
||||
public IntegerProperty leveltypeProperty(){
|
||||
return leveltype;
|
||||
}
|
||||
|
||||
public IntegerProperty difficultyProperty(){
|
||||
return difficulty;
|
||||
}
|
||||
|
||||
public IntegerProperty lastmodifiedProperty(){
|
||||
return lastmodified;
|
||||
}
|
||||
|
||||
public IntegerProperty uploadedProperty(){
|
||||
return uploaded;
|
||||
}
|
||||
|
||||
public IntegerProperty downloadsProperty(){
|
||||
return downloads;
|
||||
}
|
||||
|
||||
public IntegerProperty starsProperty(){
|
||||
return stars;
|
||||
}
|
||||
|
||||
public IntegerProperty ispackageProperty(){
|
||||
return ispackage;
|
||||
}
|
||||
|
||||
public IntegerProperty updatereqProperty(){
|
||||
return updatereq;
|
||||
}
|
||||
|
||||
public StringProperty titleProperty(){
|
||||
return title;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return idProperty().get();
|
||||
}
|
||||
|
||||
public int getOwner() {
|
||||
return ownerProperty().get();
|
||||
}
|
||||
|
||||
public int getCoursetype() {
|
||||
return coursetypeProperty().get();
|
||||
}
|
||||
|
||||
public int getLeveltype() {
|
||||
return leveltypeProperty().get();
|
||||
}
|
||||
|
||||
public int getDifficulty() {
|
||||
return difficultyProperty().get();
|
||||
}
|
||||
|
||||
public int getLastmodified() {
|
||||
return lastmodifiedProperty().get();
|
||||
}
|
||||
|
||||
public int getUploaded() {
|
||||
return uploadedProperty().get();
|
||||
}
|
||||
|
||||
public int getDownloads() {
|
||||
return downloadsProperty().get();
|
||||
}
|
||||
|
||||
public int getStars() {
|
||||
return starsProperty().get();
|
||||
}
|
||||
|
||||
public int getIspackage() {
|
||||
return ispackageProperty().get();
|
||||
}
|
||||
|
||||
public int getUpdatereq() {
|
||||
return updatereqProperty().get();
|
||||
}
|
||||
|
||||
// public String getNintendoid() {
|
||||
// return nintendoidProperty().get();
|
||||
// }
|
||||
|
||||
public String getTitle() {
|
||||
return titleProperty().get();
|
||||
}
|
||||
|
||||
public final void setId(int id) {
|
||||
idProperty().set(id);
|
||||
}
|
||||
|
||||
public final void setOwner(int owner) {
|
||||
ownerProperty().set(owner);
|
||||
}
|
||||
|
||||
public final void setCoursetype(int coursetype) {
|
||||
coursetypeProperty().set(coursetype);
|
||||
}
|
||||
|
||||
public final void setLeveltype(int leveltype) {
|
||||
leveltypeProperty().set(leveltype);
|
||||
}
|
||||
|
||||
public final void setDifficulty(int difficulty) {
|
||||
difficultyProperty().set(difficulty);
|
||||
}
|
||||
|
||||
public final void setLastmodified(int lastmodified) {
|
||||
lastmodifiedProperty().set(lastmodified);
|
||||
}
|
||||
|
||||
public final void setUploaded(int uploaded) {
|
||||
uploadedProperty().set(uploaded);
|
||||
}
|
||||
|
||||
public final void setDownloads(int downloads) {
|
||||
downloadsProperty().set(downloads);
|
||||
}
|
||||
|
||||
public final void setStars(int stars) {
|
||||
starsProperty().set(stars);
|
||||
}
|
||||
|
||||
public final void setIspackage(int ispackage) {
|
||||
ispackageProperty().set(ispackage);
|
||||
}
|
||||
|
||||
public final void setUpdatereq(int updatereq) {
|
||||
updatereqProperty().set(updatereq);
|
||||
}
|
||||
|
||||
// public final void setNintendoid(String nintendoid) {
|
||||
// nintendoidProperty().set(nintendoid);
|
||||
// }
|
||||
|
||||
public final void setTitle(String title) {
|
||||
titleProperty().set(title);
|
||||
}
|
||||
|
||||
}
|