Compare commits
41 commits
Author | SHA1 | Date | |
---|---|---|---|
234a849a19 | |||
75557ca4aa | |||
45f303c1ae | |||
f16eef642a | |||
![]() |
0df4231b41 | ||
![]() |
48297bba56 | ||
32f817e73a | |||
![]() |
a9a89d220b | ||
1dbbe6ed4c | |||
4ab94d59af | |||
c2429a6768 | |||
![]() |
64cd06fbbb | ||
![]() |
0bdfe65d42 | ||
8e3a98cc56 | |||
e2d37bbb75 | |||
caa1bc8412 | |||
63f15a90ef | |||
cb35b5f647 | |||
2f8fa040db | |||
75841b9fb2 | |||
1590d58830 | |||
a6fa88bd1f | |||
d6eb01de9c | |||
af9820b7f3 | |||
![]() |
2e0b3f0f05 | ||
4fdbb71fee | |||
2a56ec8c30 | |||
566ca88d6f | |||
9d48755893 | |||
f6fbe83c90 | |||
3e5e60e788 | |||
084801bf5e | |||
df8c386663 | |||
98398a58b6 | |||
37579c5581 | |||
ee16a2863d | |||
38e8d326a6 | |||
d2a3a73d3c | |||
06e1e104df | |||
f36881f24c | |||
d5a9a9bca6 |
573 changed files with 4726 additions and 78903 deletions
34
.github/ISSUE_TEMPLATE/bug_report.md
vendored
34
.github/ISSUE_TEMPLATE/bug_report.md
vendored
|
@ -1,34 +0,0 @@
|
||||||
---
|
|
||||||
name: Bug report
|
|
||||||
about: Create a report to help us improve
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Describe the bug**
|
|
||||||
A clear and concise description of what the bug is.
|
|
||||||
|
|
||||||
**To Reproduce**
|
|
||||||
Steps to reproduce the behavior:
|
|
||||||
1. Go to '...'
|
|
||||||
2. Click on '....'
|
|
||||||
3. Scroll down to '....'
|
|
||||||
4. See error
|
|
||||||
|
|
||||||
**Expected behavior**
|
|
||||||
A clear and concise description of what you expected to happen.
|
|
||||||
|
|
||||||
**Screenshots**
|
|
||||||
If applicable, add screenshots to help explain your problem.
|
|
||||||
|
|
||||||
**Desktop (please complete the following information):**
|
|
||||||
- OS: [e.g. Windows, Linux]
|
|
||||||
- Browser [e.g. chrome, safari]
|
|
||||||
- Tomcat version [e.g. 8, 9]
|
|
||||||
- VIVO version [e.g. 1.11.0, 1.12.0]
|
|
||||||
- Apache Solr or ElasticSearch version
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context about the problem here.
|
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
|
@ -1,20 +0,0 @@
|
||||||
---
|
|
||||||
name: Feature request
|
|
||||||
about: Suggest an idea for this project
|
|
||||||
title: ''
|
|
||||||
labels: ''
|
|
||||||
assignees: ''
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
**Is your feature request related to a problem? Please describe.**
|
|
||||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
||||||
|
|
||||||
**Describe the solution you'd like**
|
|
||||||
A clear and concise description of what you want to happen.
|
|
||||||
|
|
||||||
**Describe alternatives you've considered**
|
|
||||||
A clear and concise description of any alternative solutions or features you've considered.
|
|
||||||
|
|
||||||
**Additional context**
|
|
||||||
Add any other context or screenshots about the feature request here.
|
|
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
3
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -1,7 +1,7 @@
|
||||||
**Thank you for submitting a pull request! Title this pull request with a brief description of what the pull request fixes/improves/changes. Please describe the pull request in detail using the template below.**
|
**Thank you for submitting a pull request! Title this pull request with a brief description of what the pull request fixes/improves/changes. Please describe the pull request in detail using the template below.**
|
||||||
* * *
|
* * *
|
||||||
|
|
||||||
**[VIVO GitHub issue](https://github.com/vivo-project/VIVO/issues)**: (please link to issue)
|
**[JIRA Issue](https://jira.duraspace.org/projects/VIVO)**: (please link to issue)
|
||||||
|
|
||||||
* Other Relevant Links (Mailing list discussion, related pull requests, etc.)
|
* Other Relevant Links (Mailing list discussion, related pull requests, etc.)
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ Example:
|
||||||
* Does this change add any new dependencies?
|
* Does this change add any new dependencies?
|
||||||
* Does this change require any other modifications to be made to the repository?
|
* Does this change require any other modifications to be made to the repository?
|
||||||
* Could this change impact execution of existing code?
|
* Could this change impact execution of existing code?
|
||||||
* Large pull requests should be avoided. If this PR is large (more than 1,000 lines of codes), please provide short explanation why your contribution can't be decoupled in smaller PRs.
|
|
||||||
|
|
||||||
# Interested parties
|
# Interested parties
|
||||||
Tag (@ mention) interested parties or, if unsure, @VIVO-project/vivo-committers
|
Tag (@ mention) interested parties or, if unsure, @VIVO-project/vivo-committers
|
||||||
|
|
32
.github/workflows/build.yml
vendored
32
.github/workflows/build.yml
vendored
|
@ -1,32 +0,0 @@
|
||||||
name: Build
|
|
||||||
|
|
||||||
on: [ push, pull_request, workflow_dispatch ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
env:
|
|
||||||
MAVEN_OPTS: -Xmx1024M
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
path: Vitro
|
|
||||||
|
|
||||||
- name: Maven Cache
|
|
||||||
uses: actions/cache@v2
|
|
||||||
with:
|
|
||||||
path: ~/.m2/repository
|
|
||||||
key: ${{ runner.os }}-cache-m2-${{ hashFiles('**/pom.xml') }}
|
|
||||||
restore-keys: ${{ runner.os }}-cache-m2-
|
|
||||||
|
|
||||||
- name: Setup Java
|
|
||||||
uses: actions/setup-java@v1
|
|
||||||
with:
|
|
||||||
java-version: 11
|
|
||||||
|
|
||||||
- name: Maven Build
|
|
||||||
run: |
|
|
||||||
cd ./Vitro
|
|
||||||
mvn clean install
|
|
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -24,8 +24,3 @@ utilities/sdb_to_tdb/.work
|
||||||
**/.classpath
|
**/.classpath
|
||||||
**/.project
|
**/.project
|
||||||
**/bin/
|
**/bin/
|
||||||
|
|
||||||
.fake
|
|
||||||
.ionide
|
|
||||||
|
|
||||||
.vscode
|
|
||||||
|
|
22
.travis.yml
Normal file
22
.travis.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
language: java
|
||||||
|
dist: trusty
|
||||||
|
sudo: false
|
||||||
|
|
||||||
|
jdk:
|
||||||
|
- openjdk8
|
||||||
|
- oraclejdk8
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Give Maven 1GB of memory to work with
|
||||||
|
- MAVEN_OPTS=-Xmx1024M
|
||||||
|
|
||||||
|
cache:
|
||||||
|
directories:
|
||||||
|
- .autoconf
|
||||||
|
- $HOME/.m2
|
||||||
|
|
||||||
|
install:
|
||||||
|
- "echo 'Skipping install stage, dependencies will be downloaded during build and test stages.'"
|
||||||
|
|
||||||
|
script:
|
||||||
|
- "mvn clean package -Dmaven.test.skip=false"
|
|
@ -1,6 +1,6 @@
|
||||||
# What is Vitro?
|
# What is Vitro?
|
||||||
|
|
||||||
[](https://github.com/vivo-project/Vitro/actions?query=workflow%3ABuild)
|
[](https://travis-ci.org/vivo-project/Vitro)
|
||||||
|
|
||||||
Vitro is a general-purpose web-based ontology and instance editor with customizable public browsing.
|
Vitro is a general-purpose web-based ontology and instance editor with customizable public browsing.
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ With Vitro, you can:
|
||||||
* Search your data with Apache Solr
|
* Search your data with Apache Solr
|
||||||
|
|
||||||
Vitro was originally developed at Cornell University, and is used as the core of the popular
|
Vitro was originally developed at Cornell University, and is used as the core of the popular
|
||||||
research and scholarship portal, [VIVO](https://vivo.lyrasis.org/).
|
research and scholarship portal, [VIVO](https://duraspace.org/vivo/).
|
||||||
|
|
||||||
|
For more information, contact the [VIVO community](https://duraspace.org/vivo/resources/contact/).
|
||||||
|
|
||||||
For more information, contact the [VIVO community](https://vivo.lyrasis.org/contact/).
|
|
||||||
|
|
15
api/pom.xml
15
api/pom.xml
|
@ -7,13 +7,13 @@
|
||||||
|
|
||||||
<groupId>org.vivoweb</groupId>
|
<groupId>org.vivoweb</groupId>
|
||||||
<artifactId>vitro-api</artifactId>
|
<artifactId>vitro-api</artifactId>
|
||||||
<version>1.14.1-SNAPSHOT</version>
|
<version>1.11.2-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.vivoweb</groupId>
|
<groupId>org.vivoweb</groupId>
|
||||||
<artifactId>vitro-project</artifactId>
|
<artifactId>vitro-project</artifactId>
|
||||||
<version>1.14.1-SNAPSHOT</version>
|
<version>1.11.2-SNAPSHOT</version>
|
||||||
<relativePath>..</relativePath>
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
@ -21,13 +21,6 @@
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<runOrder>alphabetical</runOrder>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
@ -73,7 +66,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.vivoweb</groupId>
|
<groupId>org.vivoweb</groupId>
|
||||||
<artifactId>vitro-dependencies</artifactId>
|
<artifactId>vitro-dependencies</artifactId>
|
||||||
<version>1.14.1-SNAPSHOT</version>
|
<version>1.11.2-SNAPSHOT</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -92,7 +85,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.13.1</version>
|
<version>4.11</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -8,7 +8,6 @@ public class DynamicFieldRow {
|
||||||
|
|
||||||
private int id = -1;
|
private int id = -1;
|
||||||
private String value = null;
|
private String value = null;
|
||||||
private String language = "";
|
|
||||||
private Map parameterMap = null;
|
private Map parameterMap = null;
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
@ -35,13 +34,4 @@ public class DynamicFieldRow {
|
||||||
this.parameterMap = parameterMap;
|
this.parameterMap = parameterMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLanguage() {
|
|
||||||
return language;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLanguage(String language) {
|
|
||||||
if (language != null) {
|
|
||||||
this.language = language;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,10 @@ import edu.cornell.mannlib.vedit.beans.FormObject;
|
||||||
import edu.cornell.mannlib.vedit.beans.DynamicField;
|
import edu.cornell.mannlib.vedit.beans.DynamicField;
|
||||||
import edu.cornell.mannlib.vedit.beans.DynamicFieldRow;
|
import edu.cornell.mannlib.vedit.beans.DynamicFieldRow;
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.tags.EditTag;
|
import edu.cornell.mannlib.vedit.tags.EditTag;
|
||||||
|
|
||||||
public class DynamicFieldsTag extends EditTag {
|
public class DynamicFieldsTag extends EditTag {
|
||||||
|
|
||||||
private static final String LANGUAGE = "language";
|
|
||||||
|
|
||||||
private char PATH_SEP = File.separatorChar;
|
private char PATH_SEP = File.separatorChar;
|
||||||
|
|
||||||
public final String MARKUP_FILE_PATH = "templates"+PATH_SEP+"edit"+PATH_SEP+"specific"+PATH_SEP;
|
public final String MARKUP_FILE_PATH = "templates"+PATH_SEP+"edit"+PATH_SEP+"specific"+PATH_SEP;
|
||||||
|
@ -179,12 +175,7 @@ public class DynamicFieldsTag extends EditTag {
|
||||||
String key = (String) paramIt.next();
|
String key = (String) paramIt.next();
|
||||||
String value = (String) row.getParameterMap().get(key);
|
String value = (String) row.getParameterMap().get(key);
|
||||||
byte[] valueInBase64 = Base64.encodeBase64(value.getBytes());
|
byte[] valueInBase64 = Base64.encodeBase64(value.getBytes());
|
||||||
taName.append(key).append(":").append(new String(valueInBase64));
|
taName.append(key).append(":").append(new String(valueInBase64)).append(";");
|
||||||
if (StringUtils.isNotBlank(row.getLanguage())) {
|
|
||||||
byte[] encodedLang = Base64.encodeBase64(row.getLanguage().getBytes());
|
|
||||||
taName.append(":").append(LANGUAGE).append(":").append(new String(encodedLang));
|
|
||||||
}
|
|
||||||
taName.append(";");
|
|
||||||
}
|
}
|
||||||
if (row.getValue().length() > 0) {
|
if (row.getValue().length() > 0) {
|
||||||
String templateWithVars = templateMarkup;
|
String templateWithVars = templateMarkup;
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.lang.reflect.Method;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -15,7 +17,6 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
import org.apache.commons.codec.binary.Base64;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -271,37 +272,6 @@ public class FormUtils {
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Option> makeOptionListOfNotDisjointClasses(WebappDaoFactory wadf, String baseVclassUri, String selectedUri) {
|
|
||||||
VClassDao vClassDao = wadf.getVClassDao();
|
|
||||||
Set<String> uris = getNotDisjointClassUris(wadf, baseVclassUri, vClassDao);
|
|
||||||
uris.add(baseVclassUri);
|
|
||||||
|
|
||||||
List<Option> options = new LinkedList<>();
|
|
||||||
for (String vclassUri : uris) {
|
|
||||||
VClass vclass = vClassDao.getVClassByURI(vclassUri);
|
|
||||||
Option option = new Option();
|
|
||||||
option.setValue(vclass.getURI());
|
|
||||||
option.setBody(vclass.getPickListName());
|
|
||||||
options.add(option);
|
|
||||||
if (Objects.equals(selectedUri, vclass.getURI())) {
|
|
||||||
option.setSelected(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options.sort((o1, o2) -> o1.getBody().compareTo(o2.getBody()));
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Set<String> getNotDisjointClassUris(WebappDaoFactory wadf, String classUri, VClassDao vClassDao) {
|
|
||||||
Set<String> allClasses = wadf.getVClassDao()
|
|
||||||
.getAllVclasses()
|
|
||||||
.stream()
|
|
||||||
.map(vclass -> vclass.getURI())
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
Set<String> disjointClasses = new HashSet<>(vClassDao.getDisjointWithClassURIs(classUri));
|
|
||||||
allClasses.removeAll(disjointClasses);
|
|
||||||
return allClasses;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void beanSet(Object newObj, String field, String value) {
|
public static void beanSet(Object newObj, String field, String value) {
|
||||||
beanSet (newObj, field, value, null);
|
beanSet (newObj, field, value, null);
|
||||||
}
|
}
|
||||||
|
@ -399,9 +369,6 @@ public class FormUtils {
|
||||||
for (String aParam : param) {
|
for (String aParam : param) {
|
||||||
String[] p = aParam.split(":");
|
String[] p = aParam.split(":");
|
||||||
beanParamMap.put(p[0], new String(Base64.decodeBase64(p[1].getBytes())));
|
beanParamMap.put(p[0], new String(Base64.decodeBase64(p[1].getBytes())));
|
||||||
if (p.length > 3) {
|
|
||||||
beanParamMap.put(p[2], new String(Base64.decodeBase64(p[3].getBytes())));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return beanParamMap;
|
return beanParamMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,6 @@ public class ApplicationSetup implements ServletContextListener {
|
||||||
|
|
||||||
private void locateApplicationConfigFile() {
|
private void locateApplicationConfigFile() {
|
||||||
Path path = this.vitroHomeDir.getPath().resolve(APPLICATION_SETUP_PATH);
|
Path path = this.vitroHomeDir.getPath().resolve(APPLICATION_SETUP_PATH);
|
||||||
|
|
||||||
if (!Files.exists(path)) {
|
if (!Files.exists(path)) {
|
||||||
throw new IllegalStateException("'" + path + "' does not exist.");
|
throw new IllegalStateException("'" + path + "' does not exist.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,14 +37,7 @@ public class RootUserPolicy implements PolicyIface {
|
||||||
private static final Log log = LogFactory.getLog(RootUserPolicy.class);
|
private static final Log log = LogFactory.getLog(RootUserPolicy.class);
|
||||||
|
|
||||||
private static final String PROPERTY_ROOT_USER_EMAIL = "rootUser.emailAddress";
|
private static final String PROPERTY_ROOT_USER_EMAIL = "rootUser.emailAddress";
|
||||||
/*
|
|
||||||
* UQAM Add-Feature For parameterization of rootUser
|
|
||||||
*/
|
|
||||||
private static final String PROPERTY_ROOT_USER_PASSWORD = "rootUser.password";
|
|
||||||
private static final String PROPERTY_ROOT_USER_PASSWORD_CHANGE_REQUIRED = "rootUser.passwordChangeRequired";
|
|
||||||
|
|
||||||
private static final String ROOT_USER_INITIAL_PASSWORD = "rootPassword";
|
private static final String ROOT_USER_INITIAL_PASSWORD = "rootPassword";
|
||||||
private static final String ROOT_USER_INITIAL_PASSWORD_CHANGE_REQUIRED = "true";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the entire policy. If you are a root user, you are authorized.
|
* This is the entire policy. If you are a root user, you are authorized.
|
||||||
|
@ -157,12 +150,10 @@ public class RootUserPolicy implements PolicyIface {
|
||||||
ua.setEmailAddress(configuredRootUser);
|
ua.setEmailAddress(configuredRootUser);
|
||||||
ua.setFirstName("root");
|
ua.setFirstName("root");
|
||||||
ua.setLastName("user");
|
ua.setLastName("user");
|
||||||
// UQAM Add-Feature using getRootPasswordFromConfig()
|
|
||||||
ua.setArgon2Password(Authenticator.applyArgon2iEncoding(
|
ua.setArgon2Password(Authenticator.applyArgon2iEncoding(
|
||||||
getRootPasswordFromConfig()));
|
ROOT_USER_INITIAL_PASSWORD));
|
||||||
ua.setMd5Password("");
|
ua.setMd5Password("");
|
||||||
// UQAM Add-Feature using getRootPasswdChangeRequiredFromConfig()
|
ua.setPasswordChangeRequired(true);
|
||||||
ua.setPasswordChangeRequired(getRootPasswdChangeRequiredFromConfig().booleanValue());
|
|
||||||
ua.setStatus(Status.ACTIVE);
|
ua.setStatus(Status.ACTIVE);
|
||||||
ua.setRootUser(true);
|
ua.setRootUser(true);
|
||||||
|
|
||||||
|
@ -200,31 +191,7 @@ public class RootUserPolicy implements PolicyIface {
|
||||||
ss.warning(this, "For security, "
|
ss.warning(this, "For security, "
|
||||||
+ "it is best to delete unneeded root user accounts.");
|
+ "it is best to delete unneeded root user accounts.");
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* UQAM Add-Feature
|
|
||||||
* Add for getting rootUser.password property value from runtime.properties
|
|
||||||
*/
|
|
||||||
private String getRootPasswordFromConfig() {
|
|
||||||
String passwd = ConfigurationProperties.getBean(ctx).getProperty(
|
|
||||||
PROPERTY_ROOT_USER_PASSWORD);
|
|
||||||
if (passwd == null) {
|
|
||||||
passwd = ROOT_USER_INITIAL_PASSWORD;
|
|
||||||
}
|
|
||||||
return passwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* UQAM Add-Feature
|
|
||||||
* Add for getting rootUser.passwordChangeRequired property value from runtime.properties
|
|
||||||
*/
|
|
||||||
private Boolean getRootPasswdChangeRequiredFromConfig() {
|
|
||||||
String passwdCR = ConfigurationProperties.getBean(ctx).getProperty(
|
|
||||||
PROPERTY_ROOT_USER_PASSWORD_CHANGE_REQUIRED);
|
|
||||||
if (passwdCR == null) {
|
|
||||||
passwdCR = ROOT_USER_INITIAL_PASSWORD_CHANGE_REQUIRED;
|
|
||||||
}
|
|
||||||
return new Boolean(passwdCR);
|
|
||||||
}
|
|
||||||
@Override
|
@Override
|
||||||
public void contextDestroyed(ServletContextEvent sce) {
|
public void contextDestroyed(ServletContextEvent sce) {
|
||||||
// Nothing to destroy
|
// Nothing to destroy
|
||||||
|
|
|
@ -20,7 +20,6 @@ public class ApplicationBean {
|
||||||
public final static int VIVO_SEARCHBOX_SIZE = 20;
|
public final static int VIVO_SEARCHBOX_SIZE = 20;
|
||||||
|
|
||||||
private final static String DEFAULT_APPLICATION_NAME = "Vitro";
|
private final static String DEFAULT_APPLICATION_NAME = "Vitro";
|
||||||
private final static String DEFAULT_APPLICATION_AVAILABLE_LANGS_FILE = "available-langs";
|
|
||||||
private final static String DEFAULT_ROOT_LOGOTYPE_IMAGE = "";
|
private final static String DEFAULT_ROOT_LOGOTYPE_IMAGE = "";
|
||||||
private final static int DEFAULT_ROOT_LOGOTYPE_WIDTH = 0;
|
private final static int DEFAULT_ROOT_LOGOTYPE_WIDTH = 0;
|
||||||
private final static int DEFAULT_ROOT_LOGOTYPE_HEIGHT = 0;
|
private final static int DEFAULT_ROOT_LOGOTYPE_HEIGHT = 0;
|
||||||
|
@ -34,7 +33,6 @@ public class ApplicationBean {
|
||||||
private boolean initialized = false;
|
private boolean initialized = false;
|
||||||
private String sessionIdStr = null;
|
private String sessionIdStr = null;
|
||||||
private String applicationName = DEFAULT_APPLICATION_NAME;
|
private String applicationName = DEFAULT_APPLICATION_NAME;
|
||||||
private String availableLangsFile = DEFAULT_APPLICATION_AVAILABLE_LANGS_FILE;
|
|
||||||
|
|
||||||
private String rootLogotypeImage = DEFAULT_ROOT_LOGOTYPE_IMAGE;
|
private String rootLogotypeImage = DEFAULT_ROOT_LOGOTYPE_IMAGE;
|
||||||
private int rootLogotypeWidth = DEFAULT_ROOT_LOGOTYPE_WIDTH;
|
private int rootLogotypeWidth = DEFAULT_ROOT_LOGOTYPE_WIDTH;
|
||||||
|
@ -54,7 +52,6 @@ public class ApplicationBean {
|
||||||
output += " initialized from DB: [" + initialized + "]\n";
|
output += " initialized from DB: [" + initialized + "]\n";
|
||||||
output += " session id: [" + sessionIdStr + "]\n";
|
output += " session id: [" + sessionIdStr + "]\n";
|
||||||
output += " application name: [" + applicationName + "]\n";
|
output += " application name: [" + applicationName + "]\n";
|
||||||
output += " available langs file: [" + availableLangsFile + "]\n";
|
|
||||||
output += " root logotype image: [" + rootLogotypeImage + "]\n";
|
output += " root logotype image: [" + rootLogotypeImage + "]\n";
|
||||||
output += " root logotype width: [" + rootLogotypeWidth + "]\n";
|
output += " root logotype width: [" + rootLogotypeWidth + "]\n";
|
||||||
output += " root logotype height: [" + rootLogotypeHeight + "]\n";
|
output += " root logotype height: [" + rootLogotypeHeight + "]\n";
|
||||||
|
@ -180,10 +177,6 @@ public class ApplicationBean {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAvailableLangsFile() {
|
|
||||||
return availableLangsFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Directory to find the images. Subdirectories include css, jsp and site_icons.
|
* Directory to find the images. Subdirectories include css, jsp and site_icons.
|
||||||
* Example: "themes/enhanced/"
|
* Example: "themes/enhanced/"
|
||||||
|
|
|
@ -87,11 +87,6 @@ public class DataProperty extends Property implements Comparable<DataProperty>,
|
||||||
public String getRangeDatatypeURI() {
|
public String getRangeDatatypeURI() {
|
||||||
return rangeDatatypeURI;
|
return rangeDatatypeURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRangeVClassURI() {
|
|
||||||
return rangeDatatypeURI;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRangeDatatypeURI(String rangeDatatypeURI) {
|
public void setRangeDatatypeURI(String rangeDatatypeURI) {
|
||||||
this.rangeDatatypeURI = rangeDatatypeURI;
|
this.rangeDatatypeURI = rangeDatatypeURI;
|
||||||
|
|
|
@ -6,8 +6,6 @@ import static org.apache.jena.rdf.model.ResourceFactory.createResource;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.RoleRestrictedProperty;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.RoleRestrictedProperty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,9 +20,7 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean,
|
||||||
private String configUri;
|
private String configUri;
|
||||||
|
|
||||||
// Must not be null on insert or update. Partial identifier on delete.
|
// Must not be null on insert or update. Partial identifier on delete.
|
||||||
private String rangeURI = "";
|
private String rangeURI;
|
||||||
|
|
||||||
private String rootRangeURI;
|
|
||||||
// May be null. Partial identifier on delete.
|
// May be null. Partial identifier on delete.
|
||||||
private String domainURI;
|
private String domainURI;
|
||||||
|
|
||||||
|
@ -59,7 +55,7 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean,
|
||||||
*/
|
*/
|
||||||
public FauxProperty(String domainURI, String baseURI, String rangeURI) {
|
public FauxProperty(String domainURI, String baseURI, String rangeURI) {
|
||||||
super(Objects.requireNonNull(baseURI, "baseURI may not be null"));
|
super(Objects.requireNonNull(baseURI, "baseURI may not be null"));
|
||||||
this.setRangeURI(rangeURI);
|
this.rangeURI = rangeURI;
|
||||||
this.domainURI = domainURI;
|
this.domainURI = domainURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,11 +93,7 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean,
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRangeURI(String rangeURI) {
|
public void setRangeURI(String rangeURI) {
|
||||||
if (StringUtils.isEmpty(rangeURI)) {
|
this.rangeURI = rangeURI;
|
||||||
this.rangeURI = "";
|
|
||||||
} else {
|
|
||||||
this.rangeURI = rangeURI;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBaseLabel() {
|
public String getBaseLabel() {
|
||||||
|
@ -113,14 +105,7 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean,
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRangeLabel() {
|
public String getRangeLabel() {
|
||||||
if (StringUtils.isEmpty(rangeLabel)) {
|
return (rangeLabel == null) ? localName(rangeURI) : rangeLabel;
|
||||||
if (StringUtils.isEmpty(rangeURI)) {
|
|
||||||
return "untyped";
|
|
||||||
}
|
|
||||||
return localName(rangeURI);
|
|
||||||
} else {
|
|
||||||
return rangeLabel;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRangeLabel(String rangeLabel) {
|
public void setRangeLabel(String rangeLabel) {
|
||||||
|
@ -262,12 +247,4 @@ public class FauxProperty extends BaseResourceBean implements ResourceBean,
|
||||||
public String getRangeVClassURI() {
|
public String getRangeVClassURI() {
|
||||||
return getRangeURI();
|
return getRangeURI();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRootRangeUri(String rootRangeUri) {
|
|
||||||
this.rootRangeURI = rootRangeUri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRootRangeUri() {
|
|
||||||
return rootRangeURI;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.beans;
|
||||||
|
|
||||||
import java.beans.XMLEncoder;
|
import java.beans.XMLEncoder;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.apache.commons.lang3.RandomStringUtils;
|
||||||
*/
|
*/
|
||||||
public class UserAccount {
|
public class UserAccount {
|
||||||
public static final int MIN_PASSWORD_LENGTH = 6;
|
public static final int MIN_PASSWORD_LENGTH = 6;
|
||||||
public static final int MAX_PASSWORD_LENGTH = 64;
|
public static final int MAX_PASSWORD_LENGTH = 12;
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
ACTIVE, INACTIVE;
|
ACTIVE, INACTIVE;
|
||||||
|
|
|
@ -109,7 +109,7 @@ public abstract class ConfigurationProperties {
|
||||||
throw new NullPointerException("bean may not be null.");
|
throw new NullPointerException("bean may not be null.");
|
||||||
}
|
}
|
||||||
context.setAttribute(ATTRIBUTE_NAME, bean);
|
context.setAttribute(ATTRIBUTE_NAME, bean);
|
||||||
log.debug(bean);
|
log.info(bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Package access, so unit tests can call it. */
|
/** Package access, so unit tests can call it. */
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class ConfigurationPropertiesSetup implements ServletContextListener {
|
||||||
vitroHomeDir, vitroHomeDirConfig);
|
vitroHomeDir, vitroHomeDirConfig);
|
||||||
|
|
||||||
File runtimePropertiesFile = locateRuntimePropertiesFile(
|
File runtimePropertiesFile = locateRuntimePropertiesFile(
|
||||||
vitroHomeDir, vitroHomeDirConfig, ss);
|
vitroHomeDir, vitroHomeDirConfig, ss);
|
||||||
stream = new FileInputStream(runtimePropertiesFile);
|
stream = new FileInputStream(runtimePropertiesFile);
|
||||||
|
|
||||||
Map<String, String> preempts = createPreemptiveProperties(
|
Map<String, String> preempts = createPreemptiveProperties(
|
||||||
|
@ -118,6 +118,7 @@ public class ConfigurationPropertiesSetup implements ServletContextListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private File locateRuntimePropertiesFile(File vitroHomeDir,
|
private File locateRuntimePropertiesFile(File vitroHomeDir,
|
||||||
File vitroHomeDirConfig, StartupStatus ss) {
|
File vitroHomeDirConfig, StartupStatus ss) {
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ public class ConfigurationPropertiesSmokeTests implements
|
||||||
String vivoBundle = VIVO_BUNDLE_PREFIX + language + ".properties";
|
String vivoBundle = VIVO_BUNDLE_PREFIX + language + ".properties";
|
||||||
String vitroBundle = VITRO_BUNDLE_PREFIX + language + ".properties";
|
String vitroBundle = VITRO_BUNDLE_PREFIX + language + ".properties";
|
||||||
if (!i18nNames.contains(vivoBundle) && !i18nNames.contains(vitroBundle)) {
|
if (!i18nNames.contains(vivoBundle) && !i18nNames.contains(vitroBundle)) {
|
||||||
ss.info(this, language + " was found in the value for "
|
ss.warning(this, language + " was found in the value for "
|
||||||
+ PROPERTY_LANGUAGE_SELECTABLE + " but no corresponding "
|
+ PROPERTY_LANGUAGE_SELECTABLE + " but no corresponding "
|
||||||
+ "language file was found.");
|
+ "language file was found.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.config;
|
package edu.cornell.mannlib.vitro.webapp.config;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -15,6 +14,8 @@ 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.ibm.icu.text.SimpleDateFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about the provenance of this application: release, revision
|
* Information about the provenance of this application: release, revision
|
||||||
* level, build date, etc.
|
* level, build date, etc.
|
||||||
|
@ -40,7 +41,7 @@ public class RevisionInfoBean {
|
||||||
new Date(0), Collections.singleton(LevelRevisionInfo.DUMMY_LEVEL));
|
new Date(0), Collections.singleton(LevelRevisionInfo.DUMMY_LEVEL));
|
||||||
|
|
||||||
/** The bean is attached to the session by this name. */
|
/** The bean is attached to the session by this name. */
|
||||||
public static final String ATTRIBUTE_NAME = RevisionInfoBean.class.getName();
|
static final String ATTRIBUTE_NAME = RevisionInfoBean.class.getName();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// static methods
|
// static methods
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class Controllers {
|
||||||
|
|
||||||
public static final String ABOUT = "/about";
|
public static final String ABOUT = "/about";
|
||||||
public static final String CONTACT_URL = "/comments";
|
public static final String CONTACT_URL = "/comments";
|
||||||
|
public static final String TERMS_OF_USE_URL = "/termsOfUse";
|
||||||
public static final String SEARCH_URL = "/search";
|
public static final String SEARCH_URL = "/search";
|
||||||
public static final String ENTITY = "/entity";
|
public static final String ENTITY = "/entity";
|
||||||
|
|
||||||
|
|
|
@ -57,6 +57,8 @@ public abstract class UserAccountsAddPageStrategy extends UserAccountsPage {
|
||||||
|
|
||||||
private static class EmailStrategy extends UserAccountsAddPageStrategy {
|
private static class EmailStrategy extends UserAccountsAddPageStrategy {
|
||||||
public static final String CREATE_PASSWORD_URL = "/accounts/createPassword";
|
public static final String CREATE_PASSWORD_URL = "/accounts/createPassword";
|
||||||
|
private static final String EMAIL_TEMPLATE_WITH_PASSWORD = "userAccounts-acctCreatedEmail.ftl";
|
||||||
|
private static final String EMAIL_TEMPLATE_NO_PASSWORD = "userAccounts-acctCreatedExternalOnlyEmail.ftl";
|
||||||
|
|
||||||
private boolean sentEmail;
|
private boolean sentEmail;
|
||||||
|
|
||||||
|
@ -98,19 +100,15 @@ public abstract class UserAccountsAddPageStrategy extends UserAccountsPage {
|
||||||
body.put("userAccount", page.getAddedAccount());
|
body.put("userAccount", page.getAddedAccount());
|
||||||
body.put("passwordLink", buildCreatePasswordLink());
|
body.put("passwordLink", buildCreatePasswordLink());
|
||||||
body.put("siteName", getSiteName());
|
body.put("siteName", getSiteName());
|
||||||
|
|
||||||
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
||||||
.createNewMessage(vreq);
|
.createNewMessage(vreq);
|
||||||
email.addRecipient(TO, page.getAddedAccount().getEmailAddress());
|
email.addRecipient(TO, page.getAddedAccount().getEmailAddress());
|
||||||
String subject = i18n.text("account_created_subject", getSiteName());
|
email.setSubject(i18n.text("account_created_subject", getSiteName()));
|
||||||
email.setSubject(subject);
|
|
||||||
if (page.isExternalAuthOnly()) {
|
if (page.isExternalAuthOnly()) {
|
||||||
body.put("subject", subject);
|
email.setTemplate(EMAIL_TEMPLATE_NO_PASSWORD);
|
||||||
body.put("textMessage", i18n.text("acct_created_external_only_email_plain_text"));
|
|
||||||
body.put("htmlMessage", i18n.text("acct_created_external_only_email_html_text"));
|
|
||||||
} else {
|
} else {
|
||||||
body.put("subject", subject);
|
email.setTemplate(EMAIL_TEMPLATE_WITH_PASSWORD);
|
||||||
body.put("textMessage", i18n.text("acct_created_email_plain_text"));
|
|
||||||
body.put("htmlMessage", i18n.text("acct_created_email_html_text"));
|
|
||||||
}
|
}
|
||||||
email.setBodyMap(body);
|
email.setBodyMap(body);
|
||||||
email.processTemplate();
|
email.processTemplate();
|
||||||
|
|
|
@ -56,6 +56,8 @@ public abstract class UserAccountsEditPageStrategy extends UserAccountsPage {
|
||||||
|
|
||||||
private static class EmailStrategy extends UserAccountsEditPageStrategy {
|
private static class EmailStrategy extends UserAccountsEditPageStrategy {
|
||||||
private static final String PARAMETER_RESET_PASSWORD = "resetPassword";
|
private static final String PARAMETER_RESET_PASSWORD = "resetPassword";
|
||||||
|
private static final String EMAIL_TEMPLATE = "userAccounts-passwordResetPendingEmail.ftl";
|
||||||
|
|
||||||
public static final String RESET_PASSWORD_URL = "/accounts/resetPassword";
|
public static final String RESET_PASSWORD_URL = "/accounts/resetPassword";
|
||||||
|
|
||||||
private boolean resetPassword;
|
private boolean resetPassword;
|
||||||
|
@ -105,13 +107,11 @@ public abstract class UserAccountsEditPageStrategy extends UserAccountsPage {
|
||||||
body.put("userAccount", page.getUpdatedAccount());
|
body.put("userAccount", page.getUpdatedAccount());
|
||||||
body.put("passwordLink", buildResetPasswordLink());
|
body.put("passwordLink", buildResetPasswordLink());
|
||||||
body.put("siteName", getSiteName());
|
body.put("siteName", getSiteName());
|
||||||
body.put("subject", i18n.text("password_reset_pending_email_subject"));
|
|
||||||
body.put("textMessage",i18n.text("password_reset_pending_email_plain_text"));
|
|
||||||
body.put("htmlMessage", i18n.text("password_reset_pending_email_html_text"));
|
|
||||||
|
|
||||||
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
||||||
.createNewMessage(vreq);
|
.createNewMessage(vreq);
|
||||||
email.addRecipient(TO, page.getUpdatedAccount().getEmailAddress());
|
email.addRecipient(TO, page.getUpdatedAccount().getEmailAddress());
|
||||||
|
email.setTemplate(EMAIL_TEMPLATE);
|
||||||
email.setBodyMap(body);
|
email.setBodyMap(body);
|
||||||
email.processTemplate();
|
email.processTemplate();
|
||||||
email.send();
|
email.send();
|
||||||
|
|
|
@ -26,6 +26,8 @@ public class UserAccountsCreatePasswordPage extends
|
||||||
.getLog(UserAccountsCreatePasswordPage.class);
|
.getLog(UserAccountsCreatePasswordPage.class);
|
||||||
|
|
||||||
private static final String TEMPLATE_NAME = "userAccounts-createPassword.ftl";
|
private static final String TEMPLATE_NAME = "userAccounts-createPassword.ftl";
|
||||||
|
private static final String EMAIL_TEMPLATE = "userAccounts-passwordCreatedEmail.ftl";
|
||||||
|
|
||||||
public UserAccountsCreatePasswordPage(VitroRequest vreq) {
|
public UserAccountsCreatePasswordPage(VitroRequest vreq) {
|
||||||
super(vreq);
|
super(vreq);
|
||||||
}
|
}
|
||||||
|
@ -71,11 +73,8 @@ public class UserAccountsCreatePasswordPage extends
|
||||||
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
||||||
.createNewMessage(vreq);
|
.createNewMessage(vreq);
|
||||||
email.addRecipient(TO, userAccount.getEmailAddress());
|
email.addRecipient(TO, userAccount.getEmailAddress());
|
||||||
final String subject = i18n.text("password_created_subject", getSiteName());
|
email.setSubject(i18n.text("password_created_subject", getSiteName()));
|
||||||
email.setSubject(subject);
|
email.setTemplate(EMAIL_TEMPLATE);
|
||||||
body.put("subject", subject);
|
|
||||||
body.put("textMessage", i18n.text("password_created_email_plain_text"));
|
|
||||||
body.put("htmlMessage", i18n.text("password_created_email_html_text"));
|
|
||||||
email.setBodyMap(body);
|
email.setBodyMap(body);
|
||||||
email.processTemplate();
|
email.processTemplate();
|
||||||
email.send();
|
email.send();
|
||||||
|
|
|
@ -52,6 +52,8 @@ public abstract class UserAccountsFirstTimeExternalPageStrategy extends
|
||||||
public static class EmailStrategy extends
|
public static class EmailStrategy extends
|
||||||
UserAccountsFirstTimeExternalPageStrategy {
|
UserAccountsFirstTimeExternalPageStrategy {
|
||||||
|
|
||||||
|
private static final String EMAIL_TEMPLATE = "userAccounts-firstTimeExternalEmail.ftl";
|
||||||
|
|
||||||
public EmailStrategy(VitroRequest vreq,
|
public EmailStrategy(VitroRequest vreq,
|
||||||
UserAccountsFirstTimeExternalPage page) {
|
UserAccountsFirstTimeExternalPage page) {
|
||||||
super(vreq, page);
|
super(vreq, page);
|
||||||
|
@ -71,11 +73,8 @@ public abstract class UserAccountsFirstTimeExternalPageStrategy extends
|
||||||
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
||||||
.createNewMessage(vreq);
|
.createNewMessage(vreq);
|
||||||
email.addRecipient(TO, ua.getEmailAddress());
|
email.addRecipient(TO, ua.getEmailAddress());
|
||||||
final String subject = i18n.text("account_created_subject", getSiteName());
|
email.setSubject(i18n.text("account_created_subject", getSiteName()));
|
||||||
email.setSubject(subject);
|
email.setTemplate(EMAIL_TEMPLATE);
|
||||||
body.put("subject", subject);
|
|
||||||
body.put("textMessage", i18n.text("first_time_external_email_plain_text"));
|
|
||||||
body.put("htmlMessage", i18n.text("first_time_external_email_html_text"));
|
|
||||||
email.setBodyMap(body);
|
email.setBodyMap(body);
|
||||||
email.processTemplate();
|
email.processTemplate();
|
||||||
email.send();
|
email.send();
|
||||||
|
|
|
@ -108,6 +108,8 @@ public abstract class UserAccountsMyAccountPageStrategy extends
|
||||||
private static final String ERROR_WRONG_PASSWORD_LENGTH = "errorPasswordIsWrongLength";
|
private static final String ERROR_WRONG_PASSWORD_LENGTH = "errorPasswordIsWrongLength";
|
||||||
private static final String ERROR_PASSWORDS_DONT_MATCH = "errorPasswordsDontMatch";
|
private static final String ERROR_PASSWORDS_DONT_MATCH = "errorPasswordsDontMatch";
|
||||||
|
|
||||||
|
private static final String EMAIL_TEMPLATE = "userAccounts-confirmEmailChangedEmail.ftl";
|
||||||
|
|
||||||
private final String originalEmail;
|
private final String originalEmail;
|
||||||
|
|
||||||
private String newPassword;
|
private String newPassword;
|
||||||
|
@ -177,11 +179,8 @@ public abstract class UserAccountsMyAccountPageStrategy extends
|
||||||
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
||||||
.createNewMessage(vreq);
|
.createNewMessage(vreq);
|
||||||
email.addRecipient(TO, page.getUserAccount().getEmailAddress());
|
email.addRecipient(TO, page.getUserAccount().getEmailAddress());
|
||||||
final String subject = i18n.text("email_changed_subject", getSiteName());
|
email.setSubject(i18n.text("email_changed_subject", getSiteName()));
|
||||||
email.setSubject(subject);
|
email.setTemplate(EMAIL_TEMPLATE);
|
||||||
body.put("subject", subject);
|
|
||||||
body.put("textMessage", i18n.text("confirm_email_changed_email_plain_text"));
|
|
||||||
body.put("htmlMessage", i18n.text("confirm_email_changed_email_html_text"));
|
|
||||||
email.setBodyMap(body);
|
email.setBodyMap(body);
|
||||||
email.processTemplate();
|
email.processTemplate();
|
||||||
email.send();
|
email.send();
|
||||||
|
|
|
@ -26,6 +26,8 @@ public class UserAccountsResetPasswordPage extends UserAccountsPasswordBasePage
|
||||||
|
|
||||||
private static final String TEMPLATE_NAME = "userAccounts-resetPassword.ftl";
|
private static final String TEMPLATE_NAME = "userAccounts-resetPassword.ftl";
|
||||||
|
|
||||||
|
private static final String EMAIL_TEMPLATE = "userAccounts-passwordResetCompleteEmail.ftl";
|
||||||
|
|
||||||
protected UserAccountsResetPasswordPage(VitroRequest vreq) {
|
protected UserAccountsResetPasswordPage(VitroRequest vreq) {
|
||||||
super(vreq);
|
super(vreq);
|
||||||
}
|
}
|
||||||
|
@ -66,16 +68,14 @@ public class UserAccountsResetPasswordPage extends UserAccountsPasswordBasePage
|
||||||
|
|
||||||
private void notifyUser() {
|
private void notifyUser() {
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
FreemarkerEmailMessage email = FreemarkerEmailFactory.createNewMessage(vreq);
|
|
||||||
final String subject = i18n.text("password_changed_subject");
|
|
||||||
email.setSubject(subject);
|
|
||||||
|
|
||||||
body.put("userAccount", userAccount);
|
body.put("userAccount", userAccount);
|
||||||
body.put("siteName", getSiteName());
|
body.put("siteName", getSiteName());
|
||||||
body.put("subject", subject);
|
|
||||||
body.put("textMessage", i18n.text("password_reset_complete_email_plain_text"));
|
FreemarkerEmailMessage email = FreemarkerEmailFactory
|
||||||
body.put("htmlMessage", i18n.text("password_reset_complete_email_html_text"));
|
.createNewMessage(vreq);
|
||||||
email.addRecipient(TO, userAccount.getEmailAddress());
|
email.addRecipient(TO, userAccount.getEmailAddress());
|
||||||
|
email.setSubject(i18n.text("password_changed_subject"));
|
||||||
|
email.setTemplate(EMAIL_TEMPLATE);
|
||||||
email.setBodyMap(body);
|
email.setBodyMap(body);
|
||||||
email.processTemplate();
|
email.processTemplate();
|
||||||
email.send();
|
email.send();
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.admin;
|
package edu.cornell.mannlib.vitro.webapp.controller.admin;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -10,6 +9,8 @@ import java.util.Map;
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import com.ibm.icu.text.SimpleDateFormat;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
|
|
|
@ -17,8 +17,6 @@ import javax.servlet.annotation.WebServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -77,8 +75,8 @@ public class SparqlQueryController extends FreemarkerHttpServlet {
|
||||||
private static final String[] SAMPLE_QUERY = { //
|
private static final String[] SAMPLE_QUERY = { //
|
||||||
"", //
|
"", //
|
||||||
"#", //
|
"#", //
|
||||||
"i18n:sparql_query_description_0", //
|
"# This example query gets 20 geographic locations", //
|
||||||
"i18n:sparql_query_description_1", //
|
"# and (if available) their labels", //
|
||||||
"#", //
|
"#", //
|
||||||
"SELECT ?geoLocation ?label", //
|
"SELECT ?geoLocation ?label", //
|
||||||
"WHERE", //
|
"WHERE", //
|
||||||
|
@ -195,11 +193,9 @@ public class SparqlQueryController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) throws Exception {
|
protected ResponseValues processRequest(VitroRequest vreq) throws Exception {
|
||||||
I18nBundle i18n = I18n.bundle(vreq);
|
|
||||||
|
|
||||||
Map<String, Object> bodyMap = new HashMap<>();
|
Map<String, Object> bodyMap = new HashMap<>();
|
||||||
bodyMap.put("sampleQuery", buildSampleQuery(i18n, buildPrefixList(vreq)));
|
bodyMap.put("sampleQuery", buildSampleQuery(buildPrefixList(vreq)));
|
||||||
bodyMap.put("title", i18n.text("sparql_query_title"));
|
bodyMap.put("title", "SPARQL Query");
|
||||||
bodyMap.put("submitUrl", UrlBuilder.getUrl("admin/sparqlquery"));
|
bodyMap.put("submitUrl", UrlBuilder.getUrl("admin/sparqlquery"));
|
||||||
return new TemplateResponseValues(TEMPLATE_NAME, bodyMap);
|
return new TemplateResponseValues(TEMPLATE_NAME, bodyMap);
|
||||||
}
|
}
|
||||||
|
@ -226,7 +222,7 @@ public class SparqlQueryController extends FreemarkerHttpServlet {
|
||||||
return prefixList;
|
return prefixList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String buildSampleQuery(I18nBundle i18n, List<Prefix> prefixList) {
|
private String buildSampleQuery(List<Prefix> prefixList) {
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter writer = new PrintWriter(sw);
|
PrintWriter writer = new PrintWriter(sw);
|
||||||
|
|
||||||
|
@ -234,10 +230,6 @@ public class SparqlQueryController extends FreemarkerHttpServlet {
|
||||||
writer.println(p);
|
writer.println(p);
|
||||||
}
|
}
|
||||||
for (String line : SAMPLE_QUERY) {
|
for (String line : SAMPLE_QUERY) {
|
||||||
if (line.startsWith("i18n:")) {
|
|
||||||
// Get i18n translation
|
|
||||||
line = i18n.text(line.substring("i18n:".length()));
|
|
||||||
}
|
|
||||||
writer.println(line);
|
writer.println(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
@ -19,8 +18,6 @@ import org.apache.commons.lang3.StringUtils;
|
||||||
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 static org.apache.jena.riot.web.HttpNames.paramUsingGraphURI;
|
|
||||||
import static org.apache.jena.riot.web.HttpNames.paramUsingNamedGraphURI;
|
|
||||||
import org.apache.jena.query.Dataset;
|
import org.apache.jena.query.Dataset;
|
||||||
import org.apache.jena.query.ReadWrite;
|
import org.apache.jena.query.ReadWrite;
|
||||||
import org.apache.jena.update.GraphStore;
|
import org.apache.jena.update.GraphStore;
|
||||||
|
@ -28,9 +25,6 @@ import org.apache.jena.update.GraphStoreFactory;
|
||||||
import org.apache.jena.update.UpdateAction;
|
import org.apache.jena.update.UpdateAction;
|
||||||
import org.apache.jena.update.UpdateFactory;
|
import org.apache.jena.update.UpdateFactory;
|
||||||
import org.apache.jena.update.UpdateRequest;
|
import org.apache.jena.update.UpdateRequest;
|
||||||
import org.apache.jena.graph.Node;
|
|
||||||
import org.apache.jena.graph.NodeFactory;
|
|
||||||
import org.apache.jena.sparql.modify.UsingList;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
|
@ -82,47 +76,26 @@ public class SparqlUpdateApiController extends VitroApiServlet {
|
||||||
|
|
||||||
private UpdateRequest parseUpdateString(HttpServletRequest req)
|
private UpdateRequest parseUpdateString(HttpServletRequest req)
|
||||||
throws ParseException {
|
throws ParseException {
|
||||||
InputStream update;
|
String update = req.getParameter("update");
|
||||||
String reqtype = req.getContentType();
|
if (StringUtils.isBlank(update)) {
|
||||||
UsingList usingList = processProtocol(req);
|
log.debug("No update parameter.");
|
||||||
|
throw new ParseException("No 'update' parameter.");
|
||||||
// Support update via both POST body and an 'update' parameter
|
|
||||||
if (reqtype.equalsIgnoreCase("application/sparql-update")) {
|
|
||||||
try {
|
|
||||||
update = req.getInputStream();
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.debug("Error parsing POST body.");
|
|
||||||
throw new ParseException("Error parsing POST body.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
String updateString = req.getParameter("update");
|
if (!StringUtils.containsIgnoreCase(update, "GRAPH") && !StringUtils.containsIgnoreCase(update, "WITH")) {
|
||||||
if (StringUtils.isBlank(updateString)) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("No update parameter.");
|
log.debug("No GRAPH or WITH uri in '" + update + "'");
|
||||||
throw new ParseException("No 'update' parameter.");
|
|
||||||
}
|
|
||||||
if (!StringUtils.containsIgnoreCase(updateString, "GRAPH") && !StringUtils.containsIgnoreCase(updateString, "WITH")) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("No GRAPH or WITH uri in '" + updateString + "'");
|
|
||||||
}
|
|
||||||
throw new ParseException("SPARQL update must specify a GRAPH ( or WITH) URI.");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
update = org.apache.commons.io.IOUtils.toInputStream(updateString, "UTF-8");
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.debug("Error parsing POST body.");
|
|
||||||
throw new ParseException("Error parsing POST body.");
|
|
||||||
}
|
}
|
||||||
|
throw new ParseException("SPARQL update must specify a GRAPH ( or WITH) URI.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return UpdateFactory.read(usingList, update);
|
return UpdateFactory.create(update);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.debug("Problem parsing", e);
|
log.debug("Problem parsing", e);
|
||||||
throw new ParseException("Failed to parse SPARQL update", e);
|
throw new ParseException("Failed to parse SPARQL update", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void executeUpdate(HttpServletRequest req, UpdateRequest parsed) {
|
private void executeUpdate(HttpServletRequest req, UpdateRequest parsed) {
|
||||||
VitroRequest vreq = new VitroRequest(req);
|
VitroRequest vreq = new VitroRequest(req);
|
||||||
|
@ -148,35 +121,6 @@ public class SparqlUpdateApiController extends VitroApiServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* The method below and the 'createNode' helper were
|
|
||||||
* adapted from the Fuseki source code
|
|
||||||
*/
|
|
||||||
private UsingList processProtocol(HttpServletRequest request) {
|
|
||||||
UsingList toReturn = new UsingList();
|
|
||||||
|
|
||||||
String[] usingArgs = request.getParameterValues(paramUsingGraphURI);
|
|
||||||
String[] usingNamedArgs = request.getParameterValues(paramUsingNamedGraphURI);
|
|
||||||
if ( usingArgs == null && usingNamedArgs == null )
|
|
||||||
return toReturn;
|
|
||||||
if ( usingArgs == null )
|
|
||||||
usingArgs = new String[0];
|
|
||||||
if ( usingNamedArgs == null )
|
|
||||||
usingNamedArgs = new String[0];
|
|
||||||
// Impossible.
|
|
||||||
// if ( usingArgs.length == 0 && usingNamedArgs.length == 0 )
|
|
||||||
// return;
|
|
||||||
|
|
||||||
for ( String nodeUri : usingArgs ) {
|
|
||||||
toReturn.addUsing(createNode(nodeUri));
|
|
||||||
}
|
|
||||||
for ( String nodeUri : usingNamedArgs ) {
|
|
||||||
toReturn.addUsingNamed(createNode(nodeUri));
|
|
||||||
}
|
|
||||||
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void do200response(HttpServletResponse resp) throws IOException {
|
private void do200response(HttpServletResponse resp) throws IOException {
|
||||||
sendShortResponse(SC_OK, "SPARQL update accepted.", resp);
|
sendShortResponse(SC_OK, "SPARQL update accepted.", resp);
|
||||||
}
|
}
|
||||||
|
@ -214,14 +158,4 @@ public class SparqlUpdateApiController extends VitroApiServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Node createNode(String x) {
|
|
||||||
try {
|
|
||||||
return NodeFactory.createURI(x);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
log.debug("SPARQL Update: bad IRI: "+x);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,9 +108,7 @@ public class LoginRedirector {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
try {
|
try {
|
||||||
DisplayMessage.setMessage(request, assembleWelcomeMessage());
|
DisplayMessage.setMessage(request, assembleWelcomeMessage());
|
||||||
String redirectUrl = getRedirectionUriForLoggedInUser();
|
response.sendRedirect(getRedirectionUriForLoggedInUser());
|
||||||
log.debug("Sending redirect to path: " + redirectUrl);
|
|
||||||
response.sendRedirect(redirectUrl);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.debug("Problem with re-direction", e);
|
log.debug("Problem with re-direction", e);
|
||||||
response.sendRedirect(getApplicationHomePageUrl());
|
response.sendRedirect(getApplicationHomePageUrl());
|
||||||
|
@ -177,13 +175,21 @@ public class LoginRedirector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The application home page can be overridden by an attribute in the
|
||||||
|
* ServletContext. Further, it can either be an absolute URL, or it can be
|
||||||
|
* relative to the application. Weird.
|
||||||
|
*/
|
||||||
private String getApplicationHomePageUrl() {
|
private String getApplicationHomePageUrl() {
|
||||||
String contextPath = request.getContextPath();
|
String contextRedirect = (String) session.getServletContext()
|
||||||
if (contextPath.equals("")) {
|
.getAttribute("postLoginRequest");
|
||||||
return "/";
|
if (contextRedirect != null) {
|
||||||
}
|
if (contextRedirect.indexOf(":") == -1) {
|
||||||
else {
|
return request.getContextPath() + contextRedirect;
|
||||||
return contextPath;
|
} else {
|
||||||
|
return contextRedirect;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return request.getContextPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class Classes2ClassesRetryController extends BaseEditController {
|
||||||
action = epo.getAction();
|
action = epo.getAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
VClassDao vcDao = ModelAccess.on(request).getWebappDaoFactory().getVClassDao();
|
VClassDao vcDao = ModelAccess.on(getServletContext()).getWebappDaoFactory().getVClassDao();
|
||||||
epo.setDataAccessObject(vcDao);
|
epo.setDataAccessObject(vcDao);
|
||||||
Classes2Classes objectForEditing = new Classes2Classes();
|
Classes2Classes objectForEditing = new Classes2Classes();
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@ public class ClassgroupRetryController extends BaseEditController {
|
||||||
action = epo.getAction();
|
action = epo.getAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
VClassGroupDao cgDao = ModelAccess.on(request).getWebappDaoFactory().getVClassGroupDao();
|
VClassGroupDao cgDao = ModelAccess.on(
|
||||||
|
getServletContext()).getWebappDaoFactory().getVClassGroupDao();
|
||||||
|
|
||||||
epo.setDataAccessObject(cgDao);
|
epo.setDataAccessObject(cgDao);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ import edu.cornell.mannlib.vedit.controller.BaseEditController;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.FauxProperty;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
import edu.cornell.mannlib.vitro.webapp.beans.Ontology;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
|
@ -177,11 +176,6 @@ public class DatapropEditController extends BaseEditController {
|
||||||
assertionsDpDao.getEquivalentPropertyURIs(dp.getURI()), assertionsDpDao);
|
assertionsDpDao.getEquivalentPropertyURIs(dp.getURI()), assertionsDpDao);
|
||||||
sortForPickList(eqProps, vreq);
|
sortForPickList(eqProps, vreq);
|
||||||
request.setAttribute("equivalentProperties", eqProps);
|
request.setAttribute("equivalentProperties", eqProps);
|
||||||
|
|
||||||
List<FauxProperty> fauxProps = vreq.getUnfilteredAssertionsWebappDaoFactory().getFauxPropertyDao().
|
|
||||||
getFauxPropertiesForBaseUri(dp.getURI());
|
|
||||||
sortForPickList(fauxProps, vreq);
|
|
||||||
request.setAttribute("fauxproperties", fauxProps);
|
|
||||||
|
|
||||||
ApplicationBean appBean = vreq.getAppBean();
|
ApplicationBean appBean = vreq.getAppBean();
|
||||||
|
|
||||||
|
|
|
@ -50,12 +50,11 @@ public class DatapropRetryController extends BaseEditController {
|
||||||
|
|
||||||
//create an EditProcessObject for this and put it in the session
|
//create an EditProcessObject for this and put it in the session
|
||||||
EditProcessObject epo = super.createEpo(request);
|
EditProcessObject epo = super.createEpo(request);
|
||||||
epo.setImplementationClass(DataProperty.class);
|
|
||||||
epo.setBeanClass(DataProperty.class);
|
epo.setBeanClass(DataProperty.class);
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
|
|
||||||
WebappDaoFactory wadf = ModelAccess.on(vreq).getWebappDaoFactory();
|
WebappDaoFactory wadf = ModelAccess.on(getServletContext()).getWebappDaoFactory();
|
||||||
|
|
||||||
DatatypeDao dDao = wadf.getDatatypeDao();
|
DatatypeDao dDao = wadf.getDatatypeDao();
|
||||||
DataPropertyDao dpDao = wadf.getDataPropertyDao();
|
DataPropertyDao dpDao = wadf.getDataPropertyDao();
|
||||||
|
|
|
@ -20,12 +20,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.JSPPageHandler;
|
import edu.cornell.mannlib.vitro.webapp.utils.JSPPageHandler;
|
||||||
import org.apache.commons.collections4.map.ListOrderedMap;
|
import org.apache.commons.collections4.map.ListOrderedMap;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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.ctc.wstx.util.StringUtil;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vedit.beans.DynamicField;
|
import edu.cornell.mannlib.vedit.beans.DynamicField;
|
||||||
import edu.cornell.mannlib.vedit.beans.DynamicFieldRow;
|
import edu.cornell.mannlib.vedit.beans.DynamicFieldRow;
|
||||||
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
|
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
|
||||||
|
@ -253,12 +250,7 @@ public class EntityRetryController extends BaseEditController {
|
||||||
//TODO: UGH
|
//TODO: UGH
|
||||||
//row.setId(existingValue.getId());
|
//row.setId(existingValue.getId());
|
||||||
row.setParameterMap(parameterMap);
|
row.setParameterMap(parameterMap);
|
||||||
String value = existingValue.getData();
|
row.setValue(existingValue.getData());
|
||||||
row.setValue(value);
|
|
||||||
String language = existingValue.getLanguage();
|
|
||||||
if (!StringUtils.isBlank(language)) {
|
|
||||||
row.setLanguage(language);
|
|
||||||
}
|
|
||||||
if (dynamo.getRowList() == null)
|
if (dynamo.getRowList() == null)
|
||||||
dynamo.setRowList(new ArrayList());
|
dynamo.setRowList(new ArrayList());
|
||||||
dynamo.getRowList().add(row);
|
dynamo.getRowList().add(row);
|
||||||
|
|
|
@ -32,14 +32,12 @@ import edu.cornell.mannlib.vedit.validator.Validator;
|
||||||
import edu.cornell.mannlib.vedit.validator.impl.RequiredFieldValidator;
|
import edu.cornell.mannlib.vedit.validator.impl.RequiredFieldValidator;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionListener;
|
import edu.cornell.mannlib.vitro.webapp.auth.policy.bean.PropertyRestrictionListener;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.FauxProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.FauxProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.edit.utils.RoleLevelOptionsSetup;
|
import edu.cornell.mannlib.vitro.webapp.controller.edit.utils.RoleLevelOptionsSetup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.FauxPropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.FauxPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
|
@ -90,8 +88,6 @@ public class FauxPropertyRetryController extends BaseEditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class EpoPopulator {
|
private static class EpoPopulator {
|
||||||
private static final String LITERAL = "http://www.w3.org/2000/01/rdf-schema#Literal";
|
|
||||||
private static final String XML_LITERAL = "http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral";
|
|
||||||
private final VitroRequest req;
|
private final VitroRequest req;
|
||||||
private final ServletContext ctx;
|
private final ServletContext ctx;
|
||||||
private final WebappDaoFactory wadf;
|
private final WebappDaoFactory wadf;
|
||||||
|
@ -102,8 +98,6 @@ public class FauxPropertyRetryController extends BaseEditController {
|
||||||
|
|
||||||
private FauxProperty beanForEditing;
|
private FauxProperty beanForEditing;
|
||||||
private Property baseProperty;
|
private Property baseProperty;
|
||||||
|
|
||||||
private boolean isFauxDataProperty = false;
|
|
||||||
|
|
||||||
EpoPopulator(HttpServletRequest req, EditProcessObject epo) {
|
EpoPopulator(HttpServletRequest req, EditProcessObject epo) {
|
||||||
this.req = new VitroRequest(req);
|
this.req = new VitroRequest(req);
|
||||||
|
@ -112,7 +106,7 @@ public class FauxPropertyRetryController extends BaseEditController {
|
||||||
|
|
||||||
this.epo = epo;
|
this.epo = epo;
|
||||||
|
|
||||||
this.fpDao = ModelAccess.on(req).getWebappDaoFactory()
|
this.fpDao = ModelAccess.on(ctx).getWebappDaoFactory()
|
||||||
.getFauxPropertyDao();
|
.getFauxPropertyDao();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -120,8 +114,6 @@ public class FauxPropertyRetryController extends BaseEditController {
|
||||||
void populate() {
|
void populate() {
|
||||||
epo.setDataAccessObject(fpDao);
|
epo.setDataAccessObject(fpDao);
|
||||||
epo.setAction(determineAction());
|
epo.setAction(determineAction());
|
||||||
epo.setImplementationClass(FauxProperty.class);
|
|
||||||
epo.setBeanClass(FauxProperty.class);
|
|
||||||
|
|
||||||
if (epo.getUseRecycledBean()) {
|
if (epo.getUseRecycledBean()) {
|
||||||
beanForEditing = (FauxProperty) epo.getNewBean();
|
beanForEditing = (FauxProperty) epo.getNewBean();
|
||||||
|
@ -133,19 +125,10 @@ public class FauxPropertyRetryController extends BaseEditController {
|
||||||
this.baseProperty = req.getUnfilteredWebappDaoFactory()
|
this.baseProperty = req.getUnfilteredWebappDaoFactory()
|
||||||
.getObjectPropertyDao()
|
.getObjectPropertyDao()
|
||||||
.getObjectPropertyByURI(beanForEditing.getURI());
|
.getObjectPropertyByURI(beanForEditing.getURI());
|
||||||
if (this.baseProperty == null) {
|
|
||||||
this.baseProperty = req.getUnfilteredWebappDaoFactory()
|
|
||||||
.getDataPropertyDao()
|
|
||||||
.getDataPropertyByURI(beanForEditing.getURI());
|
|
||||||
isFauxDataProperty = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
addCheckboxValuesToTheRequest();
|
addCheckboxValuesToTheRequest();
|
||||||
|
|
||||||
if (!isFauxDataProperty) {
|
setFieldValidators();
|
||||||
setFieldValidators();
|
|
||||||
}
|
|
||||||
|
|
||||||
setListeners();
|
setListeners();
|
||||||
setForwarders();
|
setForwarders();
|
||||||
|
|
||||||
|
@ -165,7 +148,8 @@ public class FauxPropertyRetryController extends BaseEditController {
|
||||||
return newFauxProperty(baseUri);
|
return newFauxProperty(baseUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
FauxProperty bean = fpDao.getFauxPropertyByUris(domainUri, baseUri, rangeUri);
|
FauxProperty bean = fpDao.getFauxPropertyByUris(domainUri, baseUri,
|
||||||
|
rangeUri);
|
||||||
if (bean == null) {
|
if (bean == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"FauxProperty does not exist for <" + domainUri
|
"FauxProperty does not exist for <" + domainUri
|
||||||
|
@ -182,16 +166,7 @@ public class FauxPropertyRetryController extends BaseEditController {
|
||||||
private FauxProperty newFauxProperty(String baseUri) {
|
private FauxProperty newFauxProperty(String baseUri) {
|
||||||
FauxProperty fp = new FauxProperty(null, baseUri, null);
|
FauxProperty fp = new FauxProperty(null, baseUri, null);
|
||||||
ObjectPropertyDao opDao = wadf.getObjectPropertyDao();
|
ObjectPropertyDao opDao = wadf.getObjectPropertyDao();
|
||||||
DataPropertyDao dpDao = wadf.getDataPropertyDao();
|
ObjectProperty base = opDao.getObjectPropertyByURI(baseUri);
|
||||||
ObjectProperty objBase = opDao.getObjectPropertyByURI(baseUri);
|
|
||||||
Property base;
|
|
||||||
if (objBase != null) {
|
|
||||||
fp.setSelectFromExisting(objBase.getSelectFromExisting());
|
|
||||||
fp.setOfferCreateNewOption(objBase.getOfferCreateNewOption());
|
|
||||||
base = objBase;
|
|
||||||
} else {
|
|
||||||
base = dpDao.getDataPropertyByURI(baseUri);
|
|
||||||
}
|
|
||||||
fp.setGroupURI(base.getGroupURI());
|
fp.setGroupURI(base.getGroupURI());
|
||||||
fp.setRangeURI(base.getRangeVClassURI());
|
fp.setRangeURI(base.getRangeVClassURI());
|
||||||
fp.setDomainURI(base.getDomainVClassURI());
|
fp.setDomainURI(base.getDomainVClassURI());
|
||||||
|
@ -293,7 +268,7 @@ public class FauxPropertyRetryController extends BaseEditController {
|
||||||
list.addAll(FormUtils.makeVClassOptionList(wadf,
|
list.addAll(FormUtils.makeVClassOptionList(wadf,
|
||||||
beanForEditing.getDomainURI()));
|
beanForEditing.getDomainURI()));
|
||||||
} else {
|
} else {
|
||||||
list.addAll(FormUtils.makeOptionListOfNotDisjointClasses(wadf,
|
list.addAll(FormUtils.makeOptionListOfSubVClasses(wadf,
|
||||||
baseProperty.getDomainVClassURI(),
|
baseProperty.getDomainVClassURI(),
|
||||||
beanForEditing.getDomainURI()));
|
beanForEditing.getDomainURI()));
|
||||||
}
|
}
|
||||||
|
@ -302,20 +277,12 @@ public class FauxPropertyRetryController extends BaseEditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Option> buildRangeOptionList() {
|
private List<Option> buildRangeOptionList() {
|
||||||
if (isFauxDataProperty) {
|
|
||||||
return buildDataPropOptionList();
|
|
||||||
} else {
|
|
||||||
return buildObjectPropOptionList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<Option> buildObjectPropOptionList() {
|
|
||||||
List<Option> list = new ArrayList<>();
|
List<Option> list = new ArrayList<>();
|
||||||
if (baseProperty.getRangeVClassURI() == null) {
|
if (baseProperty.getRangeVClassURI() == null) {
|
||||||
list.addAll(FormUtils.makeVClassOptionList(wadf,
|
list.addAll(FormUtils.makeVClassOptionList(wadf,
|
||||||
beanForEditing.getRangeURI()));
|
beanForEditing.getRangeURI()));
|
||||||
} else {
|
} else {
|
||||||
list.addAll(FormUtils.makeOptionListOfNotDisjointClasses(wadf,
|
list.addAll(FormUtils.makeOptionListOfSubVClasses(wadf,
|
||||||
baseProperty.getRangeVClassURI(),
|
baseProperty.getRangeVClassURI(),
|
||||||
beanForEditing.getRangeURI()));
|
beanForEditing.getRangeURI()));
|
||||||
if (containsVCardKind(list)) {
|
if (containsVCardKind(list)) {
|
||||||
|
@ -326,43 +293,6 @@ public class FauxPropertyRetryController extends BaseEditController {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Option> buildDataPropOptionList() {
|
|
||||||
List<Option> list = new ArrayList<>();
|
|
||||||
String rangeUri = baseProperty.getRangeVClassURI();
|
|
||||||
if (rangeUri == null) {
|
|
||||||
Option option = new Option();
|
|
||||||
option.setValue("");
|
|
||||||
option.setBody("Untyped");
|
|
||||||
option.setSelected(true);
|
|
||||||
list.add(option);
|
|
||||||
} else if (rangeUri.equals(LITERAL)) {
|
|
||||||
Option option = new Option();
|
|
||||||
option.setValue(rangeUri);
|
|
||||||
option.setBody("Literal");
|
|
||||||
option.setSelected(true);
|
|
||||||
list.add(option);
|
|
||||||
} else if (rangeUri.equals(XML_LITERAL)) {
|
|
||||||
Option option = new Option();
|
|
||||||
option.setValue(rangeUri);
|
|
||||||
option.setBody("XML Literal");
|
|
||||||
option.setSelected(true);
|
|
||||||
list.add(option);
|
|
||||||
} else {
|
|
||||||
Datatype dataType = wadf.getDatatypeDao().getDatatypeByURI(rangeUri);
|
|
||||||
Option option = new Option();
|
|
||||||
if (dataType != null) {
|
|
||||||
option.setValue(dataType.getUri());
|
|
||||||
option.setBody(dataType.getName());
|
|
||||||
} else {
|
|
||||||
option.setValue(rangeUri);
|
|
||||||
option.setBody(rangeUri);
|
|
||||||
}
|
|
||||||
option.setSelected(true);
|
|
||||||
list.add(option);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String VCARD_KIND_URI = "http://www.w3.org/2006/vcard/ns#Kind";
|
private static final String VCARD_KIND_URI = "http://www.w3.org/2006/vcard/ns#Kind";
|
||||||
private static final String VCARD_NAMESPACE = "http://www.w3.org/2006/vcard/ns#";
|
private static final String VCARD_NAMESPACE = "http://www.w3.org/2006/vcard/ns#";
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class NamespacePrefixOperationController extends BaseEditController {
|
||||||
|
|
||||||
if (request.getParameter("_cancel") == null) {
|
if (request.getParameter("_cancel") == null) {
|
||||||
|
|
||||||
OntModel ontModel = ModelAccess.on(req).getOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
String namespaceStr = request.getParameter("namespace");
|
String namespaceStr = request.getParameter("namespace");
|
||||||
String prefixStr = request.getParameter("prefix");
|
String prefixStr = request.getParameter("prefix");
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class PropertyGroupRetryController extends BaseEditController {
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyGroupDao pgDao = ModelAccess.on(
|
PropertyGroupDao pgDao = ModelAccess.on(
|
||||||
req).getWebappDaoFactory().getPropertyGroupDao();
|
getServletContext()).getWebappDaoFactory().getPropertyGroupDao();
|
||||||
|
|
||||||
epo.setDataAccessObject(pgDao);
|
epo.setDataAccessObject(pgDao);
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ public class PropertyRetryController extends BaseEditController {
|
||||||
|
|
||||||
/*for testing*/
|
/*for testing*/
|
||||||
ObjectProperty testMask = new ObjectProperty();
|
ObjectProperty testMask = new ObjectProperty();
|
||||||
epo.setImplementationClass(ObjectProperty.class);
|
|
||||||
epo.setBeanClass(ObjectProperty.class);
|
epo.setBeanClass(ObjectProperty.class);
|
||||||
epo.setBeanMask(testMask);
|
epo.setBeanMask(testMask);
|
||||||
|
|
||||||
|
@ -65,7 +64,7 @@ public class PropertyRetryController extends BaseEditController {
|
||||||
action = epo.getAction();
|
action = epo.getAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectPropertyDao propDao = ModelAccess.on(req).getWebappDaoFactory().getObjectPropertyDao();
|
ObjectPropertyDao propDao = ModelAccess.on(getServletContext()).getWebappDaoFactory().getObjectPropertyDao();
|
||||||
epo.setDataAccessObject(propDao);
|
epo.setDataAccessObject(propDao);
|
||||||
OntologyDao ontDao = request.getUnfilteredWebappDaoFactory().getOntologyDao();
|
OntologyDao ontDao = request.getUnfilteredWebappDaoFactory().getOntologyDao();
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class RestrictionOperationController extends BaseEditController {
|
||||||
String defaultLandingPage = getDefaultLandingPage(request);
|
String defaultLandingPage = getDefaultLandingPage(request);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OntModel ontModel = ModelAccess.on(req)
|
OntModel ontModel = ModelAccess.on(getServletContext())
|
||||||
.getOntModel(TBOX_ASSERTIONS);
|
.getOntModel(TBOX_ASSERTIONS);
|
||||||
|
|
||||||
HashMap epoHash = null;
|
HashMap epoHash = null;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class VclassEditController extends BaseEditController {
|
||||||
EditProcessObject epo = super.createEpo(request, FORCE_NEW);
|
EditProcessObject epo = super.createEpo(request, FORCE_NEW);
|
||||||
request.setAttribute("epoKey", epo.getKey());
|
request.setAttribute("epoKey", epo.getKey());
|
||||||
|
|
||||||
VClassDao vcwDao = ModelAccess.on(req).getWebappDaoFactory(ASSERTIONS_ONLY).getVClassDao();
|
VClassDao vcwDao = ModelAccess.on(getServletContext()).getWebappDaoFactory(ASSERTIONS_ONLY).getVClassDao();
|
||||||
VClass vcl = (VClass)vcwDao.getVClassByURI(request.getParameter("uri"));
|
VClass vcl = (VClass)vcwDao.getVClassByURI(request.getParameter("uri"));
|
||||||
|
|
||||||
if (vcl == null) {
|
if (vcl == null) {
|
||||||
|
@ -152,8 +152,8 @@ public class VclassEditController extends BaseEditController {
|
||||||
request.setAttribute("formSelect",formSelect);
|
request.setAttribute("formSelect",formSelect);
|
||||||
|
|
||||||
// if supported, we want to show only the asserted superclasses and subclasses.
|
// if supported, we want to show only the asserted superclasses and subclasses.
|
||||||
VClassDao vcDao = ModelAccess.on(req).getWebappDaoFactory(ASSERTIONS_ONLY).getVClassDao();
|
VClassDao vcDao = ModelAccess.on(getServletContext()).getWebappDaoFactory(ASSERTIONS_ONLY).getVClassDao();
|
||||||
VClassDao displayVcDao = ModelAccess.on(req).getWebappDaoFactory().getVClassDao();
|
VClassDao displayVcDao = ModelAccess.on(getServletContext()).getWebappDaoFactory().getVClassDao();
|
||||||
|
|
||||||
List<VClass> superVClasses = getVClassesForURIList(
|
List<VClass> superVClasses = getVClassesForURIList(
|
||||||
vcDao.getSuperClassURIs(vcl.getURI(),false), displayVcDao);
|
vcDao.getSuperClassURIs(vcl.getURI(),false), displayVcDao);
|
||||||
|
|
|
@ -66,10 +66,11 @@ public class VclassRetryController extends BaseEditController {
|
||||||
action = epo.getAction();
|
action = epo.getAction();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebappDaoFactory wadf = ModelAccess.on(req).getWebappDaoFactory();
|
WebappDaoFactory wadf = ModelAccess.on(getServletContext()).getWebappDaoFactory();
|
||||||
|
|
||||||
VClassDao vcwDao = wadf.getVClassDao();
|
VClassDao vcwDao = wadf.getVClassDao();
|
||||||
epo.setDataAccessObject(vcwDao);
|
epo.setDataAccessObject(vcwDao);
|
||||||
|
VClassGroupDao cgDao = wadf.getVClassGroupDao();
|
||||||
OntologyDao oDao = wadf.getOntologyDao();
|
OntologyDao oDao = wadf.getOntologyDao();
|
||||||
|
|
||||||
VClass vclassForEditing = null;
|
VClass vclassForEditing = null;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class NamespacesListingController extends BaseEditController {
|
||||||
|
|
||||||
VitroRequest vrequest = new VitroRequest(request);
|
VitroRequest vrequest = new VitroRequest(request);
|
||||||
|
|
||||||
OntModel ontModel = ModelAccess.on(vrequest).getOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
|
|
||||||
ArrayList results = new ArrayList();
|
ArrayList results = new ArrayList();
|
||||||
request.setAttribute("results",results);
|
request.setAttribute("results",results);
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class RestrictionsListingController extends BaseEditController {
|
||||||
|
|
||||||
epo = super.createEpo(request);
|
epo = super.createEpo(request);
|
||||||
|
|
||||||
OntModel ontModel = ModelAccess.on(vrequest).getOntModel();
|
OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
|
||||||
|
|
||||||
ObjectPropertyDao opDao = vrequest.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
|
ObjectPropertyDao opDao = vrequest.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
|
||||||
VClassDao vcDao = vrequest.getUnfilteredWebappDaoFactory().getVClassDao();
|
VClassDao vcDao = vrequest.getUnfilteredWebappDaoFactory().getVClassDao();
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -44,8 +42,6 @@ public class BrowseController extends FreemarkerHttpServlet {
|
||||||
List<VClassGroup> groups = null;
|
List<VClassGroup> groups = null;
|
||||||
VClassGroupsForRequest vcgc = VClassGroupCache.getVClassGroups(vreq);
|
VClassGroupsForRequest vcgc = VClassGroupCache.getVClassGroups(vreq);
|
||||||
groups =vcgc.getGroups();
|
groups =vcgc.getGroups();
|
||||||
Collections.sort(groups, publicNameComparator);
|
|
||||||
// sortGroupListByPublicName(groups);
|
|
||||||
List<VClassGroupTemplateModel> vcgroups = new ArrayList<VClassGroupTemplateModel>(groups.size());
|
List<VClassGroupTemplateModel> vcgroups = new ArrayList<VClassGroupTemplateModel>(groups.size());
|
||||||
for (VClassGroup group : groups) {
|
for (VClassGroup group : groups) {
|
||||||
vcgroups.add(new VClassGroupTemplateModel(group));
|
vcgroups.add(new VClassGroupTemplateModel(group));
|
||||||
|
@ -54,35 +50,4 @@ public class BrowseController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
return new TemplateResponseValues(templateName, body);
|
return new TemplateResponseValues(templateName, body);
|
||||||
}
|
}
|
||||||
public Comparator<VClassGroup> publicNameComparator = new Comparator<VClassGroup>() {
|
|
||||||
|
|
||||||
public int compare(VClassGroup s1, VClassGroup s2) {
|
|
||||||
String groupName1 = s1.getPublicName().toUpperCase();
|
|
||||||
String groupName2 = s2.getPublicName().toUpperCase();
|
|
||||||
|
|
||||||
//ascending order
|
|
||||||
return groupName1.compareTo(groupName2);
|
|
||||||
|
|
||||||
//descending order
|
|
||||||
//return groupName2.compareTo(groupName1);
|
|
||||||
}};
|
|
||||||
|
|
||||||
//
|
|
||||||
// public void sortGroupListByPublicName(List<VClassGroup> groupList) {
|
|
||||||
// groupList.sort(new Comparator<VClassGroup>() {
|
|
||||||
// public int compare(VClassGroup first, VClassGroup second) {
|
|
||||||
// if (first != null) {
|
|
||||||
// if (second != null) {
|
|
||||||
// return (first.getDisplayRank() - second.getDisplayRank());
|
|
||||||
// } else {
|
|
||||||
// log.error("error--2nd VClassGroup is null in VClassGroupDao.getGroupList().compare()");
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// log.error("error--1st VClassGroup is null in VClassGroupDao.getGroupList().compare()");
|
|
||||||
// }
|
|
||||||
// return 0;
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,8 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.StringWriter;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
@ -22,70 +19,68 @@ import org.apache.jena.query.QuerySolution;
|
||||||
import org.apache.jena.query.QuerySolutionMap;
|
import org.apache.jena.query.QuerySolutionMap;
|
||||||
import org.apache.jena.query.ResultSet;
|
import org.apache.jena.query.ResultSet;
|
||||||
import org.apache.jena.rdf.model.Model;
|
import org.apache.jena.rdf.model.Model;
|
||||||
import org.apache.jena.rdf.model.ModelFactory;
|
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
import org.apache.jena.rdf.model.ResourceFactory;
|
||||||
import org.apache.jena.shared.Lock;
|
import org.apache.jena.shared.Lock;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.HAS_DELETE_QUERY;
|
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.BulkUpdateEvent;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.BulkUpdateEvent;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeSet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils;
|
||||||
|
|
||||||
@WebServlet(name = "DeleteIndividualController", urlPatterns = "/deleteIndividualController")
|
@WebServlet(name="DeleteIndividualController",urlPatterns="/deleteIndividualController")
|
||||||
public class DeleteIndividualController extends FreemarkerHttpServlet {
|
public class DeleteIndividualController extends FreemarkerHttpServlet{
|
||||||
|
|
||||||
private static final String INDIVIDUAL_URI = "individualUri";
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final Log log = LogFactory.getLog(DeleteIndividualController.class);
|
private static final Log log = LogFactory.getLog(DeleteIndividualController.class);
|
||||||
private static final boolean BEGIN = true;
|
private static final boolean BEGIN = true;
|
||||||
private static final boolean END = !BEGIN;
|
private static final boolean END = !BEGIN;
|
||||||
|
|
||||||
private static String queryForDeleteQuery = ""
|
private static String TYPE_QUERY_START = ""
|
||||||
+ "SELECT ?deleteQueryText WHERE { "
|
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#>"
|
||||||
+ "?associatedUri <" + HAS_DELETE_QUERY + "> ?deleteQueryText ."
|
+ "SELECT ?type "
|
||||||
+ "}";
|
+ "WHERE"
|
||||||
|
+ "{ <";
|
||||||
private static final String DEFAULT_DELETE_QUERY_TEXT = ""
|
private static String TYPE_QUERY_END = "> vitro:mostSpecificType ?type ."
|
||||||
+ "CONSTRUCT { ?individualUri ?p1 ?o1 . ?s2 ?p2 ?individualUri . } "
|
+ "}";
|
||||||
+ "WHERE {"
|
private static String queryForDeleteQuery =
|
||||||
+ " { ?individualUri ?p1 ?o1 . } UNION { ?s2 ?p2 ?individualUri. } "
|
"PREFIX display: <" + DisplayVocabulary.DISPLAY_NS +"> \n" +
|
||||||
+ "}";
|
"SELECT ?deleteQueryText WHERE { ?associatedURI display:hasDeleteQuery ?deleteQueryText }";
|
||||||
|
|
||||||
|
private static final String DEFAULT_DELETE_QUERY_TEXT = "DESCRIBE ?individualURI";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
||||||
return SimplePermission.DO_FRONT_END_EDITING.ACTION;
|
return SimplePermission.DO_FRONT_END_EDITING.ACTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
String errorMessage = handleErrors(vreq);
|
String errorMessage = handleErrors(vreq);
|
||||||
if (!errorMessage.isEmpty()) {
|
if (!errorMessage.isEmpty()) {
|
||||||
return prepareErrorMessage(errorMessage);
|
return prepareErrorMessage(errorMessage);
|
||||||
}
|
}
|
||||||
String individualUri = vreq.getParameter(INDIVIDUAL_URI);
|
String individualUri = vreq.getParameter("individualUri");
|
||||||
List<String> types = getObjectMostSpecificTypes(individualUri, vreq);
|
String type = getObjectMostSpecificType(individualUri, vreq);
|
||||||
Model displayModel = vreq.getDisplayModel();
|
Model displayModel = vreq.getDisplayModel();
|
||||||
|
|
||||||
String deleteQueryText = getDeleteQueryForTypes(types, displayModel);
|
String delteQueryText = getDeleteQueryForType(type, displayModel);
|
||||||
Model toRemove = getIndividualsToDelete(individualUri, deleteQueryText, vreq);
|
byte[] toRemove = getIndividualsToDelete(individualUri, delteQueryText, vreq);
|
||||||
if (toRemove.size() > 0) {
|
if (toRemove.length > 0) {
|
||||||
deleteIndividuals(toRemove, vreq);
|
deleteIndividuals(toRemove,vreq);
|
||||||
}
|
}
|
||||||
String redirectUrl = getRedirectUrl(vreq);
|
String redirectUrl = getRedirectUrl(vreq);
|
||||||
|
|
||||||
return new RedirectResponseValues(redirectUrl, HttpServletResponse.SC_SEE_OTHER);
|
return new RedirectResponseValues(redirectUrl, HttpServletResponse.SC_SEE_OTHER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getRedirectUrl(VitroRequest vreq) {
|
private String getRedirectUrl(VitroRequest vreq) {
|
||||||
String redirectUrl = vreq.getParameter("redirectUrl");
|
String redirectUrl = vreq.getParameter("redirectUrl");
|
||||||
if (redirectUrl != null) {
|
if (redirectUrl != null) {
|
||||||
|
@ -94,118 +89,113 @@ public class DeleteIndividualController extends FreemarkerHttpServlet {
|
||||||
return "/";
|
return "/";
|
||||||
}
|
}
|
||||||
|
|
||||||
private TemplateResponseValues prepareErrorMessage(String errorMessage) {
|
|
||||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
||||||
map.put("errorMessage", errorMessage);
|
|
||||||
return new TemplateResponseValues("error-message.ftl", map);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private TemplateResponseValues prepareErrorMessage(String errorMessage) {
|
||||||
|
HashMap<String,Object> map = new HashMap<String,Object>();
|
||||||
|
map.put("errorMessage", errorMessage);
|
||||||
|
return new TemplateResponseValues("error-message.ftl", map);
|
||||||
|
}
|
||||||
|
|
||||||
private String handleErrors(VitroRequest vreq) {
|
private String handleErrors(VitroRequest vreq) {
|
||||||
String uri = vreq.getParameter(INDIVIDUAL_URI);
|
String uri = vreq.getParameter("individualUri");
|
||||||
if (uri == null) {
|
if ( uri == null) {
|
||||||
return "Individual uri is null. No object to delete.";
|
return "Individual uri is null. No object to delete.";
|
||||||
}
|
}
|
||||||
if (uri.contains("<") || uri.contains(">")) {
|
if (uri.contains(">")) {
|
||||||
return "Individual IRI shouldn't contain '<' or '>";
|
return "Individual uri shouldn't contain >";
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getDeleteQueryForTypes(List<String> types, Model displayModel) {
|
private static String getDeleteQueryForType(String typeURI,Model displayModel) {
|
||||||
|
|
||||||
String deleteQueryText = DEFAULT_DELETE_QUERY_TEXT;
|
String deleteQueryText = DEFAULT_DELETE_QUERY_TEXT;
|
||||||
String foundType = "";
|
|
||||||
for ( String type: types) {
|
|
||||||
Query queryForTypeSpecificDeleteQuery = QueryFactory.create(queryForDeleteQuery);
|
|
||||||
QuerySolutionMap initialBindings = new QuerySolutionMap();
|
|
||||||
initialBindings.add("associatedURI", ResourceFactory.createResource(type));
|
|
||||||
displayModel.enterCriticalSection(Lock.READ);
|
|
||||||
try {
|
|
||||||
QueryExecution qexec = QueryExecutionFactory.create(queryForTypeSpecificDeleteQuery, displayModel,
|
|
||||||
initialBindings);
|
|
||||||
try {
|
|
||||||
ResultSet results = qexec.execSelect();
|
|
||||||
if (results.hasNext()) {
|
|
||||||
QuerySolution solution = results.nextSolution();
|
|
||||||
deleteQueryText = solution.get("deleteQueryText").toString();
|
|
||||||
foundType = type;
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
qexec.close();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
displayModel.leaveCriticalSection();
|
|
||||||
}
|
|
||||||
if (!foundType.isEmpty()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!foundType.isEmpty()) {
|
Query queryForTypeSpecificDeleteQuery = QueryFactory.create(queryForDeleteQuery);
|
||||||
log.debug("For " + foundType + " found delete query \n" + deleteQueryText);
|
|
||||||
if (!deleteQueryText.contains(INDIVIDUAL_URI)){
|
QuerySolutionMap initialBindings = new QuerySolutionMap();
|
||||||
log.error("Safety check failed. Delete query text should contain " + INDIVIDUAL_URI + ", "
|
initialBindings.add("associatedURI", ResourceFactory.createResource( typeURI ));
|
||||||
+ "but it didn't. To prevent bad consequences query was rejected.");
|
|
||||||
log.error("Delete query which caused the error: \n" + deleteQueryText);
|
displayModel.enterCriticalSection(Lock.READ);
|
||||||
deleteQueryText = DEFAULT_DELETE_QUERY_TEXT;
|
try{
|
||||||
}
|
QueryExecution qexec = QueryExecutionFactory.create(queryForTypeSpecificDeleteQuery,displayModel,initialBindings );
|
||||||
} else {
|
try{
|
||||||
log.debug("For most specific types: " + types.stream().collect(Collectors.joining(",")) + " no delete query was found. Using default query \n" + deleteQueryText);
|
ResultSet results = qexec.execSelect();
|
||||||
}
|
while (results.hasNext()) {
|
||||||
return deleteQueryText;
|
QuerySolution solution = results.nextSolution();
|
||||||
|
deleteQueryText = solution.get("deleteQueryText").toString();
|
||||||
|
}
|
||||||
|
}finally{ qexec.close(); }
|
||||||
|
}finally{ displayModel.leaveCriticalSection(); }
|
||||||
|
|
||||||
|
if (!deleteQueryText.equals(DEFAULT_DELETE_QUERY_TEXT)) {
|
||||||
|
log.debug("For " + typeURI + " found delete query \n" + deleteQueryText);
|
||||||
|
} else {
|
||||||
|
log.debug("For " + typeURI + " delete query not found. Using defalut query \n" + deleteQueryText);
|
||||||
|
}
|
||||||
|
return deleteQueryText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getObjectMostSpecificType(String individualURI, VitroRequest vreq) {
|
||||||
|
String type = "";
|
||||||
|
try {
|
||||||
|
ResultSet results = QueryUtils.getLanguageNeutralQueryResults(makeTypeQuery(individualURI), vreq);
|
||||||
|
while (results.hasNext()) {
|
||||||
|
QuerySolution solution = results.nextSolution();
|
||||||
|
type = solution.get("type").toString();
|
||||||
|
log.debug(type);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Failed to get type for individual URI " + individualURI);
|
||||||
|
log.error(e, e);
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
private byte[] getIndividualsToDelete(String targetIndividual, String deleteQuery,VitroRequest vreq) {
|
||||||
|
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||||
|
try {
|
||||||
|
Query queryForTypeSpecificDeleteQuery = QueryFactory.create(deleteQuery);
|
||||||
|
QuerySolutionMap initialBindings = new QuerySolutionMap();
|
||||||
|
initialBindings.add("individualURI", ResourceFactory.createResource( targetIndividual ));
|
||||||
|
Model ontModel = vreq.getJenaOntModel();
|
||||||
|
QueryExecution qexec = QueryExecutionFactory.create(queryForTypeSpecificDeleteQuery,ontModel,initialBindings );
|
||||||
|
Model results = qexec.execDescribe();
|
||||||
|
results.write(out,"N3");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("Query raised an error \n" + deleteQuery);
|
||||||
|
log.error(e, e);
|
||||||
|
}
|
||||||
|
return out.toByteArray();
|
||||||
|
}
|
||||||
|
|
||||||
private List<String> getObjectMostSpecificTypes(String individualUri, VitroRequest vreq) {
|
private String makeTypeQuery(String objectURI) {
|
||||||
List<String> types = new LinkedList<String>();
|
return TYPE_QUERY_START + objectURI + TYPE_QUERY_END;
|
||||||
Individual individual = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(individualUri);
|
|
||||||
if (individual != null) {
|
|
||||||
types = individual.getMostSpecificTypeURIs();
|
|
||||||
}
|
|
||||||
if (types.isEmpty()) {
|
|
||||||
log.error("Failed to get most specific type for individual Uri " + individualUri);
|
|
||||||
}
|
|
||||||
return types;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Model getIndividualsToDelete(String targetIndividual, String deleteQuery, VitroRequest vreq) {
|
private void deleteIndividuals(byte[] toRemove, VitroRequest vreq) {
|
||||||
try {
|
String removingString = new String(toRemove, StandardCharsets.UTF_8);
|
||||||
Query queryForTypeSpecificDeleteQuery = QueryFactory.create(deleteQuery);
|
|
||||||
QuerySolutionMap bindings = new QuerySolutionMap();
|
|
||||||
bindings.add(INDIVIDUAL_URI, ResourceFactory.createResource(targetIndividual));
|
|
||||||
Model ontModel = ModelAccess.on(vreq).getOntModelSelector().getABoxModel();
|
|
||||||
QueryExecution qexec = QueryExecutionFactory.create(queryForTypeSpecificDeleteQuery, ontModel, bindings);
|
|
||||||
Model results = qexec.execConstruct();
|
|
||||||
return results;
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Query raised an error \n" + deleteQuery);
|
|
||||||
log.error(e, e);
|
|
||||||
}
|
|
||||||
return ModelFactory.createDefaultModel();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteIndividuals(Model model, VitroRequest vreq) {
|
|
||||||
RDFService rdfService = vreq.getRDFService();
|
RDFService rdfService = vreq.getRDFService();
|
||||||
ChangeSet cs = makeChangeSet(rdfService);
|
ChangeSet cs = makeChangeSet(rdfService);
|
||||||
try {
|
InputStream in = new ByteArrayInputStream(toRemove);
|
||||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
cs.addRemoval(in, RDFServiceUtils.getSerializationFormatFromJenaString("N3"), ModelNames.ABOX_ASSERTIONS);
|
||||||
model.write(out, "N3");
|
try {
|
||||||
InputStream in = new ByteArrayInputStream(out.toByteArray());
|
rdfService.changeSetUpdate(cs);
|
||||||
cs.addRemoval(in, RDFServiceUtils.getSerializationFormatFromJenaString("N3"), ModelNames.ABOX_ASSERTIONS);
|
} catch (RDFServiceException e) {
|
||||||
rdfService.changeSetUpdate(cs);
|
log.error("Got error while removing\n" + removingString);
|
||||||
} catch (Exception e) {
|
throw new RuntimeException(e);
|
||||||
StringWriter sw = new StringWriter();
|
}
|
||||||
model.write(sw, "N3");
|
|
||||||
log.error("Got " + e.getClass().getSimpleName() + " while removing\n" + sw.toString());
|
|
||||||
log.error(e,e);
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChangeSet makeChangeSet(RDFService rdfService) {
|
private ChangeSet makeChangeSet(RDFService rdfService) {
|
||||||
ChangeSet cs = rdfService.manufactureChangeSet();
|
ChangeSet cs = rdfService.manufactureChangeSet();
|
||||||
cs.addPreChangeEvent(new BulkUpdateEvent(null, BEGIN));
|
cs.addPreChangeEvent(new BulkUpdateEvent(null, BEGIN));
|
||||||
cs.addPostChangeEvent(new BulkUpdateEvent(null, END));
|
cs.addPostChangeEvent(new BulkUpdateEvent(null, END));
|
||||||
return cs;
|
return cs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
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 org.apache.jena.rdf.model.Property;
|
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||||
|
@ -28,8 +25,6 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationUti
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3EditUtils;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3EditUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Custom deletion controller to which deletion requests from default property form are sent. May be replaced
|
* Custom deletion controller to which deletion requests from default property form are sent. May be replaced
|
||||||
* later with additional features in process rdf form controller or alternative location.
|
* later with additional features in process rdf form controller or alternative location.
|
||||||
|
@ -66,14 +61,14 @@ public class DeletePropertyController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
|
|
||||||
private String getRedirectUrl(VitroRequest vreq) {
|
private String getRedirectUrl(VitroRequest vreq) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
|
||||||
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
|
||||||
Property prop = ResourceFactory.createProperty(predicateUri);
|
int hashIndex = predicateUri.lastIndexOf("#");
|
||||||
String localName = prop.getLocalName();
|
String localName = predicateUri.substring(hashIndex + 1);
|
||||||
String redirectUrl = "/entity?uri=" + URLEncoder.encode(subjectUri);
|
String redirectUrl = "/entity?uri=" + URLEncoder.encode(subjectUri);
|
||||||
return redirectUrl + "#" + URLEncoder.encode(localName);
|
return redirectUrl + "#" + URLEncoder.encode(localName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String handleErrors(VitroRequest vreq) {
|
private String handleErrors(VitroRequest vreq) {
|
||||||
|
|
|
@ -1,417 +0,0 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
|
||||||
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest.UNAUTHORIZED;
|
|
||||||
import static edu.cornell.mannlib.vitro.webapp.controller.freemarker.ImageUploadController.PARAMETER_UPLOADED_FILE;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.apache.commons.fileupload.FileItem;
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.apache.commons.lang3.RandomStringUtils;
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.apache.jena.ontology.OntModel;
|
|
||||||
import org.apache.tika.Tika;
|
|
||||||
import org.apache.tika.mime.MimeType;
|
|
||||||
import org.apache.tika.mime.MimeTypeException;
|
|
||||||
import org.apache.tika.mime.MimeTypes;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.application.ApplicationUtils;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.RequestedAction;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.AddObjectPropertyStatement;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.propstmt.DropObjectPropertyStatement;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.filestorage.UploadedFileHelper;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.filestorage.model.FileInfo;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.fileStorage.FileStorage;
|
|
||||||
|
|
||||||
@WebServlet(name = "FileUploadController", urlPatterns = { "/uploadFile" })
|
|
||||||
public class FileUploadController extends FreemarkerHttpServlet {
|
|
||||||
private static final String REFERER_HEADER = "Referer";
|
|
||||||
private static final String TEMPLATE_VAR_FORM_ACTION = "formAction";
|
|
||||||
private static final String TEMPLATE_VAR_MAX_FILE_SIZE = "maxFileSize";
|
|
||||||
private static final String PARAM_REFERRER = "referrer";
|
|
||||||
private static final String TEMPLATE_VAR_SUPPORTED_MEDIA_TYPES = "supportedMediaTypes";
|
|
||||||
|
|
||||||
private static final String TEMPLATE_VAR_ERROR_MESSAGE = "errorMessage";
|
|
||||||
private static final String DEFAULT_FILE_NAME = "fileName";
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final Log log = LogFactory.getLog(FileUploadController.class);
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private static final String PARAMETER_ACTION = "action";
|
|
||||||
private static final String ACTION_DELETE = "delete";
|
|
||||||
private static final String ACTION_UPLOAD = "upload";
|
|
||||||
private static final String PARAMETER_FILE_URI = "fileUri";
|
|
||||||
private static final String PARAMETER_SUBJECT_URI = "subjectUri";
|
|
||||||
private static final String CONFIG_MAX_FILE_SIZE = "fileUpload.maxFileSize";
|
|
||||||
private static final String ALLOWED_MEDIA_TYPES = "fileUpload.allowedMIMETypes";
|
|
||||||
private static final Long DEFAULT_FILE_SIZE = (long) (10 * 1024 * 1024);
|
|
||||||
private static final String PARAMETER_PREDICATE_URI = "predicateUri";
|
|
||||||
private static final String DEFAULT_TEMPLATE = "fileUpload-default.ftl";
|
|
||||||
private static Long maxFileSize = DEFAULT_FILE_SIZE;
|
|
||||||
private FileStorage fileStorage;
|
|
||||||
private Set<String> allowedMediaTypes;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init() throws ServletException {
|
|
||||||
super.init();
|
|
||||||
fileStorage = ApplicationUtils.instance().getFileStorage();
|
|
||||||
setMaxFileSize();
|
|
||||||
setAllowedMediaTypes();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
|
||||||
RequestedAction ra;
|
|
||||||
try {
|
|
||||||
Property predicate = new Property(getPredicateUri(vreq));
|
|
||||||
final OntModel jenaOntModel = vreq.getJenaOntModel();
|
|
||||||
final String subject = getSubjectUri(vreq);
|
|
||||||
if (isUpload(vreq)) {
|
|
||||||
ra = new AddObjectPropertyStatement(jenaOntModel, subject, predicate,RequestedAction.SOME_URI);
|
|
||||||
} else { // delete
|
|
||||||
ra = new DropObjectPropertyStatement(jenaOntModel, subject, predicate, getFileUri(vreq));
|
|
||||||
}
|
|
||||||
return ra;
|
|
||||||
} catch (Exception e) {
|
|
||||||
return UNAUTHORIZED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getFileUri(VitroRequest vreq) {
|
|
||||||
return vreq.getParameter(PARAMETER_FILE_URI);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
getReferrer(vreq);
|
|
||||||
validateRequest(vreq);
|
|
||||||
if (isUpload(vreq)) {
|
|
||||||
uploadFile(vreq);
|
|
||||||
} else if (isDelete(vreq)) {
|
|
||||||
deleteFile(vreq);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
return pageResponse(vreq, e.getMessage());
|
|
||||||
}
|
|
||||||
return new RedirectResponseValues(getNextPageUrl(vreq), HttpServletResponse.SC_SEE_OTHER);
|
|
||||||
}
|
|
||||||
private String getNextPageUrl(VitroRequest vreq) {
|
|
||||||
return getReferrer(vreq);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TemplateResponseValues pageResponse(VitroRequest vreq, String error) {
|
|
||||||
TemplateResponseValues rv = new TemplateResponseValues(DEFAULT_TEMPLATE);
|
|
||||||
rv.put(PARAMETER_ACTION, vreq.getParameter(PARAMETER_ACTION));
|
|
||||||
rv.put(TEMPLATE_VAR_FORM_ACTION, formatRequestUrl(vreq));
|
|
||||||
if (!error.isEmpty()) {
|
|
||||||
rv.put(TEMPLATE_VAR_ERROR_MESSAGE, error);
|
|
||||||
}
|
|
||||||
rv.put(PARAM_REFERRER,getReferrer(vreq));
|
|
||||||
rv.put(TEMPLATE_VAR_SUPPORTED_MEDIA_TYPES, printAllowedMediaTypes());
|
|
||||||
rv.put(TEMPLATE_VAR_MAX_FILE_SIZE, maxFileSizeInMegabytes());
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String formatRequestUrl(VitroRequest vreq) {
|
|
||||||
String result = vreq.getRequestURL().toString() + "?";
|
|
||||||
String query = vreq.getQueryString();
|
|
||||||
if (query != null) {
|
|
||||||
result += query;
|
|
||||||
}
|
|
||||||
String referrer = vreq.getParameter(PARAM_REFERRER);
|
|
||||||
if (referrer == null || referrer.isEmpty()) {
|
|
||||||
result += "&" + PARAM_REFERRER + "=" + getReferrer(vreq);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Double maxFileSizeInMegabytes() {
|
|
||||||
if (maxFileSize > 0) {
|
|
||||||
return ((double) maxFileSize/1048576);
|
|
||||||
} else {
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateRequest(VitroRequest vreq) throws FileUploadException {
|
|
||||||
I18nBundle i18nBundle = I18n.bundle(vreq);
|
|
||||||
if (isUpload(vreq)) {
|
|
||||||
validateUploadRequest(vreq,i18nBundle);
|
|
||||||
} else if (isDelete(vreq)) {
|
|
||||||
validateDeleteRequest(vreq,i18nBundle);
|
|
||||||
} else if (hasAction(vreq)) {
|
|
||||||
throw new FileUploadException(i18nBundle.text("file_upload_error_supported_actions"));
|
|
||||||
} else {
|
|
||||||
throw new FileUploadException(i18nBundle.text("file_upload_error_no_action"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateDeleteRequest(VitroRequest vreq, I18nBundle i18nBundle) throws FileUploadException {
|
|
||||||
validateSubjectUri(vreq, i18nBundle);
|
|
||||||
validatePredicateUri(vreq, i18nBundle);
|
|
||||||
validateFileUri(vreq,i18nBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateUploadRequest(VitroRequest vreq, I18nBundle i18nBundle) throws FileUploadException {
|
|
||||||
validateSubjectUri(vreq ,i18nBundle);
|
|
||||||
validatePredicateUri(vreq , i18nBundle);
|
|
||||||
validateFile(vreq, i18nBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateFile(VitroRequest vreq, I18nBundle i18nBundle) throws FileUploadException {
|
|
||||||
Map<String, List<FileItem>> map = vreq.getFiles();
|
|
||||||
if (map == null) {
|
|
||||||
throw new FileUploadException(i18nBundle.text("file_upload_error_file_not_found"));
|
|
||||||
}
|
|
||||||
List<FileItem> list = map.get(PARAMETER_UPLOADED_FILE);
|
|
||||||
if ((list == null) || list.isEmpty()) {
|
|
||||||
throw new FileUploadException(i18nBundle.text("file_upload_error_file_not_found"));
|
|
||||||
}
|
|
||||||
FileItem file = list.get(0);
|
|
||||||
if (file.getSize() == 0) {
|
|
||||||
throw new FileUploadException(i18nBundle.text("file_upload_error_file_size_is_zero"));
|
|
||||||
}
|
|
||||||
if (file.getSize() > maxFileSize) {
|
|
||||||
throw new FileUploadException(i18nBundle.text("file_upload_error_file_is_too_big", maxFileSize, file.getSize()));
|
|
||||||
}
|
|
||||||
validateMediaType(file, i18nBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateMediaType(FileItem file, I18nBundle i18nBundle) throws FileUploadException {
|
|
||||||
String mediaType = getMediaType(file);
|
|
||||||
if (mediaType.isEmpty()) {
|
|
||||||
throw new FileUploadException(i18nBundle.text("file_upload_error_file_type_not_recognized"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!allowedMediaTypes.contains(mediaType.toLowerCase())) {
|
|
||||||
String errorMessage = i18nBundle.text("file_upload_error_media_type_not_allowed", mediaType);
|
|
||||||
log.error(errorMessage);
|
|
||||||
throw new FileUploadException(errorMessage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String printAllowedMediaTypes() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
if (allowedMediaTypes.isEmpty()) {
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
for (Iterator<String> it = allowedMediaTypes.iterator(); it.hasNext();) {
|
|
||||||
String mediaType = (String) it.next();
|
|
||||||
sb.append(mediaType);
|
|
||||||
if (it.hasNext()) {
|
|
||||||
sb.append(", ");
|
|
||||||
} else {
|
|
||||||
sb.append(".");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasAction(VitroRequest vreq) {
|
|
||||||
return vreq.getParameter(PARAMETER_ACTION) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteFile(VitroRequest vreq) {
|
|
||||||
String subjectUri = getSubjectUri(vreq);
|
|
||||||
String predicateUri = getPredicateUri(vreq);
|
|
||||||
String fileUri = getFileUri(vreq);
|
|
||||||
WebappDaoFactory webAppDaoFactory = vreq.getUnfilteredWebappDaoFactory();
|
|
||||||
UploadedFileHelper fileHelper = new UploadedFileHelper(fileStorage, webAppDaoFactory, getServletContext());
|
|
||||||
fileHelper.removeUploadedFile(subjectUri, predicateUri, fileUri);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void uploadFile(VitroRequest vreq) throws FileUploadException {
|
|
||||||
String subjectUri = getSubjectUri(vreq);
|
|
||||||
String predicateUri = getPredicateUri(vreq);
|
|
||||||
FileItem file = getUploadedFile(vreq);
|
|
||||||
String uploadedFileName = getUploadedFileName(file);
|
|
||||||
String storedFileName = createStoredFileName(file);
|
|
||||||
WebappDaoFactory webAppDaoFactory = vreq.getUnfilteredWebappDaoFactory();
|
|
||||||
UploadedFileHelper fileHelper = new UploadedFileHelper(fileStorage, webAppDaoFactory, getServletContext());
|
|
||||||
FileInfo fileInfo = createFile(file, storedFileName, fileHelper);
|
|
||||||
fileHelper.attachFileToSubject(fileInfo, subjectUri, predicateUri);
|
|
||||||
fileHelper.setPublicFileName(fileInfo, uploadedFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private FileInfo createFile(FileItem file, String storedFileName, UploadedFileHelper fileHelper)
|
|
||||||
throws FileUploadException {
|
|
||||||
FileInfo fileInfo = null;
|
|
||||||
try {
|
|
||||||
fileInfo = fileHelper.createFile(storedFileName, getMediaType(file), file.getInputStream());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e.getLocalizedMessage());
|
|
||||||
throw new FileUploadException(e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
return fileInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String createStoredFileName(FileItem file) {
|
|
||||||
String mediaType = getMediaType(file);
|
|
||||||
int length = 64;
|
|
||||||
boolean useLetters = true;
|
|
||||||
boolean useNumbers = true;
|
|
||||||
String storedFileName = RandomStringUtils.random(length, useLetters, useNumbers) + getExtension(mediaType);
|
|
||||||
return storedFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getExtension(String mediaType) {
|
|
||||||
String extension = "";
|
|
||||||
MimeTypes types = MimeTypes.getDefaultMimeTypes();
|
|
||||||
try {
|
|
||||||
MimeType mimeType = types.forName(mediaType);
|
|
||||||
extension = mimeType.getExtension();
|
|
||||||
} catch (MimeTypeException e) {
|
|
||||||
log.error(e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
return extension;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getUploadedFileName(FileItem file) {
|
|
||||||
String fileName = file.getName();
|
|
||||||
if (fileName == null) {
|
|
||||||
return DEFAULT_FILE_NAME;
|
|
||||||
} else {
|
|
||||||
return FilenameUtils.getName(fileName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getMediaType(FileItem file) {
|
|
||||||
Tika tika = new Tika();
|
|
||||||
InputStream is;
|
|
||||||
String mediaType = "";
|
|
||||||
try {
|
|
||||||
is = file.getInputStream();
|
|
||||||
mediaType = tika.detect(is);
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.error(e.getLocalizedMessage());
|
|
||||||
}
|
|
||||||
return mediaType;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateFileUri(VitroRequest vreq, I18nBundle i18nBundle) throws FileUploadException {
|
|
||||||
String fileUri = getFileUri(vreq);
|
|
||||||
validateUriNotEmpty(fileUri, i18nBundle.text("file_upload_file"), i18nBundle);
|
|
||||||
validateIndividual(vreq, fileUri, i18nBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateSubjectUri(VitroRequest vreq, I18nBundle i18nBundle) throws FileUploadException {
|
|
||||||
String subjectUri = getSubjectUri(vreq);
|
|
||||||
validateUriNotEmpty(subjectUri, i18nBundle.text("file_upload_subject"), i18nBundle);
|
|
||||||
validateIndividual(vreq, subjectUri, i18nBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validatePredicateUri(VitroRequest vreq, I18nBundle i18nBundle) throws FileUploadException {
|
|
||||||
String predicateUri = getPredicateUri(vreq);
|
|
||||||
validateUriNotEmpty(predicateUri, i18nBundle.text("file_upload_predicate"), i18nBundle);
|
|
||||||
validateIndividual(vreq, predicateUri, i18nBundle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateIndividual(VitroRequest vreq, String name, I18nBundle i18nBundle) throws FileUploadException {
|
|
||||||
Individual subject = vreq.getUnfilteredWebappDaoFactory().getIndividualDao()
|
|
||||||
.getIndividualByURI(name);
|
|
||||||
if (subject == null) {
|
|
||||||
throw new FileUploadException(i18nBundle.text("file_upload_error_uri_not_exists", name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void validateUriNotEmpty(String predicateUri, String name, I18nBundle i18nBundle) throws FileUploadException {
|
|
||||||
if (predicateUri == null || predicateUri.trim().isEmpty()) {
|
|
||||||
throw new FileUploadException(i18nBundle.text("file_upload_error_uri_not_given", name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getPredicateUri(VitroRequest vreq) {
|
|
||||||
return vreq.getParameter(PARAMETER_PREDICATE_URI);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getSubjectUri(VitroRequest vreq) {
|
|
||||||
return vreq.getParameter(PARAMETER_SUBJECT_URI);
|
|
||||||
}
|
|
||||||
|
|
||||||
private FileItem getUploadedFile(VitroRequest vreq) {
|
|
||||||
return vreq.getFiles().get(PARAMETER_UPLOADED_FILE).get(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isUpload(VitroRequest vreq) {
|
|
||||||
String action = vreq.getParameter(PARAMETER_ACTION);
|
|
||||||
return ACTION_UPLOAD.equals(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isDelete(VitroRequest vreq) {
|
|
||||||
String action = vreq.getParameter(PARAMETER_ACTION);
|
|
||||||
return ACTION_DELETE.equals(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setAllowedMediaTypes() {
|
|
||||||
ConfigurationProperties config = ConfigurationProperties.getBean(getServletContext());
|
|
||||||
String allowedTypes = config.getProperty(ALLOWED_MEDIA_TYPES, "");
|
|
||||||
if (allowedTypes.isEmpty()) {
|
|
||||||
allowedMediaTypes = new HashSet<String>();
|
|
||||||
} else {
|
|
||||||
allowedMediaTypes = new HashSet<String>(Arrays.asList(allowedTypes.toLowerCase().trim().split("\\s*,\\s*")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getReferrer(VitroRequest vreq) {
|
|
||||||
String referrer = vreq.getParameter(PARAM_REFERRER);
|
|
||||||
if (referrer == null) {
|
|
||||||
referrer = vreq.getHeader(REFERER_HEADER);
|
|
||||||
}
|
|
||||||
if (referrer == null) {
|
|
||||||
referrer = "/";
|
|
||||||
}
|
|
||||||
return referrer;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setMaxFileSize() {
|
|
||||||
ConfigurationProperties config = ConfigurationProperties.getBean(getServletContext());
|
|
||||||
String configFileSize = config.getProperty(CONFIG_MAX_FILE_SIZE, DEFAULT_FILE_SIZE.toString());
|
|
||||||
try {
|
|
||||||
maxFileSize = Long.parseLong(configFileSize);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
log.error("maxFileSize parsing failed");
|
|
||||||
log.error(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static class FileUploadException extends Exception {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
private final Object[] parameters;
|
|
||||||
|
|
||||||
FileUploadException(String message, Object... parameters) {
|
|
||||||
super(message);
|
|
||||||
this.parameters = parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String formatMessage(HttpServletRequest req) {
|
|
||||||
return I18n.text(req, getMessage(), parameters);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,7 +8,6 @@ import static javax.mail.Message.RecipientType.TO;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -18,6 +17,7 @@ import javax.servlet.ServletException;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.MenuDaoJena;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -41,8 +41,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Tem
|
||||||
import edu.cornell.mannlib.vitro.webapp.email.FreemarkerEmailFactory;
|
import edu.cornell.mannlib.vitro.webapp.email.FreemarkerEmailFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.email.FreemarkerEmailMessage;
|
import edu.cornell.mannlib.vitro.webapp.email.FreemarkerEmailMessage;
|
||||||
import edu.cornell.mannlib.vitro.webapp.freemarker.config.FreemarkerConfiguration;
|
import edu.cornell.mannlib.vitro.webapp.freemarker.config.FreemarkerConfiguration;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.Tags;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.Tags;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.User;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.User;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.MainMenu;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.menu.MainMenu;
|
||||||
|
@ -69,6 +67,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
|
|
||||||
// error templates
|
// error templates
|
||||||
ERROR_DISPLAY("error-display.ftl"),
|
ERROR_DISPLAY("error-display.ftl"),
|
||||||
|
ERROR_EMAIL("error-email.ftl"),
|
||||||
ERROR_MESSAGE("error-message.ftl"),
|
ERROR_MESSAGE("error-message.ftl"),
|
||||||
STANDARD_ERROR("error-standard.ftl"),
|
STANDARD_ERROR("error-standard.ftl"),
|
||||||
TITLED_ERROR_MESSAGE("error-titled.ftl"),
|
TITLED_ERROR_MESSAGE("error-titled.ftl"),
|
||||||
|
@ -94,8 +93,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
|
|
||||||
super.doGet(request,response);
|
super.doGet(request,response);
|
||||||
//UQAM-Optimization set for UTF-8
|
|
||||||
response.setCharacterEncoding("UTF-8");
|
|
||||||
|
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
ResponseValues responseValues = null;
|
ResponseValues responseValues = null;
|
||||||
|
@ -106,8 +103,8 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
if (!isAuthorizedToDisplayPage(request, response, requiredActions(vreq))) {
|
if (!isAuthorizedToDisplayPage(request, response, requiredActions(vreq))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
responseValues = processRequest(vreq);
|
|
||||||
|
|
||||||
|
responseValues = processRequest(vreq);
|
||||||
doResponse(vreq, response, responseValues);
|
doResponse(vreq, response, responseValues);
|
||||||
|
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -162,8 +159,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
}
|
}
|
||||||
adminErrorData.put("cause", cause);
|
adminErrorData.put("cause", cause);
|
||||||
|
|
||||||
SimpleDateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
|
adminErrorData.put("datetime", new Date());
|
||||||
adminErrorData.put("datetime", dateformat.format(new Date()));
|
|
||||||
|
|
||||||
templateMap.put("errorOnHomePage", this instanceof HomePageController);
|
templateMap.put("errorOnHomePage", this instanceof HomePageController);
|
||||||
|
|
||||||
|
@ -177,11 +173,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
} else if (FreemarkerEmailFactory.isConfigured(vreq)) {
|
} else if (FreemarkerEmailFactory.isConfigured(vreq)) {
|
||||||
FreemarkerEmailMessage email = FreemarkerEmailFactory.createNewMessage(vreq);
|
FreemarkerEmailMessage email = FreemarkerEmailFactory.createNewMessage(vreq);
|
||||||
email.addRecipient(TO, email.getReplyToAddress());
|
email.addRecipient(TO, email.getReplyToAddress());
|
||||||
I18nBundle i18n = I18n.bundle(vreq);
|
email.setTemplate(Template.ERROR_EMAIL.toString());
|
||||||
addSiteName(vreq, adminErrorData);
|
|
||||||
adminErrorData.put("subject", i18n.text("application_error_email_subject"));
|
|
||||||
adminErrorData.put("textMessage", i18n.text("application_error_email_plain_text"));
|
|
||||||
adminErrorData.put("htmlMessage", i18n.text("application_error_email_html_text"));
|
|
||||||
email.setBodyMap(adminErrorData);
|
email.setBodyMap(adminErrorData);
|
||||||
email.processTemplate();
|
email.processTemplate();
|
||||||
sentEmail = email.send();
|
sentEmail = email.send();
|
||||||
|
@ -199,16 +191,6 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSiteName(VitroRequest vreq, Map<String, Object> adminErrorData) {
|
|
||||||
try {
|
|
||||||
ApplicationBean appBean = vreq.getAppBean();
|
|
||||||
String appName = appBean.getApplicationName();
|
|
||||||
adminErrorData.put("siteName", appName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e,e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
||||||
throws ServletException, IOException {
|
throws ServletException, IOException {
|
||||||
|
@ -274,7 +256,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
protected void doTemplate(VitroRequest vreq, HttpServletResponse response,
|
protected void doTemplate(VitroRequest vreq, HttpServletResponse response,
|
||||||
ResponseValues values) throws TemplateProcessingException {
|
ResponseValues values) throws TemplateProcessingException {
|
||||||
|
|
||||||
Map<String, Object> templateDataModel = new HashMap<String, Object>();
|
Map<String, Object> templateDataModel = new HashMap<String, Object>();
|
||||||
templateDataModel.putAll(getPageTemplateValues(vreq));
|
templateDataModel.putAll(getPageTemplateValues(vreq));
|
||||||
|
|
||||||
// Add the values that we got from the subcontroller processRequest() method, and merge to the template.
|
// Add the values that we got from the subcontroller processRequest() method, and merge to the template.
|
||||||
|
@ -294,15 +276,8 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
// is specified in the main page template.
|
// is specified in the main page template.
|
||||||
bodyString = "";
|
bodyString = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
templateDataModel.put("body", bodyString);
|
templateDataModel.put("body", bodyString);
|
||||||
|
|
||||||
String lang = vreq.getLocale().getLanguage();
|
|
||||||
if (!vreq.getLocale().getCountry().isEmpty()) {
|
|
||||||
lang += "-" + vreq.getLocale().getCountry();
|
|
||||||
}
|
|
||||||
templateDataModel.put("country", lang);
|
|
||||||
|
|
||||||
// Tell the template and any directives it uses that we're processing a page template.
|
// Tell the template and any directives it uses that we're processing a page template.
|
||||||
templateDataModel.put("templateType", PAGE_TEMPLATE_TYPE);
|
templateDataModel.put("templateType", PAGE_TEMPLATE_TYPE);
|
||||||
|
|
||||||
|
@ -487,7 +462,7 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
||||||
|
|
||||||
protected MainMenu getDisplayModelMenu(VitroRequest vreq){
|
protected MainMenu getDisplayModelMenu(VitroRequest vreq){
|
||||||
String url = vreq.getRequestURI().substring(vreq.getContextPath().length());
|
String url = vreq.getRequestURI().substring(vreq.getContextPath().length());
|
||||||
return vreq.getWebappDaoFactory().getMenuDao().getMainMenu(url);
|
return vreq.getWebappDaoFactory().getMenuDao().getMainMenu(vreq, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NIHVIVO-3307: we need this here instead of FreemarkerConfiguration.java so that updates to
|
// NIHVIVO-3307: we need this here instead of FreemarkerConfiguration.java so that updates to
|
||||||
|
|
|
@ -6,11 +6,9 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividualBuilder;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -18,7 +16,6 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
|
@ -30,7 +27,8 @@ import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchEngineExcepti
|
||||||
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery;
|
import edu.cornell.mannlib.vitro.webapp.modules.searchEngine.SearchQuery;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils;
|
import edu.cornell.mannlib.vitro.webapp.utils.searchengine.SearchQueryUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individuallist.ListedIndividualBuilder;
|
|
||||||
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a list of individuals for display in a template
|
* Generates a list of individuals for display in a template
|
||||||
|
@ -45,7 +43,6 @@ public class IndividualListController extends FreemarkerHttpServlet {
|
||||||
private static final int MAX_PAGES = 40; // must be even
|
private static final int MAX_PAGES = 40; // must be even
|
||||||
|
|
||||||
private static final String TEMPLATE_DEFAULT = "individualList.ftl";
|
private static final String TEMPLATE_DEFAULT = "individualList.ftl";
|
||||||
private static final String LANGUAGE_FILTER_PROPERTY = "RDFService.languageFilter";
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
|
@ -155,12 +152,12 @@ public class IndividualListController extends FreemarkerHttpServlet {
|
||||||
return SearchQueryUtils.getPageParameter(request);
|
return SearchQueryUtils.getPageParameter(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IndividualListResults getResultsForVClass(String vclassURI,
|
public static IndividualListResults getResultsForVClass(String vclassURI, int page, String alpha, VitroRequest vreq)
|
||||||
int page, String alpha, VitroRequest vreq)
|
|
||||||
throws SearchException{
|
throws SearchException{
|
||||||
try{
|
try{
|
||||||
List<String> classUris = Collections.singletonList(vclassURI);
|
List<String> classUris = Collections.singletonList(vclassURI);
|
||||||
return buildAndExecuteVClassQuery(classUris, page, INDIVIDUALS_PER_PAGE, alpha, vreq);
|
IndividualListQueryResults results = buildAndExecuteVClassQuery(classUris, alpha, page, INDIVIDUALS_PER_PAGE, vreq.getWebappDaoFactory().getIndividualDao());
|
||||||
|
return getResultsForVClassQuery(results, page, INDIVIDUALS_PER_PAGE, alpha, vreq);
|
||||||
} catch (SearchEngineException e) {
|
} catch (SearchEngineException e) {
|
||||||
String msg = "An error occurred retrieving results for vclass query";
|
String msg = "An error occurred retrieving results for vclass query";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
|
@ -172,27 +169,16 @@ public class IndividualListController extends FreemarkerHttpServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IndividualListResults getResultsForVClassIntersections(
|
public static IndividualListResults getResultsForVClassIntersections(List<String> vclassURIs, int page, int pageSize, String alpha, VitroRequest vreq) {
|
||||||
List<String> classUris, int page, int pageSize, String alpha, VitroRequest vreq) {
|
|
||||||
try{
|
try{
|
||||||
return buildAndExecuteVClassQuery(classUris, page, pageSize, alpha, vreq);
|
IndividualListQueryResults results = buildAndExecuteVClassQuery(vclassURIs, alpha, page, pageSize, vreq.getWebappDaoFactory().getIndividualDao());
|
||||||
|
return getResultsForVClassQuery(results, page, pageSize, alpha, vreq);
|
||||||
} catch(Throwable th) {
|
} catch(Throwable th) {
|
||||||
log.error("Error retrieving individuals corresponding to intersection multiple classes." + classUris.toString(), th);
|
log.error("Error retrieving individuals corresponding to intersection multiple classes." + vclassURIs.toString(), th);
|
||||||
return IndividualListResults.EMPTY;
|
return IndividualListResults.EMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IndividualListResults buildAndExecuteVClassQuery(List<String> classUris, int page, int pageSize,
|
|
||||||
String alpha, VitroRequest vreq) throws SearchEngineException {
|
|
||||||
ConfigurationProperties props = ConfigurationProperties.getBean(vreq);
|
|
||||||
boolean languageFilter = Boolean.valueOf(props.getProperty(LANGUAGE_FILTER_PROPERTY, "false"));
|
|
||||||
IndividualListQueryResults results = buildAndExecuteVClassQuery(classUris, alpha,
|
|
||||||
((languageFilter) ? vreq.getLocale() : null), page, pageSize,
|
|
||||||
vreq.getWebappDaoFactory().getIndividualDao());
|
|
||||||
IndividualListResults indListResults = getResultsForVClassQuery(results, page, pageSize, alpha, vreq);
|
|
||||||
return indListResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IndividualListResults getRandomResultsForVClass(String vclassURI, int page, int pageSize, VitroRequest vreq) {
|
public static IndividualListResults getRandomResultsForVClass(String vclassURI, int page, int pageSize, VitroRequest vreq) {
|
||||||
try{
|
try{
|
||||||
List<String> classUris = Collections.singletonList(vclassURI);
|
List<String> classUris = Collections.singletonList(vclassURI);
|
||||||
|
@ -215,10 +201,9 @@ public class IndividualListController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
|
|
||||||
private static IndividualListQueryResults buildAndExecuteVClassQuery(
|
private static IndividualListQueryResults buildAndExecuteVClassQuery(
|
||||||
List<String> vclassURIs, String alpha, Locale locale, int page,
|
List<String> vclassURIs, String alpha, int page, int pageSize, IndividualDao indDao)
|
||||||
int pageSize, IndividualDao indDao)
|
|
||||||
throws SearchEngineException {
|
throws SearchEngineException {
|
||||||
SearchQuery query = SearchQueryUtils.getQuery(vclassURIs, alpha, locale, page, pageSize);
|
SearchQuery query = SearchQueryUtils.getQuery(vclassURIs, alpha, page, pageSize);
|
||||||
IndividualListQueryResults results = IndividualListQueryResults.runQuery(query, indDao);
|
IndividualListQueryResults results = IndividualListQueryResults.runQuery(query, indDao);
|
||||||
log.debug("Executed search query for " + vclassURIs);
|
log.debug("Executed search query for " + vclassURIs);
|
||||||
if (results.getIndividuals().isEmpty()) {
|
if (results.getIndividuals().isEmpty()) {
|
||||||
|
@ -265,7 +250,8 @@ public class IndividualListController extends FreemarkerHttpServlet {
|
||||||
}else if ( requiredPages > MAX_PAGES && selectedPage > requiredPages - MAX_PAGES ){
|
}else if ( requiredPages > MAX_PAGES && selectedPage > requiredPages - MAX_PAGES ){
|
||||||
//the selected page is in the end of the list
|
//the selected page is in the end of the list
|
||||||
int startPage = requiredPages - MAX_PAGES;
|
int startPage = requiredPages - MAX_PAGES;
|
||||||
for(int page = startPage; page <= requiredPages; page++ ){
|
double max = Math.ceil(size/pageSize);
|
||||||
|
for(int page = startPage; page <= max; page++ ){
|
||||||
records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) );
|
records.add( new PageRecord( "page=" + page, Integer.toString(page), Integer.toString(page), selectedPage == page ) );
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -8,40 +8,39 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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 edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
import edu.cornell.mannlib.vitro.webapp.auth.permissions.SimplePermission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.AuthorizationRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.FauxProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.FauxProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Property;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
import edu.cornell.mannlib.vitro.webapp.beans.PropertyGroup;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.FauxPropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.FauxPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||||
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
|
||||||
@WebServlet(name = "ListFauxPropertiesController", urlPatterns = { "/listFauxProperties" })
|
@WebServlet(name = "ListFauxPropertiesController", urlPatterns = {"/listFauxProperties"} )
|
||||||
public class ListFauxPropertiesController extends FreemarkerHttpServlet {
|
public class ListFauxPropertiesController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(ListFauxPropertiesController.class.getName());
|
private static final Log log = LogFactory.getLog(ListFauxPropertiesController.class.getName());
|
||||||
|
|
||||||
private static final String TEMPLATE_NAME = "siteAdmin-fauxPropertiesList.ftl";
|
private static final String TEMPLATE_NAME = "siteAdmin-fauxPropertiesList.ftl";
|
||||||
|
|
||||||
private String notFoundMessage = "";
|
private ObjectPropertyDao opDao = null;
|
||||||
|
private PropertyGroupDao pgDao = null;
|
||||||
|
private FauxPropertyDao fpDao = null;
|
||||||
|
private String notFoundMessage = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
protected AuthorizationRequest requiredActions(VitroRequest vreq) {
|
||||||
return SimplePermission.EDIT_ONTOLOGY.ACTION;
|
return SimplePermission.EDIT_ONTOLOGY.ACTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
|
@ -51,303 +50,176 @@ public class ListFauxPropertiesController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
String displayOption = "";
|
String displayOption = "";
|
||||||
|
|
||||||
if (vreq.getParameter("displayOption") != null) {
|
if ( vreq.getParameter("displayOption") != null ) {
|
||||||
displayOption = vreq.getParameter("displayOption");
|
displayOption = vreq.getParameter("displayOption");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
displayOption = "listing";
|
displayOption = "listing";
|
||||||
}
|
}
|
||||||
body.put("displayOption", displayOption);
|
body.put("displayOption", displayOption);
|
||||||
|
|
||||||
if (displayOption.equals("listing")) {
|
if ( displayOption.equals("listing") ) {
|
||||||
body.put("pageTitle", "Faux Property Listing");
|
body.put("pageTitle", "Faux Property Listing");
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
body.put("pageTitle", "Faux Properties by Base Property");
|
body.put("pageTitle", "Faux Properties by Base Property");
|
||||||
}
|
}
|
||||||
List<ObjectProperty> objectProps = getOPDao(vreq).getRootObjectProperties();
|
|
||||||
List<DataProperty> dataProps = getDPDao(vreq).getRootDataProperties();
|
|
||||||
Map<String, Object> allFauxProps = new TreeMap<String, Object>();
|
|
||||||
|
|
||||||
// get the faux depending on the display option
|
opDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getObjectPropertyDao();
|
||||||
if (displayOption.equals("listing")) {
|
fpDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getFauxPropertyDao();
|
||||||
allFauxProps.putAll(getFauxPropertyList(objectProps, vreq));
|
pgDao = vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao();
|
||||||
allFauxProps.putAll(getFauxDataPropertyList(dataProps, vreq));
|
|
||||||
} else {
|
List<ObjectProperty> objectProps = null;
|
||||||
allFauxProps.putAll(getFauxByBaseList(objectProps, vreq));
|
objectProps = opDao.getRootObjectProperties();
|
||||||
allFauxProps.putAll(getFauxDataPropsByBaseList(dataProps, vreq));
|
|
||||||
|
Map<String, Object> allFauxProps = new TreeMap<String, Object>();
|
||||||
|
// get the faux depending on the display option
|
||||||
|
if ( displayOption.equals("listing") ) {
|
||||||
|
allFauxProps = getFauxPropertyList(objectProps);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
allFauxProps = getFauxByBaseList(objectProps);
|
||||||
|
}
|
||||||
|
|
||||||
log.debug(allFauxProps.toString());
|
log.debug(allFauxProps.toString());
|
||||||
|
|
||||||
if (notFoundMessage.length() == 0) {
|
if ( notFoundMessage.length() == 0 ) {
|
||||||
body.put("message", notFoundMessage);
|
body.put("message", notFoundMessage);
|
||||||
} else {
|
}
|
||||||
body.put("fauxProps", allFauxProps);
|
else {
|
||||||
}
|
body.put("fauxProps", allFauxProps);
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.error(t, t);
|
t.printStackTrace();
|
||||||
}
|
}
|
||||||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyGroupDao getPGDao(VitroRequest vreq) {
|
private TreeMap<String, Object> getFauxPropertyList(List<ObjectProperty> objectProps) {
|
||||||
return vreq.getUnfilteredAssertionsWebappDaoFactory().getPropertyGroupDao();
|
List<FauxProperty> fauxProps = null;
|
||||||
}
|
TreeMap<String, Object> theFauxProps = new TreeMap<String, Object>();
|
||||||
|
if ( objectProps != null ) {
|
||||||
private FauxPropertyDao getFPDao(VitroRequest vreq) {
|
|
||||||
return vreq.getUnfilteredAssertionsWebappDaoFactory().getFauxPropertyDao();
|
|
||||||
}
|
|
||||||
|
|
||||||
private DataPropertyDao getDPDao(VitroRequest vreq) {
|
|
||||||
return vreq.getUnfilteredAssertionsWebappDaoFactory().getDataPropertyDao();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ObjectPropertyDao getOPDao(VitroRequest vreq) {
|
|
||||||
return vreq.getUnfilteredAssertionsWebappDaoFactory().getObjectPropertyDao();
|
|
||||||
}
|
|
||||||
|
|
||||||
private TreeMap<String, Object> getFauxPropertyList(List<ObjectProperty> objectProps, VitroRequest vreq) {
|
|
||||||
List<FauxProperty> fauxProps = null;
|
|
||||||
TreeMap<String, Object> theFauxProps = new TreeMap<String, Object>();
|
|
||||||
if (objectProps != null) {
|
|
||||||
Iterator<ObjectProperty> opIt = objectProps.iterator();
|
Iterator<ObjectProperty> opIt = objectProps.iterator();
|
||||||
if (!opIt.hasNext()) {
|
if ( !opIt.hasNext()) {
|
||||||
notFoundMessage = "No object properties found.";
|
notFoundMessage = "No object properties found.";
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
while (opIt.hasNext()) {
|
while (opIt.hasNext()) {
|
||||||
|
|
||||||
ObjectProperty op = opIt.next();
|
ObjectProperty op = opIt.next();
|
||||||
String baseURI = op.getURI();
|
String baseURI = op.getURI();
|
||||||
fauxProps = getFPDao(vreq).getFauxPropertiesForBaseUri(baseURI);
|
fauxProps = fpDao.getFauxPropertiesForBaseUri(baseURI);
|
||||||
if (fauxProps != null) {
|
if ( fauxProps != null ) {
|
||||||
Iterator<FauxProperty> fpIt = fauxProps.iterator();
|
Iterator<FauxProperty> fpIt = fauxProps.iterator();
|
||||||
if (!fpIt.hasNext()) {
|
if ( !fpIt.hasNext()) {
|
||||||
notFoundMessage = "No faux properties found.";
|
notFoundMessage = "No faux properties found.";
|
||||||
} else {
|
}
|
||||||
while (fpIt.hasNext()) {
|
else {
|
||||||
// No point in getting these unless we have a
|
while (fpIt.hasNext()) {
|
||||||
// faux property
|
// No point in getting these unless we have a faux property
|
||||||
String baseLabel = getBaseLabel(op, false);
|
String baseLabel = getDisplayLabel(op) == null ? "(no name)" : getDisplayLabel(op);
|
||||||
// get the info we need from the faux property
|
String baseLocalName = op.getLocalNameWithPrefix();
|
||||||
FauxProperty fp = fpIt.next();
|
baseLabel = baseLabel.substring(0,baseLabel.indexOf("("));
|
||||||
String fauxLabel = fp.getDisplayName();
|
baseLabel += "(" + baseLocalName + ")";
|
||||||
String rangeLabel = fp.getRangeLabel();
|
// get the info we need from the faux property
|
||||||
String rangeURI = fp.getRangeURI();
|
FauxProperty fp = fpIt.next();
|
||||||
String domainLabel = fp.getDomainLabel();
|
String fauxLabel = fp.getDisplayName();
|
||||||
String domainURI = fp.getDomainURI();
|
String rangeLabel = fp.getRangeLabel();
|
||||||
String groupURI = fp.getGroupURI();
|
String rangeURI = fp.getRangeURI();
|
||||||
// FauxProperty only gets groupURI but we want
|
String domainLabel = fp.getDomainLabel();
|
||||||
// the label
|
String domainURI = fp.getDomainURI();
|
||||||
PropertyGroup pGroup = getPGDao(vreq).getGroupByURI(groupURI);
|
String groupURI = fp.getGroupURI();
|
||||||
String groupLabel = (pGroup == null) ? "unspecified" : pGroup.getName();
|
// FauxProperty only gets groupURI but we want the label
|
||||||
// store all the strings in a hash with the faux
|
PropertyGroup pGroup = pgDao.getGroupByURI(groupURI);
|
||||||
// property label as the key
|
String groupLabel = ( pGroup == null ) ? "unspecified" : pGroup.getName();
|
||||||
Map<String, Object> tmpHash = new HashMap<String, Object>();
|
// store all the strings in a hash with the faux property label as the key
|
||||||
tmpHash.put("base", baseLabel);
|
Map<String, Object> tmpHash = new HashMap<String, Object>();
|
||||||
tmpHash.put("baseURI", baseURI);
|
tmpHash.put("base", baseLabel);
|
||||||
tmpHash.put("group", groupLabel);
|
tmpHash.put("baseURI", baseURI);
|
||||||
tmpHash.put("range", rangeLabel);
|
tmpHash.put("group", groupLabel);
|
||||||
tmpHash.put("rangeURI", rangeURI);
|
tmpHash.put("range", rangeLabel);
|
||||||
tmpHash.put("domain", domainLabel);
|
tmpHash.put("rangeURI", rangeURI);
|
||||||
tmpHash.put("domainURI", domainURI);
|
tmpHash.put("domain", domainLabel);
|
||||||
tmpHash.put("editUrl", "propertyEdit");
|
tmpHash.put("domainURI", domainURI);
|
||||||
|
// add the faux and its details to the treemap
|
||||||
// add the faux and its details to the treemap
|
theFauxProps.put(fauxLabel + "@@" + domainLabel, tmpHash);
|
||||||
theFauxProps.put(fauxLabel + "@@" + domainLabel, tmpHash);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return theFauxProps;
|
return theFauxProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TreeMap<String, Object> getFauxByBaseList(List<ObjectProperty> objectProps, VitroRequest vreq) {
|
private TreeMap<String, Object> getFauxByBaseList(List<ObjectProperty> objectProps) {
|
||||||
List<FauxProperty> fauxProps = null;
|
List<FauxProperty> fauxProps = null;
|
||||||
TreeMap<String, Object> fauxByBaseProps = new TreeMap<String, Object>();
|
TreeMap<String, Object> fauxByBaseProps = new TreeMap<String, Object>();
|
||||||
if (objectProps != null) {
|
if ( objectProps != null ) {
|
||||||
Iterator<ObjectProperty> opIt = objectProps.iterator();
|
Iterator<ObjectProperty> opIt = objectProps.iterator();
|
||||||
if (!opIt.hasNext()) {
|
if ( !opIt.hasNext()) {
|
||||||
notFoundMessage = "No object properties found.";
|
notFoundMessage = "No object properties found.";
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
while (opIt.hasNext()) {
|
while (opIt.hasNext()) {
|
||||||
TreeMap<String, Object> fauxForGivenBase = new TreeMap<String, Object>();
|
TreeMap<String, Object> fauxForGivenBase = new TreeMap<String, Object>();
|
||||||
ObjectProperty op = opIt.next();
|
ObjectProperty op = opIt.next();
|
||||||
String baseURI = op.getURI();
|
String baseURI = op.getURI();
|
||||||
fauxProps = getFPDao(vreq).getFauxPropertiesForBaseUri(baseURI);
|
fauxProps = fpDao.getFauxPropertiesForBaseUri(baseURI);
|
||||||
|
|
||||||
if (fauxProps != null) {
|
if ( fauxProps != null ) {
|
||||||
Iterator<FauxProperty> fpIt = fauxProps.iterator();
|
Iterator<FauxProperty> fpIt = fauxProps.iterator();
|
||||||
if (!fpIt.hasNext()) {
|
if ( !fpIt.hasNext()) {
|
||||||
notFoundMessage = "No faux properties found.";
|
notFoundMessage = "No faux properties found.";
|
||||||
} else {
|
}
|
||||||
String baseLabel = getBaseLabel(op, true);
|
else {
|
||||||
while (fpIt.hasNext()) {
|
String baseLabel = getDisplayLabel(op) == null ? "(no name)" : getDisplayLabel(op);
|
||||||
// get the info we need from the faux property
|
String baseLocalName = op.getLocalNameWithPrefix();
|
||||||
FauxProperty fp = fpIt.next();
|
baseLabel = baseLabel.substring(0,baseLabel.indexOf("("));
|
||||||
String fauxLabel = fp.getDisplayName();
|
baseLabel += "(" + baseLocalName + ")" + "|" + baseURI;
|
||||||
String rangeLabel = fp.getRangeLabel();
|
while (fpIt.hasNext()) {
|
||||||
String rangeURI = fp.getRangeURI();
|
// get the info we need from the faux property
|
||||||
String domainLabel = fp.getDomainLabel();
|
FauxProperty fp = fpIt.next();
|
||||||
String domainURI = fp.getDomainURI();
|
String fauxLabel = fp.getDisplayName();
|
||||||
String groupURI = fp.getGroupURI();
|
String rangeLabel = fp.getRangeLabel();
|
||||||
// FauxProperty only gets groupURI but we want
|
String rangeURI = fp.getRangeURI();
|
||||||
// the label
|
String domainLabel = fp.getDomainLabel();
|
||||||
PropertyGroup pGroup = getPGDao(vreq).getGroupByURI(groupURI);
|
String domainURI = fp.getDomainURI();
|
||||||
String groupLabel = (pGroup == null) ? "unspecified" : pGroup.getName();
|
String groupURI = fp.getGroupURI();
|
||||||
// store all the strings in a hash with the faux
|
// FauxProperty only gets groupURI but we want the label
|
||||||
// property label as the key
|
PropertyGroup pGroup = pgDao.getGroupByURI(groupURI);
|
||||||
Map<String, Object> tmpHash = new HashMap<String, Object>();
|
String groupLabel = ( pGroup == null ) ? "unspecified" : pGroup.getName();
|
||||||
tmpHash.put("baseURI", baseURI);
|
// store all the strings in a hash with the faux property label as the key
|
||||||
tmpHash.put("group", groupLabel);
|
Map<String, Object> tmpHash = new HashMap<String, Object>();
|
||||||
tmpHash.put("range", rangeLabel);
|
tmpHash.put("baseURI", baseURI);
|
||||||
tmpHash.put("rangeURI", rangeURI);
|
tmpHash.put("group", groupLabel);
|
||||||
tmpHash.put("domain", domainLabel);
|
tmpHash.put("range", rangeLabel);
|
||||||
tmpHash.put("domainURI", domainURI);
|
tmpHash.put("rangeURI", rangeURI);
|
||||||
|
tmpHash.put("domain", domainLabel);
|
||||||
// add the faux and its details to the treemap
|
tmpHash.put("domainURI", domainURI);
|
||||||
fauxForGivenBase.put(fauxLabel + "@@" + domainLabel, tmpHash);
|
// add the faux and its details to the treemap
|
||||||
fauxForGivenBase.put("editUrl", "propertyEdit");
|
fauxForGivenBase.put(fauxLabel + "@@" + domainLabel, tmpHash);
|
||||||
}
|
}
|
||||||
fauxByBaseProps.put(baseLabel, fauxForGivenBase);
|
fauxByBaseProps.put(baseLabel, fauxForGivenBase);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fauxByBaseProps;
|
return fauxByBaseProps;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TreeMap<String, Object> getFauxDataPropertyList(List<DataProperty> dataProps, VitroRequest vreq) {
|
/*
|
||||||
List<FauxProperty> fauxProps = null;
|
* should never be null
|
||||||
TreeMap<String, Object> theFauxProps = new TreeMap<String, Object>();
|
*/
|
||||||
if (dataProps != null) {
|
public static String getDisplayLabel(ObjectProperty op) {
|
||||||
Iterator<DataProperty> opIt = dataProps.iterator();
|
String displayLabel = op.getPickListName();
|
||||||
if (!opIt.hasNext()) {
|
displayLabel = (displayLabel != null && displayLabel.length() > 0)
|
||||||
notFoundMessage = "No data properties found.";
|
? displayLabel
|
||||||
} else {
|
: op.getLocalName();
|
||||||
while (opIt.hasNext()) {
|
return (displayLabel != null) ? displayLabel : "[object property]" ;
|
||||||
DataProperty dp = opIt.next();
|
|
||||||
String baseURI = dp.getURI();
|
|
||||||
fauxProps = getFPDao(vreq).getFauxPropertiesForBaseUri(baseURI);
|
|
||||||
if (fauxProps != null) {
|
|
||||||
Iterator<FauxProperty> fpIt = fauxProps.iterator();
|
|
||||||
if (!fpIt.hasNext()) {
|
|
||||||
notFoundMessage = "No faux properties found.";
|
|
||||||
} else {
|
|
||||||
while (fpIt.hasNext()) {
|
|
||||||
// No point in getting these unless we have a
|
|
||||||
// faux property
|
|
||||||
String baseLabel = getBaseLabel(dp, false);
|
|
||||||
// get the info we need from the faux property
|
|
||||||
FauxProperty fp = fpIt.next();
|
|
||||||
String fauxLabel = fp.getDisplayName();
|
|
||||||
String rangeLabel = fp.getRangeLabel();
|
|
||||||
String rangeURI = fp.getRangeURI();
|
|
||||||
String domainLabel = fp.getDomainLabel();
|
|
||||||
String domainURI = fp.getDomainURI();
|
|
||||||
String groupURI = fp.getGroupURI();
|
|
||||||
// FauxProperty only gets groupURI but we want
|
|
||||||
// the label
|
|
||||||
PropertyGroup pGroup = getPGDao(vreq).getGroupByURI(groupURI);
|
|
||||||
String groupLabel = (pGroup == null) ? "unspecified" : pGroup.getName();
|
|
||||||
// store all the strings in a hash with the faux
|
|
||||||
// property label as the key
|
|
||||||
Map<String, Object> tmpHash = new HashMap<String, Object>();
|
|
||||||
tmpHash.put("base", baseLabel);
|
|
||||||
tmpHash.put("baseURI", baseURI);
|
|
||||||
tmpHash.put("group", groupLabel);
|
|
||||||
tmpHash.put("range", rangeLabel);
|
|
||||||
tmpHash.put("rangeURI", rangeURI);
|
|
||||||
tmpHash.put("domain", domainLabel);
|
|
||||||
tmpHash.put("domainURI", domainURI);
|
|
||||||
tmpHash.put("editUrl", "datapropEdit");
|
|
||||||
// add the faux and its details to the treemap
|
|
||||||
theFauxProps.put(fauxLabel + "@@" + domainLabel, tmpHash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return theFauxProps;
|
|
||||||
}
|
|
||||||
|
|
||||||
private TreeMap<String, Object> getFauxDataPropsByBaseList(List<DataProperty> dataProps, VitroRequest vreq) {
|
|
||||||
List<FauxProperty> fauxProps = null;
|
|
||||||
TreeMap<String, Object> fauxByBaseProps = new TreeMap<String, Object>();
|
|
||||||
if (dataProps != null) {
|
|
||||||
Iterator<DataProperty> opIt = dataProps.iterator();
|
|
||||||
if (!opIt.hasNext()) {
|
|
||||||
notFoundMessage = "No data properties found.";
|
|
||||||
} else {
|
|
||||||
while (opIt.hasNext()) {
|
|
||||||
TreeMap<String, Object> fauxForGivenBase = new TreeMap<String, Object>();
|
|
||||||
DataProperty dp = opIt.next();
|
|
||||||
String baseURI = dp.getURI();
|
|
||||||
fauxProps = getFPDao(vreq).getFauxPropertiesForBaseUri(baseURI);
|
|
||||||
|
|
||||||
if (fauxProps != null) {
|
|
||||||
Iterator<FauxProperty> fpIt = fauxProps.iterator();
|
|
||||||
if (!fpIt.hasNext()) {
|
|
||||||
notFoundMessage = "No faux properties found.";
|
|
||||||
} else {
|
|
||||||
String baseLabel = getBaseLabel(dp, true);
|
|
||||||
while (fpIt.hasNext()) {
|
|
||||||
// get the info we need from the faux property
|
|
||||||
FauxProperty fp = fpIt.next();
|
|
||||||
String fauxLabel = fp.getDisplayName();
|
|
||||||
String rangeLabel = fp.getRangeLabel();
|
|
||||||
String rangeURI = fp.getRangeURI();
|
|
||||||
String domainLabel = fp.getDomainLabel();
|
|
||||||
String domainURI = fp.getDomainURI();
|
|
||||||
String groupURI = fp.getGroupURI();
|
|
||||||
// FauxProperty only gets groupURI but we want
|
|
||||||
// the label
|
|
||||||
PropertyGroup pGroup = getPGDao(vreq).getGroupByURI(groupURI);
|
|
||||||
String groupLabel = (pGroup == null) ? "unspecified" : pGroup.getName();
|
|
||||||
// store all the strings in a hash with the faux
|
|
||||||
// property label as the key
|
|
||||||
Map<String, Object> tmpHash = new HashMap<String, Object>();
|
|
||||||
tmpHash.put("baseURI", baseURI);
|
|
||||||
tmpHash.put("group", groupLabel);
|
|
||||||
tmpHash.put("range", rangeLabel);
|
|
||||||
tmpHash.put("rangeURI", rangeURI);
|
|
||||||
tmpHash.put("domain", domainLabel);
|
|
||||||
tmpHash.put("domainURI", domainURI);
|
|
||||||
// add the faux and its details to the treemap
|
|
||||||
fauxForGivenBase.put(fauxLabel + "@@" + domainLabel, tmpHash);
|
|
||||||
fauxForGivenBase.put("editUrl", "datapropEdit");
|
|
||||||
}
|
|
||||||
fauxByBaseProps.put(baseLabel, fauxForGivenBase);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fauxByBaseProps;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getBaseLabel(Property property, boolean addUri) {
|
|
||||||
String baseLabel = property.getPickListName();
|
|
||||||
if (StringUtils.isEmpty(baseLabel)) {
|
|
||||||
baseLabel = property.getLocalName();
|
|
||||||
}
|
|
||||||
if (StringUtils.isEmpty(baseLabel)) {
|
|
||||||
baseLabel = "[property]";
|
|
||||||
}
|
|
||||||
String baseLocalName = property.getLocalNameWithPrefix();
|
|
||||||
int indexOf = baseLabel.indexOf("(");
|
|
||||||
if (indexOf > 0) {
|
|
||||||
baseLabel = baseLabel.substring(0, indexOf);
|
|
||||||
}
|
|
||||||
baseLabel += "(" + baseLocalName + ")";
|
|
||||||
if (addUri) {
|
|
||||||
baseLabel += "|" + property.getURI();
|
|
||||||
}
|
|
||||||
return baseLabel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class TemplateProcessingHelper {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Environment env = template.createProcessingEnvironment(map, writer);
|
Environment env = template.createProcessingEnvironment(map, writer);
|
||||||
|
|
||||||
// Define a setup template to be included by every page template
|
// Define a setup template to be included by every page template
|
||||||
String templateType = (String) map.get("templateType");
|
String templateType = (String) map.get("templateType");
|
||||||
if (FreemarkerHttpServlet.PAGE_TEMPLATE_TYPE.equals(templateType)) {
|
if (FreemarkerHttpServlet.PAGE_TEMPLATE_TYPE.equals(templateType)) {
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
|
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
|
|
||||||
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
|
||||||
|
@WebServlet(name = "TermsOfUseController", urlPatterns = {"/termsOfUse"} )
|
||||||
|
public class TermsOfUseController extends FreemarkerHttpServlet {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private static final Log log = LogFactory.getLog(TermsOfUseController.class);
|
||||||
|
private static final String TEMPLATE_DEFAULT = "termsOfUse.ftl";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
Map<String, String> termsOfUse = new HashMap<String, String>();
|
||||||
|
|
||||||
|
ApplicationBean appBean = vreq.getAppBean();
|
||||||
|
|
||||||
|
termsOfUse.put("siteName", appBean.getApplicationName());
|
||||||
|
|
||||||
|
String siteHost = appBean.getCopyrightAnchor();
|
||||||
|
if (siteHost == null) {
|
||||||
|
siteHost = "the hosting institution";
|
||||||
|
}
|
||||||
|
termsOfUse.put("siteHost", siteHost);
|
||||||
|
|
||||||
|
map.put("termsOfUse", termsOfUse);
|
||||||
|
return new TemplateResponseValues(TEMPLATE_DEFAULT, map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTitle(String siteName, VitroRequest vreq) {
|
||||||
|
return siteName + " Terms of Use";
|
||||||
|
}
|
||||||
|
}
|
|
@ -37,7 +37,7 @@ public class UrlBuilder {
|
||||||
LOGIN("/login"),
|
LOGIN("/login"),
|
||||||
LOGOUT("/logout"),
|
LOGOUT("/logout"),
|
||||||
OBJECT_PROPERTY_EDIT("/propertyEdit"),
|
OBJECT_PROPERTY_EDIT("/propertyEdit"),
|
||||||
EXTENDED_SEARCH("/extendedsearch"),
|
CUSTOMSEARCH("/customsearch"),
|
||||||
SEARCH("/search"),
|
SEARCH("/search"),
|
||||||
SITE_ADMIN("/siteAdmin"),
|
SITE_ADMIN("/siteAdmin"),
|
||||||
TERMS_OF_USE("/termsOfUse"),
|
TERMS_OF_USE("/termsOfUse"),
|
||||||
|
|
|
@ -11,29 +11,28 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.servlet.ServletException;
|
import javax.servlet.ServletException;
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.apache.commons.lang3.LocaleUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
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 org.apache.jena.query.QuerySolution;
|
import org.apache.jena.query.QuerySolution;
|
||||||
import org.apache.jena.query.ResultSet;
|
import org.apache.jena.query.ResultSet;
|
||||||
import org.apache.jena.rdf.model.Literal;
|
import org.apache.jena.rdf.model.Literal;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
|
import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringUtils;
|
|
||||||
|
|
||||||
|
|
||||||
/*Servlet to view all labels in various languages for individual*/
|
/*Servlet to view all labels in various languages for individual*/
|
||||||
|
@ -48,13 +47,12 @@ public class ViewLabelsServlet extends FreemarkerHttpServlet{
|
||||||
String subjectUri = vreq.getParameter("subjectUri");
|
String subjectUri = vreq.getParameter("subjectUri");
|
||||||
body.put("subjectUri", subjectUri);
|
body.put("subjectUri", subjectUri);
|
||||||
try {
|
try {
|
||||||
//the labels already added by the user
|
//Get all language codes/labels in the system, and this list is sorted by language name
|
||||||
ArrayList<Literal> existingLabels = this.getExistingLabels(subjectUri, vreq);
|
List<HashMap<String, String>> locales = this.getLocales(vreq);
|
||||||
//Get all language codes/labels used in the list of existing labels
|
|
||||||
List<HashMap<String, String>> locales = this.getLocales(vreq, existingLabels);
|
|
||||||
//Get code to label hashmap - we use this to get the language name for the language code returned in the rdf literal
|
//Get code to label hashmap - we use this to get the language name for the language code returned in the rdf literal
|
||||||
HashMap<String, String> localeCodeToNameMap = this.getFullCodeToLanguageNameMap(locales);
|
HashMap<String, String> localeCodeToNameMap = this.getFullCodeToLanguageNameMap(locales);
|
||||||
|
//the labels already added by the user
|
||||||
|
ArrayList<Literal> existingLabels = this.getExistingLabels(subjectUri, vreq);
|
||||||
//existing labels keyed by language name and each of the list of labels is sorted by language name
|
//existing labels keyed by language name and each of the list of labels is sorted by language name
|
||||||
HashMap<String, List<LabelInformation>> existingLabelsByLanguageName = this.getLabelsSortedByLanguageName(existingLabels, localeCodeToNameMap, vreq, subjectUri);
|
HashMap<String, List<LabelInformation>> existingLabelsByLanguageName = this.getLabelsSortedByLanguageName(existingLabels, localeCodeToNameMap, vreq, subjectUri);
|
||||||
//Get available locales for the drop down for adding a new label, also sorted by language name
|
//Get available locales for the drop down for adding a new label, also sorted by language name
|
||||||
|
@ -139,26 +137,20 @@ public class ViewLabelsServlet extends FreemarkerHttpServlet{
|
||||||
doGet(request, response);
|
doGet(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
//get locales present in list of literals
|
//get locales
|
||||||
public List<HashMap<String, String>> getLocales(VitroRequest vreq,
|
public List<HashMap<String, String>> getLocales(VitroRequest vreq) {
|
||||||
List<Literal> existingLiterals) {
|
List<Locale> selectables = SelectedLocale.getSelectableLocales(vreq);
|
||||||
Set<Locale> locales = new HashSet<Locale>();
|
if (selectables.isEmpty()) {
|
||||||
for(Literal literal : existingLiterals) {
|
|
||||||
String language = literal.getLanguage();
|
|
||||||
if(!StringUtils.isEmpty(language)) {
|
|
||||||
locales.add(LanguageFilteringUtils.languageToLocale(language));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (locales.isEmpty()) {
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
|
List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
|
||||||
Locale currentLocale = SelectedLocale.getCurrentLocale(vreq);
|
Locale currentLocale = SelectedLocale.getCurrentLocale(vreq);
|
||||||
for (Locale locale : locales) {
|
for (Locale locale : selectables) {
|
||||||
try {
|
try {
|
||||||
list.add(buildLocaleMap(locale, currentLocale));
|
list.add(buildLocaleMap(locale, currentLocale));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
log.warn("Can't show locale '" + locale + "': " + e);
|
log.warn("Can't show the Locale selector for '" + locale
|
||||||
|
+ "': " + e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +162,7 @@ public class ViewLabelsServlet extends FreemarkerHttpServlet{
|
||||||
Locale currentLocale) throws FileNotFoundException {
|
Locale currentLocale) throws FileNotFoundException {
|
||||||
HashMap<String, String> map = new HashMap<String, String>();
|
HashMap<String, String> map = new HashMap<String, String>();
|
||||||
//Replacing the underscore with a hyphen because that is what is represented in the actual literals
|
//Replacing the underscore with a hyphen because that is what is represented in the actual literals
|
||||||
map.put("code", locale.toLanguageTag().replace("_", "-"));
|
map.put("code", locale.toString().replace("_", "-"));
|
||||||
map.put("label", locale.getDisplayName(currentLocale));
|
map.put("label", locale.getDisplayName(currentLocale));
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
@ -196,8 +188,8 @@ public class ViewLabelsServlet extends FreemarkerHttpServlet{
|
||||||
|
|
||||||
ArrayList<Literal> labels = new ArrayList<Literal>();
|
ArrayList<Literal> labels = new ArrayList<Literal>();
|
||||||
try {
|
try {
|
||||||
// Show only labels with current language filtering
|
//We want to get the labels for all the languages, not just the display language
|
||||||
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
ResultSet results = QueryUtils.getLanguageNeutralQueryResults(queryStr, vreq);
|
||||||
while (results.hasNext()) {
|
while (results.hasNext()) {
|
||||||
QuerySolution soln = results.nextSolution();
|
QuerySolution soln = results.nextSolution();
|
||||||
Literal nodeLiteral = soln.get("label").asLiteral();
|
Literal nodeLiteral = soln.get("label").asLiteral();
|
||||||
|
|
|
@ -338,7 +338,7 @@ public class JSONReconcileServlet extends VitroHttpServlet {
|
||||||
}
|
}
|
||||||
|
|
||||||
resultJson.put("type", typesJsonArr);
|
resultJson.put("type", typesJsonArr);
|
||||||
resultJson.put("match", false);
|
resultJson.put("match", "false");
|
||||||
resultJsonArr.add(resultJson);
|
resultJsonArr.add(resultJson);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -6,13 +6,14 @@ import java.io.IOException;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
import org.apache.jena.rdf.model.RDFNode;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModelBuilder;
|
||||||
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 org.apache.jena.query.QuerySolution;
|
import org.apache.jena.query.QuerySolution;
|
||||||
import org.apache.jena.query.ResultSet;
|
import org.apache.jena.query.ResultSet;
|
||||||
|
|
||||||
|
@ -35,7 +36,6 @@ import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ExecuteDataRetrieval;
|
import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.ExecuteDataRetrieval;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.beanswrappers.ReadOnlyBeansWrapper;
|
import edu.cornell.mannlib.vitro.webapp.web.beanswrappers.ReadOnlyBeansWrapper;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
|
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel;
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModelBuilder;
|
|
||||||
import edu.ucsf.vitro.opensocial.OpenSocialManager;
|
import edu.ucsf.vitro.opensocial.OpenSocialManager;
|
||||||
import freemarker.ext.beans.BeansWrapper;
|
import freemarker.ext.beans.BeansWrapper;
|
||||||
import freemarker.template.TemplateModel;
|
import freemarker.template.TemplateModel;
|
||||||
|
@ -94,7 +94,6 @@ class IndividualResponseBuilder {
|
||||||
body.put("relatedSubject", getRelatedSubject());
|
body.put("relatedSubject", getRelatedSubject());
|
||||||
body.put("namespaces", namespaces);
|
body.put("namespaces", namespaces);
|
||||||
body.put("temporalVisualizationEnabled", getTemporalVisualizationFlag());
|
body.put("temporalVisualizationEnabled", getTemporalVisualizationFlag());
|
||||||
body.put("mapOfScienceVisualizationEnabled", getMapOfScienceVisualizationFlag());
|
|
||||||
body.put("profilePageTypesEnabled", getprofilePageTypesFlag());
|
body.put("profilePageTypesEnabled", getprofilePageTypesFlag());
|
||||||
body.put("verbosePropertySwitch", getVerbosePropertyValues());
|
body.put("verbosePropertySwitch", getVerbosePropertyValues());
|
||||||
|
|
||||||
|
@ -124,10 +123,8 @@ class IndividualResponseBuilder {
|
||||||
* into the data model: no real data can be modified.
|
* into the data model: no real data can be modified.
|
||||||
*/
|
*/
|
||||||
// body.put("individual", wrap(itm, BeansWrapper.EXPOSE_SAFE));
|
// body.put("individual", wrap(itm, BeansWrapper.EXPOSE_SAFE));
|
||||||
LabelAndLanguageCount labelAndLanguageCount = getLabelAndLanguageCount(
|
body.put("labelCount", getLabelCount(itm.getUri(), vreq));
|
||||||
itm.getUri(), vreq);
|
body.put("languageCount", getLanguagesRepresentedCount(itm.getUri(), vreq));
|
||||||
body.put("labelCount", labelAndLanguageCount.getLabelCount());
|
|
||||||
body.put("languageCount", labelAndLanguageCount.getLanguageCount());
|
|
||||||
//We also need to know the number of available locales
|
//We also need to know the number of available locales
|
||||||
body.put("localesCount", SelectedLocale.getSelectableLocales(vreq).size());
|
body.put("localesCount", SelectedLocale.getSelectableLocales(vreq).size());
|
||||||
body.put("profileType", getProfileType(itm.getUri(), vreq));
|
body.put("profileType", getProfileType(itm.getUri(), vreq));
|
||||||
|
@ -196,12 +193,6 @@ class IndividualResponseBuilder {
|
||||||
return "enabled".equals(property);
|
return "enabled".equals(property);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getMapOfScienceVisualizationFlag() {
|
|
||||||
String property = ConfigurationProperties.getBean(vreq).getProperty(
|
|
||||||
"visualization.mapOfScience");
|
|
||||||
return "enabled".equals(property);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean getprofilePageTypesFlag() {
|
private boolean getprofilePageTypesFlag() {
|
||||||
String property = ConfigurationProperties.getBean(vreq).getProperty(
|
String property = ConfigurationProperties.getBean(vreq).getProperty(
|
||||||
"multiViews.profilePageTypes");
|
"multiViews.profilePageTypes");
|
||||||
|
@ -291,103 +282,61 @@ class IndividualResponseBuilder {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String LABEL_QUERY = ""
|
private static String LABEL_COUNT_QUERY = ""
|
||||||
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
|
+ "SELECT ( str(COUNT(?label)) AS ?labelCount ) WHERE { \n"
|
||||||
|
+ " ?subject rdfs:label ?label \n"
|
||||||
|
+ " FILTER isLiteral(?label) \n"
|
||||||
|
+ "}" ;
|
||||||
|
|
||||||
|
private static String DISTINCT_LANGUAGE_QUERY = ""
|
||||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||||
+ "SELECT ?label WHERE { \n"
|
+ "SELECT ( str(COUNT(DISTINCT lang(?label))) AS ?languageCount ) WHERE { \n"
|
||||||
+ " ?subject rdfs:label ?label \n"
|
+ " ?subject rdfs:label ?label \n"
|
||||||
+ " FILTER isLiteral(?label) \n"
|
+ " FILTER isLiteral(?label) \n"
|
||||||
+ "}" ;
|
+ "}" ;
|
||||||
|
|
||||||
// Queries that were previously used for counts via RDFService that didn't
|
|
||||||
// filter results by language. With language filtering, aggregate
|
|
||||||
// functions like COUNT() cannot be used.
|
|
||||||
|
|
||||||
// private static String LABEL_COUNT_QUERY = ""
|
|
||||||
// + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
|
||||||
// + "SELECT ( str(COUNT(?label)) AS ?labelCount ) WHERE { \n"
|
|
||||||
// + " ?subject rdfs:label ?label \n"
|
|
||||||
// + " FILTER isLiteral(?label) \n"
|
|
||||||
// + "}" ;
|
|
||||||
|
|
||||||
// private static String DISTINCT_LANGUAGE_QUERY = ""
|
private static Integer getLabelCount(String subjectUri, VitroRequest vreq) {
|
||||||
// + "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
String queryStr = QueryUtils.subUriForQueryVar(LABEL_COUNT_QUERY, "subject", subjectUri);
|
||||||
// + "SELECT ( str(COUNT(DISTINCT lang(?label))) AS ?languageCount ) WHERE { \n"
|
|
||||||
// + " ?subject rdfs:label ?label \n"
|
|
||||||
// + " FILTER isLiteral(?label) \n"
|
|
||||||
// + "}" ;
|
|
||||||
|
|
||||||
private static LabelAndLanguageCount getLabelAndLanguageCount(
|
|
||||||
String subjectUri, VitroRequest vreq) {
|
|
||||||
// 1.12.0 Now filtering to only the labels for the current locale so as
|
|
||||||
// to be consistent with other editing forms. Because the language
|
|
||||||
// filter can only act on a result set containing actual literals,
|
|
||||||
// we can't do the counting with a COUNT() in the query itself. So
|
|
||||||
// we will now use the LABEL_QUERY instead of LABEL_COUNT_QUERY and
|
|
||||||
// count the rows and the number of distinct languages represented.
|
|
||||||
Set<String> distinctLanguages = new HashSet<String>();
|
|
||||||
String queryStr = QueryUtils.subUriForQueryVar(LABEL_QUERY, "subject", subjectUri);
|
|
||||||
log.debug("queryStr = " + queryStr);
|
log.debug("queryStr = " + queryStr);
|
||||||
int labelCount = 0;
|
int theCount = 0;
|
||||||
try {
|
try {
|
||||||
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
//ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
|
||||||
while(results.hasNext()) {
|
//Get query results across all languages in order for template to show manage labels link correctly
|
||||||
QuerySolution qsoln = results.next();
|
ResultSet results = QueryUtils.getLanguageNeutralQueryResults(queryStr, vreq);
|
||||||
labelCount++;
|
if (results.hasNext()) {
|
||||||
String lang = qsoln.getLiteral("label").getLanguage();
|
QuerySolution soln = results.nextSolution();
|
||||||
if(lang == null) {
|
RDFNode labelCount = soln.get("labelCount");
|
||||||
lang = "";
|
if (labelCount != null && labelCount.isLiteral()) {
|
||||||
|
theCount = labelCount.asLiteral().getInt();
|
||||||
}
|
}
|
||||||
distinctLanguages.add(lang);
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e, e);
|
log.error(e, e);
|
||||||
}
|
}
|
||||||
return new LabelAndLanguageCount(labelCount, distinctLanguages.size());
|
return theCount;
|
||||||
}
|
|
||||||
|
|
||||||
private static class LabelAndLanguageCount {
|
|
||||||
|
|
||||||
private Integer labelCount;
|
|
||||||
private Integer languageCount;
|
|
||||||
|
|
||||||
public LabelAndLanguageCount(Integer labelCount, Integer languageCount) {
|
|
||||||
this.labelCount = labelCount;
|
|
||||||
this.languageCount = languageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getLabelCount() {
|
|
||||||
return this.labelCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getLanguageCount() {
|
|
||||||
return this.languageCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//what is the number of languages represented across the labels
|
//what is the number of languages represented across the labels
|
||||||
// This version not compatible with language-filtering RDF services
|
private static Integer getLanguagesRepresentedCount(String subjectUri, VitroRequest vreq) {
|
||||||
// private static Integer getLanguagesRepresentedCount(String subjectUri, VitroRequest vreq) {
|
String queryStr = QueryUtils.subUriForQueryVar(DISTINCT_LANGUAGE_QUERY, "subject", subjectUri);
|
||||||
// String queryStr = QueryUtils.subUriForQueryVar(DISTINCT_LANGUAGE_QUERY, "subject", subjectUri);
|
log.debug("queryStr = " + queryStr);
|
||||||
// log.debug("queryStr = " + queryStr);
|
int theCount = 0;
|
||||||
// int theCount = 0;
|
try {
|
||||||
// try {
|
|
||||||
//
|
ResultSet results = QueryUtils.getLanguageNeutralQueryResults(queryStr, vreq);
|
||||||
// ResultSet results = QueryUtils.getLanguageNeutralQueryResults(queryStr, vreq);
|
if (results.hasNext()) {
|
||||||
// if (results.hasNext()) {
|
QuerySolution soln = results.nextSolution();
|
||||||
// QuerySolution soln = results.nextSolution();
|
RDFNode languageCount = soln.get("languageCount");
|
||||||
// RDFNode languageCount = soln.get("languageCount");
|
if (languageCount != null && languageCount.isLiteral()) {
|
||||||
// if (languageCount != null && languageCount.isLiteral()) {
|
theCount = languageCount.asLiteral().getInt();
|
||||||
// theCount = languageCount.asLiteral().getInt();
|
}
|
||||||
// log.info("Language count is " + theCount);
|
}
|
||||||
// }
|
} catch (Exception e) {
|
||||||
// }
|
log.error(e, e);
|
||||||
// } catch (Exception e) {
|
}
|
||||||
// log.error(e, e);
|
return theCount;
|
||||||
// }
|
}
|
||||||
// log.info("Returning language count " + theCount);
|
|
||||||
// return theCount;
|
|
||||||
// }
|
|
||||||
|
|
||||||
private static String PROFILE_TYPE_QUERY = ""
|
private static String PROFILE_TYPE_QUERY = ""
|
||||||
+ "PREFIX display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> \n"
|
+ "PREFIX display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> \n"
|
||||||
|
|
|
@ -17,7 +17,6 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -35,7 +34,6 @@ import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.utils.JSPPageHandler;
|
import edu.cornell.mannlib.vitro.webapp.utils.JSPPageHandler;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
|
||||||
import org.apache.commons.lang3.StringEscapeUtils;
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
@ -292,16 +290,13 @@ public class JenaIngestController extends BaseEditController {
|
||||||
private void processOutputModelRequest(VitroRequest vreq,
|
private void processOutputModelRequest(VitroRequest vreq,
|
||||||
HttpServletResponse response) {
|
HttpServletResponse response) {
|
||||||
String modelNameStr = vreq.getParameter("modelName");
|
String modelNameStr = vreq.getParameter("modelName");
|
||||||
DateTimeFormatter timeStampPattern = DateTimeFormatter.ofPattern("yyyy-MM-dd-HHmmss");
|
|
||||||
String fileName = FilenameUtils.getName(modelNameStr) + "-" + timeStampPattern.format(java.time.LocalDateTime.now());
|
|
||||||
Model model = getModel(modelNameStr,vreq);
|
Model model = getModel(modelNameStr,vreq);
|
||||||
JenaOutputUtils.setNameSpacePrefixes(model,vreq.getWebappDaoFactory());
|
JenaOutputUtils.setNameSpacePrefixes(model,vreq.getWebappDaoFactory());
|
||||||
model.enterCriticalSection(Lock.READ);
|
model.enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
OutputStream out = response.getOutputStream();
|
OutputStream out = response.getOutputStream();
|
||||||
response.setContentType("application/x-turtle");
|
response.setContentType("application/x-turtle");
|
||||||
response.setHeader("Content-Transfer-Encoding", "binary");
|
//out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n".getBytes());
|
||||||
response.setHeader("Content-disposition", "attachment; filename=" + fileName + ".ttl");
|
|
||||||
model.write(out, "TTL");
|
model.write(out, "TTL");
|
||||||
out.flush();
|
out.flush();
|
||||||
out.close();
|
out.close();
|
||||||
|
|
|
@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.controller.json;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
|
@ -16,7 +15,6 @@ import org.apache.commons.logging.LogFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.selection.SelectedLocale;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService;
|
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService.ShortViewContext;
|
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewService.ShortViewContext;
|
||||||
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceSetup;
|
import edu.cornell.mannlib.vitro.webapp.services.shortview.ShortViewServiceSetup;
|
||||||
|
@ -75,11 +73,7 @@ public class GetRandomSearchIndividualsByVClass extends GetSearchIndividualsByVC
|
||||||
modelMap.put("individual",
|
modelMap.put("individual",
|
||||||
IndividualTemplateModelBuilder.build(individual, vreq));
|
IndividualTemplateModelBuilder.build(individual, vreq));
|
||||||
modelMap.put("vclass", vclassName);
|
modelMap.put("vclass", vclassName);
|
||||||
String langCtx = vreq.getLocale().getLanguage(); //UQAM-Linguistic-Management build the linguistic context
|
|
||||||
if (!vreq.getLocale().getCountry().isEmpty()) {
|
|
||||||
langCtx += "-" + vreq.getLocale().getCountry();
|
|
||||||
}
|
|
||||||
modelMap.put("langCtx", langCtx); // UQAM-Linguistic-Management add the linguistic context to map
|
|
||||||
ShortViewService svs = ShortViewServiceSetup.getService(ctx);
|
ShortViewService svs = ShortViewServiceSetup.getService(ctx);
|
||||||
return svs.renderShortView(individual, ShortViewContext.BROWSE,
|
return svs.renderShortView(individual, ShortViewContext.BROWSE,
|
||||||
modelMap, vreq);
|
modelMap, vreq);
|
||||||
|
|
|
@ -53,8 +53,6 @@ public class DisplayVocabulary {
|
||||||
//specific case for internal class, value is true or false
|
//specific case for internal class, value is true or false
|
||||||
public static final String RESTRICT_RESULTS_BY_INTERNAL = NS + "restrictResultsByInternalClass";
|
public static final String RESTRICT_RESULTS_BY_INTERNAL = NS + "restrictResultsByInternalClass";
|
||||||
|
|
||||||
public static final String HAS_DELETE_QUERY = NS + "hasDeleteQuery";
|
|
||||||
|
|
||||||
|
|
||||||
/* Data Properties */
|
/* Data Properties */
|
||||||
public static final DatatypeProperty URL_MAPPING = m_model.createDatatypeProperty(NS + "urlMapping");
|
public static final DatatypeProperty URL_MAPPING = m_model.createDatatypeProperty(NS + "urlMapping");
|
||||||
|
|
|
@ -234,9 +234,6 @@ public class VitroVocabulary {
|
||||||
public static final String IND_MAIN_IMAGE = VITRO_PUBLIC + "mainImage";
|
public static final String IND_MAIN_IMAGE = VITRO_PUBLIC + "mainImage";
|
||||||
public static final String IND_IMAGE = VITRO_PUBLIC + "image";
|
public static final String IND_IMAGE = VITRO_PUBLIC + "image";
|
||||||
|
|
||||||
public static final String STORED_FILE = VITRO_PUBLIC + "storedFile";
|
|
||||||
public static final String PUBLIC_FILENAME = VITRO_PUBLIC + "publicFilename";
|
|
||||||
|
|
||||||
// =============== Date Time with Precision vocabulary ===============
|
// =============== Date Time with Precision vocabulary ===============
|
||||||
private static final String DATETIME_NS = "http://vivoweb.org/ontology/core#";
|
private static final String DATETIME_NS = "http://vivoweb.org/ontology/core#";
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.dao;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
|
||||||
|
|
||||||
public interface WebappDaoFactory {
|
public interface WebappDaoFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,6 +132,4 @@ public interface WebappDaoFactory {
|
||||||
|
|
||||||
public MenuDao getMenuDao();
|
public MenuDao getMenuDao();
|
||||||
|
|
||||||
public I18nBundle getI18nBundle();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,25 +5,21 @@ package edu.cornell.mannlib.vitro.webapp.dao;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao.FullPropertyKey;
|
import edu.cornell.mannlib.vitro.webapp.dao.PropertyDao.FullPropertyKey;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringUtils;
|
|
||||||
|
|
||||||
public class WebappDaoFactoryConfig {
|
public class WebappDaoFactoryConfig {
|
||||||
|
|
||||||
private List<String> preferredLanguages;
|
private List<String> preferredLanguages;
|
||||||
private List<Locale> preferredLocales;
|
|
||||||
private String defaultNamespace;
|
private String defaultNamespace;
|
||||||
private Set<String> nonUserNamespaces;
|
private Set<String> nonUserNamespaces;
|
||||||
private boolean isUnderlyingStoreReasoned = false;
|
private boolean isUnderlyingStoreReasoned = false;
|
||||||
public Map<FullPropertyKey, String> customListViewConfigFileMap;
|
public Map<FullPropertyKey, String> customListViewConfigFileMap;
|
||||||
|
|
||||||
public WebappDaoFactoryConfig() {
|
public WebappDaoFactoryConfig() {
|
||||||
preferredLanguages = Arrays.asList("en-US", "en", "EN");
|
preferredLanguages = Arrays.asList("en-US", "en", "EN");
|
||||||
preferredLocales = LanguageFilteringUtils.languagesToLocales(preferredLanguages);
|
|
||||||
defaultNamespace = "http://vitro.mannlib.cornell.edu/ns/default#";
|
defaultNamespace = "http://vitro.mannlib.cornell.edu/ns/default#";
|
||||||
nonUserNamespaces = new HashSet<String>();
|
nonUserNamespaces = new HashSet<String>();
|
||||||
nonUserNamespaces.add(VitroVocabulary.vitroURI);
|
nonUserNamespaces.add(VitroVocabulary.vitroURI);
|
||||||
|
@ -37,14 +33,6 @@ public class WebappDaoFactoryConfig {
|
||||||
this.preferredLanguages = pl;
|
this.preferredLanguages = pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Locale> getPreferredLocales() {
|
|
||||||
return this.preferredLocales;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPreferredLocales(List<Locale> pl) {
|
|
||||||
this.preferredLocales = pl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDefaultNamespace() {
|
public String getDefaultNamespace() {
|
||||||
return defaultNamespace;
|
return defaultNamespace;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||||
|
|
||||||
public class DataPropertyDaoFiltering extends BaseFiltering implements DataPropertyDao{
|
class DataPropertyDaoFiltering extends BaseFiltering implements DataPropertyDao{
|
||||||
final DataPropertyDao innerDataPropertyDao;
|
final DataPropertyDao innerDataPropertyDao;
|
||||||
final VitroFilters filters;
|
final VitroFilters filters;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||||
|
|
||||||
public class DataPropertyStatementDaoFiltering extends BaseFiltering implements DataPropertyStatementDao{
|
class DataPropertyStatementDaoFiltering extends BaseFiltering implements DataPropertyStatementDao{
|
||||||
|
|
||||||
final DataPropertyStatementDao innerDataPropertyStatementDao;
|
final DataPropertyStatementDao innerDataPropertyStatementDao;
|
||||||
final VitroFilters filters;
|
final VitroFilters filters;
|
||||||
|
|
|
@ -26,34 +26,47 @@ public class FauxPropertyDaoFiltering extends BaseFiltering implements FauxPrope
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<FauxProperty> getFauxPropertiesForBaseUri(String uri) {
|
public List<FauxProperty> getFauxPropertiesForBaseUri(String uri) {
|
||||||
return innerFauxPropertyDao.getFauxPropertiesForBaseUri(uri);
|
// TODO Auto-generated method stub
|
||||||
|
throw new RuntimeException(
|
||||||
|
"FauxPropertyDao.getFauxPropertiesForBaseUri() not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FauxProperty getFauxPropertyFromContextUri(String contextUri) {
|
public FauxProperty getFauxPropertyFromContextUri(String contextUri) {
|
||||||
return innerFauxPropertyDao.getFauxPropertyFromContextUri(contextUri);
|
// TODO Auto-generated method stub
|
||||||
|
throw new RuntimeException(
|
||||||
|
"FauxPropertyDaoFiltering.getFauxPropertyFromConfigContextUri() not implemented.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FauxProperty getFauxPropertyByUris(String domainUri, String baseUri,
|
public FauxProperty getFauxPropertyByUris(String domainUri, String baseUri,
|
||||||
String rangeUri) {
|
String rangeUri) {
|
||||||
return innerFauxPropertyDao.getFauxPropertyByUris(domainUri, baseUri,
|
// TODO Auto-generated method stub
|
||||||
rangeUri);
|
throw new RuntimeException(
|
||||||
|
"FauxPropertyDaoFiltering.getFauxPropertyByUris() not implemented.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateFauxProperty(FauxProperty fp) {
|
public void updateFauxProperty(FauxProperty fp) {
|
||||||
innerFauxPropertyDao.updateFauxProperty(fp);
|
// TODO Auto-generated method stub
|
||||||
|
throw new RuntimeException("FauxPropertyDaoFiltering.updateFauxProperty() not implemented.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteFauxProperty(FauxProperty fp) {
|
public void deleteFauxProperty(FauxProperty fp) {
|
||||||
innerFauxPropertyDao.deleteFauxProperty(fp);
|
// TODO Auto-generated method stub
|
||||||
|
throw new RuntimeException("FauxPropertyDao.deleteFauxProperty() not implemented.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertFauxProperty(FauxProperty fp) {
|
public void insertFauxProperty(FauxProperty fp) {
|
||||||
innerFauxPropertyDao.insertFauxProperty(fp);
|
// TODO Auto-generated method stub
|
||||||
|
throw new RuntimeException("FauxPropertyDao.insertFauxProperty() not implemented.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
||||||
|
|
||||||
|
|
||||||
public class IndividualDaoFiltering extends BaseFiltering implements IndividualDao{
|
class IndividualDaoFiltering extends BaseFiltering implements IndividualDao{
|
||||||
IndividualDao innerIndividualDao;
|
IndividualDao innerIndividualDao;
|
||||||
VitroFilters filters;
|
VitroFilters filters;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||||
|
|
||||||
public class ObjectPropertyDaoFiltering extends BaseFiltering implements ObjectPropertyDao{
|
class ObjectPropertyDaoFiltering extends BaseFiltering implements ObjectPropertyDao{
|
||||||
final ObjectPropertyDao innerObjectPropertyDao;
|
final ObjectPropertyDao innerObjectPropertyDao;
|
||||||
final VitroFilters filters;
|
final VitroFilters filters;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||||
|
|
||||||
public class ObjectPropertyStatementDaoFiltering extends BaseFiltering implements ObjectPropertyStatementDao{
|
class ObjectPropertyStatementDaoFiltering extends BaseFiltering implements ObjectPropertyStatementDao{
|
||||||
final ObjectPropertyStatementDao innerObjectPropertyStatementDao;
|
final ObjectPropertyStatementDao innerObjectPropertyStatementDao;
|
||||||
final VitroFilters filters;
|
final VitroFilters filters;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This wraps a WebappDaoFactory and applies filtering.
|
* This wraps a WebappDaoFactory and applies filtering.
|
||||||
|
@ -68,7 +67,7 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory {
|
||||||
transient private PropertyGroupDao filteringPropertyGroupDao=null;
|
transient private PropertyGroupDao filteringPropertyGroupDao=null;
|
||||||
transient private PropertyInstanceDao filteringPropertyInstanceDao=null;
|
transient private PropertyInstanceDao filteringPropertyInstanceDao=null;
|
||||||
|
|
||||||
public WebappDaoFactoryFiltering(WebappDaoFactory innerDao, VitroFilters filters){
|
public WebappDaoFactoryFiltering( WebappDaoFactory innerDao, VitroFilters filters){
|
||||||
if( innerDao == null )
|
if( innerDao == null )
|
||||||
throw new Error("innerWebappDaoFactory must be non-null");
|
throw new Error("innerWebappDaoFactory must be non-null");
|
||||||
this.filters = filters;
|
this.filters = filters;
|
||||||
|
@ -277,9 +276,4 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory {
|
||||||
public void close() {
|
public void close() {
|
||||||
innerWebappDaoFactory.close();
|
innerWebappDaoFactory.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public I18nBundle getI18nBundle() {
|
|
||||||
return innerWebappDaoFactory.getI18nBundle();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,21 +83,22 @@ public class ApplicationDaoJena extends JenaBaseDao implements ApplicationDao {
|
||||||
}
|
}
|
||||||
ontModel.enterCriticalSection(Lock.WRITE);
|
ontModel.enterCriticalSection(Lock.WRITE);
|
||||||
try {
|
try {
|
||||||
updateRDFSLabel(appInd, application.getApplicationName());
|
appInd.setLabel(application.getApplicationName(), null);
|
||||||
updatePlainLiteralValue(
|
updatePropertyStringValue(
|
||||||
appInd, APPLICATION_ABOUTTEXT, application.getAboutText());
|
appInd, APPLICATION_ABOUTTEXT, application.getAboutText(),
|
||||||
updatePlainLiteralValue(
|
ontModel);
|
||||||
|
updatePropertyStringValue(
|
||||||
appInd, APPLICATION_ACKNOWLEGETEXT,
|
appInd, APPLICATION_ACKNOWLEGETEXT,
|
||||||
application.getAcknowledgeText());
|
application.getAcknowledgeText(), ontModel);
|
||||||
updatePropertyStringValue(
|
updatePropertyStringValue(
|
||||||
appInd, APPLICATION_CONTACTMAIL,
|
appInd, APPLICATION_CONTACTMAIL,
|
||||||
application.getContactMail(), ontModel);
|
application.getContactMail(), ontModel);
|
||||||
updatePropertyStringValue(
|
updatePropertyStringValue(
|
||||||
appInd, APPLICATION_CORRECTIONMAIL,
|
appInd, APPLICATION_CORRECTIONMAIL,
|
||||||
application.getCorrectionMail(), ontModel);
|
application.getCorrectionMail(), ontModel);
|
||||||
updatePlainLiteralValue(
|
updatePropertyStringValue(
|
||||||
appInd, APPLICATION_COPYRIGHTANCHOR,
|
appInd, APPLICATION_COPYRIGHTANCHOR,
|
||||||
application.getCopyrightAnchor());
|
application.getCopyrightAnchor(), ontModel);
|
||||||
updatePropertyStringValue(
|
updatePropertyStringValue(
|
||||||
appInd, APPLICATION_COPYRIGHTURL,
|
appInd, APPLICATION_COPYRIGHTURL,
|
||||||
application.getCopyrightURL(), ontModel);
|
application.getCopyrightURL(), ontModel);
|
||||||
|
|
|
@ -24,10 +24,6 @@ public class BlankNodeFilteringGraph implements Graph {
|
||||||
|
|
||||||
private Graph graph;
|
private Graph graph;
|
||||||
|
|
||||||
public Graph getInnerGraph() {
|
|
||||||
return graph;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlankNodeFilteringGraph(Graph graph) {
|
public BlankNodeFilteringGraph(Graph graph) {
|
||||||
this.graph = graph;
|
this.graph = graph;
|
||||||
}
|
}
|
||||||
|
|
|
@ -516,9 +516,9 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||||
if (dtp.getFunctional()) {
|
if (dtp.getFunctional()) {
|
||||||
ontModel.add(jDataprop,RDF.type,OWL.FunctionalProperty);
|
ontModel.add(jDataprop,RDF.type,OWL.FunctionalProperty);
|
||||||
}
|
}
|
||||||
updatePlainLiteralValue(jDataprop, EXAMPLE, dtp.getExample());
|
addPropertyStringValue(jDataprop, EXAMPLE, dtp.getExample(), ontModel);
|
||||||
updatePlainLiteralValue(jDataprop, DESCRIPTION_ANNOT, dtp.getDescription());
|
addPropertyStringValue(jDataprop, DESCRIPTION_ANNOT, dtp.getDescription(), ontModel);
|
||||||
updatePlainLiteralValue(jDataprop, PUBLIC_DESCRIPTION_ANNOT, dtp.getPublicDescription());
|
addPropertyStringValue(jDataprop, PUBLIC_DESCRIPTION_ANNOT, dtp.getPublicDescription(), ontModel);
|
||||||
addPropertyStringValue(jDataprop, EDITING, dtp.getEditing(), ontModel);
|
addPropertyStringValue(jDataprop, EDITING, dtp.getEditing(), ontModel);
|
||||||
addPropertyNonNegativeIntValue(jDataprop, DISPLAY_RANK_ANNOT, dtp.getDisplayTier(), ontModel);
|
addPropertyNonNegativeIntValue(jDataprop, DISPLAY_RANK_ANNOT, dtp.getDisplayTier(), ontModel);
|
||||||
addPropertyNonNegativeIntValue(jDataprop, DISPLAY_LIMIT, dtp.getDisplayLimit(), ontModel);
|
addPropertyNonNegativeIntValue(jDataprop, DISPLAY_LIMIT, dtp.getDisplayLimit(), ontModel);
|
||||||
|
@ -587,9 +587,9 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePlainLiteralValue(jDataprop, EXAMPLE, dtp.getExample());
|
updatePropertyStringValue(jDataprop, EXAMPLE, dtp.getExample(), ontModel);
|
||||||
updatePlainLiteralValue(jDataprop, DESCRIPTION_ANNOT, dtp.getDescription());
|
updatePropertyStringValue(jDataprop, DESCRIPTION_ANNOT, dtp.getDescription(), ontModel);
|
||||||
updatePlainLiteralValue(jDataprop, PUBLIC_DESCRIPTION_ANNOT, dtp.getPublicDescription());
|
updatePropertyStringValue(jDataprop, PUBLIC_DESCRIPTION_ANNOT, dtp.getPublicDescription(), ontModel);
|
||||||
updatePropertyStringValue(jDataprop, EDITING, dtp.getEditing(), ontModel);
|
updatePropertyStringValue(jDataprop, EDITING, dtp.getEditing(), ontModel);
|
||||||
updatePropertyNonNegativeIntValue(jDataprop, DISPLAY_RANK_ANNOT, dtp.getDisplayTier(), ontModel);
|
updatePropertyNonNegativeIntValue(jDataprop, DISPLAY_RANK_ANNOT, dtp.getDisplayTier(), ontModel);
|
||||||
updatePropertyNonNegativeIntValue(jDataprop, DISPLAY_LIMIT, dtp.getDisplayLimit(), ontModel);
|
updatePropertyNonNegativeIntValue(jDataprop, DISPLAY_LIMIT, dtp.getDisplayLimit(), ontModel);
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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 org.apache.jena.ontology.ObjectProperty;
|
import org.apache.jena.ontology.ObjectProperty;
|
||||||
|
@ -153,22 +152,20 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
|
||||||
|
|
||||||
Collection<String> rangeUris = getPropertyResourceURIValues(
|
Collection<String> rangeUris = getPropertyResourceURIValues(
|
||||||
context, QUALIFIED_BY_RANGE);
|
context, QUALIFIED_BY_RANGE);
|
||||||
String rangeUri = null;
|
if (rangeUris.isEmpty()) {
|
||||||
if (!rangeUris.isEmpty()) {
|
log.debug("'" + contextUri + "' has no value for '"
|
||||||
rangeUri = rangeUris.iterator().next();
|
+ QUALIFIED_BY_RANGE + "'");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
String rangeUri = rangeUris.iterator().next();
|
||||||
|
|
||||||
// domainURI is optional.
|
// domainURI is optional.
|
||||||
Collection<String> domainUris = getPropertyResourceURIValues(
|
Collection<String> domainUris = getPropertyResourceURIValues(
|
||||||
context, QUALIFIED_BY_DOMAIN);
|
context, QUALIFIED_BY_DOMAIN);
|
||||||
String domainUri = domainUris.isEmpty() ? null : domainUris
|
String domainUri = domainUris.isEmpty() ? null : domainUris
|
||||||
.iterator().next();
|
.iterator().next();
|
||||||
|
|
||||||
Collection<String> rootRangeUris = getPropertyResourceURIValues(context, QUALIFIED_BY_ROOT);
|
|
||||||
|
|
||||||
FauxProperty fp = new FauxProperty(domainUri, baseUri, rangeUri);
|
FauxProperty fp = new FauxProperty(domainUri, baseUri, rangeUri);
|
||||||
if (!rootRangeUris.isEmpty()) {
|
|
||||||
fp.setRootRangeUri(rootRangeUris.iterator().next());
|
|
||||||
}
|
|
||||||
fp.setContextUri(contextUri);
|
fp.setContextUri(contextUri);
|
||||||
populateInstance(fp);
|
populateInstance(fp);
|
||||||
log.debug("Loaded FauxProperty: " + fp);
|
log.debug("Loaded FauxProperty: " + fp);
|
||||||
|
@ -217,7 +214,7 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
|
||||||
addPropertyResourceValue(context, RDF.type, CONFIG_CONTEXT);
|
addPropertyResourceValue(context, RDF.type, CONFIG_CONTEXT);
|
||||||
addPropertyResourceURIValue(context, CONFIG_CONTEXT_FOR,
|
addPropertyResourceURIValue(context, CONFIG_CONTEXT_FOR,
|
||||||
fp.getBaseURI());
|
fp.getBaseURI());
|
||||||
addPropertyResourceURINotEmpty(context, QUALIFIED_BY_RANGE,
|
addPropertyResourceURIValue(context, QUALIFIED_BY_RANGE,
|
||||||
fp.getRangeURI());
|
fp.getRangeURI());
|
||||||
addPropertyResourceURINotEmpty(context, QUALIFIED_BY_DOMAIN,
|
addPropertyResourceURINotEmpty(context, QUALIFIED_BY_DOMAIN,
|
||||||
fp.getDomainURI());
|
fp.getDomainURI());
|
||||||
|
@ -233,9 +230,10 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
|
||||||
OBJECT_PROPERTY_DISPLAY_CONFIG);
|
OBJECT_PROPERTY_DISPLAY_CONFIG);
|
||||||
addPropertyResourceURINotEmpty(config, PROPERTY_GROUP,
|
addPropertyResourceURINotEmpty(config, PROPERTY_GROUP,
|
||||||
fp.getGroupURI());
|
fp.getGroupURI());
|
||||||
updatePlainLiteralValue(config, DISPLAY_NAME, fp.getDisplayName());
|
addPropertyStringValue(config, DISPLAY_NAME, fp.getDisplayName(),
|
||||||
updatePlainLiteralValue(config, PUBLIC_DESCRIPTION_ANNOT,
|
displayModel);
|
||||||
fp.getPublicDescription());
|
addPropertyStringValue(config, PUBLIC_DESCRIPTION_ANNOT,
|
||||||
|
fp.getPublicDescription(), displayModel);
|
||||||
addPropertyIntValue(config, DISPLAY_RANK_ANNOT,
|
addPropertyIntValue(config, DISPLAY_RANK_ANNOT,
|
||||||
fp.getDisplayTier(), displayModel);
|
fp.getDisplayTier(), displayModel);
|
||||||
addPropertyIntValue(config, DISPLAY_LIMIT, fp.getDisplayLimit(),
|
addPropertyIntValue(config, DISPLAY_LIMIT, fp.getDisplayLimit(),
|
||||||
|
@ -330,10 +328,10 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
|
||||||
.getConfigUri());
|
.getConfigUri());
|
||||||
updatePropertyResourceURIValue(config, PROPERTY_GROUP,
|
updatePropertyResourceURIValue(config, PROPERTY_GROUP,
|
||||||
fp.getGroupURI());
|
fp.getGroupURI());
|
||||||
updatePlainLiteralValue(config, DISPLAY_NAME,
|
updatePropertyStringValue(config, DISPLAY_NAME,
|
||||||
fp.getDisplayName());
|
fp.getDisplayName(), displayModel);
|
||||||
updatePlainLiteralValue(config, PUBLIC_DESCRIPTION_ANNOT,
|
updatePropertyStringValue(config, PUBLIC_DESCRIPTION_ANNOT,
|
||||||
fp.getPublicDescription());
|
fp.getPublicDescription(), displayModel);
|
||||||
updatePropertyIntValue(config, DISPLAY_RANK_ANNOT,
|
updatePropertyIntValue(config, DISPLAY_RANK_ANNOT,
|
||||||
fp.getDisplayTier(), displayModel);
|
fp.getDisplayTier(), displayModel);
|
||||||
updatePropertyIntValue(config, DISPLAY_LIMIT, fp.getDisplayLimit(),
|
updatePropertyIntValue(config, DISPLAY_LIMIT, fp.getDisplayLimit(),
|
||||||
|
@ -496,22 +494,31 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
|
||||||
// ConfigContext
|
// ConfigContext
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
private static String queryLocateConfigContext(boolean hasDomain, boolean hasRange) {
|
private static final String QUERY_LOCATE_CONFIG_CONTEXT_WITH_DOMAIN = "" //
|
||||||
return "PREFIX : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n"
|
+ "PREFIX : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" //
|
||||||
+ "SELECT DISTINCT ?context ?config \n"
|
+ "\n" //
|
||||||
+ "WHERE { \n"
|
+ "SELECT DISTINCT ?context ?config \n" //
|
||||||
+ " ?context a :ConfigContext . \n"
|
+ "WHERE { \n" //
|
||||||
+ " ?context :configContextFor ?baseUri . \n"
|
+ " ?context a :ConfigContext ; \n" //
|
||||||
+ ( hasDomain ? "" : " FILTER NOT EXISTS { \n " )
|
+ " :configContextFor ?baseUri ; \n" //
|
||||||
+ " ?context :qualifiedByDomain ?domainUri . \n"
|
+ " :qualifiedByDomain ?domainUri ; \n" //
|
||||||
+ ( hasDomain ? "" : "} \n" )
|
+ " :qualifiedBy ?rangeUri ; \n" //
|
||||||
+ ( hasRange ? "" : " FILTER NOT EXISTS { \n " )
|
+ " :hasConfiguration ?config . \n" //
|
||||||
+ " ?context :qualifiedBy ?rangeUri . \n"
|
+ "} \n"; //
|
||||||
+ ( hasRange ? "" : "} \n" )
|
|
||||||
+ " ?context :hasConfiguration ?config . \n"
|
|
||||||
+ "} \n";
|
|
||||||
|
|
||||||
}
|
private static final String QUERY_LOCATE_CONFIG_CONTEXT_WITH_NO_DOMAIN = "" //
|
||||||
|
+ "PREFIX : <http://vitro.mannlib.cornell.edu/ns/vitro/ApplicationConfiguration#> \n" //
|
||||||
|
+ "\n" //
|
||||||
|
+ "SELECT DISTINCT ?context ?config \n" //
|
||||||
|
+ "WHERE { \n" //
|
||||||
|
+ " ?context a :ConfigContext ; \n" //
|
||||||
|
+ " :configContextFor ?baseUri ; \n" //
|
||||||
|
+ " :qualifiedBy ?rangeUri ; \n" //
|
||||||
|
+ " :hasConfiguration ?config . \n" //
|
||||||
|
+ " FILTER NOT EXISTS { \n" //
|
||||||
|
+ " ?context :qualifiedByDomain ?domainUri \n" //
|
||||||
|
+ " } \n" //
|
||||||
|
+ "} \n"; //
|
||||||
|
|
||||||
private static class ParserLocateConfigContext extends
|
private static class ParserLocateConfigContext extends
|
||||||
ResultSetParser<Set<ConfigContext>> {
|
ResultSetParser<Set<ConfigContext>> {
|
||||||
|
@ -550,16 +557,22 @@ public class FauxPropertyDaoJena extends JenaBaseDao implements FauxPropertyDao
|
||||||
|
|
||||||
private static class ConfigContext {
|
private static class ConfigContext {
|
||||||
public static Set<ConfigContext> findByQualifiers(
|
public static Set<ConfigContext> findByQualifiers(
|
||||||
LockableOntModel lockableDisplayModel, String domainUri, String baseUri, String rangeUri) {
|
LockableOntModel lockableDisplayModel, String domainUri,
|
||||||
|
String baseUri, String rangeUri) {
|
||||||
try (LockedOntModel displayModel = lockableDisplayModel.read()) {
|
try (LockedOntModel displayModel = lockableDisplayModel.read()) {
|
||||||
boolean hasDomain = !StringUtils.isEmpty(domainUri) && !domainUri.equals(OWL.Thing.getURI());
|
QueryHolder qHolder;
|
||||||
boolean hasRange = !StringUtils.isEmpty(rangeUri);
|
if (domainUri == null || domainUri.trim().isEmpty()
|
||||||
QueryHolder qHolder = queryHolder(queryLocateConfigContext(hasDomain, hasRange)).bindToUri("baseUri", baseUri);
|
|| domainUri.equals(OWL.Thing.getURI())) {
|
||||||
if (hasDomain) {
|
qHolder = queryHolder(
|
||||||
qHolder = qHolder.bindToUri("domainUri", domainUri);
|
QUERY_LOCATE_CONFIG_CONTEXT_WITH_NO_DOMAIN)
|
||||||
}
|
.bindToUri("baseUri", baseUri).bindToUri(
|
||||||
if (hasRange) {
|
"rangeUri", rangeUri);
|
||||||
qHolder = qHolder.bindToUri("rangeUri", rangeUri);
|
} else {
|
||||||
|
qHolder = queryHolder(
|
||||||
|
QUERY_LOCATE_CONFIG_CONTEXT_WITH_DOMAIN)
|
||||||
|
.bindToUri("baseUri", baseUri)
|
||||||
|
.bindToUri("rangeUri", rangeUri)
|
||||||
|
.bindToUri("domainUri", domainUri);
|
||||||
}
|
}
|
||||||
if (log.isDebugEnabled()) {
|
if (log.isDebugEnabled()) {
|
||||||
log.debug("domainUri=" + domainUri + ", baseUri=" + baseUri
|
log.debug("domainUri=" + domainUri + ", baseUri=" + baseUri
|
||||||
|
|
|
@ -14,7 +14,6 @@ import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang3.NotImplementedException;
|
import org.apache.commons.lang3.NotImplementedException;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -287,14 +286,15 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
|
||||||
ontModel.getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),true,ent.getURI()));
|
ontModel.getBaseModel().notifyEvent(new IndividualUpdateEvent(getWebappDaoFactory().getUserURI(),true,ent.getURI()));
|
||||||
org.apache.jena.ontology.Individual ind = ontModel.getIndividual(ent.getURI());
|
org.apache.jena.ontology.Individual ind = ontModel.getIndividual(ent.getURI());
|
||||||
if (ind != null) {
|
if (ind != null) {
|
||||||
|
if (ent.getName() != null && ( (ind.getLabel(getDefaultLanguage())==null) || (ind.getLabel(getDefaultLanguage())!=null && ent.getName()!=null && !ent.getName().equals(ind.getLabel(getDefaultLanguage())) ) ) ) {
|
||||||
String newLabel = ent.getName();
|
|
||||||
String oldLabel = ind.getLabel(getDefaultLanguage());
|
// removal of existing values done this odd way to trigger
|
||||||
if ( newLabel != null && !newLabel.equals(oldLabel) ) {
|
// the change listeners
|
||||||
if (oldLabel == null) {
|
Model temp = ModelFactory.createDefaultModel();
|
||||||
oldLabel = "";
|
temp.add(ontModel.listStatements(ind, RDFS.label, (RDFNode) null));
|
||||||
}
|
ontModel.remove(temp);
|
||||||
replaceOldLabelWithNewInDefaultLanguage(ontModel, ind, newLabel, oldLabel);
|
|
||||||
|
ind.setLabel(ent.getName(), getDefaultLanguage());
|
||||||
}
|
}
|
||||||
Set<String> oldTypeURIsSet = new HashSet<String>();
|
Set<String> oldTypeURIsSet = new HashSet<String>();
|
||||||
for (Iterator<Resource> typeIt = ind.listRDFTypes(true); typeIt.hasNext();) {
|
for (Iterator<Resource> typeIt = ind.listRDFTypes(true); typeIt.hasNext();) {
|
||||||
|
@ -347,23 +347,6 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void replaceOldLabelWithNewInDefaultLanguage(OntModel ontModel, org.apache.jena.ontology.Individual ind,
|
|
||||||
final String newLabel, final String oldLabel) {
|
|
||||||
Model temp = ModelFactory.createDefaultModel();
|
|
||||||
StmtIterator statements = ontModel.listStatements(ind, RDFS.label, (RDFNode) null);
|
|
||||||
while (statements.hasNext()) {
|
|
||||||
Statement statement = (Statement) statements.next();
|
|
||||||
Literal object = statement.getLiteral();
|
|
||||||
String lexicalForm = object.getLexicalForm();
|
|
||||||
String language = object.getLanguage();
|
|
||||||
if (oldLabel.equals(lexicalForm) && language.equals(getDefaultLanguage()) ) {
|
|
||||||
temp.add(statement);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ontModel.remove(temp);
|
|
||||||
ind.addLabel(newLabel, getDefaultLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void markModified(Individual ind) {
|
public void markModified(Individual ind) {
|
||||||
markModified(ind,getOntModel());
|
markModified(ind,getOntModel());
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,8 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -14,14 +14,14 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
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 org.apache.jena.iri.IRI;
|
||||||
|
import org.apache.jena.iri.IRIFactory;
|
||||||
|
|
||||||
import org.apache.jena.datatypes.xsd.XSDDatatype;
|
import org.apache.jena.datatypes.xsd.XSDDatatype;
|
||||||
import org.apache.jena.graph.Node;
|
import org.apache.jena.graph.Node;
|
||||||
import org.apache.jena.graph.NodeFactory;
|
import org.apache.jena.graph.NodeFactory;
|
||||||
import org.apache.jena.iri.IRI;
|
|
||||||
import org.apache.jena.iri.IRIFactory;
|
|
||||||
import org.apache.jena.ontology.DatatypeProperty;
|
import org.apache.jena.ontology.DatatypeProperty;
|
||||||
import org.apache.jena.ontology.ObjectProperty;
|
import org.apache.jena.ontology.ObjectProperty;
|
||||||
import org.apache.jena.ontology.OntClass;
|
import org.apache.jena.ontology.OntClass;
|
||||||
|
@ -39,7 +39,6 @@ import org.apache.jena.rdf.model.NodeIterator;
|
||||||
import org.apache.jena.rdf.model.Property;
|
import org.apache.jena.rdf.model.Property;
|
||||||
import org.apache.jena.rdf.model.RDFNode;
|
import org.apache.jena.rdf.model.RDFNode;
|
||||||
import org.apache.jena.rdf.model.Resource;
|
import org.apache.jena.rdf.model.Resource;
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
|
||||||
import org.apache.jena.rdf.model.Statement;
|
import org.apache.jena.rdf.model.Statement;
|
||||||
import org.apache.jena.rdf.model.StmtIterator;
|
import org.apache.jena.rdf.model.StmtIterator;
|
||||||
import org.apache.jena.shared.Lock;
|
import org.apache.jena.shared.Lock;
|
||||||
|
@ -643,7 +642,7 @@ public class JenaBaseDao extends JenaBaseDaoCon {
|
||||||
|
|
||||||
if (existingValue == null ) {
|
if (existingValue == null ) {
|
||||||
model.add(res, prop, model.createResource(uri));
|
model.add(res, prop, model.createResource(uri));
|
||||||
} else if (!isEqual(uri, existingValue)) {
|
} else if (!(existingValue.getURI()).equals(uri)) {
|
||||||
model.removeAll(res, prop, null);
|
model.removeAll(res, prop, null);
|
||||||
model.add(res, prop, model.createResource(uri));
|
model.add(res, prop, model.createResource(uri));
|
||||||
}
|
}
|
||||||
|
@ -651,15 +650,6 @@ public class JenaBaseDao extends JenaBaseDaoCon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isEqual(String uri, Resource existingValue) {
|
|
||||||
if (existingValue.asNode().isBlank()) {
|
|
||||||
final String blankNodeId = existingValue.asNode().getBlankNodeId().toString();
|
|
||||||
return uri.endsWith(blankNodeId);
|
|
||||||
} else {
|
|
||||||
return existingValue.getURI().equals(uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* convenience method for use with functional object properties
|
* convenience method for use with functional object properties
|
||||||
*/
|
*/
|
||||||
|
@ -762,111 +752,22 @@ public class JenaBaseDao extends JenaBaseDaoCon {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add to an OntResource an rdfs:label value with lexical form and default
|
|
||||||
* language tag. Remove any other existing values in default language.
|
|
||||||
* If lexicalForm parameter is null, remove all plain literal values of
|
|
||||||
* Property in default language.
|
|
||||||
* @param ontRes may not be null
|
|
||||||
* @param lexicalForm may be null. If null, existing values will be deleted
|
|
||||||
* but none will be added.
|
|
||||||
*/
|
|
||||||
protected void updateRDFSLabel(OntResource ontRes, String lexicalForm) {
|
|
||||||
updatePlainLiteralValue(ontRes, RDFS.label, lexicalForm);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add to an OntResource an rdfs:label value with lexical form and optional
|
|
||||||
* language tag. Remove any other existing plain literal values that match
|
|
||||||
* specified language or lack language tags if no language is supplied.
|
|
||||||
* If lexicalForm parameter is null, remove all plain literal labels in
|
|
||||||
* specified language, or all existing language-less labels
|
|
||||||
* if no language is specified.
|
|
||||||
* @param ontRes may not be null
|
|
||||||
* @param lexicalForm may be null. If null, existing values will be deleted
|
|
||||||
* but none will be added.
|
|
||||||
* @param lang may be null. If null, method acts on language-less plain
|
|
||||||
* literal labels and ignores those with language tags.
|
|
||||||
*/
|
|
||||||
protected void updateRDFSLabel(OntResource ontRes, String lexicalForm, String lang) {
|
|
||||||
updatePlainLiteralValue(ontRes, RDFS.label, lexicalForm, lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add to an OntResource a Property value with lexical form and default
|
* convenience method for updating the RDFS label
|
||||||
* language tag. Remove any other existing values in default language.
|
|
||||||
* If lexicalForm parameter is null, remove all plain literal values of
|
|
||||||
* Property in default language.
|
|
||||||
* @param ontRes may not be null
|
|
||||||
* @param lexicalForm may be null. If null, existing values will be deleted
|
|
||||||
* but none will be added.
|
|
||||||
*/
|
*/
|
||||||
protected void updatePlainLiteralValue(OntResource ontRes, Property property,
|
protected void updateRDFSLabel(OntResource ontRes, String label) {
|
||||||
String lexicalForm) {
|
|
||||||
updatePlainLiteralValue(ontRes, property, lexicalForm, getDefaultLanguage());
|
if (label != null && label.length() > 0) {
|
||||||
}
|
|
||||||
|
String existingValue = ontRes.getLabel(getDefaultLanguage());
|
||||||
/**
|
|
||||||
* Add to an OntResource a Property value with lexical form and optional
|
if (existingValue == null || !existingValue.equals(label)) {
|
||||||
* language tag. Remove any other existing plain literal values that match
|
ontRes.setLabel(label, getDefaultLanguage());
|
||||||
* specified language or lack language tags if no language is supplied.
|
}
|
||||||
* If lexicalForm parameter is null, remove all plain literal values of
|
} else {
|
||||||
* Property in specified language, or all existing language-less literals
|
ontRes.removeAll(RDFS.label);
|
||||||
* if no language is specified.
|
}
|
||||||
* @param ontRes may not be null
|
|
||||||
* @param lexicalForm may be null. If null, existing values will be deleted
|
|
||||||
* but none will be added.
|
|
||||||
* @param lang may be null. If null, method acts on language-less
|
|
||||||
* plain literal values and ignores those with language tags.
|
|
||||||
*/
|
|
||||||
protected void updatePlainLiteralValue(OntResource ontRes, Property property,
|
|
||||||
String lexicalForm, String lang) {
|
|
||||||
if(ontRes == null) {
|
|
||||||
throw new IllegalArgumentException("ontRes may not be null.");
|
|
||||||
}
|
|
||||||
boolean addNew = true;
|
|
||||||
List<Statement> toRemove = new ArrayList<Statement>();
|
|
||||||
StmtIterator existingStmts = ontRes.listProperties(property);
|
|
||||||
while(existingStmts.hasNext()) {
|
|
||||||
Statement stmt = existingStmts.next();
|
|
||||||
if(stmt.getObject().isLiteral()) {
|
|
||||||
Literal lit = stmt.getObject().asLiteral();
|
|
||||||
if( (lang == null && isLanguageLessPlainLiteral(lit))
|
|
||||||
|| (lang != null && lang.equals(lit.getLanguage())) ) {
|
|
||||||
if(!lit.getLexicalForm().equals(lexicalForm)) {
|
|
||||||
toRemove.add(stmt);
|
|
||||||
} else {
|
|
||||||
// New literal already exists in the model.
|
|
||||||
// Do not add it again.
|
|
||||||
addNew = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!toRemove.isEmpty()) {
|
|
||||||
ontRes.getModel().remove(toRemove);
|
|
||||||
}
|
|
||||||
if (addNew && (lexicalForm != null)) {
|
|
||||||
if(!StringUtils.isEmpty(lang)) {
|
|
||||||
ontRes.addProperty(property, ResourceFactory.createLangLiteral(
|
|
||||||
lexicalForm, lang));
|
|
||||||
} else {
|
|
||||||
ontRes.addProperty(property, ResourceFactory.createPlainLiteral(
|
|
||||||
lexicalForm));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isLanguageLessPlainLiteral(Literal lit) {
|
|
||||||
// In RDF 1.1 all the language-less literals get datatype xsd:string.
|
|
||||||
// The null datatype check is here just in case this gets run on an older
|
|
||||||
// version of Jena. rdf:PlainLiteral is also a datatype, but doesn't
|
|
||||||
// (yet) seem to be used by Jena.
|
|
||||||
return StringUtils.isEmpty(lit.getLanguage())
|
|
||||||
&& ((lit.getDatatype() == null)
|
|
||||||
|| XSDDatatype.XSDstring.equals(lit.getDatatype()) ||
|
|
||||||
(RDF.getURI() + "PlainLiteral").equals(lit.getDatatypeURI()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Literal getLabel(String lang, List<RDFNode>labelList) {
|
private Literal getLabel(String lang, List<RDFNode>labelList) {
|
||||||
|
@ -879,13 +780,6 @@ public class JenaBaseDao extends JenaBaseDaoCon {
|
||||||
}
|
}
|
||||||
if ((lang != null) && (lang.equals(labelLanguage))) {
|
if ((lang != null) && (lang.equals(labelLanguage))) {
|
||||||
return labelLit;
|
return labelLit;
|
||||||
} else
|
|
||||||
/*
|
|
||||||
* UQAM-Linguistic-Management
|
|
||||||
* Check for country-part of lang (ex: 'en' for default consideration of labelLanguage in english but not encoded by 'en-US' most case of labels in vivo.owl)
|
|
||||||
*/
|
|
||||||
if ((lang != null) && (Arrays.asList(lang.split("-")).get(0).equals(labelLanguage))) {
|
|
||||||
return labelLit;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,15 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
|
||||||
|
|
||||||
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 org.apache.jena.graph.Triple;
|
|
||||||
import org.apache.jena.ontology.Individual;
|
import org.apache.jena.ontology.Individual;
|
||||||
import org.apache.jena.ontology.OntClass;
|
import org.apache.jena.ontology.OntClass;
|
||||||
import org.apache.jena.ontology.OntModel;
|
import org.apache.jena.ontology.OntModel;
|
||||||
|
@ -23,16 +21,12 @@ import org.apache.jena.query.Query;
|
||||||
import org.apache.jena.query.QueryExecution;
|
import org.apache.jena.query.QueryExecution;
|
||||||
import org.apache.jena.query.QueryExecutionFactory;
|
import org.apache.jena.query.QueryExecutionFactory;
|
||||||
import org.apache.jena.query.QueryFactory;
|
import org.apache.jena.query.QueryFactory;
|
||||||
import org.apache.jena.query.QuerySolution;
|
|
||||||
import org.apache.jena.query.ResultSet;
|
|
||||||
import org.apache.jena.rdf.model.Model;
|
import org.apache.jena.rdf.model.Model;
|
||||||
import org.apache.jena.rdf.model.ModelFactory;
|
import org.apache.jena.rdf.model.ModelFactory;
|
||||||
import org.apache.jena.rdf.model.Property;
|
import org.apache.jena.rdf.model.Property;
|
||||||
import org.apache.jena.rdf.model.RDFNode;
|
import org.apache.jena.rdf.model.RDFNode;
|
||||||
import org.apache.jena.rdf.model.Resource;
|
import org.apache.jena.rdf.model.Resource;
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
import org.apache.jena.rdf.model.ResourceFactory;
|
||||||
import org.apache.jena.rdf.model.Statement;
|
|
||||||
import org.apache.jena.rdf.model.StmtIterator;
|
|
||||||
import org.apache.jena.shared.Lock;
|
import org.apache.jena.shared.Lock;
|
||||||
import org.apache.jena.vocabulary.OWL;
|
import org.apache.jena.vocabulary.OWL;
|
||||||
import org.apache.jena.vocabulary.RDF;
|
import org.apache.jena.vocabulary.RDF;
|
||||||
|
@ -45,8 +39,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
|
||||||
|
|
||||||
public class JenaModelUtils {
|
public class JenaModelUtils {
|
||||||
|
|
||||||
public static final String BNODE_ROOT_QUERY =
|
|
||||||
"SELECT DISTINCT ?s WHERE { ?s ?p ?o OPTIONAL { ?ss ?pp ?s } FILTER (!isBlank(?s) || !bound(?ss)) }";
|
|
||||||
private static final Log log = LogFactory.getLog(JenaModelUtils.class.getName());
|
private static final Log log = LogFactory.getLog(JenaModelUtils.class.getName());
|
||||||
|
|
||||||
private static final Set<String> nonIndividualTypeURIs ;
|
private static final Set<String> nonIndividualTypeURIs ;
|
||||||
|
@ -406,190 +398,5 @@ public class JenaModelUtils {
|
||||||
return aboxModel;
|
return aboxModel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove statements from a model by separating statements
|
|
||||||
* containing blank nodes from those that have no blank nodes.
|
|
||||||
* The blank node statements are removed by treating blank nodes as variables and
|
|
||||||
* constructing the matching subgraphs for deletion.
|
|
||||||
* The other statements are removed normally.
|
|
||||||
* @param toRemove containing statements to be removed
|
|
||||||
* @param removeFrom from which statements should be removed
|
|
||||||
*/
|
|
||||||
public static void removeWithBlankNodesAsVariables(Model toRemove, Model removeFrom) {
|
|
||||||
List<Statement> blankNodeStatements = new ArrayList<Statement>();
|
|
||||||
List<Statement> nonBlankNodeStatements = new ArrayList<Statement>();
|
|
||||||
StmtIterator stmtIt = toRemove.listStatements();
|
|
||||||
while (stmtIt.hasNext()) {
|
|
||||||
Statement stmt = stmtIt.nextStatement();
|
|
||||||
if (stmt.getSubject().isAnon() || stmt.getObject().isAnon()) {
|
|
||||||
blankNodeStatements.add(stmt);
|
|
||||||
} else {
|
|
||||||
nonBlankNodeStatements.add(stmt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!blankNodeStatements.isEmpty()) {
|
|
||||||
Model blankNodeModel = ModelFactory.createDefaultModel();
|
|
||||||
blankNodeModel.add(blankNodeStatements);
|
|
||||||
removeBlankNodesUsingSparqlConstruct(blankNodeModel, removeFrom);
|
|
||||||
}
|
|
||||||
if(!nonBlankNodeStatements.isEmpty()) {
|
|
||||||
try {
|
|
||||||
removeFrom.enterCriticalSection(Lock.WRITE);
|
|
||||||
removeFrom.remove(nonBlankNodeStatements);
|
|
||||||
} finally {
|
|
||||||
removeFrom.leaveCriticalSection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void removeBlankNodesUsingSparqlConstruct(Model blankNodeModel,
|
|
||||||
Model removeFrom) {
|
|
||||||
log.debug("blank node model size " + blankNodeModel.size());
|
|
||||||
if (blankNodeModel.size() == 1) {
|
|
||||||
log.debug("Deleting single triple with blank node: " + blankNodeModel);
|
|
||||||
log.debug("This could result in the deletion of multiple triples"
|
|
||||||
+ " if multiple blank nodes match the same triple pattern.");
|
|
||||||
}
|
|
||||||
Query rootFinderQuery = QueryFactory.create(BNODE_ROOT_QUERY);
|
|
||||||
QueryExecution qe = QueryExecutionFactory.create(rootFinderQuery, blankNodeModel);
|
|
||||||
try {
|
|
||||||
ResultSet rs = qe.execSelect();
|
|
||||||
while (rs.hasNext()) {
|
|
||||||
QuerySolution qs = rs.next();
|
|
||||||
Resource s = qs.getResource("s");
|
|
||||||
String treeFinder = makeDescribe(s);
|
|
||||||
Query treeFinderQuery = QueryFactory.create(treeFinder);
|
|
||||||
QueryExecution qee = QueryExecutionFactory.create(treeFinderQuery, blankNodeModel);
|
|
||||||
try {
|
|
||||||
Model tree = qee.execDescribe();
|
|
||||||
JenaModelUtils.removeUsingSparqlConstruct(tree, removeFrom);
|
|
||||||
} finally {
|
|
||||||
qee.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
qe.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String makeDescribe(Resource s) {
|
|
||||||
StringBuilder query = new StringBuilder("DESCRIBE <") ;
|
|
||||||
if (s.isAnon()) {
|
|
||||||
query.append("_:").append(s.getId().toString());
|
|
||||||
} else {
|
|
||||||
query.append(s.getURI());
|
|
||||||
}
|
|
||||||
query.append(">");
|
|
||||||
return query.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final boolean WHERE_CLAUSE = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove statements from a model by first constructing
|
|
||||||
* the statements to be removed with a SPARQL query that treats
|
|
||||||
* each blank node ID as a variable.
|
|
||||||
* This allows matching blank node structures to be removed even though
|
|
||||||
* the internal blank node IDs are different.
|
|
||||||
* @param toRemove containing statements to be removed
|
|
||||||
* @param removeFrom from which statements should be removed
|
|
||||||
*/
|
|
||||||
public static void removeUsingSparqlConstruct(Model toRemove, Model removeFrom) {
|
|
||||||
if(toRemove.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<Statement> stmts = toRemove.listStatements().toList();
|
|
||||||
stmts = sort(stmts);
|
|
||||||
StringBuffer queryBuff = new StringBuffer();
|
|
||||||
queryBuff.append("CONSTRUCT { \n");
|
|
||||||
addStatementPatterns(stmts, queryBuff, !WHERE_CLAUSE);
|
|
||||||
queryBuff.append("} WHERE { \n");
|
|
||||||
addStatementPatterns(stmts, queryBuff, WHERE_CLAUSE);
|
|
||||||
queryBuff.append("} \n");
|
|
||||||
String queryStr = queryBuff.toString();
|
|
||||||
log.debug(queryBuff.toString());
|
|
||||||
Query construct = QueryFactory.create(queryStr);
|
|
||||||
QueryExecution qe = QueryExecutionFactory.create(construct, removeFrom);
|
|
||||||
try {
|
|
||||||
Model constructedRemovals = qe.execConstruct();
|
|
||||||
try {
|
|
||||||
removeFrom.enterCriticalSection(Lock.WRITE);
|
|
||||||
removeFrom.remove(constructedRemovals);
|
|
||||||
} finally {
|
|
||||||
removeFrom.leaveCriticalSection();
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
qe.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<Statement> sort(List<Statement> stmts) {
|
|
||||||
List<Statement> output = new ArrayList<Statement>();
|
|
||||||
int originalSize = stmts.size();
|
|
||||||
if(originalSize == 1) {
|
|
||||||
return stmts;
|
|
||||||
}
|
|
||||||
List <Statement> remaining = stmts;
|
|
||||||
ConcurrentLinkedQueue<Resource> subjQueue = new ConcurrentLinkedQueue<Resource>();
|
|
||||||
for(Statement stmt : remaining) {
|
|
||||||
if(stmt.getSubject().isURIResource()) {
|
|
||||||
subjQueue.add(stmt.getSubject());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (subjQueue.isEmpty()) {
|
|
||||||
log.warn("No named subject in statement patterns");
|
|
||||||
return stmts;
|
|
||||||
}
|
|
||||||
while(remaining.size() > 0) {
|
|
||||||
if(subjQueue.isEmpty()) {
|
|
||||||
subjQueue.add(remaining.get(0).getSubject());
|
|
||||||
}
|
|
||||||
while(!subjQueue.isEmpty()) {
|
|
||||||
Resource subj = subjQueue.poll();
|
|
||||||
List<Statement> temp = new ArrayList<Statement>();
|
|
||||||
for (Statement stmt : remaining) {
|
|
||||||
if(stmt.getSubject().equals(subj)) {
|
|
||||||
output.add(stmt);
|
|
||||||
if (stmt.getObject().isResource()) {
|
|
||||||
subjQueue.add((Resource) stmt.getObject());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
temp.add(stmt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
remaining = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(output.size() != originalSize) {
|
|
||||||
throw new RuntimeException("original list size was " + originalSize +
|
|
||||||
" but sorted size is " + output.size());
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addStatementPatterns(List<Statement> stmts,
|
|
||||||
StringBuffer patternBuff, boolean whereClause) {
|
|
||||||
for(Statement stmt : stmts) {
|
|
||||||
Triple t = stmt.asTriple();
|
|
||||||
patternBuff.append(SparqlGraph.sparqlNodeDelete(t.getSubject(), null));
|
|
||||||
patternBuff.append(" ");
|
|
||||||
patternBuff.append(SparqlGraph.sparqlNodeDelete(t.getPredicate(), null));
|
|
||||||
patternBuff.append(" ");
|
|
||||||
patternBuff.append(SparqlGraph.sparqlNodeDelete(t.getObject(), null));
|
|
||||||
patternBuff.append(" .\n");
|
|
||||||
if (whereClause) {
|
|
||||||
if (t.getSubject().isBlank()) {
|
|
||||||
patternBuff.append(" FILTER(isBlank(").append(
|
|
||||||
SparqlGraph.sparqlNodeDelete(t.getSubject(), null)).append(")) \n");
|
|
||||||
}
|
|
||||||
if (t.getObject().isBlank()) {
|
|
||||||
patternBuff.append(" FILTER(isBlank(").append(
|
|
||||||
SparqlGraph.sparqlNodeDelete(t.getObject(), null)).append(")) \n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,6 @@ public class MenuDaoJena extends JenaBaseDao implements MenuDao {
|
||||||
return getMenu( getOntModelSelector().getDisplayModel(), url );
|
return getMenu( getOntModelSelector().getDisplayModel(), url );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public MainMenu getMainMenu( ServletRequest req, String url ) {
|
public MainMenu getMainMenu( ServletRequest req, String url ) {
|
||||||
OntModel displayModel = LanguageFilteringUtils.wrapOntModelInALanguageFilter(getOntModelSelector().getDisplayModel(), req );
|
OntModel displayModel = LanguageFilteringUtils.wrapOntModelInALanguageFilter(getOntModelSelector().getDisplayModel(), req );
|
||||||
return getMenu(displayModel, url) ;
|
return getMenu(displayModel, url) ;
|
||||||
|
|
|
@ -714,14 +714,14 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePlainLiteralValue(p, EXAMPLE_ANNOT, prop.getExample());
|
updatePropertyStringValue(p,EXAMPLE_ANNOT,prop.getExample(),getOntModel());
|
||||||
updatePlainLiteralValue(p, DESCRIPTION_ANNOT, prop.getDescription());
|
updatePropertyStringValue(p,DESCRIPTION_ANNOT,prop.getDescription(),getOntModel());
|
||||||
updatePlainLiteralValue(p, PUBLIC_DESCRIPTION_ANNOT, prop.getPublicDescription());
|
updatePropertyStringValue(p,PUBLIC_DESCRIPTION_ANNOT,prop.getPublicDescription(),getOntModel());
|
||||||
updatePropertyNonNegativeIntegerValue(p,DISPLAY_LIMIT,prop.getDomainDisplayLimitInteger(),getOntModel());
|
updatePropertyNonNegativeIntegerValue(p,DISPLAY_LIMIT,prop.getDomainDisplayLimitInteger(),getOntModel());
|
||||||
updatePropertyStringValue(p,PROPERTY_ENTITYSORTDIRECTION,prop.getDomainEntitySortDirection(),getOntModel());
|
updatePropertyStringValue(p,PROPERTY_ENTITYSORTDIRECTION,prop.getDomainEntitySortDirection(),getOntModel());
|
||||||
if (inv != null) {
|
if (inv != null) {
|
||||||
updatePlainLiteralValue(inv, EXAMPLE_ANNOT, prop.getExample());
|
updatePropertyStringValue(inv,EXAMPLE_ANNOT,prop.getExample(),getOntModel());
|
||||||
updatePlainLiteralValue(inv, DESCRIPTION_ANNOT, prop.getDescription());
|
updatePropertyStringValue(inv,DESCRIPTION_ANNOT,prop.getDescription(),getOntModel());
|
||||||
updatePropertyNonNegativeIntegerValue(inv,DISPLAY_LIMIT,prop.getRangeDisplayLimitInteger(),getOntModel());
|
updatePropertyNonNegativeIntegerValue(inv,DISPLAY_LIMIT,prop.getRangeDisplayLimitInteger(),getOntModel());
|
||||||
updatePropertyStringValue(inv,PROPERTY_ENTITYSORTDIRECTION,prop.getRangeEntitySortDirection(),getOntModel());
|
updatePropertyStringValue(inv,PROPERTY_ENTITYSORTDIRECTION,prop.getRangeEntitySortDirection(),getOntModel());
|
||||||
}
|
}
|
||||||
|
|
|
@ -813,9 +813,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao {
|
||||||
List<ObjectProperty> stragglers = getAdditionalFauxSubpropertiesForVClasses(
|
List<ObjectProperty> stragglers = getAdditionalFauxSubpropertiesForVClasses(
|
||||||
vclasses, propInsts);
|
vclasses, propInsts);
|
||||||
for (ObjectProperty op : stragglers) {
|
for (ObjectProperty op : stragglers) {
|
||||||
if (op != null) {
|
propInsts.add(makePropInst(op));
|
||||||
propInsts.add(makePropInst(op));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return propInsts;
|
return propInsts;
|
||||||
|
|
|
@ -31,7 +31,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.PropertyGroupDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
|
|
||||||
|
|
||||||
public class PropertyGroupDaoJena extends JenaBaseDao implements PropertyGroupDao {
|
public class PropertyGroupDaoJena extends JenaBaseDao implements PropertyGroupDao {
|
||||||
|
|
||||||
|
@ -143,7 +142,7 @@ public class PropertyGroupDaoJena extends JenaBaseDao implements PropertyGroupDa
|
||||||
|
|
||||||
edu.cornell.mannlib.vitro.webapp.beans.Individual groupInd =
|
edu.cornell.mannlib.vitro.webapp.beans.Individual groupInd =
|
||||||
new IndividualImpl(); // We should make a factory for these
|
new IndividualImpl(); // We should make a factory for these
|
||||||
groupInd.setNamespace(DEFAULT_NAMESPACE + "vitroPropertyGroup");
|
groupInd.setNamespace(DEFAULT_NAMESPACE+"vitroPropertyGroup");
|
||||||
groupInd.setName(group.getName());
|
groupInd.setName(group.getName());
|
||||||
groupInd.setVClassURI(PROPERTYGROUP.getURI());
|
groupInd.setVClassURI(PROPERTYGROUP.getURI());
|
||||||
groupInd.setURI(group.getURI());
|
groupInd.setURI(group.getURI());
|
||||||
|
@ -157,12 +156,8 @@ public class PropertyGroupDaoJena extends JenaBaseDao implements PropertyGroupDa
|
||||||
|
|
||||||
WebappDaoFactory wadfForURIGeneration = null;
|
WebappDaoFactory wadfForURIGeneration = null;
|
||||||
try {
|
try {
|
||||||
// Ensure that the temporary WebappDaoFactory has the same
|
wadfForURIGeneration = new WebappDaoFactoryJena(
|
||||||
// preferred languages as the main one for this DAO.
|
unionForURIGeneration);
|
||||||
WebappDaoFactoryConfig wadfConfig = new WebappDaoFactoryConfig();
|
|
||||||
wadfConfig.setPreferredLanguages(getWebappDaoFactory().getPreferredLanguages());
|
|
||||||
wadfForURIGeneration = new WebappDaoFactoryJena(new SimpleOntModelSelector(
|
|
||||||
unionForURIGeneration), wadfConfig, null);
|
|
||||||
groupURI = wadfForURIGeneration
|
groupURI = wadfForURIGeneration
|
||||||
.getIndividualDao().insertNewIndividual(groupInd);
|
.getIndividualDao().insertNewIndividual(groupInd);
|
||||||
} catch (InsertException ie) {
|
} catch (InsertException ie) {
|
||||||
|
@ -188,9 +183,11 @@ public class PropertyGroupDaoJena extends JenaBaseDao implements PropertyGroupDa
|
||||||
if (group.getPublicDescription() != null
|
if (group.getPublicDescription() != null
|
||||||
&& group.getPublicDescription().length()>0) {
|
&& group.getPublicDescription().length()>0) {
|
||||||
try {
|
try {
|
||||||
updatePlainLiteralValue(groupJenaInd, PUBLIC_DESCRIPTION_ANNOT,
|
groupJenaInd.addProperty(
|
||||||
group.getPublicDescription(), getDefaultLanguage());
|
PUBLIC_DESCRIPTION_ANNOT,
|
||||||
} catch (Exception ex) {
|
group.getPublicDescription(),
|
||||||
|
XSDDatatype.XSDstring);
|
||||||
|
} catch (Exception ex) {
|
||||||
log.error(
|
log.error(
|
||||||
"error setting public description for "
|
"error setting public description for "
|
||||||
+ groupInd.getURI());
|
+ groupInd.getURI());
|
||||||
|
@ -228,13 +225,15 @@ public class PropertyGroupDaoJena extends JenaBaseDao implements PropertyGroupDa
|
||||||
try {
|
try {
|
||||||
Individual groupInd = ontModel.getIndividual(group.getURI());
|
Individual groupInd = ontModel.getIndividual(group.getURI());
|
||||||
try {
|
try {
|
||||||
updateRDFSLabel(groupInd, group.getName(), getDefaultLanguage());
|
groupInd.setLabel(group.getName(), getDefaultLanguage());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("error updating name for "+groupInd.getURI());
|
log.error("error updating name for "+groupInd.getURI());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
updatePlainLiteralValue(groupInd, PUBLIC_DESCRIPTION_ANNOT,
|
groupInd.removeAll(PUBLIC_DESCRIPTION_ANNOT);
|
||||||
group.getPublicDescription(), getDefaultLanguage());
|
if (group.getPublicDescription()!=null && group.getPublicDescription().length()>0) {
|
||||||
|
groupInd.addProperty(PUBLIC_DESCRIPTION_ANNOT, group.getPublicDescription(), XSDDatatype.XSDstring);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Error updating public description for "+groupInd.getURI());
|
log.error("Error updating public description for "+groupInd.getURI());
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,15 +289,10 @@ public class RDFServiceGraph implements GraphWithPerform {
|
||||||
literalBuff.append("\"");
|
literalBuff.append("\"");
|
||||||
pyString(literalBuff, node.getLiteralLexicalForm());
|
pyString(literalBuff, node.getLiteralLexicalForm());
|
||||||
literalBuff.append("\"");
|
literalBuff.append("\"");
|
||||||
/*
|
if (node.getLiteralDatatypeURI() != null) {
|
||||||
* UQAM-Bug-Correction
|
|
||||||
* reversing the condition tests.
|
|
||||||
* It is important to prioritize the language typology test in order to exploit the linguistic context in testing the type of data
|
|
||||||
*/
|
|
||||||
if (!StringUtils.isEmpty(node.getLiteralLanguage())) {
|
|
||||||
literalBuff.append("@").append(node.getLiteralLanguage());
|
|
||||||
} else if (node.getLiteralDatatypeURI() != null) {
|
|
||||||
literalBuff.append("^^<").append(node.getLiteralDatatypeURI()).append(">");
|
literalBuff.append("^^<").append(node.getLiteralDatatypeURI()).append(">");
|
||||||
|
} else if (!StringUtils.isEmpty(node.getLiteralLanguage())) {
|
||||||
|
literalBuff.append("@").append(node.getLiteralLanguage());
|
||||||
}
|
}
|
||||||
return literalBuff.toString();
|
return literalBuff.toString();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
|
@ -18,6 +17,7 @@ import org.apache.jena.shared.CannotCreateException;
|
||||||
import org.apache.jena.shared.DoesNotExistException;
|
import org.apache.jena.shared.DoesNotExistException;
|
||||||
import org.apache.jena.util.iterator.ExtendedIterator;
|
import org.apache.jena.util.iterator.ExtendedIterator;
|
||||||
import org.apache.jena.util.iterator.WrappedIterator;
|
import org.apache.jena.util.iterator.WrappedIterator;
|
||||||
|
import com.ibm.icu.text.Collator;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceException;
|
||||||
|
@ -103,7 +103,7 @@ public class RDFServiceModelMaker implements ModelMaker {
|
||||||
@Override
|
@Override
|
||||||
public void removeModel(String name) {
|
public void removeModel(String name) {
|
||||||
Model m = getModel(name);
|
Model m = getModel(name);
|
||||||
m.removeAll();
|
m.removeAll(null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -232,10 +232,10 @@ public class SparqlGraph implements GraphWithPerform {
|
||||||
literalBuff.append("\"");
|
literalBuff.append("\"");
|
||||||
pyString(literalBuff, node.getLiteralLexicalForm());
|
pyString(literalBuff, node.getLiteralLexicalForm());
|
||||||
literalBuff.append("\"");
|
literalBuff.append("\"");
|
||||||
if (!StringUtils.isEmpty(node.getLiteralLanguage())) {
|
if (node.getLiteralDatatypeURI() != null) {
|
||||||
literalBuff.append("@").append(node.getLiteralLanguage());
|
|
||||||
} else if (node.getLiteralDatatypeURI() != null) {
|
|
||||||
literalBuff.append("^^<").append(node.getLiteralDatatypeURI()).append(">");
|
literalBuff.append("^^<").append(node.getLiteralDatatypeURI()).append(">");
|
||||||
|
} else if (!StringUtils.isEmpty(node.getLiteralLanguage())) {
|
||||||
|
literalBuff.append("@").append(node.getLiteralLanguage());
|
||||||
}
|
}
|
||||||
return literalBuff.toString();
|
return literalBuff.toString();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
|
|
||||||
import static java.lang.String.format;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -62,18 +60,15 @@ import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;
|
||||||
|
|
||||||
public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
|
|
||||||
protected static final Log log = LogFactory.getLog(VClassDaoJena.class);
|
protected static final Log log = LogFactory.getLog(VClassDaoJena.class);
|
||||||
private final I18nBundle i18n;
|
|
||||||
private boolean isUnderlyingStoreReasoned = false;
|
private boolean isUnderlyingStoreReasoned = false;
|
||||||
|
|
||||||
public VClassDaoJena(WebappDaoFactoryJena wadf, boolean isUnderlyingStoreReasoned) {
|
public VClassDaoJena(WebappDaoFactoryJena wadf, boolean isUnderlyingStoreReasoned) {
|
||||||
super(wadf);
|
super(wadf);
|
||||||
this.i18n = wadf.getI18nBundle();
|
|
||||||
this.isUnderlyingStoreReasoned = isUnderlyingStoreReasoned;
|
this.isUnderlyingStoreReasoned = isUnderlyingStoreReasoned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,19 +91,17 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
Restriction rest = cls.asRestriction();
|
Restriction rest = cls.asRestriction();
|
||||||
OntProperty onProperty = rest.getOnProperty();
|
OntProperty onProperty = rest.getOnProperty();
|
||||||
StringBuilder labelStr = new StringBuilder();
|
StringBuilder labelStr = new StringBuilder();
|
||||||
labelStr.append(format("%s ", i18n.text("restriction_on")))
|
labelStr.append("restriction on ").append(getLabelOrId(onProperty)).append(": ");
|
||||||
.append(getLabelOrId(onProperty))
|
|
||||||
.append(": ");
|
|
||||||
if (rest.isAllValuesFromRestriction() || rest.isSomeValuesFromRestriction()) {
|
if (rest.isAllValuesFromRestriction() || rest.isSomeValuesFromRestriction()) {
|
||||||
Resource fillerRes = null;
|
Resource fillerRes = null;
|
||||||
if (rest.isAllValuesFromRestriction()) {
|
if (rest.isAllValuesFromRestriction()) {
|
||||||
AllValuesFromRestriction avfRest = rest.asAllValuesFromRestriction();
|
AllValuesFromRestriction avfRest = rest.asAllValuesFromRestriction();
|
||||||
fillerRes = avfRest.getAllValuesFrom();
|
fillerRes = avfRest.getAllValuesFrom();
|
||||||
labelStr.append(format("%s ", i18n.text("all_values_from")));
|
labelStr.append("all values from ");
|
||||||
} else {
|
} else {
|
||||||
SomeValuesFromRestriction svfRest = rest.asSomeValuesFromRestriction();
|
SomeValuesFromRestriction svfRest = rest.asSomeValuesFromRestriction();
|
||||||
fillerRes = svfRest.getSomeValuesFrom();
|
fillerRes = svfRest.getSomeValuesFrom();
|
||||||
labelStr.append(format("%s ", i18n.text("some_values_from")));
|
labelStr.append("some values from ");
|
||||||
}
|
}
|
||||||
if (fillerRes.canAs(OntClass.class)) {
|
if (fillerRes.canAs(OntClass.class)) {
|
||||||
OntClass avf = fillerRes.as(OntClass.class);
|
OntClass avf = fillerRes.as(OntClass.class);
|
||||||
|
@ -122,7 +115,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
}
|
}
|
||||||
} else if (rest.isHasValueRestriction()) {
|
} else if (rest.isHasValueRestriction()) {
|
||||||
HasValueRestriction hvRest = rest.asHasValueRestriction();
|
HasValueRestriction hvRest = rest.asHasValueRestriction();
|
||||||
labelStr.append(format("%s ", i18n.text("has_value")));
|
labelStr.append("has value ");
|
||||||
RDFNode fillerNode = hvRest.getHasValue();
|
RDFNode fillerNode = hvRest.getHasValue();
|
||||||
try {
|
try {
|
||||||
if (fillerNode.isResource()) {
|
if (fillerNode.isResource()) {
|
||||||
|
@ -135,22 +128,22 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
}
|
}
|
||||||
} else if (rest.isMinCardinalityRestriction()) {
|
} else if (rest.isMinCardinalityRestriction()) {
|
||||||
MinCardinalityRestriction mcRest = rest.asMinCardinalityRestriction();
|
MinCardinalityRestriction mcRest = rest.asMinCardinalityRestriction();
|
||||||
labelStr.append(format("%s ", i18n.text("minimum_cardinality")));
|
labelStr.append("minimum cardinality ");
|
||||||
labelStr.append(mcRest.getMinCardinality());
|
labelStr.append(mcRest.getMinCardinality());
|
||||||
} else if (rest.isMaxCardinalityRestriction()) {
|
} else if (rest.isMaxCardinalityRestriction()) {
|
||||||
MaxCardinalityRestriction mcRest = rest.asMaxCardinalityRestriction();
|
MaxCardinalityRestriction mcRest = rest.asMaxCardinalityRestriction();
|
||||||
labelStr.append(format("%s ", i18n.text("maximum_cardinality")));
|
labelStr.append("maximum cardinality ");
|
||||||
labelStr.append(mcRest.getMaxCardinality());
|
labelStr.append(mcRest.getMaxCardinality());
|
||||||
} else if (rest.isCardinalityRestriction()) {
|
} else if (rest.isCardinalityRestriction()) {
|
||||||
CardinalityRestriction cRest = rest.asCardinalityRestriction();
|
CardinalityRestriction cRest = rest.asCardinalityRestriction();
|
||||||
labelStr.append(format("%s ", i18n.text("cardinality")));
|
labelStr.append("cardinality ");
|
||||||
labelStr.append(cRest.getCardinality());
|
labelStr.append(cRest.getCardinality());
|
||||||
}
|
}
|
||||||
return labelStr.toString();
|
return labelStr.toString();
|
||||||
} else if (isBooleanClassExpression(cls)) {
|
} else if (isBooleanClassExpression(cls)) {
|
||||||
StringBuilder labelStr = new StringBuilder("(");
|
StringBuilder labelStr = new StringBuilder("(");
|
||||||
if (cls.isComplementClass()) {
|
if (cls.isComplementClass()) {
|
||||||
labelStr.append(format("%s ", i18n.text("not")));
|
labelStr.append("not ");
|
||||||
ComplementClass ccls = cls.as(ComplementClass.class);
|
ComplementClass ccls = cls.as(ComplementClass.class);
|
||||||
labelStr.append(getLabelForClass(ccls.getOperand(), withPrefix, forPickList));
|
labelStr.append(getLabelForClass(ccls.getOperand(), withPrefix, forPickList));
|
||||||
} else if (cls.isIntersectionClass()) {
|
} else if (cls.isIntersectionClass()) {
|
||||||
|
@ -160,7 +153,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
OntClass operand = operandIt.next();
|
OntClass operand = operandIt.next();
|
||||||
labelStr.append(getLabelForClass(operand, withPrefix, forPickList));
|
labelStr.append(getLabelForClass(operand, withPrefix, forPickList));
|
||||||
if (operandIt.hasNext()) {
|
if (operandIt.hasNext()) {
|
||||||
labelStr.append(format(" %s ", i18n.text("and")));
|
labelStr.append(" and ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (cls.isUnionClass()) {
|
} else if (cls.isUnionClass()) {
|
||||||
|
@ -170,7 +163,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
OntClass operand = operandIt.next();
|
OntClass operand = operandIt.next();
|
||||||
labelStr.append(getLabelForClass(operand, withPrefix, forPickList));
|
labelStr.append(getLabelForClass(operand, withPrefix, forPickList));
|
||||||
if (operandIt.hasNext()) {
|
if (operandIt.hasNext()) {
|
||||||
labelStr.append(format(" %s ", i18n.text("or")));
|
labelStr.append(" or ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -264,7 +257,6 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
} catch (ProfileException pe) {
|
} catch (ProfileException pe) {
|
||||||
// Current language profile does not support disjointWith axioms.
|
// Current language profile does not support disjointWith axioms.
|
||||||
// We'd prefer to return an empty list instead of throwing an exception.
|
// We'd prefer to return an empty list instead of throwing an exception.
|
||||||
log.error(pe, pe);
|
|
||||||
} finally {
|
} finally {
|
||||||
getOntModel().leaveCriticalSection();
|
getOntModel().leaveCriticalSection();
|
||||||
}
|
}
|
||||||
|
@ -960,9 +952,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("error linking class "+cls.getURI()+" to class group");
|
log.error("error linking class "+cls.getURI()+" to class group");
|
||||||
}
|
}
|
||||||
updatePlainLiteralValue(ontCls, SHORTDEF, cls.getShortDef());
|
addPropertyStringValue(ontCls,SHORTDEF,cls.getShortDef(),ontModel);
|
||||||
updatePlainLiteralValue(ontCls, EXAMPLE_ANNOT, cls.getExample());
|
addPropertyStringValue(ontCls,EXAMPLE_ANNOT,cls.getExample(),ontModel);
|
||||||
updatePlainLiteralValue(ontCls, DESCRIPTION_ANNOT, cls.getDescription());
|
addPropertyStringValue(ontCls,DESCRIPTION_ANNOT,cls.getDescription(),ontModel);
|
||||||
addPropertyIntValue(ontCls,DISPLAY_LIMIT,cls.getDisplayLimit(),ontModel);
|
addPropertyIntValue(ontCls,DISPLAY_LIMIT,cls.getDisplayLimit(),ontModel);
|
||||||
addPropertyIntValue(ontCls,DISPLAY_RANK_ANNOT,cls.getDisplayRank(),ontModel);
|
addPropertyIntValue(ontCls,DISPLAY_RANK_ANNOT,cls.getDisplayRank(),ontModel);
|
||||||
|
|
||||||
|
@ -1019,9 +1011,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao {
|
||||||
if (ontCls != null) {
|
if (ontCls != null) {
|
||||||
updateRDFSLabel(ontCls, cls.getName());
|
updateRDFSLabel(ontCls, cls.getName());
|
||||||
updatePropertyResourceURIValue(ontCls,IN_CLASSGROUP,cls.getGroupURI(),ontModel);
|
updatePropertyResourceURIValue(ontCls,IN_CLASSGROUP,cls.getGroupURI(),ontModel);
|
||||||
updatePlainLiteralValue(ontCls, SHORTDEF, cls.getShortDef());
|
updatePropertyStringValue(ontCls,SHORTDEF,cls.getShortDef(),ontModel);
|
||||||
updatePlainLiteralValue(ontCls, EXAMPLE_ANNOT, cls.getExample());
|
updatePropertyStringValue(ontCls,EXAMPLE_ANNOT,cls.getExample(),ontModel);
|
||||||
updatePlainLiteralValue(ontCls, DESCRIPTION_ANNOT, cls.getDescription());
|
updatePropertyStringValue(ontCls,DESCRIPTION_ANNOT,cls.getDescription(),ontModel);
|
||||||
updatePropertyNonNegativeIntValue(ontCls,DISPLAY_LIMIT,cls.getDisplayLimit(),ontModel);
|
updatePropertyNonNegativeIntValue(ontCls,DISPLAY_LIMIT,cls.getDisplayLimit(),ontModel);
|
||||||
updatePropertyNonNegativeIntValue(ontCls,DISPLAY_RANK_ANNOT,cls.getDisplayRank(),ontModel);
|
updatePropertyNonNegativeIntValue(ontCls,DISPLAY_RANK_ANNOT,cls.getDisplayRank(),ontModel);
|
||||||
updatePropertyFloatValue(ontCls, SEARCH_BOOST_ANNOT, cls.getSearchBoost(), ontModel);
|
updatePropertyFloatValue(ontCls, SEARCH_BOOST_ANNOT, cls.getSearchBoost(), ontModel);
|
||||||
|
|
|
@ -5,12 +5,14 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ListIterator;
|
import java.util.ListIterator;
|
||||||
|
|
||||||
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 org.apache.jena.datatypes.xsd.XSDDatatype;
|
import org.apache.jena.datatypes.xsd.XSDDatatype;
|
||||||
import org.apache.jena.ontology.Individual;
|
import org.apache.jena.ontology.Individual;
|
||||||
import org.apache.jena.ontology.OntModel;
|
import org.apache.jena.ontology.OntModel;
|
||||||
|
@ -28,7 +30,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
|
|
||||||
|
|
||||||
public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao {
|
public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao {
|
||||||
|
|
||||||
|
@ -190,9 +191,9 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao {
|
||||||
edu.cornell.mannlib.vitro.webapp.beans.Individual groupInd =
|
edu.cornell.mannlib.vitro.webapp.beans.Individual groupInd =
|
||||||
new IndividualImpl(); // We should make a factory for these
|
new IndividualImpl(); // We should make a factory for these
|
||||||
groupInd.setURI(vcg.getURI());
|
groupInd.setURI(vcg.getURI());
|
||||||
groupInd.setNamespace(DEFAULT_NAMESPACE + "vitroClassGroup");
|
groupInd.setNamespace(DEFAULT_NAMESPACE+"vitroClassGroup");
|
||||||
groupInd.setVClassURI(CLASSGROUP.getURI());
|
|
||||||
groupInd.setName(vcg.getPublicName());
|
groupInd.setName(vcg.getPublicName());
|
||||||
|
groupInd.setVClassURI(CLASSGROUP.getURI());
|
||||||
|
|
||||||
String groupURI = null;
|
String groupURI = null;
|
||||||
|
|
||||||
|
@ -203,12 +204,8 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao {
|
||||||
|
|
||||||
WebappDaoFactory wadfForURIGeneration = null;
|
WebappDaoFactory wadfForURIGeneration = null;
|
||||||
try {
|
try {
|
||||||
// Ensure that the temporary WebappDaoFactory has the same
|
wadfForURIGeneration = new WebappDaoFactoryJena(
|
||||||
// preferred languages as the main one for this DAO.
|
unionForURIGeneration);
|
||||||
WebappDaoFactoryConfig wadfConfig = new WebappDaoFactoryConfig();
|
|
||||||
wadfConfig.setPreferredLanguages(getWebappDaoFactory().getPreferredLanguages());
|
|
||||||
wadfForURIGeneration = new WebappDaoFactoryJena(new SimpleOntModelSelector(
|
|
||||||
unionForURIGeneration), wadfConfig, null);
|
|
||||||
groupURI = wadfForURIGeneration
|
groupURI = wadfForURIGeneration
|
||||||
.getIndividualDao().insertNewIndividual(groupInd);
|
.getIndividualDao().insertNewIndividual(groupInd);
|
||||||
} catch (InsertException ie) {
|
} catch (InsertException ie) {
|
||||||
|
@ -279,7 +276,7 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao {
|
||||||
try {
|
try {
|
||||||
Individual groupInd = ontModel.getIndividual(vcg.getURI());
|
Individual groupInd = ontModel.getIndividual(vcg.getURI());
|
||||||
try {
|
try {
|
||||||
updateRDFSLabel(groupInd, vcg.getPublicName(), getDefaultLanguage());
|
groupInd.setLabel(vcg.getPublicName(), getDefaultLanguage());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("error updating name for "+groupInd.getURI());
|
log.error("error updating name for "+groupInd.getURI());
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,8 +50,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
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.WebappDaoFactoryConfig;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactoryConfig;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18n;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelNames;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService;
|
||||||
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel;
|
||||||
|
@ -613,10 +611,5 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public I18nBundle getI18nBundle() {
|
|
||||||
// return context based bundle for preferred locales
|
|
||||||
return I18n.bundle(config.getPreferredLocales());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,11 +132,6 @@ public class EditLiteral implements Literal {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isStmtResource() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Literal inModel(Model model) {
|
public Literal inModel(Model model) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.edit.listener.impl;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
@ -22,8 +23,7 @@ import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.BasicValidationVTwo;
|
||||||
|
|
||||||
public class IndividualDataPropertyStatementProcessor implements ChangeListener {
|
public class IndividualDataPropertyStatementProcessor implements ChangeListener {
|
||||||
|
|
||||||
private static final String LANGUAGE = "language";
|
private static final Log log = LogFactory.getLog(IndividualDataPropertyStatementProcessor.class.getName());
|
||||||
private static final Log log = LogFactory.getLog(IndividualDataPropertyStatementProcessor.class.getName());
|
|
||||||
|
|
||||||
public void doInserted(Object newObj, EditProcessObject epo) {
|
public void doInserted(Object newObj, EditProcessObject epo) {
|
||||||
processDataprops(epo);
|
processDataprops(epo);
|
||||||
|
@ -54,9 +54,6 @@ public class IndividualDataPropertyStatementProcessor implements ChangeListener
|
||||||
try {
|
try {
|
||||||
Map beanParamMap = FormUtils.beanParamMapFromString(keyArg[3]);
|
Map beanParamMap = FormUtils.beanParamMapFromString(keyArg[3]);
|
||||||
String dataPropertyURI = (String) beanParamMap.get("DatatypePropertyURI");
|
String dataPropertyURI = (String) beanParamMap.get("DatatypePropertyURI");
|
||||||
if (beanParamMap.containsKey(LANGUAGE)) {
|
|
||||||
dataPropertyStmt.setLanguage((String) beanParamMap.get(LANGUAGE));
|
|
||||||
}
|
|
||||||
if (!deletedDataPropertyURIs.contains(dataPropertyURI)) {
|
if (!deletedDataPropertyURIs.contains(dataPropertyURI)) {
|
||||||
deletedDataPropertyURIs.add(dataPropertyURI);
|
deletedDataPropertyURIs.add(dataPropertyURI);
|
||||||
dataPropertyStatementDao.deleteDataPropertyStatementsForIndividualByDataProperty(((Individual) epo.getNewBean()).getURI(), dataPropertyURI);
|
dataPropertyStatementDao.deleteDataPropertyStatementsForIndividualByDataProperty(((Individual) epo.getNewBean()).getURI(), dataPropertyURI);
|
||||||
|
|
|
@ -24,25 +24,15 @@ import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.DatatypeDaoJena;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.DatatypeDaoJena;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
|
||||||
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.i18n.I18nBundle;
|
|
||||||
|
|
||||||
public class BasicValidationVTwo {
|
public class BasicValidationVTwo {
|
||||||
|
|
||||||
public final static String REQUIRED_FIELD_EMPTY_MSG = "required_field_empty_msg";
|
|
||||||
|
|
||||||
public final static String DATA_NOT_PAST_MSG = "data_not_past_msg";
|
|
||||||
public final static String INVALID_DATE_FORM_MSG = "invalid_date_form_msg";
|
|
||||||
public final static String FILE_MUST_BE_ENTERED_MSG = "file_must_be_entered_msg";
|
|
||||||
public final static String INVALID_URL_MSG = "invalid_url_msg";
|
|
||||||
|
|
||||||
private I18nBundle i18n;
|
|
||||||
|
|
||||||
Map<String, List<String>> varsToValidations;
|
Map<String, List<String>> varsToValidations;
|
||||||
EditConfigurationVTwo editConfig;
|
EditConfigurationVTwo editConfig;
|
||||||
|
|
||||||
public BasicValidationVTwo(EditConfigurationVTwo editConfig, I18nBundle i18n){
|
public BasicValidationVTwo(EditConfigurationVTwo editConfig, MultiValueEditSubmission editSub){
|
||||||
this.editConfig = editConfig;
|
this.editConfig = editConfig;
|
||||||
this.i18n = i18n;
|
|
||||||
Map<String,List<String>> validatorsForFields = new HashMap<String,List<String>>();
|
Map<String,List<String>> validatorsForFields = new HashMap<String,List<String>>();
|
||||||
for(String fieldName: editConfig.getFields().keySet()){
|
for(String fieldName: editConfig.getFields().keySet()){
|
||||||
FieldVTwo field = editConfig.getField(fieldName);
|
FieldVTwo field = editConfig.getField(fieldName);
|
||||||
|
@ -52,9 +42,8 @@ public class BasicValidationVTwo {
|
||||||
checkValidations();
|
checkValidations();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BasicValidationVTwo(Map<String, List<String>> varsToValidations, I18nBundle i18n){
|
public BasicValidationVTwo(Map<String, List<String>> varsToValidations){
|
||||||
this.varsToValidations = varsToValidations;
|
this.varsToValidations = varsToValidations;
|
||||||
this.i18n = i18n;
|
|
||||||
checkValidations();
|
checkValidations();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +94,7 @@ public class BasicValidationVTwo {
|
||||||
//If no literals and this field was required, this is an error message
|
//If no literals and this field was required, this is an error message
|
||||||
//and can return
|
//and can return
|
||||||
if((literals == null || literals.size() == 0) && isRequiredField) {
|
if((literals == null || literals.size() == 0) && isRequiredField) {
|
||||||
errors.put(name, i18n.text(REQUIRED_FIELD_EMPTY_MSG));
|
errors.put(name, REQUIRED_FIELD_EMPTY_MSG);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//Loop through literals if literals exist
|
//Loop through literals if literals exist
|
||||||
|
@ -124,7 +113,7 @@ public class BasicValidationVTwo {
|
||||||
// incorrectly generate errors.
|
// incorrectly generate errors.
|
||||||
if (isEmpty(value)) {
|
if (isEmpty(value)) {
|
||||||
if (isRequiredField) {
|
if (isRequiredField) {
|
||||||
errors.put(name, i18n.text(REQUIRED_FIELD_EMPTY_MSG));
|
errors.put(name, REQUIRED_FIELD_EMPTY_MSG);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -165,11 +154,11 @@ public class BasicValidationVTwo {
|
||||||
private String validate(String validationType, List<FileItem> fileItems) {
|
private String validate(String validationType, List<FileItem> fileItems) {
|
||||||
if( "nonempty".equalsIgnoreCase(validationType)){
|
if( "nonempty".equalsIgnoreCase(validationType)){
|
||||||
if( fileItems == null || fileItems.size() == 0 ){
|
if( fileItems == null || fileItems.size() == 0 ){
|
||||||
return i18n.text(FILE_MUST_BE_ENTERED_MSG);
|
return "a file must be entered for this field.";
|
||||||
}else{
|
}else{
|
||||||
FileItem fileItem = fileItems.get(0);
|
FileItem fileItem = fileItems.get(0);
|
||||||
if( fileItem == null || fileItem.getName() == null || fileItem.getName().length() < 1 || fileItem.getSize() < 0){
|
if( fileItem == null || fileItem.getName() == null || fileItem.getName().length() < 1 || fileItem.getSize() < 0){
|
||||||
return i18n.text(FILE_MUST_BE_ENTERED_MSG);
|
return "a file must be entered for this field.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -185,14 +174,14 @@ public class BasicValidationVTwo {
|
||||||
// This case may be needed for validation of other field types.
|
// This case may be needed for validation of other field types.
|
||||||
if( "nonempty".equalsIgnoreCase(validationType)){
|
if( "nonempty".equalsIgnoreCase(validationType)){
|
||||||
if( isEmpty(value) )
|
if( isEmpty(value) )
|
||||||
return i18n.text(REQUIRED_FIELD_EMPTY_MSG);
|
return REQUIRED_FIELD_EMPTY_MSG;
|
||||||
}
|
}
|
||||||
// Format validation
|
// Format validation
|
||||||
else if("isDate".equalsIgnoreCase(validationType)){
|
else if("isDate".equalsIgnoreCase(validationType)){
|
||||||
if( isDate( value))
|
if( isDate( value))
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
else
|
else
|
||||||
return i18n.text(INVALID_DATE_FORM_MSG);
|
return "must be in valid date format mm/dd/yyyy.";
|
||||||
}
|
}
|
||||||
else if( validationType.indexOf("datatype:") == 0 ) {
|
else if( validationType.indexOf("datatype:") == 0 ) {
|
||||||
String datatypeURI = validationType.substring(9);
|
String datatypeURI = validationType.substring(9);
|
||||||
|
@ -205,7 +194,7 @@ public class BasicValidationVTwo {
|
||||||
} else if ("httpUrl".equalsIgnoreCase(validationType)){
|
} else if ("httpUrl".equalsIgnoreCase(validationType)){
|
||||||
//check if it has http or https, we could do more but for now this is all.
|
//check if it has http or https, we could do more but for now this is all.
|
||||||
if(! value.startsWith("http://") && ! value.startsWith("https://") ){
|
if(! value.startsWith("http://") && ! value.startsWith("https://") ){
|
||||||
return i18n.text(INVALID_URL_MSG);
|
return "This URL must start with http:// or https://";
|
||||||
}else{
|
}else{
|
||||||
return SUCCESS;
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -227,7 +216,7 @@ public class BasicValidationVTwo {
|
||||||
dayParamStr = value.substring(monthDash + 1, value.length());
|
dayParamStr = value.substring(monthDash + 1, value.length());
|
||||||
inputC.set(Integer.parseInt(yearParamStr), Integer.parseInt(monthParamStr) - 1, Integer.parseInt(dayParamStr));
|
inputC.set(Integer.parseInt(yearParamStr), Integer.parseInt(monthParamStr) - 1, Integer.parseInt(dayParamStr));
|
||||||
if(inputC.before(c)) {
|
if(inputC.before(c)) {
|
||||||
return i18n.text(DATA_NOT_PAST_MSG);
|
return this.DATE_NOT_PAST_MSG;
|
||||||
//Returning null makes the error message "field is empty" display instead
|
//Returning null makes the error message "field is empty" display instead
|
||||||
//return null;
|
//return null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -289,9 +278,14 @@ public class BasicValidationVTwo {
|
||||||
return (value == null || value.trim().length() == 0);
|
return (value == null || value.trim().length() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private static Pattern urlRX = Pattern.compile("(([a-zA-Z][0-9a-zA-Z+\\-\\.]*:)/{0,2}[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)(#[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?");
|
||||||
|
|
||||||
/** we use null to indicate success */
|
/** we use null to indicate success */
|
||||||
public final static String SUCCESS = null;
|
public final static String SUCCESS = null;
|
||||||
|
public final static String REQUIRED_FIELD_EMPTY_MSG = "This field must not be empty.";
|
||||||
|
public final static String DATE_NOT_PAST_MSG = "Please enter a future target date for publication (past dates are invalid).";
|
||||||
//public final static String MIN_FIELDS_NOT_POPULATED = "Please enter values for at least ";
|
//public final static String MIN_FIELDS_NOT_POPULATED = "Please enter values for at least ";
|
||||||
//public final static String FORM_ERROR_FIELD_ID = "formannotationerrors";
|
//public final static String FORM_ERROR_FIELD_ID = "formannotationerrors";
|
||||||
/** regex for strings like "12/31/2004" */
|
/** regex for strings like "12/31/2004" */
|
||||||
|
|
|
@ -28,7 +28,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
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.freemarker.config.FreemarkerConfiguration;
|
import edu.cornell.mannlib.vitro.webapp.freemarker.config.FreemarkerConfiguration;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
|
||||||
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess.LanguageOption;
|
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
|
|
||||||
public class EditConfigurationUtils {
|
public class EditConfigurationUtils {
|
||||||
|
@ -67,19 +66,17 @@ public class EditConfigurationUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VClass getRangeVClass(VitroRequest vreq) {
|
public static VClass getRangeVClass(VitroRequest vreq) {
|
||||||
|
// This needs a WebappDaoFactory with no filtering/RDFService
|
||||||
|
// funny business because it needs to be able to retrieve anonymous union
|
||||||
|
// classes by their "pseudo-bnode URIs".
|
||||||
|
// Someday we'll need to figure out a different way of doing this.
|
||||||
WebappDaoFactory ctxDaoFact = ModelAccess.on(
|
WebappDaoFactory ctxDaoFact = ModelAccess.on(
|
||||||
vreq.getSession().getServletContext()).getWebappDaoFactory();
|
vreq.getSession().getServletContext()).getWebappDaoFactory();
|
||||||
return ctxDaoFact.getVClassDao().getVClassByURI(getRangeUri(vreq));
|
return ctxDaoFact.getVClassDao().getVClassByURI(getRangeUri(vreq));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static VClass getLangAwardRangeVClass(VitroRequest vreq) {
|
|
||||||
// UQAM-Linguistic-Management
|
|
||||||
WebappDaoFactory vreqDaoFact = ModelAccess.on(vreq).getWebappDaoFactory(
|
|
||||||
LanguageOption.LANGUAGE_AWARE);
|
|
||||||
return vreqDaoFact.getVClassDao().getVClassByURI(getRangeUri(vreq));
|
|
||||||
}
|
|
||||||
|
|
||||||
//get individual
|
//get individual
|
||||||
|
|
||||||
public static Individual getSubjectIndividual(VitroRequest vreq) {
|
public static Individual getSubjectIndividual(VitroRequest vreq) {
|
||||||
Individual subject = null;
|
Individual subject = null;
|
||||||
String subjectUri = getSubjectUri(vreq);
|
String subjectUri = getSubjectUri(vreq);
|
||||||
|
@ -129,24 +126,12 @@ public class EditConfigurationUtils {
|
||||||
|
|
||||||
public static ObjectProperty getObjectPropertyForPredicate(VitroRequest vreq,
|
public static ObjectProperty getObjectPropertyForPredicate(VitroRequest vreq,
|
||||||
String predicateUri, String domainUri, String rangeUri) {
|
String predicateUri, String domainUri, String rangeUri) {
|
||||||
// WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
// UQAM-Linguistic-Management Use linguistic context
|
|
||||||
WebappDaoFactory wdf = ModelAccess.on(vreq).getWebappDaoFactory(LanguageOption.LANGUAGE_AWARE);
|
|
||||||
ObjectProperty objectProp = wdf.getObjectPropertyDao().getObjectPropertyByURIs(
|
ObjectProperty objectProp = wdf.getObjectPropertyDao().getObjectPropertyByURIs(
|
||||||
predicateUri, domainUri, rangeUri);
|
predicateUri, domainUri, rangeUri);
|
||||||
return objectProp;
|
return objectProp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// UQAM Use linguistic context
|
|
||||||
public static ObjectProperty getObjectPropertyForPredicateLangAware(VitroRequest vreq,
|
|
||||||
String predicateUri, String domainUri, String rangeUri) {
|
|
||||||
// WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
|
||||||
// UQAM Use linguistic context
|
|
||||||
WebappDaoFactory wdf = ModelAccess.on(vreq).getWebappDaoFactory(LanguageOption.LANGUAGE_AWARE);
|
|
||||||
ObjectProperty objectProp = wdf.getObjectPropertyDao().getObjectPropertyByURIs(
|
|
||||||
predicateUri, domainUri, rangeUri);
|
|
||||||
return objectProp;
|
|
||||||
}
|
|
||||||
public static DataProperty getDataPropertyForPredicate(VitroRequest vreq, String predicateUri) {
|
public static DataProperty getDataPropertyForPredicate(VitroRequest vreq, String predicateUri) {
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
//TODO: Check reason for employing unfiltered webapp dao factory and note if using a different version
|
//TODO: Check reason for employing unfiltered webapp dao factory and note if using a different version
|
||||||
|
@ -224,7 +209,6 @@ public class EditConfigurationUtils {
|
||||||
return (op != null && dp == null);
|
return (op != null && dp == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static boolean isVitroLabel(String predicateUri) {
|
private static boolean isVitroLabel(String predicateUri) {
|
||||||
return predicateUri.equals(VitroVocabulary.LABEL);
|
return predicateUri.equals(VitroVocabulary.LABEL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,8 +366,6 @@ public class EditN3GeneratorVTwo {
|
||||||
{
|
{
|
||||||
sbuff.append("@") ;
|
sbuff.append("@") ;
|
||||||
sbuff.append(lang) ;
|
sbuff.append(lang) ;
|
||||||
// added by UQAM to exit at this point without adding datatype
|
|
||||||
return sbuff.toString() ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format the datatype
|
// Format the datatype
|
||||||
|
|
|
@ -10,57 +10,45 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.fileupload.FileItem;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
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 org.joda.time.format.DateTimeFormat;
|
||||||
|
import org.joda.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
import org.apache.jena.rdf.model.Literal;
|
import org.apache.jena.rdf.model.Literal;
|
||||||
import org.apache.jena.rdf.model.Model;
|
import org.apache.jena.rdf.model.Model;
|
||||||
import org.apache.jena.rdf.model.ModelFactory;
|
import org.apache.jena.rdf.model.ModelFactory;
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
import org.apache.jena.rdf.model.ResourceFactory;
|
||||||
import org.apache.jena.vocabulary.XSD;
|
import org.apache.jena.vocabulary.XSD;
|
||||||
import org.apache.jena.vocabulary.RDF;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
||||||
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.i18n.I18n;
|
|
||||||
|
|
||||||
public class MultiValueEditSubmission {
|
public class MultiValueEditSubmission {
|
||||||
|
|
||||||
private static final String LABEL = "label";
|
|
||||||
|
|
||||||
String editKey;
|
String editKey;
|
||||||
|
|
||||||
private Map<String,List<Literal>> literalsFromForm ;
|
private Map<String,List<Literal>> literalsFromForm ;
|
||||||
private Map<String,List<String>> urisFromForm ;
|
private Map<String,List<String>> urisFromForm ;
|
||||||
|
|
||||||
private Map<String,String> validationErrors;
|
private Map<String,String> validationErrors;
|
||||||
private BasicValidationVTwo basicValidation;
|
private BasicValidationVTwo basicValidation;
|
||||||
|
|
||||||
|
private Map<String, List<FileItem>> filesFromForm;
|
||||||
|
|
||||||
private static Model literalCreationModel;
|
private static Model literalCreationModel;
|
||||||
|
|
||||||
private String entityToReturnTo;
|
private String entityToReturnTo;
|
||||||
private VitroRequest _vreq;
|
|
||||||
|
|
||||||
private static final String TIME_URI = XSD.time.getURI();
|
|
||||||
|
|
||||||
|
|
||||||
static{
|
static{
|
||||||
literalCreationModel = ModelFactory.createDefaultModel();
|
literalCreationModel = ModelFactory.createDefaultModel();
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
* UQAM
|
public MultiValueEditSubmission(Map<String,String[]> queryParameters, EditConfigurationVTwo editConfig){
|
||||||
* replace
|
|
||||||
* public MultiValueEditSubmission(Map<String,String[]> queryParameters, EditConfigurationVTwo editConfig)
|
|
||||||
* by this new signature
|
|
||||||
* This affect PostEditCleanupController and ProcessRdfFormController classes.
|
|
||||||
* This replacement is justified by the fact that we need a linguistic context in this class.
|
|
||||||
*/
|
|
||||||
public MultiValueEditSubmission(VitroRequest vreq, EditConfigurationVTwo editConfig){
|
|
||||||
// UQAM add this both lines
|
|
||||||
_vreq = vreq;
|
|
||||||
Map<String,String[]> queryParameters = vreq.getParameterMap();
|
|
||||||
if( editConfig == null )
|
if( editConfig == null )
|
||||||
throw new Error("EditSubmission needs an EditConfiguration");
|
throw new Error("EditSubmission needs an EditConfiguration");
|
||||||
this.editKey = editConfig.getEditKey();
|
this.editKey = editConfig.getEditKey();
|
||||||
|
@ -104,12 +92,11 @@ public class MultiValueEditSubmission {
|
||||||
processEditElementFields(editConfig,queryParameters);
|
processEditElementFields(editConfig,queryParameters);
|
||||||
//Incorporating basic validation
|
//Incorporating basic validation
|
||||||
//Validate URIS
|
//Validate URIS
|
||||||
this.basicValidation = new BasicValidationVTwo(editConfig, I18n.bundle(vreq));
|
this.basicValidation = new BasicValidationVTwo(editConfig, this);
|
||||||
Map<String,String> errors = basicValidation.validateUris( urisFromForm );
|
Map<String,String> errors = basicValidation.validateUris( urisFromForm );
|
||||||
//Validate literals and add errors to the list of existing errors
|
//Validate literals and add errors to the list of existing errors
|
||||||
errors.putAll(basicValidation.validateLiterals( literalsFromForm ));
|
errors.putAll(basicValidation.validateLiterals( literalsFromForm ));
|
||||||
// UQAM Add empty contition
|
if( errors != null ) {
|
||||||
if( errors != null && !errors.isEmpty()) {
|
|
||||||
validationErrors.putAll( errors);
|
validationErrors.putAll( errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,8 +141,9 @@ public class MultiValueEditSubmission {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* maybe this could be static */
|
/* maybe this could be static */
|
||||||
public Literal createLiteral_ORIG(String value, String datatypeUri, String lang) {
|
public Literal createLiteral(String value, String datatypeUri, String lang) {
|
||||||
if( datatypeUri != null ){
|
if( datatypeUri != null ){
|
||||||
if( "http://www.w3.org/2001/XMLSchema:anyURI".equals(datatypeUri) ){
|
if( "http://www.w3.org/2001/XMLSchema:anyURI".equals(datatypeUri) ){
|
||||||
try {
|
try {
|
||||||
|
@ -171,21 +159,12 @@ public class MultiValueEditSubmission {
|
||||||
return ResourceFactory.createPlainLiteral(value);
|
return ResourceFactory.createPlainLiteral(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* maybe this could be static */
|
private static final String DATE_TIME_URI = XSD.dateTime.getURI();
|
||||||
public Literal createLiteral(String value, String datatypeUri, String lang) {
|
private static final String DATE_URI = XSD.date.getURI();
|
||||||
if( datatypeUri != null && !datatypeUri.isEmpty() ){
|
private static final String TIME_URI = XSD.time.getURI();
|
||||||
if( XSD.anyURI.getURI().equals(datatypeUri) ){
|
|
||||||
return literalCreationModel.createTypedLiteral( value, datatypeUri);
|
private static DateTimeFormatter dformater = DateTimeFormat.forPattern("yyyy-MM-dd'T'HH:mm:00");
|
||||||
} else if ( RDF.dtLangString.getURI().equals(datatypeUri) ){
|
private static DateTimeFormatter dateFormater = DateTimeFormat.forPattern("yyyy-MM-dd");
|
||||||
if( StringUtils.isNotEmpty(lang) ) {
|
|
||||||
return ResourceFactory.createLangLiteral(value, lang);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return literalCreationModel.createTypedLiteral(value, datatypeUri);
|
|
||||||
} else if( lang != null && lang.length() > 0 )
|
|
||||||
return ResourceFactory.createLangLiteral(value, lang);
|
|
||||||
return ResourceFactory.createPlainLiteral(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String,String> getValidationErrors(){
|
public Map<String,String> getValidationErrors(){
|
||||||
return validationErrors;
|
return validationErrors;
|
||||||
|
@ -285,47 +264,12 @@ public class MultiValueEditSubmission {
|
||||||
for(String value:valueList) {
|
for(String value:valueList) {
|
||||||
value = N3EditUtils.stripInvalidXMLChars(value);
|
value = N3EditUtils.stripInvalidXMLChars(value);
|
||||||
//Add to array of literals corresponding to this variable
|
//Add to array of literals corresponding to this variable
|
||||||
/* UQAM OLD
|
|
||||||
if (!StringUtils.isEmpty(value)) {
|
if (!StringUtils.isEmpty(value)) {
|
||||||
literalsArray.add(createLiteral(
|
literalsArray.add(createLiteral(
|
||||||
value,
|
value,
|
||||||
field.getRangeDatatypeUri(),
|
field.getRangeDatatypeUri(),
|
||||||
field.getRangeLang()));
|
field.getRangeLang()));
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* UQAM Replaced by this to take the linguistic context into consideration.
|
|
||||||
*/
|
|
||||||
if (!StringUtils.isEmpty(value)) {
|
|
||||||
String rangeLang = field.getRangeLang(); //UQAM Default value
|
|
||||||
try {
|
|
||||||
if (_vreq != null ) {
|
|
||||||
// only if the request comes from the rdfsLabelGenerator the language should be used
|
|
||||||
Boolean getLabelLanguage = false;
|
|
||||||
if (!StringUtils.isBlank(editConfig.formUrl) && editConfig.formUrl.contains("RDFSLabelGenerator")) {
|
|
||||||
getLabelLanguage = true;
|
|
||||||
}
|
|
||||||
// if the language is set in the given Literal, this language-tag should be used and remain the same
|
|
||||||
// for example when you edit an label with an langauge-tag (no matter which language is selected globally)
|
|
||||||
if (getLabelLanguage && isLangSetInFirstLiteral(editConfig) )
|
|
||||||
{
|
|
||||||
rangeLang = editConfig.getLiteralsInScope().get(LABEL).get(0).getLanguage();
|
|
||||||
} else { // if the literal has no langauge-tag, use the language which is globally selected
|
|
||||||
rangeLang = _vreq.getLocale().getLanguage();
|
|
||||||
if (!_vreq.getLocale().getCountry().isEmpty()) {
|
|
||||||
rangeLang += "-" + _vreq.getLocale().getCountry();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error(e,e);
|
|
||||||
}
|
|
||||||
literalsArray.add(createLiteral(
|
|
||||||
value,
|
|
||||||
field.getRangeDatatypeUri(),
|
|
||||||
rangeLang));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
literalsFromForm.put(var, literalsArray);
|
literalsFromForm.put(var, literalsArray);
|
||||||
|
|
||||||
|
@ -333,26 +277,6 @@ public class MultiValueEditSubmission {
|
||||||
log.debug("could not find value for parameter " + var );
|
log.debug("could not find value for parameter " + var );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isLangSetInFirstLiteral(EditConfigurationVTwo editConfig) {
|
|
||||||
Map<String, List<Literal>> literalsInScope = editConfig.getLiteralsInScope();
|
|
||||||
if (!literalsInScope.containsKey(LABEL)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
List<Literal> labelLiterals = literalsInScope.get(LABEL);
|
|
||||||
if (labelLiterals == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (labelLiterals.size() == 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Literal literal = labelLiterals.get(0);
|
|
||||||
if (literal == null){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return StringUtils.isNotEmpty(literal.getLanguage());
|
|
||||||
}
|
|
||||||
//Add literal to form
|
//Add literal to form
|
||||||
//Add uri to form
|
//Add uri to form
|
||||||
public void addUriToForm(EditConfigurationVTwo editConfig, String var, String[] valuesArray) {
|
public void addUriToForm(EditConfigurationVTwo editConfig, String var, String[] valuesArray) {
|
||||||
|
|
|
@ -9,24 +9,15 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
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 org.apache.jena.datatypes.xsd.XSDDatatype;
|
|
||||||
import org.apache.jena.ontology.OntModel;
|
import org.apache.jena.ontology.OntModel;
|
||||||
import org.apache.jena.rdf.model.Literal;
|
import org.apache.jena.rdf.model.Literal;
|
||||||
import org.apache.jena.rdf.model.Model;
|
import org.apache.jena.rdf.model.Model;
|
||||||
import org.apache.jena.rdf.model.ModelFactory;
|
import org.apache.jena.rdf.model.ModelFactory;
|
||||||
import org.apache.jena.rdf.model.Property;
|
|
||||||
import org.apache.jena.rdf.model.RDFNode;
|
|
||||||
import org.apache.jena.rdf.model.Resource;
|
|
||||||
import org.apache.jena.rdf.model.ResourceFactory;
|
|
||||||
import org.apache.jena.rdf.model.Statement;
|
|
||||||
import org.apache.jena.shared.Lock;
|
import org.apache.jena.shared.Lock;
|
||||||
import org.apache.jena.vocabulary.RDF;
|
|
||||||
import org.apache.jena.vocabulary.XSD;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
|
||||||
|
@ -50,8 +41,6 @@ public class ProcessRdfForm {
|
||||||
private EditN3GeneratorVTwo populator;
|
private EditN3GeneratorVTwo populator;
|
||||||
|
|
||||||
private Map<String,String> urisForNewResources = null;
|
private Map<String,String> urisForNewResources = null;
|
||||||
private static final String langStringDatatypeUri = RDF.dtLangString.getURI();
|
|
||||||
// private VitroRequest _vreq;
|
|
||||||
/**
|
/**
|
||||||
* Construct the ProcessRdfForm object.
|
* Construct the ProcessRdfForm object.
|
||||||
*/
|
*/
|
||||||
|
@ -87,9 +76,9 @@ public class ProcessRdfForm {
|
||||||
|
|
||||||
AdditionsAndRetractions changes;
|
AdditionsAndRetractions changes;
|
||||||
if( configuration.isUpdate() ){
|
if( configuration.isUpdate() ){
|
||||||
changes = editExistingStatements(configuration, submission, vreq); //UQAM vreq for getting linguistic context
|
changes = editExistingStatements(configuration, submission);
|
||||||
} else {
|
} else {
|
||||||
changes = createNewStatements(configuration, submission, vreq ); //UQAM vreq for getting linguistic context
|
changes = createNewStatements(configuration, submission );
|
||||||
}
|
}
|
||||||
|
|
||||||
changes = getMinimalChanges(changes);
|
changes = getMinimalChanges(changes);
|
||||||
|
@ -110,15 +99,12 @@ public class ProcessRdfForm {
|
||||||
* any optional N3 is to originally configure the
|
* any optional N3 is to originally configure the
|
||||||
* configuration.setN3Optional() to be empty.
|
* configuration.setN3Optional() to be empty.
|
||||||
*
|
*
|
||||||
* UQAM add vreq for linguistic context managing
|
|
||||||
*
|
|
||||||
* @throws Exception May throw an exception if the required N3
|
* @throws Exception May throw an exception if the required N3
|
||||||
* does not parse.
|
* does not parse.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
private AdditionsAndRetractions createNewStatements(
|
private AdditionsAndRetractions createNewStatements(
|
||||||
EditConfigurationVTwo configuration,
|
EditConfigurationVTwo configuration,
|
||||||
MultiValueEditSubmission submission, VitroRequest vreq) throws Exception {
|
MultiValueEditSubmission submission) throws Exception {
|
||||||
log.debug("in createNewStatements()" );
|
log.debug("in createNewStatements()" );
|
||||||
|
|
||||||
//getN3Required and getN3Optional will return copies of the
|
//getN3Required and getN3Optional will return copies of the
|
||||||
|
@ -127,10 +113,10 @@ public class ProcessRdfForm {
|
||||||
List<String> optionalN3 = configuration.getN3Optional();
|
List<String> optionalN3 = configuration.getN3Optional();
|
||||||
|
|
||||||
/* substitute in the form values and existing values */
|
/* substitute in the form values and existing values */
|
||||||
subInValuesToN3( configuration, submission, requiredN3, optionalN3, null , null, vreq);
|
subInValuesToN3( configuration, submission, requiredN3, optionalN3, null , null);
|
||||||
|
|
||||||
/* parse N3 to RDF Models, No retractions since all of the statements are new. */
|
/* parse N3 to RDF Models, No retractions since all of the statements are new. */
|
||||||
return parseN3ToChange(requiredN3, optionalN3, null, null, vreq, null);
|
return parseN3ToChange(requiredN3, optionalN3, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for a list of N3 strings, substitute in the subject, predicate and object URIs
|
/* for a list of N3 strings, substitute in the subject, predicate and object URIs
|
||||||
|
@ -154,12 +140,10 @@ public class ProcessRdfForm {
|
||||||
* retractions are mutually diff'ed before statements are added to or
|
* retractions are mutually diff'ed before statements are added to or
|
||||||
* removed from the model. The explicit change check can cause problems in
|
* removed from the model. The explicit change check can cause problems in
|
||||||
* more complex setups, like the automatic form building in DataStaR.
|
* more complex setups, like the automatic form building in DataStaR.
|
||||||
* @param vreq For getting linguistic context
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
protected AdditionsAndRetractions editExistingStatements(
|
protected AdditionsAndRetractions editExistingStatements(
|
||||||
EditConfigurationVTwo editConfig,
|
EditConfigurationVTwo editConfig,
|
||||||
MultiValueEditSubmission submission, VitroRequest vreq) throws Exception {
|
MultiValueEditSubmission submission) throws Exception {
|
||||||
|
|
||||||
log.debug("editing an existing resource: " + editConfig.getObject() );
|
log.debug("editing an existing resource: " + editConfig.getObject() );
|
||||||
|
|
||||||
|
@ -172,18 +156,18 @@ public class ProcessRdfForm {
|
||||||
|
|
||||||
subInValuesToN3(editConfig, submission,
|
subInValuesToN3(editConfig, submission,
|
||||||
N3RequiredAssert, N3OptionalAssert,
|
N3RequiredAssert, N3OptionalAssert,
|
||||||
N3RequiredRetract, N3OptionalRetract, vreq);
|
N3RequiredRetract, N3OptionalRetract);
|
||||||
|
|
||||||
return parseN3ToChange(
|
return parseN3ToChange(
|
||||||
N3RequiredAssert,N3OptionalAssert,
|
N3RequiredAssert,N3OptionalAssert,
|
||||||
N3RequiredRetract, N3OptionalRetract, vreq, editConfig);
|
N3RequiredRetract, N3OptionalRetract);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
protected void subInValuesToN3(
|
protected void subInValuesToN3(
|
||||||
EditConfigurationVTwo editConfig, MultiValueEditSubmission submission,
|
EditConfigurationVTwo editConfig, MultiValueEditSubmission submission,
|
||||||
List<String> requiredAsserts, List<String> optionalAsserts,
|
List<String> requiredAsserts, List<String> optionalAsserts,
|
||||||
List<String> requiredRetracts, List<String> optionalRetracts, VitroRequest vreq ) throws InsertException{
|
List<String> requiredRetracts, List<String> optionalRetracts ) throws InsertException{
|
||||||
|
|
||||||
//need to substitute into the return to URL becase it may need new resource URIs
|
//need to substitute into the return to URL becase it may need new resource URIs
|
||||||
List<String> URLToReturnTo = Arrays.asList(submission.getEntityToReturnTo());
|
List<String> URLToReturnTo = Arrays.asList(submission.getEntityToReturnTo());
|
||||||
|
@ -200,41 +184,7 @@ public class ProcessRdfForm {
|
||||||
//Retractions does NOT get values from form.
|
//Retractions does NOT get values from form.
|
||||||
|
|
||||||
/* ******** Form submission Literals *********** */
|
/* ******** Form submission Literals *********** */
|
||||||
/*
|
substituteInMultiLiterals( submission.getLiteralsFromForm(), requiredAsserts, optionalAsserts, URLToReturnTo);
|
||||||
* UQAM Set all literals in the linguistic context
|
|
||||||
*/
|
|
||||||
Map<String, List<Literal>> literalsFromForm = submission.getLiteralsFromForm();
|
|
||||||
Set<String> keys = literalsFromForm.keySet();
|
|
||||||
for (String aKey : keys) {
|
|
||||||
List<Literal> literalFromForm = literalsFromForm.get(aKey);
|
|
||||||
List<Literal> newLiteralFromForm = new ArrayList<>();
|
|
||||||
for (Literal aLiteral : literalFromForm) {
|
|
||||||
if (aLiteral != null) {
|
|
||||||
String aLiteratDT = aLiteral.getDatatype().getURI();
|
|
||||||
Literal newLiteral = null;
|
|
||||||
String aText = aLiteral.getLexicalForm();
|
|
||||||
/*
|
|
||||||
* do it only if aLiteral are xstring datatype
|
|
||||||
*/
|
|
||||||
if (RDF.dtLangString.getURI().equals(aLiteratDT) && !aLiteral.getLanguage().isEmpty()) {
|
|
||||||
newLiteral = aLiteral;
|
|
||||||
}
|
|
||||||
else if ( RDF.dtLangString.getURI().equals(aLiteratDT)) {
|
|
||||||
String lang = vreq.getLocale().getLanguage();
|
|
||||||
if (!vreq.getLocale().getCountry().isEmpty()) {
|
|
||||||
lang += "-" + vreq.getLocale().getCountry();
|
|
||||||
}
|
|
||||||
newLiteral = ResourceFactory.createLangLiteral(aText, lang);
|
|
||||||
} else {
|
|
||||||
newLiteral = ResourceFactory.createTypedLiteral(aText, aLiteral.getDatatype());
|
|
||||||
}
|
|
||||||
newLiteralFromForm.add(newLiteral);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
literalsFromForm.replace(aKey, newLiteralFromForm);
|
|
||||||
}
|
|
||||||
|
|
||||||
substituteInMultiLiterals( literalsFromForm, requiredAsserts, optionalAsserts, URLToReturnTo);
|
|
||||||
logSubstitue( "Added form Literals", requiredAsserts, optionalAsserts, requiredRetracts, optionalRetracts);
|
logSubstitue( "Added form Literals", requiredAsserts, optionalAsserts, requiredRetracts, optionalRetracts);
|
||||||
//Retractions does NOT get values from form.
|
//Retractions does NOT get values from form.
|
||||||
|
|
||||||
|
@ -304,107 +254,20 @@ public class ProcessRdfForm {
|
||||||
|
|
||||||
protected AdditionsAndRetractions parseN3ToChange(
|
protected AdditionsAndRetractions parseN3ToChange(
|
||||||
List<String> requiredAdds, List<String> optionalAdds,
|
List<String> requiredAdds, List<String> optionalAdds,
|
||||||
List<String> requiredDels, List<String> optionalDels, VitroRequest vreq, EditConfigurationVTwo editConfig) throws Exception{
|
List<String> requiredDels, List<String> optionalDels) throws Exception{
|
||||||
|
|
||||||
List<Model> adds = parseN3ToRDF(requiredAdds, REQUIRED);
|
List<Model> adds = parseN3ToRDF(requiredAdds, REQUIRED);
|
||||||
adds.addAll( parseN3ToRDF(optionalAdds, OPTIONAL));
|
adds.addAll( parseN3ToRDF(optionalAdds, OPTIONAL));
|
||||||
|
|
||||||
List<Model> retracts = new ArrayList<Model>();
|
List<Model> retracts = new ArrayList<Model>();
|
||||||
if( requiredDels != null && optionalDels != null ){
|
if( requiredDels != null && optionalDels != null ){
|
||||||
String lingCxt=null;
|
retracts.addAll( parseN3ToRDF(requiredDels, REQUIRED) );
|
||||||
//UQAM Taking into account the linguistic context in retract
|
retracts.addAll( parseN3ToRDF(optionalDels, OPTIONAL) );
|
||||||
try {
|
|
||||||
// only if the request comes from the rdfsLabelGenerator the language should be used
|
|
||||||
Boolean getLabelLanguage = false;
|
|
||||||
if (!StringUtils.isBlank(editConfig.formUrl) && editConfig.formUrl.contains("RDFSLabelGenerator")) {
|
|
||||||
getLabelLanguage = true;
|
|
||||||
}
|
|
||||||
// if the language is set in the given Literal, this language-tag should be used and remain the same
|
|
||||||
// for example when you edit an label with an langauge-tag (no matter which language is selected globally)
|
|
||||||
if (editConfig != null && !StringUtils.isBlank(editConfig.getLiteralsInScope().get("label").get(0).getLanguage()) && getLabelLanguage) {
|
|
||||||
lingCxt = editConfig.getLiteralsInScope().get("label").get(0).getLanguage();
|
|
||||||
} else { // if the literal has no langauge-tag, use the language which is globally selected
|
|
||||||
lingCxt = vreq.getLocale().getLanguage();
|
|
||||||
if (!vreq.getLocale().getCountry().isEmpty()) {
|
|
||||||
lingCxt += "-" + vreq.getLocale().getCountry();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
retracts.addAll( parseN3ToRDF(requiredDels, REQUIRED, lingCxt) );
|
|
||||||
retracts.addAll( parseN3ToRDF(optionalDels, OPTIONAL, lingCxt) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AdditionsAndRetractions(adds,retracts);
|
return new AdditionsAndRetractions(adds,retracts);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Parse the n3Strings to a List of RDF Model objects.
|
|
||||||
*
|
|
||||||
* @param n3Strings N3 Strings to parse
|
|
||||||
* @param parseType if OPTIONAL, then don't throw exceptions on errors
|
|
||||||
* @param linguisticContext For Literals, Making parse only if the literal linguisticContext are same than linguisticContext parameter //UQAM
|
|
||||||
* If REQUIRED, then throw exceptions on errors.
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
protected static List<Model> parseN3ToRDF(
|
|
||||||
List<String> n3Strings, N3ParseType parseType, String linguisticContext ) throws Exception {
|
|
||||||
// Use non-linguistic version of this method if no linguisticContext is provided
|
|
||||||
if (linguisticContext == null) {
|
|
||||||
return parseN3ToRDF(n3Strings, parseType);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> errorMessages = new ArrayList<String>();
|
|
||||||
|
|
||||||
List<Model> rdfModels = new ArrayList<Model>();
|
|
||||||
for(String n3 : n3Strings){
|
|
||||||
try{
|
|
||||||
Model model = ModelFactory.createDefaultModel();
|
|
||||||
StringReader reader = new StringReader(n3);
|
|
||||||
model.read(reader, "", "N3");
|
|
||||||
List<Statement> stmts = model.listStatements().toList();
|
|
||||||
for (Iterator iterator = stmts.iterator(); iterator.hasNext();) {
|
|
||||||
Statement stmt = (Statement) iterator.next();
|
|
||||||
Resource subj = stmt.getSubject();
|
|
||||||
Property pred = stmt.getPredicate();
|
|
||||||
RDFNode obj = stmt.getObject();
|
|
||||||
if (obj.isLiteral()) {
|
|
||||||
Literal lit = obj.asLiteral();
|
|
||||||
String lang = lit.getLanguage();
|
|
||||||
if (langStringDatatypeUri.equals(lit.getDatatypeURI()) &&
|
|
||||||
! linguisticContext.equals(lang)) {
|
|
||||||
//UQAM Remove if linguisticContext != lang of the Literal
|
|
||||||
model.remove(subj, pred, obj);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
rdfModels.add( model );
|
|
||||||
}catch(Throwable t){
|
|
||||||
errorMessages.add(t.getMessage() + "\nN3: \n" + n3 + "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StringBuilder errors = new StringBuilder();
|
|
||||||
for( String errorMsg : errorMessages){
|
|
||||||
errors.append(errorMsg).append('\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !errorMessages.isEmpty() ){
|
|
||||||
if( REQUIRED.equals(parseType) ){
|
|
||||||
throw new Exception("Errors processing required N3. The EditConfiguration should " +
|
|
||||||
"be setup so that if a submission passes validation, there will not be errors " +
|
|
||||||
"in the required N3.\n" + errors );
|
|
||||||
}else if( OPTIONAL.equals(parseType) ){
|
|
||||||
log.debug("Some Optional N3 did not parse, if a optional N3 does not parse it " +
|
|
||||||
"will be ignored. This allows optional parts of a form submission to " +
|
|
||||||
"remain unfilled out and then the optional N3 does not get values subsituted in from" +
|
|
||||||
"the form submission values. It may also be the case that there are unintentional " +
|
|
||||||
"syntax errors the optional N3." );
|
|
||||||
log.debug(errors.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rdfModels;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Parse the n3Strings to a List of RDF Model objects.
|
* Parse the n3Strings to a List of RDF Model objects.
|
||||||
*
|
*
|
||||||
|
@ -616,4 +479,4 @@ public class ProcessRdfForm {
|
||||||
|
|
||||||
|
|
||||||
private static Log log = LogFactory.getLog(ProcessRdfForm.class);
|
private static Log log = LogFactory.getLog(ProcessRdfForm.class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,19 +35,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
public class RdfLiteralHash {
|
public class RdfLiteralHash {
|
||||||
|
|
||||||
private static final Log log = LogFactory.getLog(RdfLiteralHash.class.getName());
|
private static final Log log = LogFactory.getLog(RdfLiteralHash.class.getName());
|
||||||
|
|
||||||
private static final String integerPattern =
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#int$" + "|" +
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#long$" + "|" +
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#short$" + "|" +
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#unsignedByte$" + "|" +
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#unsignedShort$" + "|" +
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#unsignedInt$" + "|" +
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#unsignedLong$" + "|" +
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#nonPositiveInteger$" + "|" +
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#nonNegativeInteger$" + "|" +
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#positiveInteger$" + "|" +
|
|
||||||
"^http://www.w3.org/2001/XMLSchema#negativeInteger$";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a hash based on individual, property, literal and (lang or datatype).
|
* Make a hash based on individual, property, literal and (lang or datatype).
|
||||||
|
@ -68,11 +55,6 @@ public class RdfLiteralHash {
|
||||||
}else{
|
}else{
|
||||||
if( stmt.getDatatypeURI() != null && stmt.getDatatypeURI().trim().length() > 0){
|
if( stmt.getDatatypeURI() != null && stmt.getDatatypeURI().trim().length() > 0){
|
||||||
langOrDatatype = stmt.getDatatypeURI();
|
langOrDatatype = stmt.getDatatypeURI();
|
||||||
// TDB has a bug: if given a literal of type xsd:nonNegativeInteger, it
|
|
||||||
// stores a literal of type xsd:integer.
|
|
||||||
// Replace integer types the same way it is done in RDFServiceTDB
|
|
||||||
// TODO: remove workaround when bug is resolved
|
|
||||||
langOrDatatype = replaceIntegers(langOrDatatype);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,12 +63,7 @@ public class RdfLiteralHash {
|
||||||
log.debug("got hash " + hashMe.hashCode() + " for String '" + hashMe + "'");
|
log.debug("got hash " + hashMe.hashCode() + " for String '" + hashMe + "'");
|
||||||
return hashMe.hashCode();
|
return hashMe.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static String replaceIntegers(String predicate) {
|
|
||||||
predicate = predicate.replaceAll(integerPattern, "http://www.w3.org/2001/XMLSchema#integer");
|
|
||||||
return predicate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param stmt Data statement
|
* @param stmt Data statement
|
||||||
|
|
|
@ -7,7 +7,6 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
|
@ -41,8 +40,7 @@ public class ChildVClassesOptions implements FieldOptions {
|
||||||
public Map<String, String> getOptions(
|
public Map<String, String> getOptions(
|
||||||
EditConfigurationVTwo editConfig,
|
EditConfigurationVTwo editConfig,
|
||||||
String fieldName,
|
String fieldName,
|
||||||
WebappDaoFactory wDaoFact,
|
WebappDaoFactory wDaoFact) throws Exception{
|
||||||
I18nBundle i18n) throws Exception{
|
|
||||||
// now create an empty HashMap to populate and return
|
// now create an empty HashMap to populate and return
|
||||||
HashMap <String,String> optionsMap = new LinkedHashMap<String,String>();
|
HashMap <String,String> optionsMap = new LinkedHashMap<String,String>();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* $This file is distributed under the terms of the license in LICENSE$ */
|
/* $This file is distributed under the terms of the license in LICENSE$ */
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields;
|
package edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.fields;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -15,7 +15,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.EditConfigurationVTwo;
|
||||||
import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle;
|
|
||||||
|
|
||||||
public class ChildVClassesWithParent implements FieldOptions {
|
public class ChildVClassesWithParent implements FieldOptions {
|
||||||
|
|
||||||
|
@ -38,27 +37,27 @@ public class ChildVClassesWithParent implements FieldOptions {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Map<String, String> getOptions(
|
public Map<String, String> getOptions(
|
||||||
EditConfigurationVTwo editConfig,
|
EditConfigurationVTwo editConfig,
|
||||||
String fieldName,
|
String fieldName,
|
||||||
WebappDaoFactory wDaoFact,
|
WebappDaoFactory wDaoFact) throws Exception {
|
||||||
I18nBundle i18n) throws Exception {
|
|
||||||
HashMap <String,String> optionsMap = new LinkedHashMap<String,String>();
|
HashMap <String,String> optionsMap = new LinkedHashMap<String,String>();
|
||||||
// first test to see whether there's a default "leave blank" value specified with the literal options
|
// first test to see whether there's a default "leave blank" value specified with the literal options
|
||||||
if ( ! StringUtils.isEmpty( defaultOptionLabel ) ){
|
if ( ! StringUtils.isEmpty( defaultOptionLabel ) ){
|
||||||
optionsMap.put(LEFT_BLANK, defaultOptionLabel);
|
optionsMap.put(LEFT_BLANK, defaultOptionLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
optionsMap.put(classUri, "Other");
|
||||||
|
|
||||||
VClassDao vclassDao = wDaoFact.getVClassDao();
|
VClassDao vclassDao = wDaoFact.getVClassDao();
|
||||||
VClass rdfClass = vclassDao.getVClassByURI(classUri);
|
|
||||||
if (rdfClass != null && !OWL.Nothing.getURI().equals(classUri)) {
|
|
||||||
optionsMap.put(classUri, rdfClass.getName().trim());
|
|
||||||
}
|
|
||||||
List<String> subClassList = vclassDao.getAllSubClassURIs(classUri);
|
List<String> subClassList = vclassDao.getAllSubClassURIs(classUri);
|
||||||
if (subClassList != null && subClassList.size() > 0) {
|
if (subClassList != null && subClassList.size() > 0) {
|
||||||
for (String subClassUri : subClassList) {
|
for (String subClassUri : subClassList) {
|
||||||
rdfClass = vclassDao.getVClassByURI(subClassUri);
|
VClass subClass = vclassDao.getVClassByURI(subClassUri);
|
||||||
if (rdfClass != null && !OWL.Nothing.getURI().equals(subClassUri)) {
|
if (subClass != null && !OWL.Nothing.getURI().equals(subClassUri)) {
|
||||||
optionsMap.put(subClassUri, rdfClass.getName().trim());
|
optionsMap.put(subClassUri, subClass.getName().trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,5 +67,5 @@ public class ChildVClassesWithParent implements FieldOptions {
|
||||||
public Comparator<String[]> getCustomComparator() {
|
public Comparator<String[]> getCustomComparator() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue