Skip to content
Snippets Groups Projects
Commit 80315e5a authored by Marco Sciacovelli's avatar Marco Sciacovelli
Browse files

Comitted changes

parent bea56a47
Branches master
No related tags found
No related merge requests found
...@@ -9,9 +9,15 @@ import java.util.HashMap; ...@@ -9,9 +9,15 @@ import java.util.HashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class Event { public class Event {
<<<<<<< Updated upstream
public static final String TYPE = "events"; public static final String TYPE = "events";
public String id; public String id;
public HashMap<String, String> names; public HashMap<String, String> names;
=======
private static final String TYPE = "events";
public String id;
public HashMap<String,String> names;
>>>>>>> Stashed changes
public String description; public String description;
public String url; public String url;
public int duration; public int duration;
...@@ -19,6 +25,7 @@ public class Event { ...@@ -19,6 +25,7 @@ public class Event {
public String startDate; public String startDate;
public String endDate; public String endDate;
public String[] categories; public String[] categories;
<<<<<<< Updated upstream
public GeoShape[] geometries; public GeoShape[] geometries;
public Event() { public Event() {
...@@ -27,9 +34,25 @@ public class Event { ...@@ -27,9 +34,25 @@ public class Event {
public Event(String id, HashMap<String, String> names, String description, String url, int duration, boolean isFree, public Event(String id, HashMap<String, String> names, String description, String url, int duration, boolean isFree,
String startDate, String endDate, String[] categories, GeoShape[] geometries) { String startDate, String endDate, String[] categories, GeoShape[] geometries) {
=======
public GeoShape geometries;
public Event(String id,
HashMap<String, String> names,
String description,
String url,
int duration,
boolean isFree,
String startDate,
String endDate,
String[] categories,
GeoShape geometries
) {
>>>>>>> Stashed changes
this.id = id; this.id = id;
this.names = names; this.names = names;
this.description = description; this.description = description;
this.duration = duration;
this.url = url; this.url = url;
this.duration = duration; this.duration = duration;
this.isFree = isFree; this.isFree = isFree;
...@@ -37,6 +60,25 @@ public class Event { ...@@ -37,6 +60,25 @@ public class Event {
this.endDate = endDate; this.endDate = endDate;
this.categories = categories; this.categories = categories;
this.geometries = geometries; this.geometries = geometries;
<<<<<<< Updated upstream
=======
}
public GeoShape getGeometries() {
return geometries;
}
public void setGeometries(GeoShape geometries) {
this.geometries = geometries;
}
public int getDuration() {
return duration;
}
public void setDuration(int duration) {
this.duration = duration;
>>>>>>> Stashed changes
} }
public static ArrayList<Event> getEventsFromJSON(String json) { public static ArrayList<Event> getEventsFromJSON(String json) {
......
...@@ -4,6 +4,7 @@ import java.util.List; ...@@ -4,6 +4,7 @@ import java.util.List;
public class GeoShape { public class GeoShape {
<<<<<<< Updated upstream
public String type; public String type;
public final List<List<Double>> coordinates = new ArrayList<>(); public final List<List<Double>> coordinates = new ArrayList<>();
...@@ -11,6 +12,13 @@ public class GeoShape { ...@@ -11,6 +12,13 @@ public class GeoShape {
this.type = type; this.type = type;
this.coordinates.add(Arrays.asList(coordinates1)); this.coordinates.add(Arrays.asList(coordinates1));
this.coordinates.add(Arrays.asList(coordinates2)); this.coordinates.add(Arrays.asList(coordinates2));
=======
private static final String TYPE = "geoShapes";
private double[] coordinates;
public GeoShape(double[] coordinates) {
this.coordinates = coordinates;
>>>>>>> Stashed changes
} }
public GeoShape() { public GeoShape() {
...@@ -18,10 +26,14 @@ public class GeoShape { ...@@ -18,10 +26,14 @@ public class GeoShape {
@Override @Override
public String toString() { public String toString() {
<<<<<<< Updated upstream
return "GeoShape{" + return "GeoShape{" +
"type='" + type + '\'' + "type='" + type + '\'' +
", coordinates=" + coordinates + ", coordinates=" + coordinates +
'}'; '}';
=======
return "GeoShape of coordinates: " + Arrays.toString(coordinates);
>>>>>>> Stashed changes
} }
} }
...@@ -54,8 +54,17 @@ public class Main { ...@@ -54,8 +54,17 @@ public class Main {
.add(Json.createArrayBuilder().add(11.309296).add(46.861944).add(1342).build()).build()) .add(Json.createArrayBuilder().add(11.309296).add(46.861944).add(1342).build()).build())
.build()).build()) .build()).build())
.build(); .build();
<<<<<<< Updated upstream
return writing.toString(); return writing.toString();
} }
=======
System.out.println(writing);
//Task 4
GeoShape geoShape = new GeoShape(new double[]{1000d,223d,121d});
Jsonb jsonb = JsonbBuilder.create();
System.out.println(jsonb.toJson(geoShape));
>>>>>>> Stashed changes
public static String Task4(){ public static String Task4(){
GeoShape geoShape = new GeoShape("geoShapes", new Double[] { 1000d, 223d, 121d }, GeoShape geoShape = new GeoShape("geoShapes", new Double[] { 1000d, 223d, 121d },
......
import javax.json.bind.Jsonb; <<<<<<< Updated upstream
import javax.json.bind.JsonbBuilder; import javax.json.bind.Jsonb;
import java.util.HashMap; import javax.json.bind.JsonbBuilder;
import java.util.HashMap;
public class Task5 {
public static void main(String[] args) { public class Task5 {
GeoShape[] geometries = new GeoShape[] { public static void main(String[] args) {
new GeoShape("geoShapes", new Double[] { 1000d, 223d, 121d }, new Double[] { 1000d, 223d, 121d }) }; GeoShape[] geometries = new GeoShape[] {
HashMap<String, String> names = new HashMap<>(); new GeoShape("geoShapes", new Double[] { 1000d, 223d, 121d }, new Double[] { 1000d, 223d, 121d }) };
names.put("deu", "Braunsbergbühne Lana: The Orchestra"); HashMap<String, String> names = new HashMap<>();
names.put("ita", "Comedia: The orchestra"); names.put("deu", "Braunsbergbühne Lana: The Orchestra");
names.put("ita", "Comedia: The orchestra");
Event event = new Event("ACE69C22C9DD41E6B74123BF64725F12", names, "", "", 120, false,
"2077-11-17T00: 00: 00.000Z", "2077-11-17T00: 00: 00.000Z", Event event = new Event("ACE69C22C9DD41E6B74123BF64725F12", names, "", "", 120, false,
new String[] { "odh:theatre-cinema-and-performances", "schema:TheaterEvent" }, geometries); "2077-11-17T00: 00: 00.000Z", "2077-11-17T00: 00: 00.000Z",
new String[] { "odh:theatre-cinema-and-performances", "schema:TheaterEvent" }, geometries);
Jsonb json = JsonbBuilder.create();
String result = json.toJson(event); Jsonb json = JsonbBuilder.create();
String result = json.toJson(event);
System.out.println(result);
} System.out.println(result);
} }
}
=======
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import java.util.HashMap;
public class Task5 {
public static void main(String[] args) {
HashMap<String,String> names = new HashMap<>();
double[] coordinates1 = {11.309652, 46.863848, 1298};
double[] coordinates2 = {11.309296, 46.861944, 1342};
String[] categories = {"odh:theatre-cinema-and-performances", "schema:TheaterEvent"};
double[][] coordinates = {coordinates1, coordinates2};
GeoShape geometries = new GeoShape(coordinates1);
names.put("deu","Braunsbergbühne Lana: The Orchestra");
names.put("ita","Comedia: The orchestra");
Event event = new Event("ACE69C22C9DD41E6B74123BF64725F12", names, "", "", 120, false, "2077-11-17T00: 00: 00.000Z", "2077-11-17T00: 00: 00.000Z", categories, geometries);
Jsonb json = JsonbBuilder.create();
String result = json.toJson(event);
//TODO change coordinates to double[][]
System.out.println(result);
}
}
>>>>>>> Stashed changes
import javax.json.bind.Jsonb; <<<<<<< Updated upstream
import javax.json.bind.JsonbBuilder; import javax.json.bind.Jsonb;
import java.util.HashMap; import javax.json.bind.JsonbBuilder;
import java.util.HashSet; import java.util.HashMap;
import java.util.Set; import java.util.HashSet;
import java.util.Set;
public class Task7 {
public static void main(String[] args) { public class Task7 {
Set<Event> events = new HashSet<>(); public static void main(String[] args) {
GeoShape[] geometries = new GeoShape[] { Set<Event> events = new HashSet<>();
new GeoShape("geoShapes", new Double[] { 1000d, 223d, 121d }, new Double[] { 1000d, 223d, 121d }) }; GeoShape[] geometries = new GeoShape[] {
HashMap<String, String> names = new HashMap<>(); new GeoShape("geoShapes", new Double[] { 1000d, 223d, 121d }, new Double[] { 1000d, 223d, 121d }) };
names.put("deu", "Braunsbergbühne Lana: The Orchestra"); HashMap<String, String> names = new HashMap<>();
names.put("ita", "Comedia: The orchestra"); names.put("deu", "Braunsbergbühne Lana: The Orchestra");
names.put("ita", "Comedia: The orchestra");
Event event = new Event("ACE69C22C9DD41E6B74123BF64725F12", names, "", "", 120, false,
"2077-11-17T00: 00: 00.000Z", "2077-11-17T00: 00: 00.000Z", Event event = new Event("ACE69C22C9DD41E6B74123BF64725F12", names, "", "", 120, false,
new String[] { "odh:theatre-cinema-and-performances", "schema:TheaterEvent" }, geometries); "2077-11-17T00: 00: 00.000Z", "2077-11-17T00: 00: 00.000Z",
new String[] { "odh:theatre-cinema-and-performances", "schema:TheaterEvent" }, geometries);
for (int i = 0; i < 10; i++) {
events.add(event); for (int i = 0; i < 10; i++) {
} events.add(event);
}
Jsonb jsonb = JsonbBuilder.create();
String result = jsonb.toJson(events); Jsonb jsonb = JsonbBuilder.create();
String result = jsonb.toJson(events);
System.out.println(result);
} System.out.println(result);
} }
}
=======
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
public class Task7 {
public static void main(String[] args) {
Set<Event> events = new HashSet<Event>();
HashMap<String,String> names = new HashMap<>();
double[] coordinates1 = {11.309652, 46.863848, 1298};
double[] coordinates2 = {11.309296, 46.861944, 1342};
String[] categories = {"odh:theatre-cinema-and-performances", "schema:TheaterEvent"};
double[][] coordinates = {coordinates1, coordinates2};
GeoShape geometries = new GeoShape(coordinates1);
names.put("deu","Braunsbergbühne Lana: The Orchestra");
names.put("ita","Comedia: The orchestra");
Event event = new Event("ACE69C22C9DD41E6B74123BF64725F12", names, "", "", 120, false, "2077-11-17T00: 00: 00.000Z", "2077-11-17T00: 00: 00.000Z", categories, geometries);
for (int i = 0; i < 10; i++) {
events.add(event);
}
Jsonb jsonb = JsonbBuilder.create();
String result = jsonb.toJson(events);
System.out.println(result);
}
}
>>>>>>> Stashed changes
File added
File added
File added
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment