Commit f2f0b0141dda51a72d0b6a0839774b336158bc04

Authored by Ali B
2 parents 93215e20 d5a14569

Merge branch 'api_fixes'

Risiko/.idea/caches/build_file_checksums.ser
No preview for this file type
Risiko/app/src/main/java/activity/Activities.java
... ... @@ -61,12 +61,12 @@ public class Activities extends AppCompatActivity {
61 61 lv.setAdapter(new ListAdapterActivities(this, activities));
62 62 lv.setOnItemClickListener((parent, view, position, id) -> {
63 63 String nameOfChosenActivity = ((Activity) lv.getItemAtPosition(position)).getTitle();
64   - int activityId = ((Activity) lv.getItemAtPosition(position)).getId();
  64 + String activityId = ((Activity) lv.getItemAtPosition(position)).getId();
65 65 goToChosenActivity(nameOfChosenActivity, activityId);
66 66 });
67 67 }
68 68  
69   - private void goToChosenActivity(String nameOfChosenActivity, int activityId) {
  69 + private void goToChosenActivity(String nameOfChosenActivity, String activityId) {
70 70 Intent intent = new Intent(this, Evaluations.class);
71 71 intent.putExtra("NAME_OF_CHOSEN_ACTIVITY", nameOfChosenActivity);
72 72 intent.putExtra("ID_OF_CHOSEN_ACTIVITY", activityId);
... ...
Risiko/app/src/main/java/activity/Evaluations.java
... ... @@ -41,7 +41,7 @@ public class Evaluations extends AppCompatActivity {
41 41  
42 42 Intent intent = getIntent();
43 43 String activityName = intent.getStringExtra("NAME_OF_CHOSEN_ACTIVITY");
44   - int activityId = intent.getIntExtra("ID_OF_CHOSEN_ACTIVITY", -1);
  44 + String activityId = intent.getStringExtra("ID_OF_CHOSEN_ACTIVITY");
45 45 System.out.println(activityId);
46 46  
47 47 //TESTING AV RETROFIT: FUNKER KUN VED Å BRUKE DELING AV MOBILNETT
... ... @@ -53,12 +53,16 @@ public class Evaluations extends AppCompatActivity {
53 53 if (response.isSuccessful()) {
54 54 List<Evaluation> evaluations = response.body();
55 55 List<Evaluation> associatedEvaluations = new ArrayList<>();
56   - for (Evaluation e : evaluations) {
57   - System.out.println(e.getAssociatedactivity());
58   - if (e.getAssociatedactivity() == activityId)
59   - associatedEvaluations.add(e);
  56 +
  57 + if (evaluations != null) {
  58 + for (Evaluation e : evaluations) {
  59 + System.out.println(e.getAssociatedactivity());
  60 + System.out.println(e.getTitle());
  61 + if (e.getAssociatedactivity().equals(activityId))
  62 + associatedEvaluations.add(e);
  63 + }
60 64 }
61   - insertEvaluations(associatedEvaluations);
  65 + insertEvaluations(associatedEvaluations);
62 66 }
63 67 }
64 68  
... ...
Risiko/app/src/main/java/activity/Incident.java
... ... @@ -24,7 +24,7 @@ import retrofit2.Response;
24 24  
25 25 public class Incident extends AppCompatActivity {
26 26 ListView lv;
27   - int chosenEventId;
  27 + String chosenEventId;
28 28 DatabaseSource dbs;
29 29  
30 30 @Override
... ... @@ -34,9 +34,9 @@ public class Incident extends AppCompatActivity {
34 34  
35 35 dbs = new DatabaseSource(this);
36 36  
37   - ArrayList<dataclasses.Incident> incidentList = new ArrayList<>();
38   - dbs.getAllIncidents(incidentList);
39   - insertEvents(incidentList);
  37 +// ArrayList<dataclasses.Incident> incidentList = new ArrayList<>();
  38 +// dbs.getAllIncidents(incidentList);
  39 +// insertEvents(incidentList);
40 40  
41 41  
42 42 Api.get().getAllIncidents()
... ... @@ -46,7 +46,8 @@ public class Incident extends AppCompatActivity {
46 46 public void onResponse(Call<List<dataclasses.Incident>> call, Response<List<dataclasses.Incident>> response) {
47 47 if (response.isSuccessful()) {
48 48 List<dataclasses.Incident> incidents = response.body();
49   - insertEvents(incidents);
  49 + if (incidents != null)
  50 + insertEvents(incidents);
50 51 }
51 52 }
52 53  
... ...
Risiko/app/src/main/java/activity/NewEvaluation.java
... ... @@ -11,6 +11,7 @@ import android.widget.Spinner;
11 11 import com.risiko.risiko.R;
12 12  
13 13 import java.util.HashMap;
  14 +import java.util.UUID;
14 15  
15 16 import api.Api;
16 17 import database.DatabaseSource;
... ... @@ -32,7 +33,7 @@ public class NewEvaluation extends AppCompatActivity {
32 33 setContentView(R.layout.activity_new_evaluation);
33 34  
34 35 Intent intent = getIntent();
35   - int activityId = intent.getIntExtra("ID_OF_CHOSEN_ACTIVITY", -1);
  36 + String activityId = intent.getStringExtra("ID_OF_CHOSEN_ACTIVITY");
36 37  
37 38 dbs = new DatabaseSource(this);
38 39 etNewEvalTitle = findViewById(R.id.et_newEval_title);
... ... @@ -53,7 +54,7 @@ public class NewEvaluation extends AppCompatActivity {
53 54 int consequenceValue = getConsequenceValue(consequence);
54 55 int probabilityValue = getProbabilityValue(probability);
55 56  
56   - Api.get().newEvaluation(title, (int) (Math.random()*1000000),activityId,consequenceValue,action,outcome,probabilityValue).enqueue(new Callback<String>() {
  57 + Api.get().newEvaluation(title, UUID.randomUUID().toString() ,activityId,consequenceValue,action,outcome,probabilityValue).enqueue(new Callback<String>() {
57 58 @Override
58 59 public void onResponse(Call<String> call, Response<String> response) {
59 60 System.out.println(response);
... ...
Risiko/app/src/main/java/activity/NewIncident.java
... ... @@ -2,15 +2,19 @@ package activity;
2 2  
3 3 import android.support.v7.app.AppCompatActivity;
4 4 import android.os.Bundle;
  5 +import android.util.Log;
5 6 import android.widget.ArrayAdapter;
6 7 import android.widget.Button;
7 8 import android.widget.EditText;
8 9 import android.widget.Spinner;
  10 +import android.widget.Toast;
9 11  
10 12 import com.risiko.risiko.R;
11 13  
12 14 import java.util.ArrayList;
13 15 import java.util.HashMap;
  16 +import java.util.List;
  17 +import java.util.UUID;
14 18  
15 19 import api.Api;
16 20 import database.DatabaseSource;
... ... @@ -39,47 +43,72 @@ public class NewIncident extends AppCompatActivity {
39 43 btnNewIncident = findViewById(R.id.btn_newIncident);
40 44 dbs = new DatabaseSource(this);
41 45  
42   - ArrayList<Evaluation> evaluations = new ArrayList<>();
43   - dbs.getAllEvaluation(evaluations);
44   - HashMap<String, Integer> evalMap = convertToDictionaryWithIdAndTitle(evaluations);
45   -
46 46 spinnerAssociatedRisk = findViewById(R.id.spinner_associated_risk);
47   - ArrayAdapter<Object> adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, evalMap.keySet().toArray());
48   - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
49   - spinnerAssociatedRisk.setAdapter(adapter);
50   -
51   - btnNewIncident.setOnClickListener(view -> {
52   - if (inputAccepted()) {
53   - String title = etTitle.getText().toString();
54   - String date = etDate.getText().toString();
55   - String location = etLocation.getText().toString();
56   - String description = etDescription.getText().toString();
57   -
58   - String associatedRiskTitle = spinnerAssociatedRisk.getSelectedItem().toString();
59   - int associatedRisk = evalMap.get(associatedRiskTitle);
60   -
61   - dataclasses.Incident newIncident = new Incident(date, location, title, description, associatedRisk);
  47 +// dbs.getAllEvaluation(evaluations);
62 48  
  49 + Api.get().getAllEvaluations()
  50 + .enqueue(new Callback<List<Evaluation>>() {
63 51  
64   - Api.get().newIncident(date, title, (int) (Math.random()*1000000), associatedRisk, description, location).enqueue(new Callback<String>() {
65 52 @Override
66   - public void onResponse(Call<String> call, Response<String> response) {
67   - System.out.println(response);
  53 + public void onResponse(Call<List<dataclasses.Evaluation>> call, Response<List<dataclasses.Evaluation>> response) {
  54 + if (response.isSuccessful()) {
  55 + List<dataclasses.Evaluation> evaluations = response.body();
  56 + if (evaluations != null){
  57 + HashMap<String, String> evalMap = convertToDictionaryWithIdAndTitle(evaluations);
  58 + ArrayAdapter<Object> adapter = new ArrayAdapter<>(NewIncident.this, android.R.layout.simple_spinner_item, evalMap.keySet().toArray());
  59 + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  60 + spinnerAssociatedRisk.setAdapter(adapter);
  61 +
  62 + btnNewIncident.setOnClickListener(view -> {
  63 + if (inputAccepted()) {
  64 + String id = UUID.randomUUID().toString();
  65 + String title = etTitle.getText().toString();
  66 + String date = etDate.getText().toString();
  67 + String location = etLocation.getText().toString();
  68 + String description = etDescription.getText().toString();
  69 +
  70 + String associatedRiskTitle = spinnerAssociatedRisk.getSelectedItem().toString();
  71 + String associatedRisk = evalMap.get(associatedRiskTitle);
  72 +
  73 + dataclasses.Incident newIncident = new Incident(id, date, location, title, description, associatedRisk);
  74 +
  75 +
  76 + Api.get().newIncident(date, title, id, associatedRisk, description, location).enqueue(new Callback<String>() {
  77 + @Override
  78 + public void onResponse(Call<String> call, Response<String> response) {
  79 + System.out.println(response);
  80 + }
  81 +
  82 + @Override
  83 + public void onFailure(Call<String> call, Throwable t) {
  84 + t.printStackTrace();
  85 +
  86 + }
  87 + });
  88 +
  89 +
  90 + dbs.insertIncident(newIncident);
  91 + finish();
  92 + }
  93 + });
  94 +
  95 + } else {
  96 + Toast.makeText(NewIncident.this, "Fant ingen risikoer, for å lage en ny hendelse må den knyttes til en risiko",
  97 + Toast.LENGTH_LONG).show();
  98 + finish();
  99 + }
  100 + }
68 101 }
69 102  
70 103 @Override
71   - public void onFailure(Call<String> call, Throwable t) {
72   - t.printStackTrace();
73   -
  104 + public void onFailure(Call<List<dataclasses.Evaluation>> call, Throwable t) {
  105 + //Something went completely south (maybe you lost internet connection)
  106 + Toast.makeText(NewIncident.this, "Something went wrong",
  107 + Toast.LENGTH_LONG).show();
  108 + Log.d("Error", t.getMessage());
74 109 }
75 110 });
76 111  
77   -
78   - dbs.insertIncident(newIncident);
79   - finish();
80   - }
81   - });
82   -
83 112 }
84 113  
85 114 private boolean inputAccepted() {
... ... @@ -91,8 +120,8 @@ public class NewIncident extends AppCompatActivity {
91 120 return true;
92 121 }
93 122  
94   - private HashMap<String, Integer> convertToDictionaryWithIdAndTitle(ArrayList<Evaluation> evaluations) {
95   - HashMap<String, Integer> evalMap = new HashMap<>();
  123 + private HashMap<String, String> convertToDictionaryWithIdAndTitle(List<Evaluation> evaluations) {
  124 + HashMap<String, String> evalMap = new HashMap<>();
96 125 for (Evaluation e : evaluations) {
97 126 evalMap.put(e.getTitle(), e.getId());
98 127 }
... ...
Risiko/app/src/main/java/api/Endpoints.java
... ... @@ -3,6 +3,7 @@ package api;
3 3 import java.util.Date;
4 4 import java.util.HashMap;
5 5 import java.util.List;
  6 +import java.util.UUID;
6 7  
7 8 import dataclasses.Activity;
8 9 import dataclasses.Evaluation;
... ... @@ -22,13 +23,13 @@ public interface Endpoints {
22 23  
23 24  
24 25 // THE BASEURL HAS TO BE CHANGE TO THE IP-ADDRESS YOU ARE CONNECTED TO AT LOCALHOST
25   - String BASEURL = "http://172.20.10.2:3000/";
  26 + String BASEURL = "http://172.20.10.4:3000/";
26 27  
27 28 @GET("evaluation")
28 29 Call<List<Evaluation>> getAllEvaluations();
29 30  
30 31 @GET("evaluation/{id}")
31   - Call<List<Evaluation>> getEvaluation(@Path("id") int id);
  32 + Call<List<Evaluation>> getEvaluation(@Path("id") String id);
32 33  
33 34 @GET("activity")
34 35 Call<List<Activity>> getAllActivities();
... ... @@ -37,16 +38,16 @@ public interface Endpoints {
37 38 Call<List<Incident>> getAllIncidents();
38 39  
39 40 @GET("incident/{id}")
40   - Call<List<Incident>> getIncident(@Path("id") int id);
  41 + Call<List<Incident>> getIncident(@Path("id") String id);
41 42  
42 43 @FormUrlEncoded
43 44 @POST("incident")
44   - Call<String> newIncident(@Field("date") String date, @Field("title") String title, @Field("id") int id, @Field("associatedEval") int associatedEval,
  45 + Call<String> newIncident(@Field("date") String date, @Field("title") String title, @Field("id") String id, @Field("associatedEval") String associatedEval,
45 46 @Field("description") String description, @Field("location") String location);
46 47  
47 48 @FormUrlEncoded
48 49 @POST("evaluation")
49   - Call<String> newEvaluation(@Field("title") String title, @Field("id") int id, @Field("associatedActivity") int associatedactivity,
  50 + Call<String> newEvaluation(@Field("title") String title, @Field("id") String id, @Field("associatedActivity") String associatedactivity,
50 51 @Field("consequence") int consequence, @Field("measures") String measures, @Field("outcome") String outcome, @Field("probability") int probability);
51 52  
52 53  
... ...
Risiko/app/src/main/java/database/DatabaseSource.java
... ... @@ -6,6 +6,7 @@ import android.database.Cursor;
6 6 import android.database.sqlite.SQLiteDatabase;
7 7  
8 8 import java.util.ArrayList;
  9 +import java.util.UUID;
9 10  
10 11 import dataclasses.Evaluation;
11 12 import dataclasses.Incident;
... ... @@ -36,7 +37,8 @@ public class DatabaseSource {
36 37  
37 38 public boolean insertIncident(Incident incident) {
38 39 ContentValues values = new ContentValues();
39   - values.put(IncidentTable.INCIDENT_COL_ASSOCIATED_EVALUATION, incident.getAssociatedeval());
  40 + values.put(IncidentTable.INCIDENT_COL_ID, incident.getId());
  41 + values.put(IncidentTable.INCIDENT_COL_ASSOCIATED_EVALUATION, incident.getAssociatedeval().toString());
40 42 values.put(IncidentTable.INCIDENT_COL_TITLE, incident.getTitle());
41 43 values.put(IncidentTable.INCIDENT_COL_DATE, incident.getDate().toString());
42 44 values.put(IncidentTable.INCIDENT_COL_LOCATION, incident.getLocation());
... ... @@ -62,7 +64,7 @@ public class DatabaseSource {
62 64 database.close();
63 65 }
64 66  
65   - public Evaluation getEvaluationById(int id) {
  67 + public Evaluation getEvaluationById(String id) {
66 68 SQLiteDatabase database = helper.getWritableDatabase();
67 69 Cursor cursor = database.rawQuery("select * from " + EvaluationTable.EVALUATION_TABLE + " where " + EvaluationTable.EVALUATION_COL_ID + " = " + " ?", new String[]{String.valueOf(id)});
68 70 cursor.moveToFirst();
... ... @@ -72,7 +74,7 @@ public class DatabaseSource {
72 74 return new Evaluation();
73 75 }
74 76  
75   - public void getAllEvaluationsForActivity(int activityId, ArrayList<Evaluation> listToUpdate) {
  77 + public void getAllEvaluationsForActivity(String activityId, ArrayList<Evaluation> listToUpdate) {
76 78 SQLiteDatabase database = helper.getWritableDatabase();
77 79 Cursor cursor = database.rawQuery("select * from " + EvaluationTable.EVALUATION_TABLE + " where " + EvaluationTable.EVALUATION_COL_ASSOCIATED_ACTIVITY + " = " + " ?", new String[]{String.valueOf(activityId)});
78 80 cursor.moveToFirst();
... ... @@ -108,8 +110,8 @@ public class DatabaseSource {
108 110 int consequenceIndex = cursor.getColumnIndexOrThrow(EvaluationTable.EVALUATION_COL_CONSEQUENCE);
109 111 int probabilityIndex = cursor.getColumnIndexOrThrow(EvaluationTable.EVALUATION_COL_PROBABILITY);
110 112  
111   - data.setId(cursor.getInt(idIndex));
112   - data.setAssociatedactivity(cursor.getInt(associatedActivityIndex));
  113 + data.setId(cursor.getString(idIndex));
  114 + data.setAssociatedactivity(cursor.getString(associatedActivityIndex));
113 115 data.setTitle(cursor.getString(titleIndex));
114 116 data.setOutcome(cursor.getString(outcomeIndex));
115 117 data.setMeasures(cursor.getString(actionIndex));
... ... @@ -128,8 +130,8 @@ public class DatabaseSource {
128 130 int locationIndex = cursor.getColumnIndexOrThrow(IncidentTable.INCIDENT_COL_LOCATION);
129 131 int descriptionIndex = cursor.getColumnIndexOrThrow(IncidentTable.INCIDENT_COL_DESCRIPTION);
130 132  
131   - data.setId(cursor.getInt(idIndex));
132   - data.setAssociatedeval(cursor.getInt(associatedEvaluationIndex));
  133 + data.setId(cursor.getString(idIndex));
  134 + data.setAssociatedeval(cursor.getString(associatedEvaluationIndex));
133 135 data.setTitle(cursor.getString(titleIndex));
134 136 data.setDate(cursor.getString(dateIndex));
135 137 data.setLocation(cursor.getString(locationIndex));
... ...
Risiko/app/src/main/java/database/EvaluationTable.java
... ... @@ -15,8 +15,8 @@ public class EvaluationTable {
15 15  
16 16 private static final String EVALUATION_TABLE_CREATE =
17 17 "CREATE TABLE IF NOT EXISTS " + EVALUATION_TABLE + " ("
18   - + EVALUATION_COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
19   - + EVALUATION_COL_ASSOCIATED_ACTIVITY + " INTEGER, "
  18 + + EVALUATION_COL_ID + " TEXT PRIMARY KEY, "
  19 + + EVALUATION_COL_ASSOCIATED_ACTIVITY + " TEXT, "
20 20 + EVALUATION_COL_TITLE + " TEXT, "
21 21 + EVALUATION_COL_OUTCOME + " TEXT, "
22 22 + EVALUATION_COL_ACTION + " TEXT, "
... ...
Risiko/app/src/main/java/database/IncidentTable.java
... ... @@ -14,8 +14,8 @@ public class IncidentTable {
14 14  
15 15 private static final String INCIDENT_TABLE_CREATE =
16 16 "CREATE TABLE IF NOT EXISTS " + INCIDENT_TABLE + " ("
17   - + INCIDENT_COL_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
18   - + INCIDENT_COL_ASSOCIATED_EVALUATION + " INTEGER, "
  17 + + INCIDENT_COL_ID + " TEXT PRIMARY KEY, "
  18 + + INCIDENT_COL_ASSOCIATED_EVALUATION + " TEXT, "
19 19 + INCIDENT_COL_TITLE + " TEXT, "
20 20 + INCIDENT_COL_DATE + " TEXT, "
21 21 + INCIDENT_COL_LOCATION + " TEXT, "
... ...
Risiko/app/src/main/java/dataclasses/Activity.java
... ... @@ -9,31 +9,30 @@ import java.util.UUID;
9 9  
10 10 public class Activity {
11 11  
12   - private UUID uuid;
13   - private int id;
  12 + private String id;
14 13 private String title;
15 14 private ArrayList<Activity> allActivities;
16 15  
17 16 public Activity(String title) {
18 17 allActivities = new ArrayList<>();
19 18 this.title = title;
20   - uuid = UUID.randomUUID();
21 19 }
22 20  
23   - public Activity(int id, String name) {
  21 + public Activity(String id, String name) {
24 22 this.id = id;
25 23 allActivities = new ArrayList<>();
26 24 this.title = name;
27 25 }
28 26  
29   - public int getId() {
  27 + public String getId() {
30 28 return id;
31 29 }
32 30  
33   - public void setId(int id) {
  31 + public void setId(String id) {
34 32 this.id = id;
35 33 }
36 34  
  35 +
37 36 public String getTitle() {
38 37 return title;
39 38 }
... ...
Risiko/app/src/main/java/dataclasses/Evaluation.java
... ... @@ -11,42 +11,39 @@ public class Evaluation {
11 11 public static final int CONSEQUENCE_HARMLESS = 1, CONSEQUENCE_MODERATE = 2, CONSEQUENCE_SEVERE = 3;
12 12 public static final int PROBABILITY_LOW = 1, PROBABILITY_MEDIUM = 2, PROBABILITY_HIGH = 3;
13 13  
14   - UUID uuid;
15   - int id;
16   - int associatedactivity;
  14 + String id;
  15 + String associatedactivity;
17 16 String title;
18 17 String outcome;
19 18 String measures;
20 19 int consequence;
21 20 int probability;
22 21  
23   - public Evaluation() {
24   - uuid = UUID.randomUUID();
25   - }
  22 + public Evaluation() { }
26 23  
27   - public Evaluation(int associatedactivity, String title, String outcome, String measures, int consequence, int probability) {
  24 + public Evaluation(String associatedactivity, String title, String outcome, String measures, int consequence, int probability) {
28 25 this.title = title;
29 26 this.associatedactivity = associatedactivity;
30 27 this.outcome = outcome;
31 28 this.measures = measures;
32 29 this.consequence = consequence;
33 30 this.probability = probability;
34   - uuid = UUID.randomUUID();
35 31 }
36 32  
37   - public int getId() {
  33 + public String getId() {
38 34 return id;
39 35 }
40 36  
41   - public void setId(int id) {
  37 + public void setId(String id) {
42 38 this.id = id;
43 39 }
44 40  
45   - public int getAssociatedactivity() {
  41 +
  42 + public String getAssociatedactivity() {
46 43 return associatedactivity;
47 44 }
48 45  
49   - public void setAssociatedactivity(int associatedactivity) {
  46 + public void setAssociatedactivity(String associatedactivity) {
50 47 this.associatedactivity = associatedactivity;
51 48 }
52 49  
... ...
Risiko/app/src/main/java/dataclasses/Incident.java
... ... @@ -7,37 +7,35 @@ import java.util.UUID;
7 7  
8 8 public class Incident {
9 9  
10   - UUID uuid;
  10 + private String id;
11 11 private String date;
12 12 private String location;
13 13 private String title;
14 14 private String description;
15   - private int id;
16   - private int associatedeval;
  15 + private String associatedeval;
17 16  
18 17  
19 18 public Incident() {
20   - uuid = UUID.randomUUID();
21 19 }
22 20  
23   - public Incident(String date, String place, String title, String description, int associatedeval) {
  21 + public Incident(String id, String date, String place, String title, String description, String associatedeval) {
  22 + this.id = id;
24 23 this.date = date;
25 24 this.location = place;
26 25 this.title = title;
27 26 this.description = description;
28 27 this.associatedeval = associatedeval;
29   - uuid = UUID.randomUUID();
30 28 }
31 29  
32 30 public Incident(String title) {
33 31 this.title = title;
34 32 }
35 33  
36   - public int getAssociatedeval() {
  34 + public String getAssociatedeval() {
37 35 return associatedeval;
38 36 }
39 37  
40   - public void setAssociatedeval(int associatedeval) {
  38 + public void setAssociatedeval(String associatedeval) {
41 39 this.associatedeval = associatedeval;
42 40 }
43 41  
... ... @@ -73,11 +71,11 @@ public class Incident {
73 71 this.description = description;
74 72 }
75 73  
76   - public int getId() {
  74 + public String getId() {
77 75 return id;
78 76 }
79 77  
80   - public void setId(int id) {
  78 + public void setId(String id) {
81 79 this.id = id;
82 80 }
83 81 }
... ...
restApi/.idea/workspace.xml
... ... @@ -2,60 +2,90 @@
2 2 <project version="4">
3 3 <component name="ChangeListManager">
4 4 <list default="true" id="0e20d303-9de8-4113-bfd9-019e72b304dc" name="Default" comment="">
5   - <change beforePath="$PROJECT_DIR$/../Rapport - Distribuert server-klient.docx" afterPath="$PROJECT_DIR$/../Rapport - Distribuert server-klient.docx" />
6   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Evaluations.java" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Evaluations.java" />
7   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/NewEvaluation.java" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/NewEvaluation.java" />
8   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/api/Endpoints.java" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/api/Endpoints.java" />
9   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/database/DatabaseSource.java" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/database/DatabaseSource.java" />
10   - <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/dataclasses/Evaluation.java" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/dataclasses/Evaluation.java" />
  5 + <change beforePath="$PROJECT_DIR$/../Risiko/.idea/caches/build_file_checksums.ser" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/.idea/caches/build_file_checksums.ser" afterDir="false" />
  6 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Activities.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Activities.java" afterDir="false" />
  7 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Evaluations.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Evaluations.java" afterDir="false" />
  8 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Incident.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/Incident.java" afterDir="false" />
  9 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/NewEvaluation.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/NewEvaluation.java" afterDir="false" />
  10 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/NewIncident.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/activity/NewIncident.java" afterDir="false" />
  11 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/api/Endpoints.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/api/Endpoints.java" afterDir="false" />
  12 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/database/DatabaseSource.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/database/DatabaseSource.java" afterDir="false" />
  13 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/database/EvaluationTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/database/EvaluationTable.java" afterDir="false" />
  14 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/database/IncidentTable.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/database/IncidentTable.java" afterDir="false" />
  15 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/dataclasses/Activity.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/dataclasses/Activity.java" afterDir="false" />
  16 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/dataclasses/Evaluation.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/dataclasses/Evaluation.java" afterDir="false" />
  17 + <change beforePath="$PROJECT_DIR$/../Risiko/app/src/main/java/dataclasses/Incident.java" beforeDir="false" afterPath="$PROJECT_DIR$/../Risiko/app/src/main/java/dataclasses/Incident.java" afterDir="false" />
  18 + <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
  19 + <change beforePath="$PROJECT_DIR$/api/routes/routes.js" beforeDir="false" afterPath="$PROJECT_DIR$/api/routes/routes.js" afterDir="false" />
11 20 </list>
12 21 <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
13   - <option name="TRACKING_ENABLED" value="true" />
14 22 <option name="SHOW_DIALOG" value="false" />
15 23 <option name="HIGHLIGHT_CONFLICTS" value="true" />
16 24 <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
17 25 <option name="LAST_RESOLUTION" value="IGNORE" />
18 26 </component>
  27 + <component name="FUSProjectUsageTrigger">
  28 + <session id="535790383">
  29 + <usages-collector id="statistics.lifecycle.project">
  30 + <counts>
  31 + <entry key="project.closed" value="2" />
  32 + <entry key="project.open.time.1" value="1" />
  33 + <entry key="project.open.time.31" value="1" />
  34 + <entry key="project.opened" value="2" />
  35 + </counts>
  36 + </usages-collector>
  37 + <usages-collector id="statistics.file.extensions.edit">
  38 + <counts>
  39 + <entry key="js" value="3212" />
  40 + </counts>
  41 + </usages-collector>
  42 + <usages-collector id="statistics.file.types.edit">
  43 + <counts>
  44 + <entry key="JavaScript" value="3212" />
  45 + </counts>
  46 + </usages-collector>
  47 + <usages-collector id="statistics.file.types.open">
  48 + <counts>
  49 + <entry key="JavaScript" value="1" />
  50 + </counts>
  51 + </usages-collector>
  52 + <usages-collector id="statistics.vcs.git.usages" />
  53 + <usages-collector id="statistics.js.language.service.starts" />
  54 + <usages-collector id="statistics.file.extensions.open">
  55 + <counts>
  56 + <entry key="js" value="1" />
  57 + </counts>
  58 + </usages-collector>
  59 + </session>
  60 + </component>
19 61 <component name="FileEditorManager">
20 62 <leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
21   - <file leaf-file-name="routes.js" pinned="false" current-in-tab="false">
  63 + <file pinned="false" current-in-tab="true">
22 64 <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
23 65 <provider selected="true" editor-type-id="text-editor">
24   - <state relative-caret-position="308">
25   - <caret line="71" column="52" lean-forward="true" selection-start-line="71" selection-start-column="52" selection-end-line="71" selection-end-column="52" />
26   - <folding />
  66 + <state relative-caret-position="337">
  67 + <caret line="75" column="7" lean-forward="true" selection-start-line="75" selection-start-column="7" selection-end-line="75" selection-end-column="7" />
27 68 </state>
28 69 </provider>
29 70 </entry>
30 71 </file>
31   - <file leaf-file-name="package.json" pinned="false" current-in-tab="false">
  72 + <file pinned="false" current-in-tab="false">
32 73 <entry file="file://$PROJECT_DIR$/package.json">
33 74 <provider selected="true" editor-type-id="text-editor">
34   - <state relative-caret-position="120">
35   - <caret line="8" column="38" lean-forward="false" selection-start-line="8" selection-start-column="38" selection-end-line="8" selection-end-column="38" />
36   - <folding />
  75 + <state relative-caret-position="136">
  76 + <caret line="8" column="48" selection-start-line="8" selection-start-column="48" selection-end-line="8" selection-end-column="48" />
37 77 </state>
38 78 </provider>
39 79 </entry>
40 80 </file>
41   - <file leaf-file-name="evaluation.js" pinned="false" current-in-tab="false">
  81 + <file pinned="false" current-in-tab="false">
42 82 <entry file="file://$PROJECT_DIR$/api/modules/evaluation.js">
43   - <provider selected="true" editor-type-id="text-editor">
44   - <state relative-caret-position="0">
45   - <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
46   - <folding />
47   - </state>
48   - </provider>
  83 + <provider selected="true" editor-type-id="text-editor" />
49 84 </entry>
50 85 </file>
51   - <file leaf-file-name="incident.js" pinned="false" current-in-tab="true">
  86 + <file pinned="false" current-in-tab="false">
52 87 <entry file="file://$PROJECT_DIR$/api/modules/incident.js">
53   - <provider selected="true" editor-type-id="text-editor">
54   - <state relative-caret-position="0">
55   - <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
56   - <folding />
57   - </state>
58   - </provider>
  88 + <provider selected="true" editor-type-id="text-editor" />
59 89 </entry>
60 90 </file>
61 91 </leaf>
... ... @@ -66,8 +96,8 @@
66 96 <component name="IdeDocumentHistory">
67 97 <option name="CHANGED_PATHS">
68 98 <list>
69   - <option value="$PROJECT_DIR$/api/routes/routes.js" />
70 99 <option value="$PROJECT_DIR$/package.json" />
  100 + <option value="$PROJECT_DIR$/api/routes/routes.js" />
71 101 </list>
72 102 </option>
73 103 </component>
... ... @@ -82,28 +112,23 @@
82 112 <component name="NodeModulesDirectoryManager">
83 113 <handled-path value="$PROJECT_DIR$/node_modules" />
84 114 </component>
85   - <component name="ProjectFrameBounds" fullScreen="true">
86   - <option name="x" value="1" />
87   - <option name="y" value="23" />
88   - <option name="width" value="1440" />
89   - <option name="height" value="873" />
  115 + <component name="NodePackageJsonFileManager">
  116 + <packageJsonPaths>
  117 + <path value="$PROJECT_DIR$/package.json" />
  118 + </packageJsonPaths>
  119 + </component>
  120 + <component name="ProjectFrameBounds" extendedState="6">
  121 + <option name="x" value="352" />
  122 + <option name="y" value="96" />
  123 + <option name="width" value="1536" />
  124 + <option name="height" value="832" />
90 125 </component>
91 126 <component name="ProjectView">
92   - <navigator currentView="ProjectPane" proportions="" version="1">
93   - <flattenPackages />
94   - <showMembers />
95   - <showModules />
96   - <showLibraryContents />
97   - <hideEmptyPackages />
98   - <abbreviatePackageNames />
99   - <autoscrollToSource />
100   - <autoscrollFromSource />
101   - <sortByType />
102   - <manualOrder />
  127 + <navigator proportions="" version="1">
103 128 <foldersAlwaysOnTop value="true" />
104 129 </navigator>
105 130 <panes>
106   - <pane id="Scratches" />
  131 + <pane id="Scope" />
107 132 <pane id="ProjectPane">
108 133 <subPane>
109 134 <expand>
... ... @@ -132,11 +157,11 @@
132 157 <select />
133 158 </subPane>
134 159 </pane>
135   - <pane id="Scope" />
136 160 </panes>
137 161 </component>
138 162 <component name="PropertiesComponent">
139 163 <property name="WebServerToolWindowFactoryState" value="false" />
  164 + <property name="nodejs_package_manager_path" value="npm" />
140 165 </component>
141 166 <component name="RunDashboard">
142 167 <option name="ruleStates">
... ... @@ -151,7 +176,9 @@
151 176 </option>
152 177 </component>
153 178 <component name="RunManager" selected="npm.debug">
154   - <configuration name="server.js" type="NodeJSConfigurationType" factoryName="Node.js" temporary="true" path-to-js-file="server.js" working-dir="$PROJECT_DIR$" />
  179 + <configuration name="server.js" type="NodeJSConfigurationType" factoryName="Node.js" temporary="true" path-to-js-file="server.js" working-dir="$PROJECT_DIR$">
  180 + <method v="2" />
  181 + </configuration>
155 182 <configuration name="api" type="js.build_tools.npm" factoryName="npm" temporary="true" nameIsGenerated="true">
156 183 <package-json value="$PROJECT_DIR$/package.json" />
157 184 <command value="run" />
... ... @@ -160,6 +187,7 @@
160 187 </scripts>
161 188 <node-interpreter value="project" />
162 189 <envs />
  190 + <method v="2" />
163 191 </configuration>
164 192 <configuration name="debug" type="js.build_tools.npm" factoryName="npm" temporary="true" nameIsGenerated="true">
165 193 <package-json value="$PROJECT_DIR$/package.json" />
... ... @@ -169,23 +197,21 @@
169 197 </scripts>
170 198 <node-interpreter value="project" />
171 199 <envs />
  200 + <method v="2" />
172 201 </configuration>
173   - <list size="3">
174   - <item index="0" class="java.lang.String" itemvalue="Node.js.server.js" />
175   - <item index="1" class="java.lang.String" itemvalue="npm.api" />
176   - <item index="2" class="java.lang.String" itemvalue="npm.debug" />
  202 + <list>
  203 + <item itemvalue="Node.js.server.js" />
  204 + <item itemvalue="npm.api" />
  205 + <item itemvalue="npm.debug" />
177 206 </list>
178 207 <recent_temporary>
179   - <list size="3">
180   - <item index="0" class="java.lang.String" itemvalue="npm.debug" />
181   - <item index="1" class="java.lang.String" itemvalue="npm.api" />
182   - <item index="2" class="java.lang.String" itemvalue="Node.js.server.js" />
  208 + <list>
  209 + <item itemvalue="npm.api" />
  210 + <item itemvalue="npm.debug" />
  211 + <item itemvalue="Node.js.server.js" />
183 212 </list>
184 213 </recent_temporary>
185 214 </component>
186   - <component name="ShelveChangesManager" show_recycled="false">
187   - <option name="remove_strategy" value="false" />
188   - </component>
189 215 <component name="SvnConfiguration">
190 216 <configuration />
191 217 </component>
... ... @@ -199,33 +225,37 @@
199 225 <workItem from="1541088608198" duration="134000" />
200 226 <workItem from="1541088784358" duration="1764000" />
201 227 <workItem from="1541155443683" duration="1473000" />
  228 + <workItem from="1541596156631" duration="9351000" />
  229 + <workItem from="1541681303243" duration="9060000" />
202 230 </task>
203 231 <servers />
204 232 </component>
205 233 <component name="TimeTrackingManager">
206   - <option name="totallyTimeSpent" value="3371000" />
  234 + <option name="totallyTimeSpent" value="21782000" />
207 235 </component>
208 236 <component name="ToolWindowManager">
209   - <frame x="0" y="0" width="1440" height="900" extended-state="0" />
  237 + <frame x="-8" y="-8" width="1936" height="1056" extended-state="6" />
  238 + <editor active="true" />
210 239 <layout>
211   - <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24947146" sideWeight="0.49369368" order="0" side_tool="false" content_ui="combo" />
212   - <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
213   - <window_info id="Docker" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
214   - <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
215   - <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
216   - <window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32889965" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
217   - <window_info id="npm" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.24947146" sideWeight="0.5063063" order="2" side_tool="true" content_ui="tabs" />
218   - <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
219   - <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
220   - <window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
221   - <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.39903265" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
222   - <window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
223   - <window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
224   - <window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
225   - <window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
226   - <window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
227   - <window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
228   - <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
  240 + <window_info content_ui="combo" id="Project" order="0" sideWeight="0.7223427" visible="true" weight="0.20073763" />
  241 + <window_info id="Structure" order="1" weight="0.25" />
  242 + <window_info id="npm" order="2" sideWeight="0.27765727" side_tool="true" visible="true" weight="0.20073763" />
  243 + <window_info id="Favorites" order="3" side_tool="true" />
  244 + <window_info anchor="bottom" id="Message" order="0" />
  245 + <window_info anchor="bottom" id="Find" order="1" />
  246 + <window_info anchor="bottom" id="Run" order="2" weight="0.3286334" />
  247 + <window_info anchor="bottom" id="Debug" order="3" weight="0.39903265" />
  248 + <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
  249 + <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
  250 + <window_info anchor="bottom" id="TODO" order="6" />
  251 + <window_info anchor="bottom" id="Docker" order="7" show_stripe_button="false" />
  252 + <window_info anchor="bottom" id="Version Control" order="8" />
  253 + <window_info anchor="bottom" id="Terminal" order="9" />
  254 + <window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
  255 + <window_info anchor="bottom" id="Messages" order="11" />
  256 + <window_info anchor="right" id="Commander" order="0" weight="0.4" />
  257 + <window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
  258 + <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
229 259 </layout>
230 260 </component>
231 261 <component name="TypeScriptGeneratedFilesManager">
... ... @@ -234,79 +264,33 @@
234 264 <component name="VcsContentAnnotationSettings">
235 265 <option name="myLimit" value="2678400000" />
236 266 </component>
237   - <component name="XDebuggerManager">
238   - <breakpoint-manager>
239   - <breakpoints>
240   - <line-breakpoint enabled="true" type="javascript">
241   - <url>file://$PROJECT_DIR$/api/routes/routes.js</url>
242   - <line>171</line>
243   - <properties lambdaOrdinal="-1" />
244   - </line-breakpoint>
245   - <line-breakpoint enabled="true" type="javascript">
246   - <url>file://$PROJECT_DIR$/api/routes/routes.js</url>
247   - <line>170</line>
248   - <properties lambdaOrdinal="-1" />
249   - <option name="timeStamp" value="1" />
250   - </line-breakpoint>
251   - <line-breakpoint enabled="true" type="javascript">
252   - <url>file://$PROJECT_DIR$/api/routes/routes.js</url>
253   - <line>182</line>
254   - <properties lambdaOrdinal="-1" />
255   - <option name="timeStamp" value="2" />
256   - </line-breakpoint>
257   - </breakpoints>
258   - <option name="time" value="3" />
259   - </breakpoint-manager>
260   - <watches-manager />
261   - </component>
262 267 <component name="editorHistoryManager">
263   - <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
  268 + <entry file="file://$PROJECT_DIR$/node_modules/cassandra-driver/lib/requests.js">
264 269 <provider selected="true" editor-type-id="text-editor">
265   - <state relative-caret-position="0">
266   - <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
267   - <folding />
  270 + <state relative-caret-position="190">
  271 + <caret line="106" column="9" selection-start-line="106" selection-start-column="9" selection-end-line="106" selection-end-column="9" />
268 272 </state>
269 273 </provider>
270 274 </entry>
271   - <entry file="file://$PROJECT_DIR$/api/modules/evaluation.js">
  275 + <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
272 276 <provider selected="true" editor-type-id="text-editor">
273   - <state relative-caret-position="0">
274   - <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
275   - <folding />
  277 + <state relative-caret-position="337">
  278 + <caret line="75" column="7" lean-forward="true" selection-start-line="75" selection-start-column="7" selection-end-line="75" selection-end-column="7" />
276 279 </state>
277 280 </provider>
278 281 </entry>
279 282 <entry file="file://$PROJECT_DIR$/package.json">
280 283 <provider selected="true" editor-type-id="text-editor">
281   - <state relative-caret-position="120">
282   - <caret line="8" column="38" lean-forward="false" selection-start-line="8" selection-start-column="38" selection-end-line="8" selection-end-column="38" />
283   - <folding />
284   - </state>
285   - </provider>
286   - </entry>
287   - <entry file="file://$PROJECT_DIR$/api/routes/routes.js">
288   - <provider selected="true" editor-type-id="text-editor">
289   - <state relative-caret-position="308">
290   - <caret line="71" column="52" lean-forward="true" selection-start-line="71" selection-start-column="52" selection-end-line="71" selection-end-column="52" />
291   - <folding />
  284 + <state relative-caret-position="136">
  285 + <caret line="8" column="48" selection-start-line="8" selection-start-column="48" selection-end-line="8" selection-end-column="48" />
292 286 </state>
293 287 </provider>
294 288 </entry>
295 289 <entry file="file://$PROJECT_DIR$/api/modules/evaluation.js">
296   - <provider selected="true" editor-type-id="text-editor">
297   - <state relative-caret-position="0">
298   - <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
299   - <folding />
300   - </state>
301   - </provider>
  290 + <provider selected="true" editor-type-id="text-editor" />
302 291 </entry>
303 292 <entry file="file://$PROJECT_DIR$/api/modules/incident.js">
304   - <provider selected="true" editor-type-id="text-editor">
305   - <state relative-caret-position="0">
306   - <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
307   - <folding />
308   - </state>
309   - </provider>
  293 + <provider selected="true" editor-type-id="text-editor" />
310 294 </entry>
311 295 </component>
312 296 </project>
313 297 \ No newline at end of file
... ...
restApi/api/routes/routes.js
... ... @@ -6,7 +6,7 @@ const Activity = require(&quot;../modules/activity.js&quot;);
6 6 const uuid = require('uuid');
7 7 var cassandra = require("cassandra-driver");
8 8  
9   -var client = setupDatabase('127.0.0.1');
  9 +var db = setupDatabase('127.0.0.1');
10 10  
11 11 var appRouter = function(app) {
12 12  
... ... @@ -20,22 +20,32 @@ var appRouter = function(app) {
20 20 * Get incident by id endpoint (a get request at http://localhost:3000/incident/1 will return incident with id 1)
21 21 */
22 22 app.get("/incident/:id", function (req, res) {
23   - if (!req.params.id) return req.status(400).send("No id entered");
  23 + if (!req.params.id) {
  24 + logEndpoint("get /incident/{id}", null, "ID missing");
  25 + return req.status(400).send("No id entered");
  26 + }
24 27  
25 28 const params = [req.params.id];
26   - client.execute('SELECT * FROM risk.incident WHERE id = ?', params,{ prepare: true }, function(err, result) {
27   - if(err) {
28   - console.log(err);
29   - return res.status(400).send("Bad Request, make sure to send a request with an id")
30   - } else {
31   - if (result.rows.length != 0)
32   - return res.status(200).send(result.rows[0]);
33   - else
34   - return res.status(204).send("Id not found in database");
35   -
  29 + db.execute('SELECT * ' +
  30 + 'FROM risk.incident ' +
  31 + 'WHERE id = ?',
  32 + params,
  33 + { prepare: true },
  34 + function(err, result) {
  35 + if(err) {
  36 + logEndpoint("get /incident/{id}", err, null);
  37 + return res.status(400).send("Bad request, see API log");
  38 + } else {
  39 + if (result.rows.length != 0) {
  40 + logEndpoint("get /incident/{id}", err, "Success, incident returned");
  41 + return res.status(200).send(result.rows[0]);
  42 + } else {
  43 + logEndpoint("get /incident/{id}", err, "Success but id not found in database");
  44 + return res.status(204).send("Id not found in database");
  45 + }
  46 + }
36 47 }
37   - });
38   -
  48 + );
39 49 });
40 50  
41 51 /**
... ... @@ -43,20 +53,24 @@ var appRouter = function(app) {
43 53 */
44 54 app.get("/incident", function (req, res) {
45 55  
46   - client.execute('SELECT * FROM risk.incident', function (err, result) {
47   - if(err) {
48   - console.log(err);
49   - return res.status(400).send("Bad Request");
50   -
51   - } else {
52   - if (result.rows.length != 0)
53   - return res.status(200).send(result.rows);
54   - else
55   - return res.status(204).send("No registered incidents");
  56 + db.execute('SELECT * ' +
  57 + 'FROM risk.incident',
  58 + function (err, result) {
  59 + if(err) {