Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint i18n with main #209

Merged
merged 55 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
88129af
Layer uqam updates onto master (minus trailing whitespace)
Mar 25, 2020
1cb9a1d
Update RDFServiceFactorySingle.java
nicalico Mar 27, 2020
1f7998b
Sprint i18n whitespace (#143)
VIVO-UQAM Mar 30, 2020
be6ef13
Remove blank line
nicalico Mar 30, 2020
9ae7240
Fixed indentations
nicalico Mar 30, 2020
0a2403c
Update whitespace for: TemplateProcessingHelper.java
Mar 30, 2020
771df10
Update whitespace for: RDFServiceModel.java
Mar 30, 2020
66c5025
Removed extraneous whitespaces.
matthiasluehr Apr 2, 2020
46b05bf
Tagging UQAM Comments with following tags
michel-heon Apr 2, 2020
09a6f65
Resolve compilation failures in Vitro tests
Apr 1, 2020
6fbaab8
Remove whitespace changes from SelectListGeneratorVTwo.java
Apr 9, 2020
48e8931
Add null check on field values of RDF Form (#158)
Apr 15, 2020
f502d79
Fix incorrect tool-tip in language selection dropdown (#156)
Apr 15, 2020
3804c90
Sprint i18n/lang filtering model (#159)
brianjlowe Apr 17, 2020
6e3b9d2
Remove hardcoded link label (#161)
Apr 27, 2020
413184d
Enable filtering of non-enabled i18n language files from being loaded…
May 1, 2020
abeccaf
Add i18n version of Edit page title (#157)
May 15, 2020
9c0050c
Changing ontology extensions for n3 & assigning a base IRI to each (#…
May 22, 2020
52f2d53
Update sprint-i18n with master branch (#166)
Jun 19, 2020
289b5b2
[VIVO-1839] - Use language name for selector instead of flags (#165)
gneissone Jun 22, 2020
a990bc9
Adds internationalization to the admin/sparql-query page (#167)
Jun 26, 2020
b8b219f
removed redundat files which are now available via Vitro- and VIVO-la…
dofeldsc Jun 29, 2020
4ec92fb
Making UQAM-optimization aware of https://
Jul 6, 2020
8e1c965
Add parent reference to installer/pom.xml (#174)
Jul 14, 2020
e404012
Revert non-function RDF changes (#177)
Aug 24, 2020
1609947
Ensure 'other' in Individual->Teaching->advisees->type is translated
Jun 29, 2020
0d67f11
Re-add logic from commit 7420957
gneissone Jul 20, 2020
05c3a89
[VIVO-1812] use i18n translation for validation messages (#179)
wwelling Aug 25, 2020
35375ed
added js_string at i18n strings to handle quotes properly, ticket viv…
dofeldsc Aug 26, 2020
96cd46f
[VIVO-1870] simplify and concat translation for browse by vclass (#182)
wwelling Aug 26, 2020
4f99b0a
[VIVO-1900] i18n: added empty check for getCountry, fixing bug with s…
dofeldsc Aug 27, 2020
2863d1f
[VIVO 1870] update i18n key to JavaScript mapping (#183)
wwelling Aug 28, 2020
80140a8
[VIVO-1837] get i18n bundle from WebappDaoFactoryConfig preferred loc…
wwelling Aug 28, 2020
39cafbb
Ensure that "available langs" include base langs (#185)
Sep 2, 2020
2442d6d
Ensure I18nStub is initialized before pertinent tests (#186)
Sep 4, 2020
098cf09
add additional null checks to ensure context is ready for theme chang…
wwelling Sep 4, 2020
d9f8ff9
[VIVO-1915] i18n - Adding a label with language tag through the "new"…
dofeldsc Sep 24, 2020
f341873
- replaced hard coded "or"s with i18n().or
matthiasluehr Sep 28, 2020
284bb4a
[VIVO-1925] i18n: Editing labels results in new label (#188)
dofeldsc Oct 1, 2020
f2dd7c1
Enable lang selection without need for 'available-langs.properties' (…
Oct 6, 2020
8801ad4
Reduce number of times QuerySolutions are looped in LanguageFiltering…
Nov 12, 2020
cd7a2e1
Prevent 'ProcessRdfForm.parseN3ToRDF' from using null linguisticConte…
Jan 12, 2021
45f752b
[Vivo 1918] i18n: Reload firsttime files on start-up if changed (#195)
dofeldsc Jan 14, 2021
3e8d8c0
[VIVO-1936] i18n: updated the language comment in runtime.properties
bkampe Jan 26, 2021
55b3791
ftl function to capitalize group name affording override
wwelling Jan 26, 2021
2fc0b9c
Further i18n for BasicValidationVTwo.java
gneissone Jan 27, 2021
c69e6de
Fixed DeletePropertyController.java - getting localname of property p…
matthiasluehr Jan 27, 2021
9fb24d2
Removed hardcoded time units by properties calls in dateTimeWithPreci…
nicalico Jan 28, 2021
1614563
Use i18n values for date time form (#204)
gneissone Jan 29, 2021
2b31000
VIVO-1929: patch authorizing create individual form (#206)
wwelling Feb 2, 2021
1c2d5be
Issue/vivo 1947 (#205)
brianjlowe Feb 2, 2021
73cc117
Merge branch 'main' into sprint-i18n-main
Feb 3, 2021
0653b36
Remove comments
Feb 3, 2021
2621bc4
Merge pull request #208 from awoods/sprint-i18n-main
gneissone Feb 3, 2021
1657555
Merge branch 'main' into sprint-i18n
Feb 5, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ public class RootUserPolicy implements PolicyIface {
private static final Log log = LogFactory.getLog(RootUserPolicy.class);

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_CHANGE_REQUIRED = "true";

/**
* This is the entire policy. If you are a root user, you are authorized.
Expand Down Expand Up @@ -150,10 +157,12 @@ private void createRootUser() {
ua.setEmailAddress(configuredRootUser);
ua.setFirstName("root");
ua.setLastName("user");
// UQAM Add-Feature using getRootPasswordFromConfig()
ua.setArgon2Password(Authenticator.applyArgon2iEncoding(
ROOT_USER_INITIAL_PASSWORD));
getRootPasswordFromConfig()));
ua.setMd5Password("");
ua.setPasswordChangeRequired(true);
// UQAM Add-Feature using getRootPasswdChangeRequiredFromConfig()
ua.setPasswordChangeRequired(getRootPasswdChangeRequiredFromConfig().booleanValue());
ua.setStatus(Status.ACTIVE);
ua.setRootUser(true);

Expand Down Expand Up @@ -191,7 +200,31 @@ private void complainAboutWrongRootUsers() {
ss.warning(this, "For security, "
+ "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
public void contextDestroyed(ServletContextEvent sce) {
// Nothing to destroy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ApplicationBean {
public final static int VIVO_SEARCHBOX_SIZE = 20;

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 int DEFAULT_ROOT_LOGOTYPE_WIDTH = 0;
private final static int DEFAULT_ROOT_LOGOTYPE_HEIGHT = 0;
Expand All @@ -33,6 +34,7 @@ public class ApplicationBean {
private boolean initialized = false;
private String sessionIdStr = null;
private String applicationName = DEFAULT_APPLICATION_NAME;
private String availableLangsFile = DEFAULT_APPLICATION_AVAILABLE_LANGS_FILE;

private String rootLogotypeImage = DEFAULT_ROOT_LOGOTYPE_IMAGE;
private int rootLogotypeWidth = DEFAULT_ROOT_LOGOTYPE_WIDTH;
Expand All @@ -52,6 +54,7 @@ public String toString() {
output += " initialized from DB: [" + initialized + "]\n";
output += " session id: [" + sessionIdStr + "]\n";
output += " application name: [" + applicationName + "]\n";
output += " available langs file: [" + availableLangsFile + "]\n";
output += " root logotype image: [" + rootLogotypeImage + "]\n";
output += " root logotype width: [" + rootLogotypeWidth + "]\n";
output += " root logotype height: [" + rootLogotypeHeight + "]\n";
Expand Down Expand Up @@ -177,6 +180,10 @@ public String getShortHand() {
return "";
}

public String getAvailableLangsFile() {
return availableLangsFile;
}

/**
* Directory to find the images. Subdirectories include css, jsp and site_icons.
* Example: "themes/enhanced/"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import javax.servlet.http.HttpServletRequest;
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.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -75,8 +77,8 @@ private static List<Prefix> buildDefaults() {
private static final String[] SAMPLE_QUERY = { //
"", //
"#", //
"# This example query gets 20 geographic locations", //
"# and (if available) their labels", //
"i18n:sparql_query_description_0", //
"i18n:sparql_query_description_1", //
"#", //
"SELECT ?geoLocation ?label", //
"WHERE", //
Expand Down Expand Up @@ -193,9 +195,11 @@ private void do500InternalServerError(String message, Exception e,

@Override
protected ResponseValues processRequest(VitroRequest vreq) throws Exception {
I18nBundle i18n = I18n.bundle(vreq);

Map<String, Object> bodyMap = new HashMap<>();
bodyMap.put("sampleQuery", buildSampleQuery(buildPrefixList(vreq)));
bodyMap.put("title", "SPARQL Query");
bodyMap.put("sampleQuery", buildSampleQuery(i18n, buildPrefixList(vreq)));
bodyMap.put("title", i18n.text("sparql_query_title"));
bodyMap.put("submitUrl", UrlBuilder.getUrl("admin/sparqlquery"));
return new TemplateResponseValues(TEMPLATE_NAME, bodyMap);
}
Expand All @@ -222,14 +226,18 @@ private List<Prefix> buildPrefixList(VitroRequest vreq) {
return prefixList;
}

private String buildSampleQuery(List<Prefix> prefixList) {
private String buildSampleQuery(I18nBundle i18n, List<Prefix> prefixList) {
StringWriter sw = new StringWriter();
PrintWriter writer = new PrintWriter(sw);

for (Prefix p : prefixList) {
writer.println(p);
}
for (String line : SAMPLE_QUERY) {
if (line.startsWith("i18n:")) {
// Get i18n translation
line = i18n.text(line.substring("i18n:".length()));
}
writer.println(line);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void doPost (HttpServletRequest req, HttpServletResponse response) {
action = epo.getAction();
}

VClassDao vcDao = ModelAccess.on(getServletContext()).getWebappDaoFactory().getVClassDao();
VClassDao vcDao = ModelAccess.on(request).getWebappDaoFactory().getVClassDao();
epo.setDataAccessObject(vcDao);
Classes2Classes objectForEditing = new Classes2Classes();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public void doPost (HttpServletRequest req, HttpServletResponse response) {
action = epo.getAction();
}

VClassGroupDao cgDao = ModelAccess.on(
getServletContext()).getWebappDaoFactory().getVClassGroupDao();
VClassGroupDao cgDao = ModelAccess.on(request).getWebappDaoFactory().getVClassGroupDao();

epo.setDataAccessObject(cgDao);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ public void doPost (HttpServletRequest request, HttpServletResponse response) {

//create an EditProcessObject for this and put it in the session
EditProcessObject epo = super.createEpo(request);
epo.setImplementationClass(DataProperty.class);
epo.setBeanClass(DataProperty.class);

VitroRequest vreq = new VitroRequest(request);

WebappDaoFactory wadf = ModelAccess.on(getServletContext()).getWebappDaoFactory();
WebappDaoFactory wadf = ModelAccess.on(vreq).getWebappDaoFactory();

DatatypeDao dDao = wadf.getDatatypeDao();
DataPropertyDao dpDao = wadf.getDataPropertyDao();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,16 @@ private static class EpoPopulator {

this.epo = epo;

this.fpDao = ModelAccess.on(ctx).getWebappDaoFactory()
this.fpDao = ModelAccess.on(req).getWebappDaoFactory()
.getFauxPropertyDao();

}

void populate() {
epo.setDataAccessObject(fpDao);
epo.setAction(determineAction());
epo.setImplementationClass(FauxProperty.class);
epo.setBeanClass(FauxProperty.class);

if (epo.getUseRecycledBean()) {
beanForEditing = (FauxProperty) epo.getNewBean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse response) {

if (request.getParameter("_cancel") == null) {

OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
OntModel ontModel = ModelAccess.on(req).getOntModel();
String namespaceStr = request.getParameter("namespace");
String prefixStr = request.getParameter("prefix");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void doPost (HttpServletRequest req, HttpServletResponse response) {
}

PropertyGroupDao pgDao = ModelAccess.on(
getServletContext()).getWebappDaoFactory().getPropertyGroupDao();
req).getWebappDaoFactory().getPropertyGroupDao();

epo.setDataAccessObject(pgDao);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void doPost (HttpServletRequest req, HttpServletResponse response) {

/*for testing*/
ObjectProperty testMask = new ObjectProperty();
epo.setImplementationClass(ObjectProperty.class);
epo.setBeanClass(ObjectProperty.class);
epo.setBeanMask(testMask);

Expand All @@ -64,7 +65,7 @@ public void doPost (HttpServletRequest req, HttpServletResponse response) {
action = epo.getAction();
}

ObjectPropertyDao propDao = ModelAccess.on(getServletContext()).getWebappDaoFactory().getObjectPropertyDao();
ObjectPropertyDao propDao = ModelAccess.on(req).getWebappDaoFactory().getObjectPropertyDao();
epo.setDataAccessObject(propDao);
OntologyDao ontDao = request.getUnfilteredWebappDaoFactory().getOntologyDao();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void doPost(HttpServletRequest req, HttpServletResponse response) {
String defaultLandingPage = getDefaultLandingPage(request);

try {
OntModel ontModel = ModelAccess.on(getServletContext())
OntModel ontModel = ModelAccess.on(req)
.getOntModel(TBOX_ASSERTIONS);

HashMap epoHash = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void doPost (HttpServletRequest req, HttpServletResponse response) {
EditProcessObject epo = super.createEpo(request, FORCE_NEW);
request.setAttribute("epoKey", epo.getKey());

VClassDao vcwDao = ModelAccess.on(getServletContext()).getWebappDaoFactory(ASSERTIONS_ONLY).getVClassDao();
VClassDao vcwDao = ModelAccess.on(req).getWebappDaoFactory(ASSERTIONS_ONLY).getVClassDao();
VClass vcl = (VClass)vcwDao.getVClassByURI(request.getParameter("uri"));

if (vcl == null) {
Expand Down Expand Up @@ -152,8 +152,8 @@ public void doPost (HttpServletRequest req, HttpServletResponse response) {
request.setAttribute("formSelect",formSelect);

// if supported, we want to show only the asserted superclasses and subclasses.
VClassDao vcDao = ModelAccess.on(getServletContext()).getWebappDaoFactory(ASSERTIONS_ONLY).getVClassDao();
VClassDao displayVcDao = ModelAccess.on(getServletContext()).getWebappDaoFactory().getVClassDao();
VClassDao vcDao = ModelAccess.on(req).getWebappDaoFactory(ASSERTIONS_ONLY).getVClassDao();
VClassDao displayVcDao = ModelAccess.on(req).getWebappDaoFactory().getVClassDao();

List<VClass> superVClasses = getVClassesForURIList(
vcDao.getSuperClassURIs(vcl.getURI(),false), displayVcDao);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ public void doPost (HttpServletRequest req, HttpServletResponse response) {
action = epo.getAction();
}

WebappDaoFactory wadf = ModelAccess.on(getServletContext()).getWebappDaoFactory();
WebappDaoFactory wadf = ModelAccess.on(req).getWebappDaoFactory();

VClassDao vcwDao = wadf.getVClassDao();
epo.setDataAccessObject(vcwDao);
VClassGroupDao cgDao = wadf.getVClassGroupDao();
OntologyDao oDao = wadf.getOntologyDao();

VClass vclassForEditing = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) {

VitroRequest vrequest = new VitroRequest(request);

OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
OntModel ontModel = ModelAccess.on(vrequest).getOntModel();

ArrayList results = new ArrayList();
request.setAttribute("results",results);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) {

epo = super.createEpo(request);

OntModel ontModel = ModelAccess.on(getServletContext()).getOntModel();
OntModel ontModel = ModelAccess.on(vrequest).getOntModel();

ObjectPropertyDao opDao = vrequest.getUnfilteredWebappDaoFactory().getObjectPropertyDao();
VClassDao vcDao = vrequest.getUnfilteredWebappDaoFactory().getVClassDao();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
package edu.cornell.mannlib.vitro.webapp.controller.freemarker;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -42,6 +44,8 @@ protected ResponseValues processRequest(VitroRequest vreq) {
List<VClassGroup> groups = null;
VClassGroupsForRequest vcgc = VClassGroupCache.getVClassGroups(vreq);
groups =vcgc.getGroups();
Collections.sort(groups, publicNameComparator);
// sortGroupListByPublicName(groups);
List<VClassGroupTemplateModel> vcgroups = new ArrayList<VClassGroupTemplateModel>(groups.size());
for (VClassGroup group : groups) {
vcgroups.add(new VClassGroupTemplateModel(group));
Expand All @@ -50,4 +54,35 @@ protected ResponseValues processRequest(VitroRequest vreq) {

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;
// }
// });
// }

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import org.apache.commons.logging.Log;
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.requestedAction.AuthorizationRequest;
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
Expand All @@ -25,6 +28,8 @@
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3EditUtils;
import edu.cornell.mannlib.vitro.webapp.modelaccess.ModelAccess;
import edu.cornell.mannlib.vitro.webapp.web.URLEncoder;


/*
* 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.
Expand Down Expand Up @@ -61,14 +66,14 @@ protected ResponseValues processRequest(VitroRequest vreq) {


private String getRedirectUrl(VitroRequest vreq) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
String subjectUri = EditConfigurationUtils.getSubjectUri(vreq);
String predicateUri = EditConfigurationUtils.getPredicateUri(vreq);
int hashIndex = predicateUri.lastIndexOf("#");
String localName = predicateUri.substring(hashIndex + 1);
Property prop = ResourceFactory.createProperty(predicateUri);
String localName = prop.getLocalName();
String redirectUrl = "/entity?uri=" + URLEncoder.encode(subjectUri);
return redirectUrl + "#" + URLEncoder.encode(localName);
}
return redirectUrl + "#" + URLEncoder.encode(localName);
}


private String handleErrors(VitroRequest vreq) {
Expand Down