merging develop into dev-isf
This commit is contained in:
parent
2d3295fa2b
commit
6570e3dcc6
6 changed files with 356 additions and 368 deletions
|
@ -1,7 +1,7 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.utilities.testing;
|
package edu.cornell.mannlib.vitro.utilities.testing;
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel.BRIEF;
|
import static edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel.BRIEF;
|
||||||
import static edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel.FULL;
|
import static edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel.FULL;
|
||||||
import static edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel.MORE;
|
import static edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel.MORE;
|
||||||
|
@ -20,327 +20,327 @@ import org.junit.runner.notification.Failure;
|
||||||
import org.junit.runner.notification.RunListener;
|
import org.junit.runner.notification.RunListener;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel;
|
import edu.cornell.mannlib.vitro.utilities.testing.VitroTestRunner.ReportLevel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listen to events as they come from the JUnit test runner. The events from the
|
* Listen to events as they come from the JUnit test runner. The events from the
|
||||||
* lifecycle methods are broken down into semantic chunks and executed. Three
|
* lifecycle methods are broken down into semantic chunks and executed. Three
|
||||||
* levels of output are available.
|
* levels of output are available.
|
||||||
*
|
*
|
||||||
* On the surface, JUnit treats "failures" (failed assertions) the same as
|
* On the surface, JUnit treats "failures" (failed assertions) the same as
|
||||||
* "errors" (unexpected exceptions). We're going to distinguish between them.
|
* "errors" (unexpected exceptions). We're going to distinguish between them.
|
||||||
*
|
*
|
||||||
* @author jeb228
|
* @author jeb228
|
||||||
*/
|
*/
|
||||||
public class VitroTestRunListener extends RunListener {
|
public class VitroTestRunListener extends RunListener {
|
||||||
private final ReportLevel reportLevel;
|
private final ReportLevel reportLevel;
|
||||||
|
|
||||||
private int classCount;
|
private int classCount;
|
||||||
private int testsTotal;
|
private int testsTotal;
|
||||||
private int errorsTotal;
|
private int errorsTotal;
|
||||||
private int failuresTotal;
|
private int failuresTotal;
|
||||||
private int ignoresTotal;
|
private int ignoresTotal;
|
||||||
private long overallStartTime;
|
private long overallStartTime;
|
||||||
|
|
||||||
private Class<?> currentClass;
|
private Class<?> currentClass;
|
||||||
private int testsCurrentClass;
|
private int testsCurrentClass;
|
||||||
private int errorsCurrentClass;
|
private int errorsCurrentClass;
|
||||||
private int failuresCurrentClass;
|
private int failuresCurrentClass;
|
||||||
private int ignoresCurrentClass;
|
private int ignoresCurrentClass;
|
||||||
private long classStartTime;
|
private long classStartTime;
|
||||||
|
|
||||||
private String currentTest;
|
private String currentTest;
|
||||||
private boolean testHadError;
|
private boolean testHadError;
|
||||||
private boolean testFailed;
|
private boolean testFailed;
|
||||||
private boolean testIgnored;
|
private boolean testIgnored;
|
||||||
private long testStartTime;
|
private long testStartTime;
|
||||||
|
|
||||||
public VitroTestRunListener(ReportLevel reportLevel) {
|
public VitroTestRunListener(ReportLevel reportLevel) {
|
||||||
this.reportLevel = reportLevel;
|
this.reportLevel = reportLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Did any of the tests fail or have errors? */
|
/** Did any of the tests fail or have errors? */
|
||||||
public boolean didEverythingPass() {
|
public boolean didEverythingPass() {
|
||||||
return (failuresTotal == 0) && (errorsTotal == 0);
|
return (failuresTotal == 0) && (errorsTotal == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Life-cycle methods that will be called by the test runner.
|
// Life-cycle methods that will be called by the test runner.
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testRunStarted(Description description) throws Exception {
|
public void testRunStarted(Description description) throws Exception {
|
||||||
openTestRun();
|
openTestRun();
|
||||||
reportTestRunStart();
|
reportTestRunStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testStarted(Description description) throws Exception {
|
public void testStarted(Description description) throws Exception {
|
||||||
if (currentClass != description.getTestClass()) {
|
if (currentClass != description.getTestClass()) {
|
||||||
if (currentClass != null) {
|
if (currentClass != null) {
|
||||||
closeCurrentClass();
|
closeCurrentClass();
|
||||||
reportCurrentClass();
|
reportCurrentClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
openCurrentClass(description);
|
openCurrentClass(description);
|
||||||
reportCurrentClassStart();
|
reportCurrentClassStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
openCurrentTest(description);
|
openCurrentTest(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testAssumptionFailure(Failure failure) {
|
public void testAssumptionFailure(Failure failure) {
|
||||||
if (isError(failure)) {
|
if (isError(failure)) {
|
||||||
testHadError = true;
|
testHadError = true;
|
||||||
reportError(failure);
|
reportError(failure);
|
||||||
} else {
|
} else {
|
||||||
testFailed = true;
|
testFailed = true;
|
||||||
reportFailure(failure);
|
reportFailure(failure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testFailure(Failure failure) throws Exception {
|
public void testFailure(Failure failure) throws Exception {
|
||||||
if (isError(failure)) {
|
if (isError(failure)) {
|
||||||
testHadError = true;
|
testHadError = true;
|
||||||
reportError(failure);
|
reportError(failure);
|
||||||
} else {
|
} else {
|
||||||
testFailed = true;
|
testFailed = true;
|
||||||
reportFailure(failure);
|
reportFailure(failure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testFinished(Description description) throws Exception {
|
public void testFinished(Description description) throws Exception {
|
||||||
closeCurrentTest();
|
closeCurrentTest();
|
||||||
reportCurrentTest();
|
reportCurrentTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testIgnored(Description description) throws Exception {
|
public void testIgnored(Description description) throws Exception {
|
||||||
testStarted(description);
|
testStarted(description);
|
||||||
testIgnored = true;
|
testIgnored = true;
|
||||||
testFinished(description);
|
testFinished(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testRunFinished(Result result) throws Exception {
|
public void testRunFinished(Result result) throws Exception {
|
||||||
if (currentClass != null) {
|
if (currentClass != null) {
|
||||||
closeCurrentClass();
|
closeCurrentClass();
|
||||||
reportCurrentClass();
|
reportCurrentClass();
|
||||||
}
|
}
|
||||||
closeTestRun();
|
closeTestRun();
|
||||||
reportTestRun();
|
reportTestRun();
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Handling the logical events.
|
// Handling the logical events.
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
private void openTestRun() {
|
private void openTestRun() {
|
||||||
overallStartTime = System.currentTimeMillis();
|
overallStartTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeTestRun() {
|
private void closeTestRun() {
|
||||||
// Nothing to close.
|
// Nothing to close.
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportTestRunStart() {
|
private void reportTestRunStart() {
|
||||||
if (reportLevel == FULL) {
|
if (reportLevel == FULL) {
|
||||||
System.out
|
System.out
|
||||||
.println("Starting test run at " + time(overallStartTime));
|
.println("Starting test run at " + time(overallStartTime));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reportLevel == MORE) {
|
if (reportLevel == MORE) {
|
||||||
System.out
|
System.out
|
||||||
.println("Starting test run at " + time(overallStartTime));
|
.println("Starting test run at " + time(overallStartTime));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println("Tests Pass Error Fail Ignore Seconds");
|
System.out.println("Tests Pass Error Fail Ignore Seconds");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportTestRun() {
|
private void reportTestRun() {
|
||||||
int successes = testsTotal - errorsTotal - failuresTotal - ignoresTotal;
|
int successes = testsTotal - errorsTotal - failuresTotal - ignoresTotal;
|
||||||
|
|
||||||
if (reportLevel != BRIEF) {
|
if (reportLevel != BRIEF) {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.format(
|
System.out.format(
|
||||||
"Tests Pass Error Fail Ignore Seconds TOTAL (%d classes)\n",
|
"Tests Pass Error Fail Ignore Seconds TOTAL (%d classes)\n",
|
||||||
classCount);
|
classCount);
|
||||||
System.out.format(" %4d %4d %4d %4d %4d %6s\n", testsTotal,
|
System.out.format(" %4d %4d %4d %4d %4d %6s\n", testsTotal,
|
||||||
successes, errorsTotal, failuresTotal, ignoresTotal,
|
successes, errorsTotal, failuresTotal, ignoresTotal,
|
||||||
elapsed(overallStartTime));
|
elapsed(overallStartTime));
|
||||||
|
|
||||||
if (reportLevel != BRIEF) {
|
if (reportLevel != BRIEF) {
|
||||||
System.out.println("Ending test run at "
|
System.out.println("Ending test run at "
|
||||||
+ time(System.currentTimeMillis()));
|
+ time(System.currentTimeMillis()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openCurrentClass(Description description) {
|
private void openCurrentClass(Description description) {
|
||||||
currentClass = description.getTestClass();
|
currentClass = description.getTestClass();
|
||||||
classStartTime = System.currentTimeMillis();
|
classStartTime = System.currentTimeMillis();
|
||||||
testsCurrentClass = 0;
|
testsCurrentClass = 0;
|
||||||
errorsCurrentClass = 0;
|
errorsCurrentClass = 0;
|
||||||
failuresCurrentClass = 0;
|
failuresCurrentClass = 0;
|
||||||
ignoresCurrentClass = 0;
|
ignoresCurrentClass = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeCurrentClass() {
|
private void closeCurrentClass() {
|
||||||
classCount++;
|
classCount++;
|
||||||
testsTotal += testsCurrentClass;
|
testsTotal += testsCurrentClass;
|
||||||
errorsTotal += errorsCurrentClass;
|
errorsTotal += errorsCurrentClass;
|
||||||
failuresTotal += failuresCurrentClass;
|
failuresTotal += failuresCurrentClass;
|
||||||
ignoresTotal += ignoresCurrentClass;
|
ignoresTotal += ignoresCurrentClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportCurrentClassStart() {
|
private void reportCurrentClassStart() {
|
||||||
if (reportLevel == FULL) {
|
if (reportLevel == FULL) {
|
||||||
System.out.format("Tests Pass Error Fail Ignore Seconds %s\n",
|
System.out.format("Tests Pass Error Fail Ignore Seconds %s\n",
|
||||||
currentClass.getName());
|
currentClass.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportCurrentClass() {
|
private void reportCurrentClass() {
|
||||||
int successes = testsCurrentClass - errorsCurrentClass
|
int successes = testsCurrentClass - errorsCurrentClass
|
||||||
- failuresCurrentClass - ignoresCurrentClass;
|
- failuresCurrentClass - ignoresCurrentClass;
|
||||||
if (reportLevel == MORE) {
|
if (reportLevel == MORE) {
|
||||||
System.out.format(" %4d %4d %4d %4d %4d %6s %s\n",
|
System.out.format(" %4d %4d %4d %4d %4d %6s %s\n",
|
||||||
testsCurrentClass, successes, errorsCurrentClass,
|
testsCurrentClass, successes, errorsCurrentClass,
|
||||||
failuresCurrentClass, ignoresCurrentClass,
|
failuresCurrentClass, ignoresCurrentClass,
|
||||||
elapsed(classStartTime), currentClass.getSimpleName());
|
elapsed(classStartTime), currentClass.getSimpleName());
|
||||||
}
|
}
|
||||||
if (reportLevel == FULL) {
|
if (reportLevel == FULL) {
|
||||||
System.out.println("-----------------------------------");
|
System.out.println("-----------------------------------");
|
||||||
System.out.format(" %4d %4d %4d %4d %4d %6s\n",
|
System.out.format(" %4d %4d %4d %4d %4d %6s\n",
|
||||||
testsCurrentClass, successes, errorsCurrentClass,
|
testsCurrentClass, successes, errorsCurrentClass,
|
||||||
failuresCurrentClass, ignoresCurrentClass,
|
failuresCurrentClass, ignoresCurrentClass,
|
||||||
elapsed(classStartTime));
|
elapsed(classStartTime));
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openCurrentTest(Description description) {
|
private void openCurrentTest(Description description) {
|
||||||
currentTest = description.getMethodName();
|
currentTest = description.getMethodName();
|
||||||
testHadError = false;
|
testHadError = false;
|
||||||
testFailed = false;
|
testFailed = false;
|
||||||
testIgnored = false;
|
testIgnored = false;
|
||||||
testStartTime = System.currentTimeMillis();
|
testStartTime = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeCurrentTest() {
|
private void closeCurrentTest() {
|
||||||
if (testHadError) {
|
if (testHadError) {
|
||||||
errorsCurrentClass++;
|
errorsCurrentClass++;
|
||||||
}
|
}
|
||||||
if (testFailed) {
|
if (testFailed) {
|
||||||
failuresCurrentClass++;
|
failuresCurrentClass++;
|
||||||
}
|
}
|
||||||
if (testIgnored) {
|
if (testIgnored) {
|
||||||
ignoresCurrentClass++;
|
ignoresCurrentClass++;
|
||||||
}
|
}
|
||||||
testsCurrentClass++;
|
testsCurrentClass++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isError(Failure failure) {
|
private boolean isError(Failure failure) {
|
||||||
Throwable throwable = failure.getException();
|
Throwable throwable = failure.getException();
|
||||||
return (throwable != null) && !(throwable instanceof AssertionError);
|
return (throwable != null) && !(throwable instanceof AssertionError);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportError(Failure error) {
|
private void reportError(Failure error) {
|
||||||
Description description = error.getDescription();
|
Description description = error.getDescription();
|
||||||
String methodName = description.getMethodName();
|
String methodName = description.getMethodName();
|
||||||
String className = description.getTestClass().getName();
|
String className = description.getTestClass().getName();
|
||||||
String message = error.getMessage();
|
String message = error.getMessage();
|
||||||
System.out.format("EXCEPTION: test %s() in %s: %s\n",
|
System.out.format("EXCEPTION: test %s() in %s: %s\n",
|
||||||
methodName, className, message);
|
methodName, className, message);
|
||||||
System.out.println(formatStackTrace(error.getException()));
|
System.out.println(formatStackTrace(error.getException()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportFailure(Failure failure) {
|
private void reportFailure(Failure failure) {
|
||||||
Description description = failure.getDescription();
|
Description description = failure.getDescription();
|
||||||
String methodName = description.getMethodName();
|
String methodName = description.getMethodName();
|
||||||
String className = description.getTestClass().getName();
|
String className = description.getTestClass().getName();
|
||||||
String message = failure.getMessage();
|
String message = failure.getMessage();
|
||||||
System.out.format("TEST FAILED: test %s() in %s: %s\n", methodName,
|
System.out.format("TEST FAILED: test %s() in %s: %s\n", methodName,
|
||||||
className, message);
|
className, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reportCurrentTest() {
|
private void reportCurrentTest() {
|
||||||
if (reportLevel == FULL) {
|
if (reportLevel == FULL) {
|
||||||
char passFlag = (testIgnored | testFailed | testHadError) ? ' '
|
char passFlag = (testIgnored | testFailed | testHadError) ? ' '
|
||||||
: '1';
|
: '1';
|
||||||
char errorFlag = testHadError ? '1' : ' ';
|
char errorFlag = testHadError ? '1' : ' ';
|
||||||
char failFlag = testFailed ? '1' : ' ';
|
char failFlag = testFailed ? '1' : ' ';
|
||||||
char ignoreFlag = testIgnored ? '1' : ' ';
|
char ignoreFlag = testIgnored ? '1' : ' ';
|
||||||
System.out.format(
|
System.out.format(
|
||||||
" %c %c %c %c %6s %s()\n",
|
" %c %c %c %c %6s %s()\n",
|
||||||
passFlag, errorFlag, failFlag, ignoreFlag,
|
passFlag, errorFlag, failFlag, ignoreFlag,
|
||||||
elapsed(testStartTime), currentTest);
|
elapsed(testStartTime), currentTest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
// Formatting methods.
|
// Formatting methods.
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
private final SimpleDateFormat formatter = new SimpleDateFormat(
|
private final SimpleDateFormat formatter = new SimpleDateFormat(
|
||||||
"HH:mm:ss 'on' MMM dd, yyyy");
|
"HH:mm:ss 'on' MMM dd, yyyy");
|
||||||
|
|
||||||
private String time(long time) {
|
private String time(long time) {
|
||||||
return formatter.format(new Date(time));
|
return formatter.format(new Date(time));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Show elapsed time in 6 columns. */
|
/** Show elapsed time in 6 columns. */
|
||||||
private String elapsed(long start) {
|
private String elapsed(long start) {
|
||||||
long interval = System.currentTimeMillis() - start;
|
long interval = System.currentTimeMillis() - start;
|
||||||
return String.format("%6.2f", ((float) interval) / 1000.0);
|
return String.format("%6.2f", ((float) interval) / 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trim the stack trace: don't show the line saying "23 more", and don't
|
* Trim the stack trace: don't show the line saying "23 more", and don't
|
||||||
* show the lines about org.junit or java.lang.reflect or sun.reflect.
|
* show the lines about org.junit or java.lang.reflect or sun.reflect.
|
||||||
*
|
*
|
||||||
* Once we hit some "client code", we won't trim any futher lines even if
|
* Once we hit some "client code", we won't trim any futher lines even if
|
||||||
* they belong to org.junit, or the others.
|
* they belong to org.junit, or the others.
|
||||||
*
|
*
|
||||||
* If we have nested exceptions, the process repeats for each "Caused by"
|
* If we have nested exceptions, the process repeats for each "Caused by"
|
||||||
* section.
|
* section.
|
||||||
*/
|
*/
|
||||||
private String formatStackTrace(Throwable throwable) {
|
private String formatStackTrace(Throwable throwable) {
|
||||||
StringWriter w = new StringWriter();
|
StringWriter w = new StringWriter();
|
||||||
throwable.printStackTrace(new PrintWriter(w));
|
throwable.printStackTrace(new PrintWriter(w));
|
||||||
String[] lineArray = w.toString().split("\\n");
|
String[] lineArray = w.toString().split("\\n");
|
||||||
List<String> lines = new ArrayList<String>(Arrays.asList(lineArray));
|
List<String> lines = new ArrayList<String>(Arrays.asList(lineArray));
|
||||||
|
|
||||||
boolean removing = true;
|
boolean removing = true;
|
||||||
for (int i = lines.size() - 1; i > 0; i--) {
|
for (int i = lines.size() - 1; i > 0; i--) {
|
||||||
String line = lines.get(i);
|
String line = lines.get(i);
|
||||||
if (removing) {
|
if (removing) {
|
||||||
if (line.matches("\\s*[\\.\\s\\d]+more\\s*")
|
if (line.matches("\\s*[\\.\\s\\d]+more\\s*")
|
||||||
|| line.contains("at "
|
|| line.contains("at "
|
||||||
+ VitroTestRunner.class.getName())
|
+ VitroTestRunner.class.getName())
|
||||||
|| line.contains("at org.junit.")
|
|| line.contains("at org.junit.")
|
||||||
|| line.contains("at java.lang.reflect.")
|
|| line.contains("at java.lang.reflect.")
|
||||||
|| line.contains("at sun.reflect.")) {
|
|| line.contains("at sun.reflect.")) {
|
||||||
lines.remove(line);
|
lines.remove(line);
|
||||||
} else {
|
} else {
|
||||||
removing = false;
|
removing = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (line.contains("Caused by: ")) {
|
if (line.contains("Caused by: ")) {
|
||||||
removing = true;
|
removing = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
for (String line : lines) {
|
for (String line : lines) {
|
||||||
result.append(line).append('\n');
|
result.append(line).append('\n');
|
||||||
}
|
}
|
||||||
return result.toString().trim();
|
return result.toString().trim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
||||||
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
||||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
||||||
|
@prefix display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> .
|
||||||
|
|
||||||
rdf:type
|
rdf:type
|
||||||
a owl:ObjectProperty ;
|
a owl:ObjectProperty ;
|
||||||
|
@ -12,16 +13,16 @@ rdf:type
|
||||||
<http://vitro.mannlib.cornell.edu/ns/vitro/0.7#offerCreateNewOptionAnnot>
|
<http://vitro.mannlib.cornell.edu/ns/vitro/0.7#offerCreateNewOptionAnnot>
|
||||||
"true"^^xsd:boolean ;
|
"true"^^xsd:boolean ;
|
||||||
<http://vitro.mannlib.cornell.edu/ns/vitro/0.7#selectFromExistingAnnot>
|
<http://vitro.mannlib.cornell.edu/ns/vitro/0.7#selectFromExistingAnnot>
|
||||||
"true"^^xsd:boolean ;
|
"true"^^xsd:boolean .
|
||||||
|
|
||||||
|
|
||||||
display:requiresAction
|
display:requiresAction
|
||||||
a owl:ObjectProperty ;
|
a owl:ObjectProperty ;
|
||||||
rdfs:label "Required Action"@en-US ;
|
rdfs:label "Required Action"@en-US ;
|
||||||
rdfs:comment "Indicates that a resource has a required action that may need to be authorized" .
|
rdfs:comment "Indicates that a resource has a required action that may need to be authorized" ;
|
||||||
rdfs:range display:RequiredAction .
|
rdfs:range display:RequiredAction ;
|
||||||
<http://vitro.mannlib.cornell.edu/ns/vitro/0.7#offerCreateNewOptionAnnot>
|
<http://vitro.mannlib.cornell.edu/ns/vitro/0.7#offerCreateNewOptionAnnot>
|
||||||
"true"^^xsd:boolean ;
|
"true"^^xsd:boolean ;
|
||||||
<http://vitro.mannlib.cornell.edu/ns/vitro/0.7#selectFromExistingAnnot>
|
<http://vitro.mannlib.cornell.edu/ns/vitro/0.7#selectFromExistingAnnot>
|
||||||
"true"^^xsd:boolean ;
|
"true"^^xsd:boolean .
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
owl:Class a owl:Class .
|
owl:Class a owl:Class .
|
||||||
owl:Ontology a owl:Class .
|
owl:Ontology a owl:Class .
|
||||||
owl:AnnotationProperty a owl:Class .
|
owl:AnnotationProperty a owl:Class .
|
||||||
owl:DatatypeProperty a owl:
|
owl:DatatypeProperty a owl:Class .
|
||||||
owl:ObjectProperty a owl:Class .
|
owl:ObjectProperty a owl:Class .
|
||||||
|
|
||||||
###Display Model
|
###Display Model
|
||||||
|
@ -35,11 +35,11 @@ display:InternalClassesPage a owl:Class .
|
||||||
display:DataGetter a owl:Class .
|
display:DataGetter a owl:Class .
|
||||||
|
|
||||||
display:RequiredAction a owl:Class ;
|
display:RequiredAction a owl:Class ;
|
||||||
rdfs:comment "Represents a action that may need authorization to perform.".
|
rdfs:comment "Represents a action that may need authorization to perform." .
|
||||||
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter>
|
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter>
|
||||||
a owl:Class ;
|
a owl:Class ;
|
||||||
rdfs:comment "Data getter for running a SPARQL query."
|
rdfs:comment "Data getter for running a SPARQL query." .
|
||||||
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SolrIndividualsDataGetter>
|
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SolrIndividualsDataGetter>
|
||||||
a owl:Class ;
|
a owl:Class ;
|
||||||
|
@ -55,11 +55,11 @@ display:RequiredAction a owl:Class ;
|
||||||
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData>
|
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ClassGroupPageData>
|
||||||
a owl:Class ;
|
a owl:Class ;
|
||||||
rdfs:comment "A data getter for a VClassGroup page".
|
rdfs:comment "A data getter for a VClassGroup page" .
|
||||||
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter>
|
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.FixedHTMLDataGetter>
|
||||||
a owl:Class ;
|
a owl:Class ;
|
||||||
rdfs:comment "A data getter for a Fixed piece of HTML stored in RDF".
|
rdfs:comment "A data getter for a Fixed piece of HTML stored in RDF" .
|
||||||
|
|
||||||
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter>
|
<java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.IndividualsForClassesDataGetter>
|
||||||
a owl:Class .
|
a owl:Class .
|
||||||
|
|
|
@ -17,33 +17,20 @@ import javax.servlet.http.HttpSession;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.OntModel;
|
|
||||||
import com.hp.hpl.jena.query.Dataset;
|
|
||||||
import com.hp.hpl.jena.query.QueryExecution;
|
|
||||||
import com.hp.hpl.jena.query.QueryExecutionFactory;
|
|
||||||
import com.hp.hpl.jena.query.QuerySolution;
|
import com.hp.hpl.jena.query.QuerySolution;
|
||||||
import com.hp.hpl.jena.query.ResultSet;
|
import com.hp.hpl.jena.query.ResultSet;
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
import com.hp.hpl.jena.rdf.model.Literal;
|
||||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
|
||||||
import com.hp.hpl.jena.shared.Lock;
|
|
||||||
import com.hp.hpl.jena.sparql.resultset.ResultSetMem;
|
|
||||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||||
import com.hp.hpl.jena.vocabulary.XSD;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.PolicyHelper;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.ifaces.RequestActionConstants;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddDataPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUtils;
|
||||||
|
@ -51,8 +38,6 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTw
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields.FieldVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.FoafNameToRdfsLabelPreprocessor;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.FoafNameToRdfsLabelPreprocessor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ManageLabelsForIndividualPreprocessor;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.ManageLabelsForIndividualPreprocessor;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectionDataGetter;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.selection.LocaleSelectorUtilities;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
|
import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.DataPropertyStatementTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.DataPropertyStatementTemplateModel;
|
||||||
|
|
||||||
|
@ -335,7 +320,7 @@ public class ManageLabelsForIndividualGenerator extends BaseEditConfigurationGen
|
||||||
RequestActionConstants.SOME_URI);
|
RequestActionConstants.SOME_URI);
|
||||||
AddObjectPropertyStatement aops = new AddObjectPropertyStatement(
|
AddObjectPropertyStatement aops = new AddObjectPropertyStatement(
|
||||||
vreq.getJenaOntModel(), individual.getURI(),
|
vreq.getJenaOntModel(), individual.getURI(),
|
||||||
RequestActionConstants.SOME_URI,
|
RequestActionConstants.SOME_PREDICATE,
|
||||||
RequestActionConstants.SOME_URI);
|
RequestActionConstants.SOME_URI);
|
||||||
return PolicyHelper.isAuthorizedForActions(vreq, new Actions(adps).or(aops));
|
return PolicyHelper.isAuthorizedForActions(vreq, new Actions(adps).or(aops));
|
||||||
}
|
}
|
||||||
|
@ -401,8 +386,8 @@ public class ManageLabelsForIndividualGenerator extends BaseEditConfigurationGen
|
||||||
//This should put the label in the list
|
//This should put the label in the list
|
||||||
//Create label information instance with the required information
|
//Create label information instance with the required information
|
||||||
//To generate link
|
//To generate link
|
||||||
DataPropertyStatementTemplateModel dpstm = new DataPropertyStatementTemplateModel(subjectUri, propertyUri, l,
|
DataPropertyStatementTemplateModel dpstm = new DataPropertyStatementTemplateModel(
|
||||||
template, vreq);
|
subjectUri, new Property(propertyUri), l, template, vreq);
|
||||||
labelsList.add(new LabelInformation(
|
labelsList.add(new LabelInformation(
|
||||||
l, dpstm.getEditUrl(), dpstm.getDeleteUrl(), languageTag, languageName));
|
l, dpstm.getEditUrl(), dpstm.getDeleteUrl(), languageTag, languageName));
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,9 +58,7 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
||||||
private static final String ASK_QUERY_FILE = DATA_DIR + "askUpdated.sparql";
|
private static final String ASK_QUERY_FILE = DATA_DIR + "askUpdated.sparql";
|
||||||
private static final String SUCCESS_ASSERTIONS_FILE = DATA_DIR + "success.n3";
|
private static final String SUCCESS_ASSERTIONS_FILE = DATA_DIR + "success.n3";
|
||||||
private static final String OLD_TBOX_MODEL_DIR = DATA_DIR + "oldVersion/";
|
private static final String OLD_TBOX_MODEL_DIR = DATA_DIR + "oldVersion/";
|
||||||
private static final String NEW_TBOX_MODEL_DIR = "/WEB-INF/filegraph/tbox/";
|
|
||||||
private static final String OLD_TBOX_ANNOTATIONS_DIR = DATA_DIR + "oldAnnotations/";
|
private static final String OLD_TBOX_ANNOTATIONS_DIR = DATA_DIR + "oldAnnotations/";
|
||||||
private static final String NEW_TBOX_ANNOTATIONS_DIR = "/WEB-INF/ontologies/user/tbox/";
|
|
||||||
//For display model migration
|
//For display model migration
|
||||||
private static final String OLD_DISPLAYMODEL_TBOX_PATH = DATA_DIR + "oldDisplayModel/displayTBOX.n3";
|
private static final String OLD_DISPLAYMODEL_TBOX_PATH = DATA_DIR + "oldDisplayModel/displayTBOX.n3";
|
||||||
private static final String NEW_DISPLAYMODEL_TBOX_PATH = "/WEB-INF/ontologies/app/menuload/displayTBOX.n3";
|
private static final String NEW_DISPLAYMODEL_TBOX_PATH = "/WEB-INF/ontologies/app/menuload/displayTBOX.n3";
|
||||||
|
@ -85,17 +83,21 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
||||||
settings.setAssertionOntModelSelector(ModelAccess.on(ctx).getBaseOntModelSelector());
|
settings.setAssertionOntModelSelector(ModelAccess.on(ctx).getBaseOntModelSelector());
|
||||||
settings.setInferenceOntModelSelector(ModelAccess.on(ctx).getInferenceOntModelSelector());
|
settings.setInferenceOntModelSelector(ModelAccess.on(ctx).getInferenceOntModelSelector());
|
||||||
settings.setUnionOntModelSelector(ModelAccess.on(ctx).getUnionOntModelSelector());
|
settings.setUnionOntModelSelector(ModelAccess.on(ctx).getUnionOntModelSelector());
|
||||||
boolean tryMigrateDisplay = true;
|
|
||||||
|
ConfigurationProperties props = ConfigurationProperties.getBean(ctx);
|
||||||
|
Path homeDir = Paths.get(props.getProperty("vitro.home"));
|
||||||
|
settings.setDisplayModel(ModelAccess.on(ctx).getDisplayModel());
|
||||||
|
OntModel oldTBoxModel = loadModelFromDirectory(ctx.getRealPath(OLD_TBOX_MODEL_DIR));
|
||||||
|
settings.setOldTBoxModel(oldTBoxModel);
|
||||||
|
OntModel newTBoxModel = loadModelFromDirectory(createDirectory(homeDir, "rdf", "tbox", "filegraph").toString());
|
||||||
|
settings.setNewTBoxModel(newTBoxModel);
|
||||||
|
OntModel oldTBoxAnnotationsModel = loadModelFromDirectory(ctx.getRealPath(OLD_TBOX_ANNOTATIONS_DIR));
|
||||||
|
settings.setOldTBoxAnnotationsModel(oldTBoxAnnotationsModel);
|
||||||
|
OntModel newTBoxAnnotationsModel = loadModelFromDirectory(createDirectory(homeDir, "rdf", "tbox", "everytime").toString());
|
||||||
|
settings.setNewTBoxAnnotationsModel(newTBoxAnnotationsModel);
|
||||||
|
|
||||||
|
boolean tryMigrateDisplay = true;
|
||||||
try {
|
try {
|
||||||
settings.setDisplayModel(ModelAccess.on(ctx).getDisplayModel());
|
|
||||||
OntModel oldTBoxModel = loadModelFromDirectory(ctx.getRealPath(OLD_TBOX_MODEL_DIR));
|
|
||||||
settings.setOldTBoxModel(oldTBoxModel);
|
|
||||||
OntModel newTBoxModel = loadModelFromDirectory(ctx.getRealPath(NEW_TBOX_MODEL_DIR));
|
|
||||||
settings.setNewTBoxModel(newTBoxModel);
|
|
||||||
OntModel oldTBoxAnnotationsModel = loadModelFromDirectory(ctx.getRealPath(OLD_TBOX_ANNOTATIONS_DIR));
|
|
||||||
settings.setOldTBoxAnnotationsModel(oldTBoxAnnotationsModel);
|
|
||||||
OntModel newTBoxAnnotationsModel = loadModelFromDirectory(ctx.getRealPath(NEW_TBOX_ANNOTATIONS_DIR));
|
|
||||||
settings.setNewTBoxAnnotationsModel(newTBoxAnnotationsModel);
|
|
||||||
//Display model tbox and display metadata
|
//Display model tbox and display metadata
|
||||||
//old display model tbox model
|
//old display model tbox model
|
||||||
OntModel oldDisplayModelTboxModel = loadModelFromFile(ctx.getRealPath(OLD_DISPLAYMODEL_TBOX_PATH));
|
OntModel oldDisplayModelTboxModel = loadModelFromFile(ctx.getRealPath(OLD_DISPLAYMODEL_TBOX_PATH));
|
||||||
|
@ -117,7 +119,7 @@ public class UpdateKnowledgeBase implements ServletContextListener {
|
||||||
OntModel oldDisplayModelVivoListView = loadModelFromFile(ctx.getRealPath(OLD_DISPLAYMODEL_VIVOLISTVIEW_PATH));
|
OntModel oldDisplayModelVivoListView = loadModelFromFile(ctx.getRealPath(OLD_DISPLAYMODEL_VIVOLISTVIEW_PATH));
|
||||||
settings.setVivoListViewConfigDisplayModel(oldDisplayModelVivoListView);
|
settings.setVivoListViewConfigDisplayModel(oldDisplayModelVivoListView);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.info("Unable to read display model migration files. " + e.getMessage());
|
log.info("Unable to read display model migration files. ", e);
|
||||||
tryMigrateDisplay = false;
|
tryMigrateDisplay = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,7 +212,7 @@ name will be used as the label. -->
|
||||||
<#assign labelPropertyUri = ("http://www.w3.org/2000/01/rdf-schema#label"?url) />
|
<#assign labelPropertyUri = ("http://www.w3.org/2000/01/rdf-schema#label"?url) />
|
||||||
<#assign useEditLink = false />
|
<#assign useEditLink = false />
|
||||||
<#--edit link used if in edit mode and only one label and one language-->
|
<#--edit link used if in edit mode and only one label and one language-->
|
||||||
<#if labelCount = 1 && editable && localeCount = 1 >
|
<#if labelCount = 1 && editable>
|
||||||
<#assign useEditLink = true/>
|
<#assign useEditLink = true/>
|
||||||
</#if>
|
</#if>
|
||||||
<#local label = individual.nameStatement>
|
<#local label = individual.nameStatement>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue