diff --git a/prolod-common/src/main/scala/prolod/common/config/DatabaseConnection.scala b/prolod-common/src/main/scala/prolod/common/config/DatabaseConnection.scala index 457bb78..6d5a356 100644 --- a/prolod-common/src/main/scala/prolod/common/config/DatabaseConnection.scala +++ b/prolod-common/src/main/scala/prolod/common/config/DatabaseConnection.scala @@ -4,7 +4,7 @@ import java.io.File import java.sql._ import java.util -import com.ibm.db2.jcc.am.{SqlException, SqlIntegrityConstraintViolationException, SqlSyntaxErrorException} +import com.ibm.db2.jcc.am.{SqlDataException, SqlException, SqlIntegrityConstraintViolationException, SqlSyntaxErrorException} import com.typesafe.slick.driver.db2.DB2Driver.api._ import prolod.common.models._ import slick.jdbc.{GetResult, StaticQuery => Q} @@ -463,6 +463,7 @@ class DatabaseConnection(config : Configuration) { } catch { case e : SqlIntegrityConstraintViolationException => println(e.getMessage + System.lineSeparator() + query) case e : SqlSyntaxErrorException => println(e.getMessage + System.lineSeparator() + query) + case e : SqlDataException => println(e.getMessage + System.lineSeparator() + query) } None } @@ -486,8 +487,12 @@ class DatabaseConnection(config : Configuration) { var result : Int = -1 val statement = connection.createStatement() val resultSet = statement.executeQuery("SELECT id FROM " + name + ".subjecttable WHERE subject='" + s + "'") - resultSet.next() - result = resultSet.getInt("id") + try { + resultSet.next() + result = resultSet.getInt("id") + } catch { + case e : SqlException => println(e.getMessage) + } statement.close result } diff --git a/prolod-play/public/js/directives/graphThumbnail.js b/prolod-play/public/js/directives/graphThumbnail.js index 9c9202b..a10cbbf 100644 --- a/prolod-play/public/js/directives/graphThumbnail.js +++ b/prolod-play/public/js/directives/graphThumbnail.js @@ -68,32 +68,31 @@ define(['angular', 'd3', './directives'], function (angular, d3) { // set svg update handler after initial ticks improves performance a lot! forceNodes.on("tick", function () { - link.attr("x1", function (d) {return d.source.x;}) - .attr("y1", function (d) {return d.source.y;}) - .attr("x2", function (d) {return d.target.x;}) - .attr("y2", function (d) {return d.target.y;}); - - var inf = 1000000; - var minX = inf, maxX = -inf, minY=inf, maxY=-inf; - node.attr("cx", function (d) { - maxX = Math.max(maxX, d.x); - minX = Math.min(minX, d.x); - return d.x; - }).attr("cy", function (d) { - maxY = Math.max(maxY, d.y); - minY = Math.min(minY, d.y); - return d.y; - }); - - var padding = 10; - minX -= padding; maxX += padding; - minY -= padding; maxY += padding; - minX = Math.min(minX, 0); minY = Math.min(minY, 0); - maxX = Math.max(maxX, width); maxY = Math.max(maxY, height); - var w = maxX - minX; var h = maxY - minY; - svg.attr("viewBox", "" + minX + " " + minY + " " + w + " " + h); - - }); + link.attr("x1", function (d) {return d.source.x;}) + .attr("y1", function (d) {return d.source.y;}) + .attr("x2", function (d) {return d.target.x;}) + .attr("y2", function (d) {return d.target.y;}); + + var inf = 1000000; + var minX = inf, maxX = -inf, minY=inf, maxY=-inf; + node.attr("cx", function (d) { + maxX = Math.max(maxX, d.x); + minX = Math.min(minX, d.x); + return d.x; + }).attr("cy", function (d) { + maxY = Math.max(maxY, d.y); + minY = Math.min(minY, d.y); + return d.y; + }); + + var padding = 10; + minX -= padding; maxX += padding; + minY -= padding; maxY += padding; + minX = Math.min(minX, 0); minY = Math.min(minY, 0); + maxX = Math.max(maxX, width); maxY = Math.max(maxY, height); + var w = maxX - minX; var h = maxY - minY; + svg.attr("viewBox", "" + minX + " " + minY + " " + w + " " + h); + }); force.tick(); // one last tick that updates the nodes @@ -105,19 +104,32 @@ define(['angular', 'd3', './directives'], function (angular, d3) { if (showArrows) { svg.append("defs").selectAll("marker") .data(["target"]) - .enter().append("marker") + .enter().append("svg:marker") + .attr("id", function (d) { return d; }) + .attr("viewBox", "0 -5 10 10") + .attr("refX", 15) + .attr("refY", -1.5) + .attr("markerWidth", 6) + .attr("markerHeight", 6) + .attr("orient", "auto") + .style("fill", "#bbb") + .append("svg:path") + .attr("d", "M0,-5L10,0L0,5"); + //.attr("id", "arrowHead"); + + svg.append("defs").selectAll("marker") + .data(["target_red"]) + .enter().append("svg:marker") .attr("id", function (d) { return d; }) .attr("viewBox", "0 -5 10 10") - .attr("refX", 14) - .attr("refY", 0) - .attr("markerWidth", 10) - .attr("markerHeight", 10) + .attr("refX", 15) + .attr("refY", -1.5) + .attr("markerWidth", 6) + .attr("markerHeight", 6) .attr("orient", "auto") - .append("path") - .attr("d", "M0,-5L10,0L0,5 L10,0 L0, -5") - .style("stroke", "#BBBBBB") - .style("stroke-width",1.1) - .style("opacity", "1"); + .style("fill", "red") + .append("svg:path") + .attr("d", "M0,-5L10,0L0,5"); node.append("svg:title") .text( @@ -138,21 +150,21 @@ define(['angular', 'd3', './directives'], function (angular, d3) { node.on("click", $scope.clickHandler); } - /*function mouseover() { + link.on("mouseover", mouseover); + link.on("mouseout", mouseout); + + function mouseover() { var link = d3.select(this); - link.style('stroke-width', 2); - link.style("stroke", "black"); - var path = svg.append("svg:g").selectAll("path") - .data(force.links()) - .enter().append("svg:path") + link.style("stroke", "red"); + link.style("marker-end", "url(#target_red)"); } function mouseout() { var link = d3.select(this); - link.style('stroke-width', 1); link.style("stroke", "#bbb"); + link.style("marker-end", "url(#target)"); } -*/ + } function buildGraph(scopeGraph) { diff --git a/prolod-preprocessing/src/main/scala/prolod/preprocessing/ImportDataset.scala b/prolod-preprocessing/src/main/scala/prolod/preprocessing/ImportDataset.scala index 80f68a4..d126260 100644 --- a/prolod-preprocessing/src/main/scala/prolod/preprocessing/ImportDataset.scala +++ b/prolod-preprocessing/src/main/scala/prolod/preprocessing/ImportDataset.scala @@ -15,10 +15,10 @@ class ImportDataset(name : String, namespace: String, ontologyNamespace : String val excludeNamespaces: List[String] = if (excludeNS.isEmpty) Nil else List(excludeNS.get) db.createTables(name) - importTriples() - new GraphLodImport(db, name, namespace, ontologyNamespace, excludeNamespaces, datasetFiles) + importTriples() + def importTriples() = { for (dataset <- datasetFiles) { var nxp: NxParser = null