From ebf929415159a4f982503c6ae0d44050a3c1c6e5 Mon Sep 17 00:00:00 2001 From: Anja Jentzsch Date: Fri, 19 Jun 2015 14:53:19 +0200 Subject: [PATCH] Closes #10 - colouring based on selected clusters --- .../controllers/prolod/server/GraphLod.scala | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/prolod-server/app/controllers/prolod/server/GraphLod.scala b/prolod-server/app/controllers/prolod/server/GraphLod.scala index 1df635f..2c49018 100644 --- a/prolod-server/app/controllers/prolod/server/GraphLod.scala +++ b/prolod-server/app/controllers/prolod/server/GraphLod.scala @@ -34,13 +34,27 @@ object GraphLod extends Controller { } def getGraphPatternStatistics(datasetId: String, groups: List[String], pattern: Int) = Action { - println("groups:" + groups) var config = new Configuration() var db = new DatabaseConnection(config) - val patternList: List[Pattern] = db.getColoredPatterns(datasetId, pattern) val data: GraphLodResult = GraphLodResult(datasetId) - data.patterns = patternList - + val patternList: List[Pattern] = db.getColoredPatterns(datasetId, pattern) + if (groups.size > 0) { + var newPatternList: List[Pattern] = Nil + for (pattern : Pattern <- patternList) { + var newNodes: List[Node] = Nil + for (node : Node <- pattern.nodes) { + var newNode : Node = node + if (!groups.contains(node.group.getOrElse(""))) { + newNode = new Node(node.id, node.uri, None) + } + newNodes ::= newNode + } + newPatternList ::=new Pattern(pattern.id, pattern.name, pattern.occurences, newNodes, pattern.links) + } + data.patterns = newPatternList + } else { + data.patterns = patternList + } val json = Json.obj("statistics" -> data) Ok(json) }