|
15 | 15 | package dao.versions.cassandra; |
16 | 16 |
|
17 | 17 | import com.google.common.base.CaseFormat; |
18 | | - |
19 | 18 | import dao.versions.VersionHistoryDagFactory; |
20 | 19 | import db.CassandraClient; |
21 | | -import db.CassandraResults; |
22 | | -import db.DbClient; |
23 | 20 | import db.DbDataContainer; |
24 | 21 | import exceptions.GroundException; |
| 22 | +import java.util.ArrayList; |
| 23 | +import java.util.HashSet; |
| 24 | +import java.util.List; |
| 25 | +import java.util.Set; |
25 | 26 | import models.models.Structure; |
26 | 27 | import models.versions.GroundType; |
27 | 28 | import models.versions.Item; |
28 | 29 | import models.versions.Version; |
29 | 30 | import models.versions.VersionHistoryDag; |
30 | 31 | import models.versions.VersionSuccessor; |
31 | 32 |
|
32 | | -import java.util.ArrayList; |
33 | | -import java.util.HashSet; |
34 | | -import java.util.List; |
35 | | -import java.util.Set; |
36 | | - |
37 | 33 | public class CassandraVersionHistoryDagFactory implements VersionHistoryDagFactory { |
38 | 34 | private final CassandraClient dbClient; |
39 | 35 | private final CassandraVersionSuccessorFactory versionSuccessorFactory; |
@@ -87,14 +83,11 @@ public void addEdge(VersionHistoryDag dag, long parentId, long childId, long ite |
87 | 83 | VersionSuccessor successor = this.versionSuccessorFactory.create(parentId, childId); |
88 | 84 |
|
89 | 85 | // Adding to the entry with id = successor.getId() |
90 | | - List<DbDataContainer> predicate = new ArrayList<>(); |
| 86 | + List<DbDataContainer> newValue = new ArrayList<>(), predicate = new ArrayList<>(); |
| 87 | + newValue.add(new DbDataContainer("item_id", GroundType.LONG, itemId)); |
91 | 88 | predicate.add(new DbDataContainer("id", GroundType.LONG, successor.getId())); |
92 | 89 |
|
93 | | - // To add to a set column, must pass in a set containing the value(s) to add. See CasandraClient.addToSet |
94 | | - Set<Long> setValues = new HashSet<>(); |
95 | | - setValues.add(itemId); |
96 | | - |
97 | | - this.dbClient.addToSet("version_successor", "item_id_set", setValues, predicate); |
| 90 | + this.dbClient.update(newValue, predicate, "version_successor"); |
98 | 91 | dag.addEdge(parentId, childId, successor.getId()); |
99 | 92 | } |
100 | 93 |
|
|
0 commit comments