Commit ae785bf3 authored by Øyvin Halfdan Thuv's avatar Øyvin Halfdan Thuv
Browse files

Cleanup + comments.

parent a9585ed3
......@@ -21,14 +21,15 @@ public class IncidentController {
Cluster cluster;
Session session;
PreparedStatement insertStmt;
/*
* Initialize controller with database connection.
*
* CREATE KEYSPACE storage WITH REPLICATION = {
* 'class': 'SimpleStrategy',
* 'replication_factor': 1
* };
*/
public IncidentController () {
cluster = Cluster.builder()
.addContactPoint("127.0.0.1").build();
......@@ -39,6 +40,8 @@ public class IncidentController {
}
/*
* Get all incidents from the database.
*
* Prerequisite for DB:
*
* USE storage;
......@@ -57,6 +60,8 @@ public class IncidentController {
}
/*
* Create a new incident and store it in the database.
*
* Prerequisite for DB:
*
* USE storage;
......@@ -65,7 +70,7 @@ public class IncidentController {
@RequestMapping(value="/incidents", method=RequestMethod.POST)
public Incident newIncident(@RequestBody Incident i) {
UUID id = UUID.randomUUID();
session.execute(insertStmt.bind(id, i.getName()));
session.execute(insertStmt.bind(i.getId(), i.getName()));
i.setId(id);
return i;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment