diff --git a/README.rdoc b/README.rdoc
index 385bb31..8e568d6 100644
--- a/README.rdoc
+++ b/README.rdoc
@@ -6,17 +6,23 @@ Currently we work on integrating qSKOS into the {PoolParty Thesaurus Server}[htt
== Installation
-=== Requirements
+=== Use the latest released version
+You can find the released versions on the {qSKOS GitHub page}[https://github.com/cmader/qSKOS/releases] and download the latest .jar file, e.g. for {qSKOS Version 1.0.0}[https://github.com/cmader/qSKOS/releases/download/1.0.0/qSKOS-cmd.jar].
+Alternatively you can
+
+=== Build from Source
+
+Requirements:
* Verify that Java v.1.7 or greater is installed: javac -version
* Make sure Maven v.3.0 or greater is installed: mvn -v
-* Optional: Make sure you have the current version of the {git version control system}[http://git-scm.com/] installed on your system.
+* Make sure you have the current version of the {git version control system}[http://git-scm.com/] installed on your system
=== 1) Get the source code
You have two options:
* Clone the project (git clone https://github.com/cmader/qSKOS.git) to your system using git.
-* Download the packaged source files as {zip archive}[https://github.com/cmader/qSKOS/archive/master.zip] and extract it to a properly named directory, e.g., +qSKOS+.
+* Download the latest {release}[https://github.com/cmader/qSKOS/releases] of the project and extract it to a properly named directory, e.g., +qSKOS+.
=== 2) Build the tool
@@ -29,6 +35,7 @@ You have two options:
=== General Usage
+* Change to the +qSKOS/target+ directory
* Run the tool using java -jar qSKOS-cmd.jar
* A synopsis on the application's parameters is displayed.
@@ -37,16 +44,16 @@ You have two options:
The following examples demonstrate typical qSKOS use cases. For demonstration purposes we use the IPSV vocabulary available from the {qSKOS-data}[https://github.com/cmader/qSKOS-data] repository: {Download IPSV vocabulary}[https://github.com/cmader/qSKOS-data/raw/master/IPSV/ipsv_skos.rdf.bz2]. In the examples below we assume that the vocabulary file is placed in the same directory than the +qSKOS-cmd.jar+ file.
==== 1) Retrieving basic vocabulary statistics
-Basic statistical properties (e.g., number of concepts, semantic relations or concept schemes) can be retrieved by issuing the command:
+Basic statistical properties (e.g., number of concepts, semantic relations or concept schemes) can be retrieved and stored into the file +report.txt+ by issuing the command:
-java -jar qSKOS-cmd.jar summarize ipsv_skos.rdf
+java -jar qSKOS-cmd.jar summarize ipsv_skos.rdf -o report.txt
==== 2) Finding quality issues
-To perform a complete analysis of all quality issues, use the following command:
+To perform an analysis for quality issues, use the following command:
-java -jar qSKOS-cmd.jar analyze -dc mil,mol,bl ipsv_skos.rdf
+java -jar qSKOS-cmd.jar analyze -dc mil,bl ipsv_skos.rdf -o report.txt
-Please keep in mind that a full analysis can take quite some time, depending on the vocabulary size and structure. Especially link checking sometimes can take hours, so it is often useful to analyze only a subset of all issues. In the following examples you'll learn how this can be done. In the example above, checking for missing inlinks, missing outlinks and broken links has been disabled to speed up the checking process (using the parameter -dc mil,mol,bl).
+Please keep in mind that a full analysis can take quite some time, depending on the vocabulary size and structure. Especially link checking sometimes can take hours, so it is often useful to analyze only a subset of all issues. In the following examples you'll learn how this can be done. In the example above, checking for missing inlinks and broken links has been disabled to speed up the checking process (using the parameter -dc mil,bl).
==== 3) Output a list of *supported* statistical properties and quality issues
By starting the evaluation using either the +summarize+ or +analyze+ command and omitting the vocabulary filename, you get an overview about the supported statistical properties and quality issues:
@@ -68,19 +75,14 @@ Every property/issue is identified by an ID string, has a name and a description
==== 4) Testing for a specific issue or a subset of issues
Specific issues can be tested by passing the -c parameter followed by one or more (comma-separated) issue IDs (see example above). Keep in mind, that the -c parameter has to be placed between between the +analyze+ command and the vocabulary file like this:
-java -jar qSKOS-cmd.jar analyze -c ol,oc ipsv_skos.rdf
+java -jar qSKOS-cmd.jar analyze -c ol,oc ipsv_skos.rdf -o report.txt
The command above triggers analysis of the "Overlapping Labels" and "Orphan Concepts" issues. In a very similar way it is possible to explicitly *exclude* issues from testing. For example, the command
-java -jar qSKOS-cmd.jar analyze -dc mil ipsv_skos.rdf
+java -jar qSKOS-cmd.jar analyze -dc mil ipsv_skos.rdf -o report.txt
checks for all issues except "Missing In-Links".
-==== 5) Producing more detailed reports
-In most cases it is not sufficient to know about the presence and number of quality issues but also which resource cause these potential problems. This can be reported by using the -e (extensive) command line switch.
-
-For example, the command java -jar qSKOS-cmd.jar analyze -c usr ipsv_skos.rdf reports one "Undefined SKOS Resources". Issuing the command java -jar qSKOS-cmd.jar analyze -e -c usr ipsv_skos.rdf (mind the additional -e parameter after the +analyze+ command) reports the resource (http://www.w3.org/2004/02/skos/core#prefSymbol) causing a potential problem.
-
== FAQ
=== What are "Authoritative Concepts"?
@@ -88,13 +90,6 @@ Every concept in a SKOS vocabulary is a resource and should be identified by an
qSKOS is to some extent able to perform this distinction by examining the host part of the concept's URIs. Depending on the vocabulary's structure in some cases it might be needed to pass an "Authoritative resource identifier" (command line argument -a) to qSKOS. This is a substring of an URI that identifies a concept as authoritative.
-=== How can I write the report to a file?
-Report output is performed directly on the console (+stdout+). If you want them to be contained in text files, you can use the output redirection operator (>) of your operating system's command line shell. Here's an example:
-
-java -jar qSKOS-cmd.jar summarize -q -c ac ipsv_skos.rdf > auth_concepts.txt generates a text file auth_concepts.txt containing the report.
-
-A command-line parameter that might be handy when redirecting qSKOS' output into a file is -np. It suppresses output of the progress indicator which is thus not written into the generated report.
-
=== What version of qSKOS do I use?
Simply pass the command line switch -v like this:
@@ -108,11 +103,11 @@ The +QSkos+ class serves as facade for calculating all criteria. For each criter
// instantiation
qskos = new QSkos(new File("stw.rdf"));
- qskos.setAuthoritativeResourceIdentifier("zbw.eu");
+ qskos.setAuthResourceIdentifier("zbw.eu");
// the fun part
- DisconnectedConceptClusters dcc = qskos.getDisconnectedConceptClusters();
- dcc.getResult();
+ Issue orphanConcepts = qSkos.getIssues("oc").iterator().next();
+ long numberOfOrphans = issue.getResult().occurrenceCount());
== Publications
A subset of the quality issues qSKOS supports (including an analysis of several existing vocabularies) have been published in our paper {Finding Quality Issues in SKOS Vocabularies}[http://arxiv.org/abs/1206.1339v1].
diff --git a/pom.xml b/pom.xml
index b145038..36703b1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
at.ac.univie.mminf
qSKOS
- 0.10.4
+ 1.2.0
qSKOS
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/QSkos.java b/src/main/java/at/ac/univie/mminf/qskos4j/QSkos.java
index 21956fa..4c9c073 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/QSkos.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/QSkos.java
@@ -18,7 +18,9 @@
import at.ac.univie.mminf.qskos4j.issues.labels.*;
import at.ac.univie.mminf.qskos4j.issues.labels.util.ResourceLabelsCollector;
import at.ac.univie.mminf.qskos4j.issues.language.IncompleteLanguageCoverage;
+import at.ac.univie.mminf.qskos4j.issues.language.NoCommonLanguages;
import at.ac.univie.mminf.qskos4j.issues.language.OmittedOrInvalidLanguageTags;
+import at.ac.univie.mminf.qskos4j.issues.language.util.LanguageCoverage;
import at.ac.univie.mminf.qskos4j.issues.outlinks.BrokenLinks;
import at.ac.univie.mminf.qskos4j.issues.outlinks.HttpURIs;
import at.ac.univie.mminf.qskos4j.issues.outlinks.HttpUriSchemeViolations;
@@ -58,6 +60,7 @@ public class QSkos {
private String baseURI;
+ private LanguageCoverage languageCoverage;
private BrokenLinks brokenLinks;
private InvolvedConcepts involvedConcepts;
private AuthoritativeConcepts authoritativeConcepts;
@@ -90,6 +93,7 @@ private void addStatisticalIssues() {
authoritativeConcepts.setBaseURI(baseURI);
conceptSchemes = new ConceptSchemes();
httpURIs = new HttpURIs();
+ languageCoverage = new LanguageCoverage(involvedConcepts);
registeredIssues.add(involvedConcepts);
registeredIssues.add(authoritativeConcepts);
@@ -104,9 +108,11 @@ private void addStatisticalIssues() {
private void addAnalyticalIssues() {
HierarchyGraphBuilder hierarchyGraphBuilder = new HierarchyGraphBuilder();
+ registeredIssues.add(new EmptyLabeledResources());
registeredIssues.add(new OmittedOrInvalidLanguageTags());
- registeredIssues.add(new IncompleteLanguageCoverage(involvedConcepts));
+ registeredIssues.add(new IncompleteLanguageCoverage(languageCoverage));
registeredIssues.add(new UndocumentedConcepts(authoritativeConcepts));
+ registeredIssues.add(new NoCommonLanguages(languageCoverage));
registeredIssues.add(new MissingLabels(authoritativeConcepts, conceptSchemes));
registeredIssues.add(new OverlappingLabels(involvedConcepts));
registeredIssues.add(new OrphanConcepts(involvedConcepts));
@@ -125,7 +131,6 @@ private void addAnalyticalIssues() {
registeredIssues.add(new HttpUriSchemeViolations());
registeredIssues.add(new RelationClashes(hierarchyGraphBuilder));
registeredIssues.add(new MappingClashes());
-
}
private void addSkosIntegrityIssues() {
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/cmd/ConceptIterator.java b/src/main/java/at/ac/univie/mminf/qskos4j/cmd/ConceptIterator.java
deleted file mode 100644
index 0e16fd0..0000000
--- a/src/main/java/at/ac/univie/mminf/qskos4j/cmd/ConceptIterator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package at.ac.univie.mminf.qskos4j.cmd;
-
-import java.io.*;
-import java.util.Iterator;
-
-/**
- * Iterates over a file which contains (substrings of) concept URIs in each lines
- */
-class ConceptIterator implements Iterator {
-
- private BufferedReader br;
- private String currentLine;
-
- ConceptIterator(File conceptsFile) throws IOException
- {
- FileInputStream fstream = new FileInputStream(conceptsFile);
- DataInputStream in = new DataInputStream(fstream);
-
- br = new BufferedReader(new InputStreamReader(in));
- }
-
- @Override
- public boolean hasNext() {
- try {
- currentLine = br.readLine();
- }
- catch (IOException e) {
- return false;
- }
-
- return currentLine != null;
- }
-
- @Override
- public String next() {
- return currentLine;
- }
-
- @Override
- public void remove() {
- // not implemented intentionally
- }
-
-}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/cmd/ReportCollector.java b/src/main/java/at/ac/univie/mminf/qskos4j/cmd/ReportCollector.java
index 8a09887..1b196b6 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/cmd/ReportCollector.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/cmd/ReportCollector.java
@@ -1,16 +1,13 @@
package at.ac.univie.mminf.qskos4j.cmd;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.Result;
import org.openrdf.OpenRDFException;
import org.openrdf.model.URI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
+import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Collection;
import java.util.Date;
@@ -29,39 +26,92 @@ public ReportCollector(Collection issues, String reportFileName) {
this.reportFileName = reportFileName;
}
- void outputIssuesReport(boolean outputExtendedReport, boolean shouldWriteGraphs)
+ void outputIssuesReport(boolean shouldWriteGraphs)
throws IOException, OpenRDFException
{
File reportFile = createReportFile();
BufferedWriter reportWriter = new BufferedWriter(new FileWriter(reportFile));
- writeReportHeader(reportWriter, reportFile);
- writeReportBody(reportWriter, reportFile, outputExtendedReport, shouldWriteGraphs);
+ processIssues();
+ String reportSummary = createReportSummary();
+ logger.info("\n" +reportSummary);
+
+ writeReportHeader(reportWriter, reportFile, reportSummary);
+ writeReportBody(reportWriter, reportFile, shouldWriteGraphs);
+
+ reportWriter.close();
}
private void writeReportHeader(BufferedWriter reportWriter,
- File reportFile) throws IOException {
+ File reportFile,
+ String reportSummary) throws IOException
+ {
String issuedDate = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z").format(new Date());
String fileName = reportFile.getAbsolutePath();
- reportWriter.write("This is the quality report of file " +fileName+ ", generated on " +issuedDate);
+ reportWriter.write("This is the quality report of file " +fileName+ ", generated by qSKOS on " +issuedDate);
reportWriter.newLine();
reportWriter.newLine();
+ reportWriter.write(reportSummary);
+ }
+
+ private void processIssues() throws OpenRDFException {
+ int issueNumber = 0;
+ Iterator issueIt = issues.iterator();
+ while (issueIt.hasNext()) {
+ Issue issue = issueIt.next();
+ issueNumber++;
+
+ logger.info("Processing issue " + issueNumber + " of " + issues.size() + " (" + issue.getName() + ")");
+ issue.getResult();
+
+ }
+
+ logger.info("Report complete!");
+ }
+
+ private String createReportSummary() throws IOException, OpenRDFException {
+ StringBuffer summary = new StringBuffer();
+ summary.append("* Summary of Quality Issue Occurrences:\n");
+
+ for (Issue issue : issues) {
+ summary.append(issue.getName() + ": " + prepareOccurrenceText(issue) + "\n");
+ }
+
+ summary.append("\n");
+ return summary.toString();
+ }
+
+ private String prepareOccurrenceText(Issue issue) throws OpenRDFException {
+ String occurrenceText = "";
+ if (issue.getResult().isProblematic()) {
+ occurrenceText = "FAIL";
+ try {
+ String occurrenceCount = Long.toString(issue.getResult().occurrenceCount());
+ occurrenceText += " (" +occurrenceCount+ ")";
+ }
+ catch (UnsupportedOperationException e) {
+ // ignore this
+ }
+ }
+ else {
+ occurrenceText = "OK (no potential problems found)";
+ }
+
+ return occurrenceText;
}
private void writeReportBody(BufferedWriter reportWriter,
File reportFile,
- boolean outputExtendedReport,
boolean shouldWriteGraphs)
throws IOException, OpenRDFException
{
- int issueNumber = 0;
+ reportWriter.write("* Detailed coverage of each Quality Issue:\n\n");
Iterator issueIt = issues.iterator();
while (issueIt.hasNext()) {
Issue issue = issueIt.next();
- issueNumber++;
- logger.info("Processing issue " +issueNumber+ " of " +issues.size()+ " (" +issue.getName()+ ")");
- writeTextReport(issue, reportWriter, outputExtendedReport);
+ writeTextReport(issue, reportWriter);
+
if (issueIt.hasNext()) {
reportWriter.newLine();
}
@@ -70,9 +120,6 @@ private void writeReportBody(BufferedWriter reportWriter,
writeGraphFiles(issue, getDotFilesPath(reportFile));
}
}
-
- logger.info("Report complete!");
- reportWriter.close();
}
private File createReportFile() throws IOException {
@@ -81,17 +128,15 @@ private File createReportFile() throws IOException {
return file;
}
- private void writeTextReport(Issue issue, BufferedWriter writer, boolean outputExtendedReport)
+ private void writeTextReport(Issue issue, BufferedWriter writer)
throws IOException, OpenRDFException
{
writer.write(createIssueHeader(issue));
writer.newLine();
- issue.getReport().generateReport(writer, Report.ReportFormat.TXT, Report.ReportStyle.SHORT);
+ issue.getResult().generateReport(writer, Result.ReportFormat.TXT, Result.ReportStyle.SHORT);
- if (outputExtendedReport) {
- writer.newLine();
- issue.getReport().generateReport(writer, Report.ReportFormat.TXT, Report.ReportStyle.EXTENSIVE);
- }
+ writer.newLine();
+ issue.getResult().generateReport(writer, Result.ReportFormat.TXT, Result.ReportStyle.EXTENSIVE);
writer.newLine();
writer.flush();
@@ -115,7 +160,7 @@ private String getDotFilesPath(File reportFile) {
private void writeGraphFiles(Issue issue, String dotFilesPath) throws IOException, OpenRDFException {
BufferedWriter graphFileWriter = new BufferedWriter(new FileWriter(dotFilesPath + issue.getId() + ".dot"));
- issue.getReport().generateReport(graphFileWriter, Report.ReportFormat.DOT);
+ issue.getResult().generateReport(graphFileWriter, Result.ReportFormat.DOT);
graphFileWriter.close();
}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/cmd/VocEvaluate.java b/src/main/java/at/ac/univie/mminf/qskos4j/cmd/VocEvaluate.java
index 39f6177..3c74055 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/cmd/VocEvaluate.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/cmd/VocEvaluate.java
@@ -77,10 +77,7 @@ private class CommandAnalyze extends CommandSummarize {
@SuppressWarnings("unused")
@Parameter(names = {"-sp", "--use-subset-percentage"}, description = "Use a specified percentage of the vocabulary triples for evaluation")
private Float randomSubsetSize_percent;
-
- @Parameter(names = {"-e", "--extensive"}, description = "Output extensive report")
- private boolean extensiveReport = false;
-
+
@Parameter(names = {"-wg", "--write-graphs"}, description = "Writes graphs as .dot files to current directory")
private boolean writeGraphs = false;
@@ -194,7 +191,7 @@ private void evaluate() throws OpenRDFException, IOException
setup();
reportCollector = new ReportCollector(extractMeasures(), parsedCommand.reportFileName);
- reportCollector.outputIssuesReport(shouldOutputExtReport(), shouldWriteGraphs());
+ reportCollector.outputIssuesReport(shouldWriteGraphs());
}
private void setup() throws OpenRDFException, IOException {
@@ -231,10 +228,6 @@ private void setupLogging() {
}
}
- private boolean shouldOutputExtReport() {
- return parsedCommand instanceof CommandAnalyze && ((CommandAnalyze) parsedCommand).extensiveReport;
- }
-
private boolean shouldWriteGraphs() {
return parsedCommand instanceof CommandAnalyze && ((CommandAnalyze) parsedCommand).writeGraphs;
}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/HierarchyGraphBuilder.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/HierarchyGraphBuilder.java
index 0a854f0..ec5cc49 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/HierarchyGraphBuilder.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/HierarchyGraphBuilder.java
@@ -2,7 +2,8 @@
import at.ac.univie.mminf.qskos4j.util.graph.NamedEdge;
import at.ac.univie.mminf.qskos4j.util.vocab.SparqlPrefix;
-import org.jgrapht.graph.DirectedMultigraph;
+import org.jgrapht.DirectedGraph;
+import org.jgrapht.graph.DefaultDirectedGraph;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Resource;
import org.openrdf.model.Value;
@@ -18,15 +19,17 @@ public class HierarchyGraphBuilder {
private final Logger logger = LoggerFactory.getLogger(HierarchyGraphBuilder.class);
- private DirectedMultigraph graph = new DirectedMultigraph(NamedEdge.class);
+ private DirectedGraph graph;
private RepositoryConnection repCon;
- public DirectedMultigraph createGraph() throws OpenRDFException
+ public DirectedGraph createGraph() throws OpenRDFException
{
logger.debug("Creating hierarchy graph");
+ graph = new DefaultDirectedGraph(NamedEdge.class);
addResultsToGraph(findTriples("skos:broaderTransitive"), false);
addResultsToGraph(findTriples("skos:narrowerTransitive"), true);
+
return graph;
}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/Issue.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/Issue.java
index 3005551..2556ae8 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/Issue.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/Issue.java
@@ -2,12 +2,12 @@
import at.ac.univie.mminf.qskos4j.progress.IProgressMonitor;
import at.ac.univie.mminf.qskos4j.progress.StubProgressMonitor;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.Result;
import org.openrdf.OpenRDFException;
import org.openrdf.model.URI;
import org.openrdf.repository.RepositoryConnection;
-public abstract class Issue {
+public abstract class Issue> {
public enum IssueType {STATISTICAL, ANALYTICAL}
@@ -47,22 +47,15 @@ public Issue(Issue dependentIssue, String id, String name, String description, I
this.weblink = weblink;
}
-
- protected abstract T computeResult() throws OpenRDFException;
- protected abstract Report generateReport(T preparedData);
+ protected abstract T invoke() throws OpenRDFException;
public final T getResult() throws OpenRDFException {
if (result == null) {
- result = computeResult();
+ result = invoke();
}
return result;
}
- public final Report getReport() throws OpenRDFException
- {
- return generateReport(getResult());
- }
-
protected final void reset() {
result = null;
if (progressMonitor != null) {
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/clusters/ClustersReport.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/clusters/ClustersReport.java
deleted file mode 100644
index 8c41074..0000000
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/clusters/ClustersReport.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package at.ac.univie.mminf.qskos4j.issues.clusters;
-
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
-import at.ac.univie.mminf.qskos4j.util.graph.GraphExporter;
-import at.ac.univie.mminf.qskos4j.util.graph.NamedEdge;
-import org.jgrapht.DirectedGraph;
-import org.openrdf.model.Value;
-
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Set;
-
-public class ClustersReport extends CollectionReport>
-{
- private DirectedGraph graph;
- private Collection> data;
-
- ClustersReport(Collection> data, DirectedGraph graph) {
- super(data);
- this.graph = graph;
- this.data = data;
- }
-
- @Override
- protected void generateTextReport(BufferedWriter osw, ReportStyle style) throws IOException {
- StringBuilder report = new StringBuilder();
- long compCount = 1;
-
- if (style == ReportStyle.SHORT) {
- report.append("count: ").append(data.size()).append("\n");
- }
-
- Iterator> componentIt = data.iterator();
- while (componentIt.hasNext()) {
- Set component = componentIt.next();
-
- report.append("component ").append(compCount).append(", size: ").append(component.size());
- if (style == ReportStyle.EXTENSIVE) {
- for (Value resource : component) {
- report.append("\n\t").append(resource.toString());
- }
- }
- compCount++;
-
- if (componentIt.hasNext()) report.append("\n");
- }
-
- osw.write(report.toString());
- }
-
- @Override
- public void generateDotReport(BufferedWriter writer) throws IOException {
- for (String dotGraph : new GraphExporter(graph).exportSubGraphs(data)) {
- writer.write(dotGraph);
- writer.newLine();
- }
- }
-
-}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/clusters/ClustersResult.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/clusters/ClustersResult.java
new file mode 100644
index 0000000..2ce4df4
--- /dev/null
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/clusters/ClustersResult.java
@@ -0,0 +1,31 @@
+package at.ac.univie.mminf.qskos4j.issues.clusters;
+
+import at.ac.univie.mminf.qskos4j.result.ResourceCollectionsResult;
+import at.ac.univie.mminf.qskos4j.util.graph.GraphExporter;
+import at.ac.univie.mminf.qskos4j.util.graph.NamedEdge;
+import org.jgrapht.DirectedGraph;
+import org.openrdf.model.Resource;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.util.Collection;
+
+public class ClustersResult extends ResourceCollectionsResult
+{
+ private DirectedGraph graph;
+
+ ClustersResult(Collection> data, DirectedGraph graph) {
+ super(data, "Cluster");
+
+ this.graph = graph;
+ }
+
+ @Override
+ public void generateDotReport(BufferedWriter writer) throws IOException {
+ for (String dotGraph : new GraphExporter(graph).exportDotGraphs(getData())) {
+ writer.write(dotGraph);
+ writer.newLine();
+ }
+ }
+
+}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/clusters/DisconnectedConceptClusters.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/clusters/DisconnectedConceptClusters.java
index da39b36..e0b2d6f 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/clusters/DisconnectedConceptClusters.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/clusters/DisconnectedConceptClusters.java
@@ -2,15 +2,15 @@
import at.ac.univie.mminf.qskos4j.issues.Issue;
import at.ac.univie.mminf.qskos4j.issues.concepts.InvolvedConcepts;
-import at.ac.univie.mminf.qskos4j.report.Report;
-import at.ac.univie.mminf.qskos4j.util.graph.NamedEdge;
import at.ac.univie.mminf.qskos4j.progress.MonitoredIterator;
+import at.ac.univie.mminf.qskos4j.util.graph.NamedEdge;
import at.ac.univie.mminf.qskos4j.util.vocab.SparqlPrefix;
import org.jgrapht.DirectedGraph;
import org.jgrapht.alg.ConnectivityInspector;
import org.jgrapht.graph.DirectedMultigraph;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Resource;
+import org.openrdf.model.URI;
import org.openrdf.model.Value;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.query.BindingSet;
@@ -23,7 +23,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import java.util.Set;
/**
* Created by christian
@@ -33,11 +32,11 @@
* Finds all
* Disconnected Concept Clusters.
*/
-public class DisconnectedConceptClusters extends Issue>> {
+public class DisconnectedConceptClusters extends Issue {
private final Logger logger = LoggerFactory.getLogger(DisconnectedConceptClusters.class);
- private DirectedGraph graph;
+ private DirectedGraph graph;
private InvolvedConcepts involvedConcepts;
public DisconnectedConceptClusters(InvolvedConcepts involvedConcepts) {
@@ -52,23 +51,20 @@ public DisconnectedConceptClusters(InvolvedConcepts involvedConcepts) {
}
@Override
- protected Collection> computeResult() throws OpenRDFException {
+ protected ClustersResult invoke() throws OpenRDFException {
createGraph();
- return new ConnectivityInspector(graph).connectedSets();
- }
+ Collection> connectedSets = new ArrayList>();
+ connectedSets.addAll(new ConnectivityInspector(graph).connectedSets());
- @Override
- protected Report generateReport(Collection> preparedData) {
- return new ClustersReport(preparedData, graph);
+ return new ClustersResult(connectedSets, graph);
}
- private void createGraph()
- throws OpenRDFException
+ private void createGraph() throws OpenRDFException
{
- graph = new DirectedMultigraph(NamedEdge.class);
+ graph = new DirectedMultigraph(NamedEdge.class);
- Iterator conceptIt = new MonitoredIterator(involvedConcepts.getResult(), progressMonitor);
+ Iterator conceptIt = new MonitoredIterator(involvedConcepts.getResult().getData(), progressMonitor);
while (conceptIt.hasNext()) {
Resource concept = conceptIt.next();
Collection relations = findRelations(concept);
@@ -82,7 +78,7 @@ private void createGraph()
}
}
- private Collection findRelations(Value concept)
+ private Collection findRelations(Resource concept)
{
Collection allRelations = new ArrayList();
@@ -92,8 +88,8 @@ private Collection findRelations(Value concept)
while (result.hasNext()) {
BindingSet bindingSet = result.next();
- Value otherConcept = bindingSet.getValue("otherConcept");
- Value semanticRelation = bindingSet.getValue("semanticRelation");
+ Resource otherConcept = (Resource) bindingSet.getValue("otherConcept");
+ URI semanticRelation = (URI) bindingSet.getValue("semanticRelation");
if (otherConcept != null && semanticRelation != null) {
allRelations.add(new Relation(concept, otherConcept, semanticRelation));
@@ -107,7 +103,7 @@ private Collection findRelations(Value concept)
return allRelations;
}
- private String createConnectionsQuery(Value concept) throws OpenRDFException {
+ private String createConnectionsQuery(Value concept) {
return SparqlPrefix.SKOS +" "+ SparqlPrefix.RDFS+
"SELECT DISTINCT ?otherConcept ?semanticRelation WHERE " +
"{" +
@@ -117,9 +113,9 @@ private String createConnectionsQuery(Value concept) throws OpenRDFException {
}
private void addNodesToGraph(
- Value skosResource,
- Value otherResource,
- Value skosRelation)
+ Resource skosResource,
+ Resource otherResource,
+ Resource skosRelation)
{
graph.addVertex(skosResource);
@@ -140,9 +136,9 @@ private String extractFragmentString(Value skosRelation) {
}
private class Relation {
- private Value sourceConcept, targetConcept, property;
+ private Resource sourceConcept, targetConcept, property;
- private Relation(Value sourceConcept, Value targetConcept, Value property) {
+ private Relation(Resource sourceConcept, Resource targetConcept, Resource property) {
this.sourceConcept = sourceConcept;
this.targetConcept = targetConcept;
this.property = property;
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/AuthoritativeConcepts.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/AuthoritativeConcepts.java
index 5d800d1..65ae2d3 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/AuthoritativeConcepts.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/AuthoritativeConcepts.java
@@ -2,8 +2,7 @@
import at.ac.univie.mminf.qskos4j.issues.Issue;
import at.ac.univie.mminf.qskos4j.progress.MonitoredIterator;
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.CollectionResult;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Resource;
import org.slf4j.Logger;
@@ -19,7 +18,7 @@
* Finds all "authoritative concepts". See the
* qSKOS readme for further information.
*/
-public class AuthoritativeConcepts extends Issue> {
+public class AuthoritativeConcepts extends Issue> {
private final Logger logger = LoggerFactory.getLogger(AuthoritativeConcepts.class);
@@ -38,14 +37,9 @@ public AuthoritativeConcepts(InvolvedConcepts involvedConcepts) {
}
@Override
- protected Collection computeResult() throws OpenRDFException {
+ protected CollectionResult invoke() throws OpenRDFException {
getAuthResourceIdentifier();
- return extractAuthoritativeConceptsFromInvolved();
- }
-
- @Override
- protected Report generateReport(Collection preparedData) {
- return new CollectionReport(preparedData);
+ return new CollectionResult(extractAuthoritativeConceptsFromInvolved());
}
private void determineAuthResourceIdentifier() throws OpenRDFException {
@@ -65,7 +59,7 @@ private void guessAuthoritativeResourceIdentifier() throws OpenRDFException {
HostNameOccurrencies hostNameOccurencies = new HostNameOccurrencies();
Iterator resourcesListIt = new MonitoredIterator(
- involvedConcepts.getResult(),
+ involvedConcepts.getResult().getData(),
progressMonitor,
"guessing publishing host");
@@ -87,7 +81,7 @@ private Collection extractAuthoritativeConceptsFromInvolved() throws O
{
Collection authoritativeConcepts = new HashSet();
- for (Resource concept : involvedConcepts.getResult()) {
+ for (Resource concept : involvedConcepts.getResult().getData()) {
String lowerCaseUriValue = concept.toString().toLowerCase();
if (lowerCaseUriValue.contains(authResourceIdentifier.toLowerCase()))
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/InvolvedConcepts.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/InvolvedConcepts.java
index 2cb1eac..2ec6c13 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/InvolvedConcepts.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/InvolvedConcepts.java
@@ -1,10 +1,8 @@
package at.ac.univie.mminf.qskos4j.issues.concepts;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.CollectionResult;
import at.ac.univie.mminf.qskos4j.util.vocab.SkosOntology;
-import at.ac.univie.mminf.qskos4j.util.vocab.SparqlPrefix;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Resource;
import org.openrdf.model.Statement;
@@ -17,7 +15,7 @@
/**
* Finds all SKOS Concepts involved in the vocabulary.
*/
-public class InvolvedConcepts extends Issue> {
+public class InvolvedConcepts extends Issue> {
public InvolvedConcepts() {
super("c",
@@ -28,8 +26,7 @@ public InvolvedConcepts() {
}
@Override
- protected Collection computeResult() throws OpenRDFException
- {
+ protected CollectionResult invoke() throws OpenRDFException {
RepositoryResult result = repCon.getStatements(
null,
RDF.TYPE,
@@ -40,19 +37,8 @@ protected Collection computeResult() throws OpenRDFException
while (result.hasNext()) {
involvedConcepts.add(result.next().getSubject());
}
- return involvedConcepts;
- }
-
- @Override
- protected Report generateReport(Collection preparedData) {
- return new CollectionReport(preparedData);
- }
- private String createConceptsQuery() throws OpenRDFException {
- return SparqlPrefix.SKOS +" "+ SparqlPrefix.RDF+
- "SELECT DISTINCT ?concept WHERE {" +
- "?concept rdf:type skos:Concept"+
- "}";
+ return new CollectionResult(involvedConcepts);
}
}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/OrphanConcepts.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/OrphanConcepts.java
index 4fe0992..3ae0908 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/OrphanConcepts.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/OrphanConcepts.java
@@ -1,17 +1,16 @@
package at.ac.univie.mminf.qskos4j.issues.concepts;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.CollectionResult;
import at.ac.univie.mminf.qskos4j.util.TupleQueryResultUtil;
import at.ac.univie.mminf.qskos4j.util.vocab.SparqlPrefix;
import org.openrdf.OpenRDFException;
+import org.openrdf.model.Resource;
import org.openrdf.model.Value;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.query.QueryLanguage;
import org.openrdf.query.TupleQuery;
-import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -19,7 +18,7 @@
* Finds all "orphan concepts". Further info on Orphan
* Concepts.
*/
-public class OrphanConcepts extends Issue> {
+public class OrphanConcepts extends Issue> {
private InvolvedConcepts involvedConcepts;
@@ -36,23 +35,17 @@ public OrphanConcepts(InvolvedConcepts involvedConcepts) {
}
@Override
- protected Collection computeResult() throws OpenRDFException {
+ protected CollectionResult invoke() throws OpenRDFException {
TupleQuery query = repCon.prepareTupleQuery(QueryLanguage.SPARQL, createOrphanConceptsQuery());
Set connectedConcepts = TupleQueryResultUtil.getValuesForBindingName(query.evaluate(), "concept");
- Set orphanConcepts = new HashSet(involvedConcepts.getResult());
+ Set orphanConcepts = new HashSet(involvedConcepts.getResult().getData());
orphanConcepts.removeAll(connectedConcepts);
- return orphanConcepts;
+ return new CollectionResult(orphanConcepts);
}
- @Override
- protected Report generateReport(Collection preparedData) {
- return new CollectionReport(preparedData);
- }
-
- private String createOrphanConceptsQuery() throws OpenRDFException
- {
+ private String createOrphanConceptsQuery() {
return SparqlPrefix.SKOS +" "+ SparqlPrefix.RDF +" "+ SparqlPrefix.RDFS +
"SELECT DISTINCT ?concept WHERE " +
"{" +
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/UndocumentedConcepts.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/UndocumentedConcepts.java
index 5e45cbe..bc382c4 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/UndocumentedConcepts.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/concepts/UndocumentedConcepts.java
@@ -1,9 +1,8 @@
package at.ac.univie.mminf.qskos4j.issues.concepts;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
import at.ac.univie.mminf.qskos4j.progress.MonitoredIterator;
+import at.ac.univie.mminf.qskos4j.result.CollectionResult;
import at.ac.univie.mminf.qskos4j.util.vocab.SparqlPrefix;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Resource;
@@ -15,7 +14,6 @@
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
@@ -24,7 +22,7 @@
* Undocumented Concepts
* ).
*/
-public class UndocumentedConcepts extends Issue> {
+public class UndocumentedConcepts extends Issue> {
private final Logger logger = LoggerFactory.getLogger(UndocumentedConcepts.class);
@@ -47,11 +45,11 @@ public UndocumentedConcepts(AuthoritativeConcepts authoritativeConcepts) {
}
@Override
- protected Collection computeResult() throws OpenRDFException {
+ protected CollectionResult invoke() throws OpenRDFException {
List undocumentedConcepts = new ArrayList();
Iterator conceptIt = new MonitoredIterator(
- authoritativeConcepts.getResult(),
+ authoritativeConcepts.getResult().getData(),
progressMonitor);
while (conceptIt.hasNext()) {
@@ -61,17 +59,10 @@ protected Collection computeResult() throws OpenRDFException {
}
}
- return undocumentedConcepts;
+ return new CollectionResult(undocumentedConcepts);
}
- @Override
- protected Report generateReport(Collection preparedData) {
- return new CollectionReport(preparedData);
- }
-
- private boolean isConceptDocumented(Value concept)
- throws OpenRDFException
- {
+ private boolean isConceptDocumented(Value concept) {
for (String docProperty : documentationProperties) {
if (conceptHasProperty(concept, docProperty)) {
return true;
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/ConceptSchemes.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/ConceptSchemes.java
index dbc31f8..15d5b86 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/ConceptSchemes.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/ConceptSchemes.java
@@ -1,8 +1,7 @@
package at.ac.univie.mminf.qskos4j.issues.conceptscheme;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.CollectionResult;
import at.ac.univie.mminf.qskos4j.util.vocab.SparqlPrefix;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Resource;
@@ -23,7 +22,7 @@
*
* Finds the number of SKOS ConceptSchemes.
*/
-public class ConceptSchemes extends Issue> {
+public class ConceptSchemes extends Issue> {
private final Logger logger = LoggerFactory.getLogger(ConceptSchemes.class);
@@ -35,14 +34,9 @@ public ConceptSchemes() {
}
@Override
- protected Collection computeResult() throws OpenRDFException {
+ protected CollectionResult invoke() throws OpenRDFException {
TupleQueryResult result = repCon.prepareTupleQuery(QueryLanguage.SPARQL, createConceptSchemeQuery()).evaluate();
- return identifyResources(result);
- }
-
- @Override
- protected Report generateReport(Collection preparedData) {
- return new CollectionReport(preparedData);
+ return new CollectionResult(identifyResources(result));
}
private String createConceptSchemeQuery() {
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/MappingRelationsMisuse.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/MappingRelationsMisuse.java
index e5c44d5..66bc2b5 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/MappingRelationsMisuse.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/MappingRelationsMisuse.java
@@ -2,8 +2,7 @@
import at.ac.univie.mminf.qskos4j.issues.Issue;
import at.ac.univie.mminf.qskos4j.issues.concepts.AuthoritativeConcepts;
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.CollectionResult;
import at.ac.univie.mminf.qskos4j.util.vocab.SkosOntology;
import at.ac.univie.mminf.qskos4j.util.vocab.SparqlPrefix;
import org.openrdf.OpenRDFException;
@@ -16,7 +15,7 @@
import java.util.ArrayList;
import java.util.Collection;
-public class MappingRelationsMisuse extends Issue> {
+public class MappingRelationsMisuse extends Issue> {
private AuthoritativeConcepts authoritativeConcepts;
@@ -31,7 +30,7 @@ public MappingRelationsMisuse(AuthoritativeConcepts authoritativeConcepts) {
}
@Override
- protected Collection computeResult() throws OpenRDFException {
+ protected CollectionResult invoke() throws OpenRDFException {
Collection problematicRelations = new ArrayList();
RepositoryResult result = repCon.getStatements(
@@ -51,13 +50,13 @@ protected Collection computeResult() throws OpenRDFException {
}
}
- return problematicRelations;
+ return new CollectionResult(problematicRelations);
}
private boolean areAuthoritativeConcepts(Resource... concepts) throws OpenRDFException {
for (Resource concept : concepts) {
boolean isAuthoritativeConcept = false;
- for (Resource authoritativeConcept : authoritativeConcepts.getResult()) {
+ for (Resource authoritativeConcept : authoritativeConcepts.getResult().getData()) {
if (concept.equals(authoritativeConcept)) isAuthoritativeConcept = true;
}
if (!isAuthoritativeConcept) return false;
@@ -87,8 +86,4 @@ private String createInSchemeQuery(Resource... concepts) {
return query + "}";
}
- @Override
- protected Report generateReport(Collection preparedData) {
- return new CollectionReport(preparedData);
- }
}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/OmittedTopConcepts.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/OmittedTopConcepts.java
index 2eafbb7..377394e 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/OmittedTopConcepts.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/OmittedTopConcepts.java
@@ -1,8 +1,7 @@
package at.ac.univie.mminf.qskos4j.issues.conceptscheme;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.CollectionResult;
import at.ac.univie.mminf.qskos4j.util.vocab.SparqlPrefix;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Resource;
@@ -19,7 +18,7 @@
* Omitted Top Concepts
* ).
*/
-public class OmittedTopConcepts extends Issue> {
+public class OmittedTopConcepts extends Issue> {
private ConceptSchemes conceptSchemes;
@@ -35,10 +34,10 @@ public OmittedTopConcepts(ConceptSchemes conceptSchemes) {
}
@Override
- protected Collection computeResult() throws OpenRDFException {
+ protected CollectionResult invoke() throws OpenRDFException {
Collection csWithOmittedTopConcepts = new HashSet();
- for (Resource conceptScheme : conceptSchemes.getResult()) {
+ for (Resource conceptScheme : conceptSchemes.getResult().getData()) {
BooleanQuery hasTopConceptQuery = repCon.prepareBooleanQuery(
QueryLanguage.SPARQL,
@@ -49,12 +48,7 @@ protected Collection computeResult() throws OpenRDFException {
}
}
- return csWithOmittedTopConcepts;
- }
-
- @Override
- protected Report generateReport(Collection preparedData) {
- return new CollectionReport(preparedData);
+ return new CollectionResult(csWithOmittedTopConcepts);
}
private String createConceptSchemeWithoutTopConceptQuery(Value conceptScheme) {
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/TopConceptsHavingBroaderConcepts.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/TopConceptsHavingBroaderConcepts.java
index 647efd1..ea67dab 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/TopConceptsHavingBroaderConcepts.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/conceptscheme/TopConceptsHavingBroaderConcepts.java
@@ -1,8 +1,7 @@
package at.ac.univie.mminf.qskos4j.issues.conceptscheme;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.CollectionResult;
import at.ac.univie.mminf.qskos4j.util.vocab.SparqlPrefix;
import org.openrdf.OpenRDFException;
import org.openrdf.model.URI;
@@ -21,7 +20,7 @@
* Finds top concepts that have broader concepts (
* Top Concepts Having Broader Concepts
*/
-public class TopConceptsHavingBroaderConcepts extends Issue> {
+public class TopConceptsHavingBroaderConcepts extends Issue> {
public TopConceptsHavingBroaderConcepts() {
super("tchbc",
@@ -33,14 +32,9 @@ public TopConceptsHavingBroaderConcepts() {
}
@Override
- protected Collection computeResult() throws OpenRDFException {
+ protected CollectionResult invoke() throws OpenRDFException {
TupleQuery query = repCon.prepareTupleQuery(QueryLanguage.SPARQL, createTopConceptsHavingBroaderConceptQuery());
- return createUriResultList(query.evaluate());
- }
-
- @Override
- protected Report generateReport(Collection preparedData) {
- return new CollectionReport(preparedData);
+ return new CollectionResult(createUriResultList(query.evaluate()));
}
private String createTopConceptsHavingBroaderConceptQuery() {
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/AggregationRelations.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/AggregationRelations.java
index e5163fe..b7607b1 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/AggregationRelations.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/AggregationRelations.java
@@ -1,8 +1,7 @@
package at.ac.univie.mminf.qskos4j.issues.count;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.NumberReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.NumberResult;
import at.ac.univie.mminf.qskos4j.util.TupleQueryResultUtil;
import at.ac.univie.mminf.qskos4j.util.vocab.SparqlPrefix;
import org.openrdf.OpenRDFException;
@@ -16,7 +15,7 @@
*
* Finds the number of triples that assign concepts to concept schemes or lists.
*/
-public class AggregationRelations extends Issue {
+public class AggregationRelations extends Issue> {
private final String AGGREGATION_RELATIONS =
"skos:topConceptOf, skos:hasTopConcept, skos:inScheme, skos:member, skos:memberList";
@@ -30,14 +29,9 @@ public AggregationRelations() {
}
@Override
- protected Long computeResult() throws OpenRDFException {
+ protected NumberResult invoke() throws OpenRDFException {
TupleQuery query = repCon.prepareTupleQuery(QueryLanguage.SPARQL, createAggregationRelationsQuery());
- return TupleQueryResultUtil.countResults(query.evaluate());
- }
-
- @Override
- protected Report generateReport(Long preparedData) {
- return new NumberReport(preparedData);
+ return new NumberResult(TupleQueryResultUtil.countResults(query.evaluate()));
}
private String createAggregationRelationsQuery() {
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/Collections.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/Collections.java
index 5379c86..2cbd196 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/Collections.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/Collections.java
@@ -1,8 +1,7 @@
package at.ac.univie.mminf.qskos4j.issues.count;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.NumberReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.NumberResult;
import at.ac.univie.mminf.qskos4j.util.vocab.SkosOntology;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Statement;
@@ -16,7 +15,7 @@
*
* Finds the number of SKOS Collections.
*/
-public class Collections extends Issue {
+public class Collections extends Issue> {
public Collections() {
super("cc",
@@ -27,7 +26,7 @@ public Collections() {
}
@Override
- protected Long computeResult() throws OpenRDFException {
+ protected NumberResult invoke() throws OpenRDFException {
RepositoryResult result = repCon.getStatements(null, RDF.TYPE, SkosOntology.getInstance().getUri("Collection"), true);
long collectionCount = 0;
@@ -37,12 +36,7 @@ protected Long computeResult() throws OpenRDFException {
}
result.close();
- return collectionCount;
- }
-
- @Override
- protected Report generateReport(Long preparedData) {
- return new NumberReport(preparedData);
+ return new NumberResult(collectionCount);
}
}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/SemanticRelations.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/SemanticRelations.java
index 1a35df9..5f3f06f 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/SemanticRelations.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/count/SemanticRelations.java
@@ -1,8 +1,7 @@
package at.ac.univie.mminf.qskos4j.issues.count;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.NumberReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.result.NumberResult;
import at.ac.univie.mminf.qskos4j.util.vocab.SkosOntology;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Statement;
@@ -15,7 +14,7 @@
*
* Finds the number of triples involving (subproperties of) skos:semanticRelation.
*/
-public class SemanticRelations extends Issue {
+public class SemanticRelations extends Issue> {
public SemanticRelations() {
super("sr",
@@ -26,7 +25,7 @@ public SemanticRelations() {
}
@Override
- protected Long computeResult() throws OpenRDFException {
+ protected NumberResult invoke() throws OpenRDFException {
RepositoryResult result = repCon.getStatements(
null,
SkosOntology.getInstance().getUri("semanticRelation"),
@@ -38,12 +37,7 @@ protected Long computeResult() throws OpenRDFException {
result.next();
semanticRelationsCount++;
}
- return semanticRelationsCount;
- }
-
- @Override
- protected Report generateReport(Long preparedData) {
- return new NumberReport(preparedData);
+ return new NumberResult(semanticRelationsCount);
}
}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/cycles/HierarchicalCycles.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/cycles/HierarchicalCycles.java
index 843ca08..bf8e699 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/cycles/HierarchicalCycles.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/cycles/HierarchicalCycles.java
@@ -2,13 +2,12 @@
import at.ac.univie.mminf.qskos4j.issues.HierarchyGraphBuilder;
import at.ac.univie.mminf.qskos4j.issues.Issue;
-import at.ac.univie.mminf.qskos4j.report.Report;
import at.ac.univie.mminf.qskos4j.util.graph.NamedEdge;
import org.jgrapht.DirectedGraph;
import org.jgrapht.alg.CycleDetector;
import org.jgrapht.alg.StrongConnectivityInspector;
import org.openrdf.OpenRDFException;
-import org.openrdf.model.Value;
+import org.openrdf.model.Resource;
import org.openrdf.model.impl.URIImpl;
import org.openrdf.repository.RepositoryConnection;
import org.slf4j.Logger;
@@ -26,11 +25,11 @@
*
* Finds all Cyclic Hierarchical Relations.
*/
-public class HierarchicalCycles extends Issue>> {
+public class HierarchicalCycles extends Issue {
private final Logger logger = LoggerFactory.getLogger(HierarchicalCycles.class);
- private DirectedGraph hierarchyGraph;
+ private DirectedGraph hierarchyGraph;
private HierarchyGraphBuilder hierarchyGraphBuilder;
public HierarchicalCycles(HierarchyGraphBuilder hierarchyGraphBuilder) {
@@ -44,31 +43,26 @@ public HierarchicalCycles(HierarchyGraphBuilder hierarchyGraphBuilder) {
}
@Override
- protected Collection> computeResult() throws OpenRDFException {
+ protected HierarchicalCyclesResult invoke() throws OpenRDFException {
hierarchyGraph = hierarchyGraphBuilder.createGraph();
- return findCycleContainingComponents();
+ return new HierarchicalCyclesResult(findCycleContainingComponents(), hierarchyGraph);
}
- @Override
- protected Report generateReport(Collection> preparedData) {
- return new HierarchicalCyclesReport(preparedData, hierarchyGraph);
- }
-
- private List> findCycleContainingComponents() {
+ private List> findCycleContainingComponents() {
logger.debug("Finding cycles");
- Set nodesInCycles = new CycleDetector(hierarchyGraph).findCycles();
+ Set nodesInCycles = new CycleDetector(hierarchyGraph).findCycles();
return trackNodesInCycles(nodesInCycles);
}
- private List> trackNodesInCycles(Set nodesInCycles)
+ private List> trackNodesInCycles(Set nodesInCycles)
{
- List> ret = new ArrayList>();
- List> stronglyConnectedSets =
- new StrongConnectivityInspector(hierarchyGraph).stronglyConnectedSets();
+ List> ret = new ArrayList>();
+ List> stronglyConnectedSets =
+ new StrongConnectivityInspector(hierarchyGraph).stronglyConnectedSets();
- for (Value node : nodesInCycles) {
- for (Set stronglyConnectedSet : stronglyConnectedSets) {
+ for (Resource node : nodesInCycles) {
+ for (Set stronglyConnectedSet : stronglyConnectedSets) {
if (stronglyConnectedSet.contains(node)) {
if (!ret.contains(stronglyConnectedSet)) {
ret.add(stronglyConnectedSet);
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/cycles/HierarchicalCyclesReport.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/cycles/HierarchicalCyclesResult.java
similarity index 53%
rename from src/main/java/at/ac/univie/mminf/qskos4j/issues/cycles/HierarchicalCyclesReport.java
rename to src/main/java/at/ac/univie/mminf/qskos4j/issues/cycles/HierarchicalCyclesResult.java
index 33d4485..a4ab838 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/cycles/HierarchicalCyclesReport.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/cycles/HierarchicalCyclesResult.java
@@ -1,30 +1,31 @@
package at.ac.univie.mminf.qskos4j.issues.cycles;
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
+import at.ac.univie.mminf.qskos4j.result.ResourceCollectionsResult;
import at.ac.univie.mminf.qskos4j.util.graph.GraphExporter;
import at.ac.univie.mminf.qskos4j.util.graph.NamedEdge;
import org.jgrapht.DirectedGraph;
-import org.openrdf.model.Value;
+import org.openrdf.model.Resource;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.Collection;
-import java.util.Set;
-public class HierarchicalCyclesReport extends CollectionReport> {
+public class HierarchicalCyclesResult extends ResourceCollectionsResult {
- private DirectedGraph graph;
- private Collection> data;
-
- public HierarchicalCyclesReport(Collection> data, DirectedGraph graph) {
- super(data);
- this.graph = graph;
- this.data = data;
- }
+ private DirectedGraph graph;
+
+ public HierarchicalCyclesResult(
+ Collection> data,
+ DirectedGraph graph)
+ {
+ super(data, "Cycle");
+
+ this.graph = graph;
+ }
@Override
public void generateDotReport(BufferedWriter writer) throws IOException {
- for (String hierarchyCycleDot : new GraphExporter(graph).exportSubGraphs(data)) {
+ for (String hierarchyCycleDot : new GraphExporter(graph).exportDotGraphs(getData())) {
writer.write(hierarchyCycleDot);
writer.newLine();
}
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/inlinks/MissingInLinks.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/inlinks/MissingInLinks.java
index e5d4585..ef58526 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/inlinks/MissingInLinks.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/inlinks/MissingInLinks.java
@@ -2,10 +2,9 @@
import at.ac.univie.mminf.qskos4j.issues.Issue;
import at.ac.univie.mminf.qskos4j.issues.concepts.AuthoritativeConcepts;
-import at.ac.univie.mminf.qskos4j.report.ExtrapolatedCollectionReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
-import at.ac.univie.mminf.qskos4j.util.RandomSubSet;
import at.ac.univie.mminf.qskos4j.progress.MonitoredIterator;
+import at.ac.univie.mminf.qskos4j.result.ExtrapolatedCollectionResult;
+import at.ac.univie.mminf.qskos4j.util.RandomSubSet;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Resource;
import org.openrdf.model.URI;
@@ -28,7 +27,7 @@
* Missing In-Links
* ).
*/
-public class MissingInLinks extends Issue> {
+public class MissingInLinks extends Issue> {
private final Logger logger = LoggerFactory.getLogger(MissingInLinks.class);
@@ -50,7 +49,7 @@ public MissingInLinks(AuthoritativeConcepts authoritativeConcepts) {
}
@Override
- protected Collection computeResult() throws OpenRDFException {
+ protected ExtrapolatedCollectionResult invoke() throws OpenRDFException {
Collection conceptsToCheck = getConceptsToCheck(randomSubsetSize_percent);
if (randomSubsetSize_percent != null) {
@@ -66,21 +65,16 @@ protected Collection computeResult() throws OpenRDFException {
rankConcept(conceptIt.next());
}
- return extractUnreferencedConcepts();
- }
-
- @Override
- protected Report generateReport(Collection preparedData) {
- return new ExtrapolatedCollectionReport(preparedData, randomSubsetSize_percent);
+ return new ExtrapolatedCollectionResult(extractUnreferencedConcepts(), randomSubsetSize_percent);
}
private Collection getConceptsToCheck(Float randomSubsetSize_percent) throws OpenRDFException
{
if (randomSubsetSize_percent == null) {
- return authoritativeConcepts.getResult();
+ return authoritativeConcepts.getResult().getData();
}
else {
- return new RandomSubSet(authoritativeConcepts.getResult(), randomSubsetSize_percent);
+ return new RandomSubSet(authoritativeConcepts.getResult().getData(), randomSubsetSize_percent);
}
}
@@ -91,17 +85,11 @@ private void rankConcept(Resource concept)
}
for (RepositoryConnection connection : connections) {
- try {
- rankConceptForConnection(concept, connection);
- }
- catch (OpenRDFException e) {
- logger.error("Error ranking concept '" +concept+ "', " + e.toString());
- }
+ rankConceptForConnection(concept, connection);
}
}
private void rankConceptForConnection(Resource concept, RepositoryConnection connection)
- throws OpenRDFException
{
String query = "SELECT distinct ?resource WHERE " +
"{?resource ?p <"+concept.toString()+"> " +
diff --git a/src/main/java/at/ac/univie/mminf/qskos4j/issues/labels/DisjointLabelsViolations.java b/src/main/java/at/ac/univie/mminf/qskos4j/issues/labels/DisjointLabelsViolations.java
index e02ef55..6fc7732 100644
--- a/src/main/java/at/ac/univie/mminf/qskos4j/issues/labels/DisjointLabelsViolations.java
+++ b/src/main/java/at/ac/univie/mminf/qskos4j/issues/labels/DisjointLabelsViolations.java
@@ -4,8 +4,7 @@
import at.ac.univie.mminf.qskos4j.issues.labels.util.LabelConflict;
import at.ac.univie.mminf.qskos4j.issues.labels.util.LabeledConcept;
import at.ac.univie.mminf.qskos4j.issues.labels.util.ResourceLabelsCollector;
-import at.ac.univie.mminf.qskos4j.report.CollectionReport;
-import at.ac.univie.mminf.qskos4j.report.Report;
+import at.ac.univie.mminf.qskos4j.issues.labels.util.LabelConflictsResult;
import org.openrdf.OpenRDFException;
import org.openrdf.model.Literal;
import org.openrdf.model.impl.URIImpl;
@@ -21,7 +20,7 @@
* Disjoint Labels Violation
* ).
*/
-public class DisjointLabelsViolations extends Issue