-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajout des modeles et test de récupération des données
- Loading branch information
1 parent
165f1a3
commit 6f63c06
Showing
6 changed files
with
142 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package fr.univlyon1.bda; | ||
|
||
|
||
import fr.univlyon1.bda.extern.RaceServiceREST; | ||
import fr.univlyon1.bda.modele.RaceMoment; | ||
|
||
public class App { | ||
|
||
public static void main(String[] args) { | ||
System.out.println("START APPLICATION..."); | ||
|
||
RaceServiceREST raceServiceREST = new RaceServiceREST(); | ||
|
||
try { | ||
RaceMoment raceMoment = raceServiceREST.getRaceMoment(); | ||
raceMoment.print(); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/fr/univlyon1/bda/extern/RaceServiceREST.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package fr.univlyon1.bda.extern; | ||
|
||
import fr.univlyon1.bda.modele.RaceMoment; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
|
||
public class RaceServiceREST { | ||
|
||
RestTemplate restTemplate = new RestTemplate(); | ||
|
||
public RaceMoment getRaceMoment() throws Exception { | ||
ResponseEntity<RaceMoment> response | ||
= restTemplate.getForEntity("http:https://tortues.ecoquery.os.univ-lyon1.fr/race/tiny", RaceMoment.class); | ||
|
||
return response.getBody(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package fr.univlyon1.bda.modele; | ||
|
||
|
||
public class RaceMoment { | ||
|
||
private float quality; | ||
private float temperature; | ||
private Tortoise[] tortoises; | ||
|
||
|
||
public RaceMoment(float quality, float temperature, Tortoise[] tortoises) { | ||
this.quality = quality; | ||
this.temperature = temperature; | ||
this.tortoises = tortoises; | ||
} | ||
|
||
public void print() { | ||
int i = 0; | ||
String str = ""; | ||
while(i < tortoises.length || i < 10) { | ||
str += " { \"id\": "+tortoises[i].getId()+", \"top\": "+tortoises[i].getTop()+", \"position\": "+tortoises[i].getPosition()+" },\n"; | ||
i++; | ||
} | ||
System.out.println("\n" + | ||
"{\n" + | ||
" tortoises : [\n" + | ||
str + | ||
" ]," + | ||
" qualite : " + quality + "\n" + | ||
" temperature : " + temperature + "\n" + | ||
"}"); | ||
} | ||
|
||
public float getQuality() { | ||
return quality; | ||
} | ||
|
||
public void setQuality(float quality) { | ||
this.quality = quality; | ||
} | ||
|
||
public float getTemperature() { | ||
return temperature; | ||
} | ||
|
||
public void setTemperature(float temperature) { | ||
this.temperature = temperature; | ||
} | ||
|
||
public Tortoise[] getTortoises() { | ||
return tortoises; | ||
} | ||
|
||
public void setTortoises(Tortoise[] tortoises) { | ||
this.tortoises = tortoises; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package fr.univlyon1.bda.modele; | ||
|
||
public class Tortoise { | ||
|
||
private int id; | ||
private int top; | ||
private int position; | ||
|
||
public Tortoise(int id, int top, int position) { | ||
this.id = id; | ||
this.top = top; | ||
this.position = position; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
|
||
public int getTop() { | ||
return top; | ||
} | ||
|
||
public void setTop(int top) { | ||
this.top = top; | ||
} | ||
|
||
public int getPosition() { | ||
return position; | ||
} | ||
|
||
public void setPosition(int position) { | ||
this.position = position; | ||
} | ||
} |