diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/AbstractPageHandler.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/AbstractPageHandler.java index 3cb19c96d..6aab54794 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/AbstractPageHandler.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/AbstractPageHandler.java @@ -25,6 +25,8 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext; import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector; +import edu.cornell.mannlib.vitro.webapp.i18n.I18n; +import edu.cornell.mannlib.vitro.webapp.i18n.I18nBundle; /** * A base class with some utility routines for page handler (created by @@ -39,6 +41,7 @@ public abstract class AbstractPageHandler { private static final Log log = LogFactory.getLog(AbstractPageHandler.class); protected final VitroRequest vreq; + protected final I18nBundle i18n; protected final ServletContext ctx; protected final OntModel userAccountsModel; protected final OntModel unionModel; @@ -50,6 +53,7 @@ public abstract class AbstractPageHandler { protected AbstractPageHandler(VitroRequest vreq) { this.vreq = vreq; + this.i18n = I18n.bundle(vreq); this.ctx = vreq.getSession().getServletContext(); OntModelSelector oms = ModelContext.getUnionOntModelSelector(ctx); @@ -154,7 +158,8 @@ public abstract class AbstractPageHandler { private static final String ATTRIBUTE = Message.class.getName(); public static void setMessage(HttpServletRequest req, Message message) { - log.debug("Added message to session: " + message.getMessageInfoMap()); + log.debug("Added message to session: " + + message.getMessageInfoMap()); req.getSession().setAttribute(ATTRIBUTE, message); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java index 88416f911..53587eae2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/VitroRequest.java @@ -214,32 +214,14 @@ public class VitroRequest extends HttpServletRequestWrapper { } //Get the display and editing configuration model - public OntModel getDisplayModel(){ - //bdc34: I have no idea what the correct way to get this model is - - //try from the request - if( _req.getAttribute("displayOntModel") != null ){ - return (OntModel) _req.getAttribute(DISPLAY_ONT_MODEL); - - //try from the session - } else { - HttpSession session = _req.getSession(false); - if( session != null ){ - if( session.getAttribute(DISPLAY_ONT_MODEL) != null ){ - return (OntModel) session.getAttribute(DISPLAY_ONT_MODEL); - - //try from the context - }else{ - if( session.getServletContext().getAttribute(DISPLAY_ONT_MODEL) != null){ - return (OntModel)session.getServletContext().getAttribute(DISPLAY_ONT_MODEL); - } - } - } - } - - //nothing worked, could not find display model - log.error("No display model could be found."); - return null; + public OntModel getDisplayModel(){ + Object value = _req.getAttribute(DISPLAY_ONT_MODEL); + if (value instanceof OntModel) { + return (OntModel) value; + } else { + log.error("No display model on the VitroRequest. Expecting an OntModel but found " + value); + return null; + } } /** diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsAddPageStrategy.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsAddPageStrategy.java index 19b135bc3..caa52e38a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsAddPageStrategy.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsAddPageStrategy.java @@ -103,7 +103,7 @@ public abstract class UserAccountsAddPageStrategy extends UserAccountsPage { FreemarkerEmailMessage email = FreemarkerEmailFactory .createNewMessage(vreq); email.addRecipient(TO, page.getAddedAccount().getEmailAddress()); - email.setSubject("Your VIVO account has been created."); + email.setSubject(i18n.text("account_created_subject", getSiteName())); if (page.isExternalAuthOnly()) { email.setTemplate(EMAIL_TEMPLATE_NO_PASSWORD); } else { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsDeleter.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsDeleter.java index b8484715a..012b9abc6 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsDeleter.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsDeleter.java @@ -2,6 +2,8 @@ package edu.cornell.mannlib.vitro.webapp.controller.accounts.admin; +import static edu.cornell.mannlib.vitro.webapp.controller.accounts.user.UserAccountsUserController.getBogusStandardMessage; + import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -15,7 +17,6 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageRoot import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.accounts.UserAccountsPage; -import edu.cornell.mannlib.vitro.webapp.controller.accounts.user.UserAccountsUserController; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; /** @@ -51,7 +52,7 @@ public class UserAccountsDeleter extends UserAccountsPage { UserAccount loggedInAccount = LoginStatusBean.getCurrentUser(vreq); if (loggedInAccount == null) { log.warn("Trying to delete accounts while not logged in!"); - bogusMessage = UserAccountsUserController.BOGUS_STANDARD_MESSAGE; + bogusMessage = getBogusStandardMessage(vreq); return; } @@ -61,14 +62,14 @@ public class UserAccountsDeleter extends UserAccountsPage { if (u == null) { log.warn("Delete account for '" + uri + "' is bogus: no such user"); - bogusMessage = UserAccountsUserController.BOGUS_STANDARD_MESSAGE; + bogusMessage = getBogusStandardMessage(vreq); return; } if (u.getUri().equals(loggedInAccount.getUri())) { log.warn("'" + u.getUri() + "' is trying to delete his own account."); - bogusMessage = UserAccountsUserController.BOGUS_STANDARD_MESSAGE; + bogusMessage = getBogusStandardMessage(vreq); return; } @@ -78,7 +79,7 @@ public class UserAccountsDeleter extends UserAccountsPage { log.warn("Attempting to delete the root account, " + "but not authorized. Logged in as " + LoginStatusBean.getCurrentUser(vreq)); - bogusMessage = UserAccountsUserController.BOGUS_STANDARD_MESSAGE; + bogusMessage = getBogusStandardMessage(vreq); return; } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsEditPage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsEditPage.java index 0b2e81045..f13c2eab3 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsEditPage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/admin/UserAccountsEditPage.java @@ -2,6 +2,8 @@ package edu.cornell.mannlib.vitro.webapp.controller.accounts.admin; +import static edu.cornell.mannlib.vitro.webapp.controller.accounts.user.UserAccountsUserController.getBogusStandardMessage; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -20,7 +22,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration; import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.accounts.UserAccountsPage; -import edu.cornell.mannlib.vitro.webapp.controller.accounts.user.UserAccountsUserController; import edu.cornell.mannlib.vitro.webapp.controller.authenticate.Authenticator; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; @@ -116,7 +117,7 @@ public class UserAccountsEditPage extends UserAccountsPage { if (userAccount == null) { log.warn("Edit account for '" + userUri + "' is bogus: no such user"); - bogusMessage = UserAccountsUserController.BOGUS_STANDARD_MESSAGE; + bogusMessage = getBogusStandardMessage(vreq); return; } if (userAccount.isRootUser()) { @@ -125,7 +126,7 @@ public class UserAccountsEditPage extends UserAccountsPage { log.warn("User is attempting to edit the root account, " + "but is not authorized to do so. Logged in as: " + LoginStatusBean.getCurrentUser(vreq)); - bogusMessage = UserAccountsUserController.BOGUS_STANDARD_MESSAGE; + bogusMessage = getBogusStandardMessage(vreq); return; } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsCreatePasswordPage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsCreatePasswordPage.java index b227a0728..3b6585e72 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsCreatePasswordPage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsCreatePasswordPage.java @@ -46,14 +46,12 @@ public class UserAccountsCreatePasswordPage extends @Override protected String alreadyLoggedInMessage(String currentUserEmail) { - return "You may not activate the account for " + userEmail - + " while you are logged in as " + currentUserEmail - + ". Please log out and try again."; + return i18n.text("cant_activate_while_logged_in", userEmail, currentUserEmail); } @Override protected String passwordChangeNotPendingMessage() { - return "The account for " + userEmail + " has already been activated."; + return i18n.text("account_already_activated", userEmail); } @Override @@ -69,7 +67,7 @@ public class UserAccountsCreatePasswordPage extends FreemarkerEmailMessage email = FreemarkerEmailFactory .createNewMessage(vreq); email.addRecipient(TO, userAccount.getEmailAddress()); - email.setSubject("Password successfully created."); + email.setSubject(i18n.text("password_created_subject", getSiteName())); email.setTemplate(EMAIL_TEMPLATE); email.setBodyMap(body); email.processTemplate(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPage.java index 78ea1c7ec..9ac36f700 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPage.java @@ -115,18 +115,17 @@ public class UserAccountsFirstTimeExternalPage extends UserAccountsPage { private void validateExternalAuthId() { if (externalAuthId.isEmpty()) { - bogusMessage = "Login failed - External ID is not found."; + bogusMessage = i18n.text("external_id_not_provided"); return; } if (null != userAccountsDao .getUserAccountByExternalAuthId(externalAuthId)) { - bogusMessage = "User account already exists for '" + externalAuthId - + "'"; + bogusMessage = i18n.text("external_id_already_in_use", + externalAuthId); return; } if (!Authenticator.getInstance(vreq).isUserPermittedToLogin(null)) { - bogusMessage = "User logins are temporarily disabled " - + "while the system is being maintained."; + bogusMessage = i18n.text("logins_disabled_for_maintenance"); return; } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPageStrategy.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPageStrategy.java index 79ee65e1d..ca1423ad3 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPageStrategy.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsFirstTimeExternalPageStrategy.java @@ -73,7 +73,7 @@ public abstract class UserAccountsFirstTimeExternalPageStrategy extends FreemarkerEmailMessage email = FreemarkerEmailFactory .createNewMessage(vreq); email.addRecipient(TO, ua.getEmailAddress()); - email.setSubject("Your VIVO account has been created."); + email.setSubject(i18n.text("account_created_subject", getSiteName())); email.setTemplate(EMAIL_TEMPLATE); email.setBodyMap(body); email.processTemplate(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsMyAccountPageStrategy.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsMyAccountPageStrategy.java index 6d72a941e..b16094631 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsMyAccountPageStrategy.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsMyAccountPageStrategy.java @@ -178,7 +178,7 @@ public abstract class UserAccountsMyAccountPageStrategy extends FreemarkerEmailMessage email = FreemarkerEmailFactory .createNewMessage(vreq); email.addRecipient(TO, page.getUserAccount().getEmailAddress()); - email.setSubject("Your VIVO email account has been changed."); + email.setSubject(i18n.text("email_changed_subject")); email.setTemplate(EMAIL_TEMPLATE); email.setBodyMap(body); email.processTemplate(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsPasswordBasePage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsPasswordBasePage.java index 1764c9e7a..78e78ce3f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsPasswordBasePage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsPasswordBasePage.java @@ -23,8 +23,6 @@ public abstract class UserAccountsPasswordBasePage extends UserAccountsPage { private static final Log log = LogFactory .getLog(UserAccountsPasswordBasePage.class); - public static final String BOGUS_MESSAGE_NO_SUCH_ACCOUNT = "The account you are trying to set a password on is no longer available. Please contact your system administrator if you think this is an error."; - private static final String PARAMETER_SUBMIT = "submit"; private static final String PARAMETER_USER = "user"; private static final String PARAMETER_KEY = "key"; @@ -79,7 +77,7 @@ public abstract class UserAccountsPasswordBasePage extends UserAccountsPage { if (userAccount == null) { log.warn("Password request for '" + userEmail + "' is bogus: no such user"); - bogusMessage = BOGUS_MESSAGE_NO_SUCH_ACCOUNT; + bogusMessage = i18n.text("account_no_longer_exists"); return; } @@ -170,9 +168,9 @@ public abstract class UserAccountsPasswordBasePage extends UserAccountsPage { public String getSuccessMessage() { if (loggedIn) { - return "Your password has been saved."; + return i18n.text("password_saved"); } else { - return "Your password has been saved. Please log in."; + return i18n.text("password_saved_please_login"); } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsResetPasswordPage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsResetPasswordPage.java index e9b07ba36..9a42ab8c7 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsResetPasswordPage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsResetPasswordPage.java @@ -46,14 +46,13 @@ public class UserAccountsResetPasswordPage extends UserAccountsPasswordBasePage @Override protected String alreadyLoggedInMessage(String currentUserEmail) { - return "You may not reset the password for " + userEmail - + " while you are logged in as " + currentUserEmail - + ". Please log out and try again."; + return i18n.text("cant_change_password_while_logged_in", userEmail, + currentUserEmail); } @Override protected String passwordChangeNotPendingMessage() { - return "The password for " + userEmail + " has already been reset."; + return i18n.text("password_change_not_pending", userEmail); } @Override @@ -69,7 +68,7 @@ public class UserAccountsResetPasswordPage extends UserAccountsPasswordBasePage FreemarkerEmailMessage email = FreemarkerEmailFactory .createNewMessage(vreq); email.addRecipient(TO, userAccount.getEmailAddress()); - email.setSubject("Password changed."); + email.setSubject(i18n.text("password_changed_subject")); email.setTemplate(EMAIL_TEMPLATE); email.setBodyMap(body); email.processTemplate(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java index e2f7a47e6..eb2d175fe 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/user/UserAccountsUserController.java @@ -4,6 +4,8 @@ package edu.cornell.mannlib.vitro.webapp.controller.accounts.user; import static edu.cornell.mannlib.vedit.beans.LoginStatusBean.AuthenticationSource.EXTERNAL; +import javax.servlet.http.HttpServletRequest; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -18,6 +20,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.authenticate.LoginRedirector; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet; 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.i18n.I18n; /** * Parcel out the different actions required of the UserAccounts GUI. @@ -26,8 +29,6 @@ public class UserAccountsUserController extends FreemarkerHttpServlet { private static final Log log = LogFactory .getLog(UserAccountsUserController.class); - public static final String BOGUS_STANDARD_MESSAGE = "Request failed. Please contact your system administrator."; - private static final String ACTION_CREATE_PASSWORD = "/createPassword"; private static final String ACTION_RESET_PASSWORD = "/resetPassword"; private static final String ACTION_MY_ACCOUNT = "/myAccount"; @@ -116,7 +117,7 @@ public class UserAccountsUserController extends FreemarkerHttpServlet { return showLoginRedirection(vreq, page.getAfterLoginUrl()); } catch (LoginNotPermitted e) { // This should have been anticipated by the page. - return showHomePage(vreq, BOGUS_STANDARD_MESSAGE); + return showHomePage(vreq, getBogusStandardMessage(vreq)); } } else { return page.showPage(); @@ -124,7 +125,7 @@ public class UserAccountsUserController extends FreemarkerHttpServlet { } private ResponseValues handleInvalidRequest(VitroRequest vreq) { - return showHomePage(vreq, BOGUS_STANDARD_MESSAGE); + return showHomePage(vreq, getBogusStandardMessage(vreq)); } private ResponseValues showHomePage(VitroRequest vreq, String message) { @@ -159,4 +160,8 @@ public class UserAccountsUserController extends FreemarkerHttpServlet { } return uri; } + + public static String getBogusStandardMessage(HttpServletRequest req) { + return I18n.bundle(req).text("request_failed"); + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java index 6dfa102d7..22aaaa804 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/HomePageController.java @@ -9,6 +9,7 @@ import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +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.ResponseValues; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; @@ -48,6 +49,7 @@ public class HomePageController extends FreemarkerHttpServlet { } }*/ body.put("dataServiceUrlVClassesForVClassGroup", UrlBuilder.getUrl("/dataservice?getVClassesForVClassGroup=1&classgroupUri=")); + body.put("geoFocusMapsEnabled", getGeoFocusMapsFlag(vreq)); return new TemplateResponseValues(BODY_TEMPLATE, body); } @@ -61,4 +63,11 @@ public class HomePageController extends FreemarkerHttpServlet { protected String getPageTemplateName() { return PAGE_TEMPLATE; } + + private boolean getGeoFocusMapsFlag(VitroRequest vreq) { + String property = ConfigurationProperties.getBean(vreq).getProperty( + "homePage.geoFocusMaps"); + return "enabled".equals(property); + } + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadController.java index 842a6201d..dcbe01f07 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadController.java @@ -36,6 +36,7 @@ import edu.cornell.mannlib.vitro.webapp.filestorage.backend.FileStorageSetup; import edu.cornell.mannlib.vitro.webapp.filestorage.model.FileInfo; import edu.cornell.mannlib.vitro.webapp.filestorage.model.ImageInfo; import edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest.FileUploadServletRequest; +import edu.cornell.mannlib.vitro.webapp.i18n.I18n; import edu.cornell.mannlib.vitro.webapp.web.images.PlaceholderUtil; /** @@ -48,6 +49,9 @@ public class ImageUploadController extends FreemarkerHttpServlet { private static final String ATTRIBUTE_REFERRING_PAGE = "ImageUploadController.referringPage"; + private static final String ERROR_CODE_UNRECOGNIZED_URI = "imageUpload.errorUnrecognizedURI"; + private static final String ERROR_CODE_NO_URI = "imageUpload.errorNoURI"; + /** Limit file size to 6 megabytes. */ public static final int MAXIMUM_FILE_SIZE = 6 * 1024 * 1024; @@ -97,6 +101,14 @@ public class ImageUploadController extends FreemarkerHttpServlet { private static final String URL_HERE = UrlBuilder.getUrl("/uploadImages"); + private static final String TEXT_BUNDLE = "imageUpload"; + private static final String TEXT_STRING_UPLOAD_TITLE = "upload_page_title"; + private static final String TEXT_STRING_UPLOAD_TITLE_WITH_NAME = "upload_page_title_with_name"; + private static final String TEXT_STRING_REPLACE_TITLE = "replace_page_title"; + private static final String TEXT_STRING_REPLACE_TITLE_WITH_NAME = "replace_page_title_with_name"; + private static final String TEXT_STRING_CROP_TITLE = "crop_page_title"; + private static final String TEXT_STRING_CROP_TITLE_WITH_NAME = "crop_page_title_with_name"; + private FileStorage fileStorage; /** @@ -218,7 +230,7 @@ public class ImageUploadController extends FreemarkerHttpServlet { } } catch (UserMistakeException e) { // Can't find the entity? Complain. - return showAddImagePageWithError(vreq, null, e.getMessage()); + return showAddImagePageWithError(vreq, null, e.formatMessage(vreq)); } catch (Exception e) { // We weren't expecting this - log it, and apologize to the user. return new ExceptionResponseValues(e); @@ -274,7 +286,7 @@ public class ImageUploadController extends FreemarkerHttpServlet { return showCropImagePage(vreq, entity, fileInfo.getBytestreamAliasUrl(), size); } catch (UserMistakeException e) { - return showErrorMessage(vreq, entity, e.getMessage()); + return showErrorMessage(vreq, entity, e.formatMessage(vreq)); } } @@ -284,6 +296,7 @@ public class ImageUploadController extends FreemarkerHttpServlet { */ private ResponseValues showErrorMessage(VitroRequest vreq, Individual entity, String message) { + ImageInfo imageInfo = ImageInfo.instanceFromEntityUri( vreq.getFullWebappDaoFactory(), entity); if (imageInfo == null) { @@ -313,7 +326,7 @@ public class ImageUploadController extends FreemarkerHttpServlet { return showExitPage(vreq, entity); } catch (UserMistakeException e) { - return showErrorMessage(vreq, entity, e.getMessage()); + return showErrorMessage(vreq, entity, e.formatMessage(vreq)); } } @@ -350,15 +363,14 @@ public class ImageUploadController extends FreemarkerHttpServlet { throws UserMistakeException { String entityUri = vreq.getParameter(PARAMETER_ENTITY_URI); if (entityUri == null) { - throw new UserMistakeException("No entity URI was provided"); + throw new UserMistakeException(ERROR_CODE_NO_URI); } Individual entity = vreq.getFullWebappDaoFactory().getIndividualDao() .getIndividualByURI(entityUri); if (entity == null) { - throw new UserMistakeException( - "This URI is not recognized as belonging to anyone: '" - + entityUri + "'"); + throw new UserMistakeException(ERROR_CODE_UNRECOGNIZED_URI, + entityUri); } return entity; } @@ -416,7 +428,7 @@ public class ImageUploadController extends FreemarkerHttpServlet { rv.put(BODY_THUMBNAIL_URL, placeholderUrl); rv.put(BODY_FORM_ACTION, formAction); rv.put(BODY_CANCEL_URL, cancelUrl); - rv.put(BODY_TITLE, "Upload image" + forName(entity)); + rv.put(BODY_TITLE, figureUploadPageTitle(vreq, entity)); rv.put(BODY_MAX_FILE_SIZE, MAXIMUM_FILE_SIZE / (1024 * 1024)); rv.put(BODY_THUMBNAIL_HEIGHT, THUMBNAIL_HEIGHT); rv.put(BODY_THUMBNAIL_WIDTH, THUMBNAIL_WIDTH); @@ -442,7 +454,7 @@ public class ImageUploadController extends FreemarkerHttpServlet { rv.put(BODY_DELETE_URL, formAction(entity.getURI(), ACTION_DELETE_EDIT)); rv.put(BODY_FORM_ACTION, formAction(entity.getURI(), ACTION_UPLOAD)); rv.put(BODY_CANCEL_URL, exitPageUrl(vreq, entity.getURI())); - rv.put(BODY_TITLE, "Replace image" + forName(entity)); + rv.put(BODY_TITLE, figureReplacePageTitle(vreq, entity)); rv.put(BODY_MAX_FILE_SIZE, MAXIMUM_FILE_SIZE / (1024 * 1024)); rv.put(BODY_THUMBNAIL_HEIGHT, THUMBNAIL_HEIGHT); rv.put(BODY_THUMBNAIL_WIDTH, THUMBNAIL_WIDTH); @@ -472,7 +484,7 @@ public class ImageUploadController extends FreemarkerHttpServlet { rv.put(BODY_MAIN_IMAGE_WIDTH, dimensions.width); rv.put(BODY_FORM_ACTION, formAction(entity.getURI(), ACTION_SAVE)); rv.put(BODY_CANCEL_URL, exitPageUrl(vreq, entity.getURI())); - rv.put(BODY_TITLE, "Crop Photo" + forName(entity)); + rv.put(BODY_TITLE, figureCropPageTitle(vreq, entity)); return rv; } @@ -522,24 +534,59 @@ public class ImageUploadController extends FreemarkerHttpServlet { } /** - * Format the entity's name for display as part of the page title. + * Format the title for the Upload page. */ - private String forName(Individual entity) { + private String figureUploadPageTitle(HttpServletRequest req, + Individual entity) { + return figurePageTitle(req, entity, TEXT_STRING_UPLOAD_TITLE, + TEXT_STRING_UPLOAD_TITLE_WITH_NAME); + } + + /** + * Format the title for the Replace page. + */ + private String figureReplacePageTitle(HttpServletRequest req, + Individual entity) { + return figurePageTitle(req, entity, TEXT_STRING_REPLACE_TITLE, + TEXT_STRING_REPLACE_TITLE_WITH_NAME); + } + + /** + * Format the title for the Crop page. + */ + private String figureCropPageTitle(HttpServletRequest req, Individual entity) { + return figurePageTitle(req, entity, TEXT_STRING_CROP_TITLE, + TEXT_STRING_CROP_TITLE_WITH_NAME); + } + + /** + * Format one of two page titles, depending on whether the entity has a + * name. + */ + private String figurePageTitle(HttpServletRequest req, Individual entity, + String noNameTitleKey, String nameTitleKey) { if (entity != null) { String name = entity.getName(); if (name != null) { - return " for " + name; + return I18n.text(req, TEXT_BUNDLE, nameTitleKey, name); } } - return ""; + return I18n.text(req, TEXT_BUNDLE, noNameTitleKey); } /** * Holds an error message to use as a complaint to the user. */ static class UserMistakeException extends Exception { - UserMistakeException(String message) { + private final Object[] parameters; + + UserMistakeException(String message, Object... parameters) { super(message); + this.parameters = parameters; + } + + public String formatMessage(HttpServletRequest req) { + return I18n.text(req, getMessage(), parameters); } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadHelper.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadHelper.java index 656a0f0a7..e0052b7bd 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadHelper.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/ImageUploadHelper.java @@ -49,6 +49,18 @@ import edu.cornell.mannlib.vitro.webapp.filestorage.uploadrequest.FileUploadServ public class ImageUploadHelper { private static final Log log = LogFactory.getLog(ImageUploadHelper.class); + /* + * Keys to text strings for error messages. + */ + private static final String ERROR_CODE_NO_IMAGE_TO_CROP = "imageUpload.errorNoImageForCropping"; + private static final String ERROR_CODE_IMAGE_TOO_SMALL = "imageUpload.errorImageTooSmall"; + private static final String ERROR_CODE_UNKNOWN = "imageUpload.errorUnknown"; + private static final String ERROR_CODE_FILE_TOO_BIG = "imageUpload.errorFileTooBig"; + private static final String ERROR_CODE_UNRECOGNIZED_FILE_TYPE = "imageUpload.errorUnrecognizedFileType"; + private static final String ERROR_CODE_NO_PHOTO_SELECTED = "imageUpload.errorNoPhotoSelected"; + private static final String ERROR_CODE_BAD_MULTIPART_REQUEST = "imageUpload.errorBadMultipartRequest"; + private static final String ERROR_CODE_FORM_FIELD_MISSING = "imageUpload.errorFormFieldMissing"; + /** * When they upload a new image, store it as this session attribute until * we're ready to attach it to the Individual. @@ -127,35 +139,31 @@ public class ImageUploadHelper { Object exception = request.getAttribute(FILE_UPLOAD_EXCEPTION); if (exception != null) { int limit = MAXIMUM_FILE_SIZE / (1024 * 1024); - throw new UserMistakeException( - "Please upload an image smaller than " + limit - + " megabytes"); + throw new UserMistakeException(ERROR_CODE_FILE_TOO_BIG, limit); } Map> map = (Map>) request .getAttribute(FILE_ITEM_MAP); if (map == null) { - throw new IllegalStateException("Failed to parse the " - + "multi-part request for uploading an image."); + throw new IllegalStateException(ERROR_CODE_BAD_MULTIPART_REQUEST); } List list = map.get(PARAMETER_UPLOADED_FILE); if ((list == null) || list.isEmpty()) { - throw new UserMistakeException("The form did not contain a '" - + PARAMETER_UPLOADED_FILE + "' field."); + throw new UserMistakeException(ERROR_CODE_FORM_FIELD_MISSING, + PARAMETER_UPLOADED_FILE); } FileItem file = list.get(0); if (file.getSize() == 0) { - throw new UserMistakeException("Please browse and select a photo."); + throw new UserMistakeException(ERROR_CODE_NO_PHOTO_SELECTED); } String filename = getSimpleFilename(file); String mimeType = getMimeType(file); if (!RECOGNIZED_FILE_TYPES.containsValue(mimeType)) { log.debug("Unrecognized MIME type: '" + mimeType + "'"); - throw new UserMistakeException("'" + filename - + "' is not a recognized image file type. " - + "Please upload JPEG, GIF, or PNG files only."); + throw new UserMistakeException(ERROR_CODE_UNRECOGNIZED_FILE_TYPE, + filename); } return file; @@ -221,10 +229,8 @@ public class ImageUploadHelper { if ((size.height < THUMBNAIL_HEIGHT) || (size.width < THUMBNAIL_WIDTH)) { - throw new UserMistakeException( - "The uploaded image should be at least " - + THUMBNAIL_HEIGHT + " pixels high and " - + THUMBNAIL_WIDTH + " pixels wide."); + throw new UserMistakeException(ERROR_CODE_IMAGE_TOO_SMALL, + THUMBNAIL_HEIGHT, THUMBNAIL_WIDTH); } return size; @@ -237,8 +243,7 @@ public class ImageUploadHelper { throw e; } catch (Exception e) { log.warn("Unexpected exception in image handling", e); - throw new UserMistakeException("Sorry, we were unable to process " - + "the photo you provided. Please try another photo."); + throw new UserMistakeException(ERROR_CODE_UNKNOWN); } finally { if (source != null) { try { @@ -261,8 +266,7 @@ public class ImageUploadHelper { ATTRIBUTE_TEMP_FILE); if (fileInfo == null) { - throw new UserMistakeException( - "There is no image file to be cropped."); + throw new UserMistakeException(ERROR_CODE_NO_IMAGE_TO_CROP); } return fileInfo; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java index 77f1cc601..54b295e6d 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java @@ -182,8 +182,19 @@ public class IndividualListController extends FreemarkerHttpServlet { } return rvMap; } - + public static Map getRandomResultsForVClass(String vclassURI, int page, int pageSize, IndividualDao indDao, ServletContext context) { + Map rvMap = new HashMap(); + try{ + List classUris = Collections.singletonList(vclassURI); + IndividualListQueryResults results = SolrQueryUtils.buildAndExecuteRandomVClassQuery(classUris, page, pageSize, context, indDao); + rvMap = getResultsForVClassQuery(results, page, pageSize, ""); + } catch(Throwable th) { + log.error("An error occurred retrieving random results for vclass query", th); + } + return rvMap; + } + //TODO: Get rid of this method and utilize SolrQueryUtils - currently appears to be referenced //only within DataGetterUtils public static long getIndividualCount(List vclassUris, IndividualDao indDao, ServletContext context) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/NavigationController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/NavigationController.java deleted file mode 100644 index 21b96f5eb..000000000 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/NavigationController.java +++ /dev/null @@ -1,216 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.webapp.controller.freemarker; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import com.hp.hpl.jena.ontology.Individual; -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.rdf.listeners.StatementListener; -import com.hp.hpl.jena.rdf.model.Literal; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.NodeIterator; -import com.hp.hpl.jena.rdf.model.RDFNode; -import com.hp.hpl.jena.rdf.model.Resource; -import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.rdf.model.StmtIterator; - -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 edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; -import freemarker.template.Configuration; -import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.DISPLAY_ONT_MODEL; - -public class NavigationController extends FreemarkerHttpServlet { - private static final long serialVersionUID = 1L; - private static final Log log = LogFactory.getLog(NavigationController.class.getName()); - - //private Map urlPatternToURI; - private NavigationURLPatternListener urlPatterns; - - @Override - public void init(ServletConfig config) throws ServletException { - super.init(config); - OntModel displayOntModel = (OntModel)config.getServletContext().getAttribute(DISPLAY_ONT_MODEL); - this.urlPatterns = new NavigationURLPatternListener( ); - displayOntModel.getBaseModel().register( urlPatterns ); - } - - @Override - protected ResponseValues processRequest(VitroRequest vreq) { - OntModel displayOntModel = (OntModel)getServletContext().getAttribute(DISPLAY_ONT_MODEL); - OntModel jenaOntModel = (OntModel)getServletContext().getAttribute("jenaOntModel"); - - //figure out what is being requested - Individual ind = urlPatterns.getDisplayIndividual(vreq.getPathInfo(),displayOntModel); - Map values = getValues(ind, displayOntModel,jenaOntModel, getValuesFromRequest(/*?*/) ); - String template = getTemplate(ind, displayOntModel); - - return new TemplateResponseValues(template, values); - } - - private MapgetValuesFromRequest(){ - // TODO: figure out how to get request for FreeMarkerHttpServlet. - return Collections.emptyMap(); - } - - private String getTemplate(Individual ind, OntModel displayOntModel) { - if( ind == null ) return "defaultBody"; - - // check vitroDisplay:requiresBodyTemplate - displayOntModel.enterCriticalSection(Model.READ); - StmtIterator it = displayOntModel.listStatements(ind, DisplayVocabulary.REQUIRES_BODY_TEMPLATE, (RDFNode) null); - //NodeIterator it = ind.listPropertyValues(DisplayVocabulary.REQUIRES_BODY_TEMPLATE); - try{ - while(it.hasNext()){ - Statement stmt = it.nextStatement(); - if( stmt.getObject().isLiteral() ){ - String template = ((Literal)stmt.getObject().as(Literal.class)).getLexicalForm(); - if( template != null && template.length() > 0 ){ - return template; - } - } - } - }finally{ - it.close(); - displayOntModel.leaveCriticalSection(); - } - return "defaultBody"; - } - - Map getValues(Individual ind, OntModel displayOntModel, OntModel assertionModel, Map baseValues){ - if( ind == null ) return Collections.emptyMap(); - - /* Figure out what ValueFactories are specified in the display ontology for this individual. */ - Set valueFactories = new HashSet(); - displayOntModel.enterCriticalSection(Model.READ); - StmtIterator stmts = ind.listProperties(DisplayVocabulary.REQUIRES_VALUES); - try{ - while(stmts.hasNext()){ - Statement stmt = stmts.nextStatement(); - RDFNode obj = stmt.getObject(); - valueFactories.addAll(getValueFactory(obj,displayOntModel)); - } - }finally{ - stmts.close(); - displayOntModel.leaveCriticalSection(); - } - - /* Get values from the ValueFactories. */ - HashMap values = new HashMap(); - values.putAll(baseValues); - for(ValueFactory vf : valueFactories){ - values.putAll( vf.getValues(assertionModel, values)); - } - return values; - } - - protected Set getValueFactory( RDFNode valueNode, OntModel displayOntModel) { - //maybe use jenabean or owl2java for this? - if( valueNode.isResource() ){ - Resource res = (Resource)valueNode.as(Resource.class); - Statement stmt = res.getProperty(DisplayVocabulary.JAVA_CLASS_NAME); - if( stmt == null || !stmt.getObject().isLiteral() ){ - log.debug("Cannot build value factory: java class was " + stmt.getObject()); - return Collections.emptySet(); - } - String javaClassName = ((Literal)stmt.getObject().as(Literal.class)).getLexicalForm(); - if( javaClassName == null || javaClassName.length() == 0 ){ - log.debug("Cannot build value factory: no java class was set."); - return Collections.emptySet(); - } - Class clazz; - Object newObj; - try { - clazz = Class.forName(javaClassName); - } catch (ClassNotFoundException e) { - log.debug("Cannot build value factory: no class found for " + javaClassName); - return Collections.emptySet(); - } - try { - newObj = clazz.newInstance(); - } catch (Exception e) { - log.debug("Cannot build value factory: exception while creating object of java class " + javaClassName + " " + e.getMessage()); - return Collections.emptySet(); - } - if( newObj instanceof ValueFactory){ - ValueFactory valueFactory = (ValueFactory)newObj; - return Collections.singleton( valueFactory ); - }else{ - log.debug("Cannot build value factory: " + javaClassName + " does not implement " + ValueFactory.class.getName() ); - return Collections.emptySet(); - } - }else{ - log.debug("Cannot build value factory for " + valueNode); - return Collections.emptySet(); - } - } - - interface ValueFactory { - void configure( Map config); - Map getValues(OntModel model, Map values); - } - - private class NavigationURLPatternListener extends StatementListener { - private Map urlPatternToURI; - - public synchronized Map getUrlPatternToURIMap(){ - if( urlPatternToURI == null || urlPatternToURI.isEmpty() ){ - this.urlPatternToURI = buildUrlPatternToURI(); - } - return urlPatternToURI; - } - - protected synchronized void invalidateURLPatternMap(){ - this.urlPatternToURI = null; - } - - public Individual getDisplayIndividual( String pathInfo , OntModel displayModel){ - Map map = getUrlPatternToURIMap(); - for( Pattern regex : map.keySet()){ - Matcher m = regex.matcher(pathInfo); - if(m.matches() ){ - return displayModel.getIndividual(map.get(regex)); - } - } - return null; - } - - protected synchronized Map buildUrlPatternToURI(){ - OntModel displayModel = (OntModel)getServletContext().getAttribute("displayOntModel"); - Map map = new HashMap(); - StmtIterator stmts = displayModel.listStatements(null, DisplayVocabulary.URL_MAPPING,(Literal)null); - while(stmts.hasNext()){ - Statement stmt = stmts.nextStatement(); - if( stmt.getSubject().isURIResource() && stmt.getObject().isLiteral()){ - Resource r = (Resource)stmt.getSubject().as( Resource.class); - Pattern regex = Pattern.compile(stmt.getLiteral().getLexicalForm()); - map.put(regex,r.getURI()); - } - } - return map; - } - - @Override - public void addedStatement(Statement s) { - invalidateURLPatternMap(); - } - @Override - public void removedStatement(Statement s) { - invalidateURLPatternMap(); - } - } -} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java index ac39c3b10..e63791df5 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/individual/IndividualResponseBuilder.java @@ -180,7 +180,7 @@ class IndividualResponseBuilder { private boolean getprofilePageTypesFlag() { String property = ConfigurationProperties.getBean(vreq).getProperty( - "MultiViews.profilePageTypes"); + "multiViews.profilePageTypes"); return "enabled".equals(property); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/GetRandomSolrIndividualsByVClass.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/GetRandomSolrIndividualsByVClass.java new file mode 100644 index 000000000..5e4c268dd --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/GetRandomSolrIndividualsByVClass.java @@ -0,0 +1,84 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.json; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import edu.cornell.mannlib.vitro.webapp.beans.Individual; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; +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.ShortViewServiceSetup; +import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.IndividualTemplateModel; + +/** + * Does a Solr search for individuals, and uses the short view to render each of + * the results. + */ +public class GetRandomSolrIndividualsByVClass extends GetSolrIndividualsByVClass { + private static final Log log = LogFactory + .getLog(GetRandomSolrIndividualsByVClass.class); + + protected GetRandomSolrIndividualsByVClass(VitroRequest vreq) { + super(vreq); + } + + /** + * Search for individuals by VClass. + */ + @Override + protected JSONObject process() throws Exception { + JSONObject rObj = null; + + //This gets the first vclass value and sets that as display type. + List vclassIds = super.getVclassIds(vreq); + String vclassId = vclassIds.get(0); + vreq.setAttribute("queryType", "random"); +// vreq.setAttribute("displayType", vclassId); + + //This will get all the solr individuals by VClass (if one value) or the intersection + //i.e. individuals that have all the types for the different vclasses entered + rObj = super.process(); + addShortViewRenderings(rObj); + return rObj; + } + + /** + * Look through the return object. For each individual, render the short + * view and insert the resulting HTML into the object. + */ + private void addShortViewRenderings(JSONObject rObj) throws JSONException { + JSONArray individuals = rObj.getJSONArray("individuals"); + String vclassName = rObj.getJSONObject("vclass").getString("name"); + for (int i = 0; i < individuals.length(); i++) { + JSONObject individual = individuals.getJSONObject(i); + individual.put("shortViewHtml", + renderShortView(individual.getString("URI"), vclassName)); + } + } + + private String renderShortView(String individualUri, String vclassName) { + IndividualDao iDao = vreq.getWebappDaoFactory().getIndividualDao(); + Individual individual = iDao.getIndividualByURI(individualUri); + + Map modelMap = new HashMap(); + modelMap.put("individual", + new IndividualTemplateModel(individual, vreq)); + modelMap.put("vclass", vclassName); + + ShortViewService svs = ShortViewServiceSetup.getService(ctx); + return svs.renderShortView(individual, ShortViewContext.BROWSE, + modelMap, vreq); + } +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/GetSolrIndividualsByVClass.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/GetSolrIndividualsByVClass.java index 154753322..0d40e6026 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/GetSolrIndividualsByVClass.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/GetSolrIndividualsByVClass.java @@ -24,6 +24,7 @@ public class GetSolrIndividualsByVClass extends JsonObjectProducer { protected JSONObject process() throws Exception { VClass vclass=null; + String queryType = (String) vreq.getAttribute("queryType"); String vitroClassIdStr = vreq.getParameter("vclassId"); if ( vitroClassIdStr != null && !vitroClassIdStr.isEmpty()){ vclass = vreq.getWebappDaoFactory().getVClassDao().getVClassByURI(vitroClassIdStr); @@ -35,8 +36,13 @@ public class GetSolrIndividualsByVClass extends JsonObjectProducer { log.debug("parameter vclassId URI parameter expected "); throw new Exception("parameter vclassId URI parameter expected "); } + vreq.setAttribute("displayType", vitroClassIdStr); - return JsonServlet.getSolrIndividualsByVClass(vclass.getURI(), vreq, ctx); + if ( queryType != null && queryType.equals("random")){ + return JsonServlet.getRandomSolrIndividualsByVClass(vclass.getURI(), vreq, ctx); + } else { + return JsonServlet.getSolrIndividualsByVClass(vclass.getURI(), vreq, ctx); + } } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/JsonServlet.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/JsonServlet.java index be3c2eb01..2fbd9d09f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/JsonServlet.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/json/JsonServlet.java @@ -72,7 +72,10 @@ public class JsonServlet extends VitroHttpServlet { new GetDataForPage(vreq).process(resp); }else if( vreq.getParameter("getRenderedSolrIndividualsByVClass") != null ){ new GetRenderedSolrIndividualsByVClass(vreq).process(resp); + }else if( vreq.getParameter("getRandomSolrIndividualsByVClass") != null ){ + new GetRandomSolrIndividualsByVClass(vreq).process(resp); } + } @@ -135,7 +138,35 @@ public class JsonServlet extends VitroHttpServlet { return value; } + public static JSONObject getRandomSolrIndividualsByVClass(String vclassURI, HttpServletRequest req, ServletContext context) throws Exception { + VitroRequest vreq = new VitroRequest(req); + + Map map = getRandomSolrVClassResults(vclassURI, vreq, context); + //last parameter indicates single vclass instead of multiple vclasses + return processVClassResults(map, vreq, context, false); + } + //Including version for Random Solr query for Vclass Intersections + private static Map getRandomSolrVClassResults(String vclassURI, VitroRequest vreq, ServletContext context){ + log.debug("Retrieving random Solr intersection results for " + vclassURI); + + int page = IndividualListController.getPageParameter(vreq); + int pageSize = Integer.parseInt(vreq.getParameter("pageSize")); + log.debug("page and pageSize parameters = " + page + " and " + pageSize); + Map map = null; + try { + map = IndividualListController.getRandomResultsForVClass( + vclassURI, + page, + pageSize, + vreq.getWebappDaoFactory().getIndividualDao(), + context); + } catch(Exception ex) { + log.error("Error in retrieval of search results for VClass " + vclassURI, ex); + } + + return map; + } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyDaoJena.java index 8a1ce1189..0d4d77a9b 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyDaoJena.java @@ -8,7 +8,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -24,7 +23,6 @@ import com.hp.hpl.jena.ontology.OntProperty; import com.hp.hpl.jena.ontology.OntResource; import com.hp.hpl.jena.ontology.ProfileException; import com.hp.hpl.jena.ontology.Restriction; -import com.hp.hpl.jena.ontology.SomeValuesFromRestriction; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; @@ -53,7 +51,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao; import edu.cornell.mannlib.vitro.webapp.dao.InsertException; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; -import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; 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.pellet.PelletListener; @@ -93,7 +90,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements try { com.hp.hpl.jena.ontology.OntResource ind = ontModel.getOntResource(dataPropertyURI); if( ind != null ){ - ontModel.add(ind,(Property)DATAPROPERTY_ISEXTERNALID, "TRUE"); + ontModel.add(ind, DATAPROPERTY_ISEXTERNALID, "TRUE"); return true; }else{ return false; @@ -114,7 +111,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements while(restIt.hasNext()) { Resource restRes = restIt.next(); if (restRes.canAs(OntResource.class)) { - OntResource restOntRes = (OntResource) restRes.as(OntResource.class); + OntResource restOntRes = restRes.as(OntResource.class); smartRemove(restOntRes, ontModel); } } @@ -181,7 +178,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements dp.setNamespace(op.getNameSpace()); dp.setLocalName(op.getLocalName()); OntologyDao oDao=getWebappDaoFactory().getOntologyDao(); - Ontology o = (Ontology)oDao.getOntologyByURI(dp.getNamespace()); + Ontology o = oDao.getOntologyByURI(dp.getNamespace()); if (o==null) { if (!VitroVocabulary.vitroURI.equals(dp.getNamespace())) { log.debug("datapropFromOntProperty(): no ontology object found for the namespace "+dp.getNamespace()); @@ -206,8 +203,8 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements dp.setExample(getPropertyStringValue(op,EXAMPLE_ANNOT)); dp.setDescription(getPropertyStringValue(op,DESCRIPTION_ANNOT)); dp.setPublicDescription(getPropertyStringValue(op,PUBLIC_DESCRIPTION_ANNOT)); - dp.setDisplayTier(((WebappDaoFactoryJena)getWebappDaoFactory()).getJenaBaseDao().getPropertyNonNegativeIntValue(op, DISPLAY_RANK_ANNOT)); - dp.setDisplayLimit(((WebappDaoFactoryJena)getWebappDaoFactory()).getJenaBaseDao().getPropertyNonNegativeIntValue(op, DISPLAY_LIMIT)); + dp.setDisplayTier((getWebappDaoFactory()).getJenaBaseDao().getPropertyNonNegativeIntValue(op, DISPLAY_RANK_ANNOT)); + dp.setDisplayLimit((getWebappDaoFactory()).getJenaBaseDao().getPropertyNonNegativeIntValue(op, DISPLAY_LIMIT)); //There might be multiple HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT properties, only use the highest StmtIterator it = op.listProperties(HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT); @@ -216,7 +213,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements Statement stmt = it.nextStatement(); RDFNode obj; if( stmt != null && (obj = stmt.getObject()) != null && obj.isURIResource() ){ - Resource res = (Resource)obj.as(Resource.class); + Resource res = obj.as(Resource.class); if( res != null && res.getURI() != null ){ BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI()); if( roleFromModel != null && @@ -235,7 +232,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements Statement stmt = it.nextStatement(); RDFNode obj; if( stmt != null && (obj = stmt.getObject()) != null && obj.isURIResource() ){ - Resource res = (Resource)obj.as(Resource.class); + Resource res = obj.as(Resource.class); if( res != null && res.getURI() != null ){ BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI()); if( roleFromModel != null && @@ -365,7 +362,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements while (restIt.hasNext()) { Resource restRes = restIt.next(); if (restRes.canAs(Restriction.class)) { - Restriction rest = (Restriction) restRes.as(Restriction.class); + Restriction rest = restRes.as(Restriction.class); if (rest.isAllValuesFromRestriction()) { AllValuesFromRestriction avfrest = rest.asAllValuesFromRestriction(); if (avfrest.getAllValuesFrom() != null) { @@ -485,7 +482,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements } com.hp.hpl.jena.ontology.DatatypeProperty jDataprop = ontModel.createDatatypeProperty(dtp.getURI()); if (dtp.getPublicName() != null && dtp.getPublicName().length() > 0) { - jDataprop.setLabel(dtp.getPublicName(), (String) getDefaultLanguage()); + jDataprop.setLabel(dtp.getPublicName(), getDefaultLanguage()); } else { jDataprop.removeAll(RDFS.label); } @@ -609,7 +606,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements while (parentNodeIt.hasNext()) { RDFNode parentNode = parentNodeIt.next(); if (parentNode.canAs(Property.class)) { - parentList.add((Property) parentNode.as(Property.class)); + parentList.add(parentNode.as(Property.class)); } } if (parentList.size()==0) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoJena.java index 600d0fa4d..9abceea00 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoJena.java @@ -10,6 +10,9 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import com.hp.hpl.jena.datatypes.TypeMapper; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntResource; @@ -27,7 +30,6 @@ import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Property; -import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.Statement; @@ -40,14 +42,9 @@ import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl; import edu.cornell.mannlib.vitro.webapp.beans.Individual; -import edu.cornell.mannlib.vitro.webapp.controller.edit.ReorderController; import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualUpdateEvent; -import edu.cornell.mannlib.vitro.webapp.dao.jena.ObjectPropertyStatementDaoJena; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPropertyStatementDao { @@ -114,7 +111,7 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro StmtIterator stmtIt = ind.listProperties(); while( stmtIt.hasNext() ) { - Statement st = (Statement)stmtIt.next(); + Statement st = stmtIt.next(); boolean addToList = /*allowAnyNameSpace ? st.getObject().canAs(Literal.class) :*/ st.getObject().isLiteral() && ( (RDF.value.equals(st.getPredicate()) || VitroVocabulary.value.equals(st.getPredicate().getURI())) @@ -210,7 +207,7 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro // do something annoying if we are dealing with a blank node try { getOntModel().enterCriticalSection(Lock.READ); - OntResource ontRes = (OntResource) getOntModel().createResource( + OntResource ontRes = getOntModel().createResource( new AnonId(entity.getLocalName())).as(OntResource.class); if (ontRes == null) { return edList; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoSDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoSDB.java index dcdc82f19..64f39301c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoSDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoSDB.java @@ -3,7 +3,6 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena; import java.util.ArrayList; -import java.util.Collection; import java.util.List; import com.hp.hpl.jena.ontology.OntModel; @@ -12,20 +11,15 @@ import com.hp.hpl.jena.query.Dataset; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; import com.hp.hpl.jena.query.QueryFactory; -import com.hp.hpl.jena.query.QuerySolution; -import com.hp.hpl.jena.query.QuerySolutionMap; -import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; -import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.vocabulary.RDF; -import edu.cornell.mannlib.vitro.webapp.beans.DataProperty; import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement; import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatementImpl; import edu.cornell.mannlib.vitro.webapp.beans.Individual; @@ -85,7 +79,7 @@ public class DataPropertyStatementDaoSDB extends DataPropertyStatementDaoJena StmtIterator stmtIt = ind.listProperties(); while( stmtIt.hasNext() ) { - Statement st = (Statement)stmtIt.next(); + Statement st = stmtIt.next(); boolean addToList = /*allowAnyNameSpace ? st.getObject().canAs(Literal.class) :*/ st.getObject().isLiteral() && ( (RDF.value.equals(st.getPredicate()) || VitroVocabulary.value.equals(st.getPredicate().getURI())) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DatatypeDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DatatypeDaoJena.java index f6a41b3bc..c0d31c9ee 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DatatypeDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DatatypeDaoJena.java @@ -4,14 +4,10 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.List; -import com.hp.hpl.jena.ontology.OntModel; - import edu.cornell.mannlib.vitro.webapp.beans.Datatype; import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; public class DatatypeDaoJena extends JenaBaseDao implements DatatypeDao { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DependentResourceDeleteJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DependentResourceDeleteJena.java index 08b879c0b..8583ebe93 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DependentResourceDeleteJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DependentResourceDeleteJena.java @@ -9,7 +9,6 @@ import java.util.List; import java.util.ListIterator; import java.util.Set; -import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Property; @@ -89,14 +88,13 @@ public class DependentResourceDeleteJena { * Find all statements where for a given statement in the assertions, * there is at least one statement in the retractions that has * the same predicate and object. */ - @SuppressWarnings("unchecked") private static List getChangedStmts(Model assertions, Model retractions){ List changedStmts = new LinkedList(); StmtIterator it = assertions.listStatements(); while(it.hasNext()){ Statement assertionStmtStatement = it.nextStatement(); if( assertionStmtStatement.getObject().canAs( Resource.class )){ - Resource asserObj = (Resource) assertionStmtStatement.getObject().as(Resource.class); + Resource asserObj = assertionStmtStatement.getObject().as(Resource.class); StmtIterator retractionStmts = retractions.listStatements( (Resource)null, @@ -138,7 +136,7 @@ public class DependentResourceDeleteJena { if( ( obj.canAs(Resource.class) && isPredicateDependencyRelation(stmt.getPredicate(), model) ) || ( obj.isAnon() && perviousWasDependentResource ) ){ - Resource res = (Resource)obj.as(Resource.class); + Resource res = obj.as(Resource.class); String id = res.isAnon()?res.getId().toString():res.getURI(); if( !visitedUris.contains(id) ){ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DisplayModelDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DisplayModelDaoJena.java index d1568e413..59af49fa8 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DisplayModelDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DisplayModelDaoJena.java @@ -7,9 +7,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileReader; -import java.io.FileWriter; import java.io.IOException; -import java.io.InputStream; import java.io.StringReader; import java.nio.channels.FileChannel; @@ -22,7 +20,6 @@ import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.util.FileManager; import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao; import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/EmptyReifier.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/EmptyReifier.java index 064dce350..ac29c9077 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/EmptyReifier.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/EmptyReifier.java @@ -2,7 +2,6 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena; -import java.util.ArrayList; import java.util.Collections; import org.apache.commons.collections.iterators.EmptyIterator; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java index 7293e0dda..ec2a79761 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java @@ -146,7 +146,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { if (theClass.isAnon() && theClass.canAs(UnionClass.class)) { - UnionClass u = (UnionClass) theClass.as(UnionClass.class); + UnionClass u = theClass.as(UnionClass.class); for (OntClass operand : u.listOperands().toList()) { VClass vc = new VClassJena(operand, getWebappDaoFactory()); ents.addAll(getIndividualsByVClass(vc)); @@ -159,8 +159,8 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { try { while (stmtIt.hasNext()) { Statement stmt = stmtIt.nextStatement(); - OntResource ind = (OntResource) stmt.getSubject().as(OntResource.class); - ents.add(new IndividualJena(ind, (WebappDaoFactoryJena) getWebappDaoFactory())); + OntResource ind = stmt.getSubject().as(OntResource.class); + ents.add(new IndividualJena(ind, getWebappDaoFactory())); } } finally { stmtIt.close(); @@ -232,7 +232,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { ontModel.getBaseModel().notifyEvent(new IndividualCreationEvent(getWebappDaoFactory().getUserURI(),true,entURI)); com.hp.hpl.jena.ontology.Individual ind = ontModel.createIndividual(entURI,cls); if (ent.getName() != null) { - ind.setLabel(ent.getName(), (String) getDefaultLanguage()); + ind.setLabel(ent.getName(), getDefaultLanguage()); } List vclasses = ent.getVClasses(false); if (vclasses != null) { @@ -388,7 +388,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { return 1; } if (res.canAs(OntResource.class)) { - OntResource ontRes = (OntResource) res.as(OntResource.class); + OntResource ontRes = res.as(OntResource.class); smartRemove(ontRes, ontModel); } else { ontModel.removeAll(res,null,null); @@ -420,7 +420,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { OntResource ontRes = (entityURI.startsWith(VitroVocabulary.PSEUDO_BNODE_NS)) ? (OntResource) ontModel.createResource(new AnonId(entityURI.substring(VitroVocabulary.PSEUDO_BNODE_NS.length()))).as(OntResource.class) : ontModel.getOntResource(entityURI); - Individual ent = new IndividualJena(ontRes, (WebappDaoFactoryJena) getWebappDaoFactory()); + Individual ent = new IndividualJena(ontRes, getWebappDaoFactory()); return ent; } catch (Exception ex) { return null; @@ -494,7 +494,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { String subUri = ((Resource)sub).getURI(); if( ! individualsMap.containsKey(subUri)){ com.hp.hpl.jena.ontology.Individual ind = getOntModel().getIndividual(subUri); - individualsMap.put(subUri,new IndividualJena(ind, (WebappDaoFactoryJena) getWebappDaoFactory())); + individualsMap.put(subUri,new IndividualJena(ind, getWebappDaoFactory())); } } @@ -519,7 +519,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { String subUri = ((Resource)sub).getURI(); if( ! individualsMap.containsKey(subUri)){ com.hp.hpl.jena.ontology.Individual ind = getOntModel().getIndividual(subUri); - individualsMap.put(subUri,new IndividualJena(ind, (WebappDaoFactoryJena) getWebappDaoFactory())); + individualsMap.put(subUri,new IndividualJena(ind, getWebappDaoFactory())); } } @@ -544,7 +544,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { String subUri = ((Resource)sub).getURI(); if( ! individualsMap.containsKey(subUri)){ com.hp.hpl.jena.ontology.Individual ind = getOntModel().getIndividual(subUri); - individualsMap.put(subUri,new IndividualJena(ind, (WebappDaoFactoryJena) getWebappDaoFactory())); + individualsMap.put(subUri,new IndividualJena(ind, getWebappDaoFactory())); } } } finally { @@ -594,7 +594,7 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { continue; } com.hp.hpl.jena.ontology.Individual ind = getOntModel().getIndividual(st.getURI()); - inds.add(new IndividualJena(ind, (WebappDaoFactoryJena) getWebappDaoFactory())); + inds.add(new IndividualJena(ind, getWebappDaoFactory())); } } finally { if( stmts != null ) stmts.close(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java index 388a69078..6ddec9a32 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoSDB.java @@ -106,7 +106,7 @@ public class IndividualDaoSDB extends IndividualDaoJena { : ResourceFactory.createResource(vclassURI); if (theClass.isAnon() && theClass.canAs(UnionClass.class)) { - UnionClass u = (UnionClass) theClass.as(UnionClass.class); + UnionClass u = theClass.as(UnionClass.class); for (OntClass operand : u.listOperands().toList()) { VClass vc = new VClassJena(operand, getWebappDaoFactory()); ents.addAll(getIndividualsByVClass(vc)); @@ -523,7 +523,7 @@ public class IndividualDaoSDB extends IndividualDaoJena { try { ResultSet results = qe.execSelect(); while (results.hasNext()) { - QuerySolution qs = (QuerySolution) results.next(); + QuerySolution qs = results.next(); Resource res = (Resource) qs.get("?ent"); if (res.getURI() != null) { individualURIs.add(res.getURI()); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualJena.java index c0e6c0b61..944851dd8 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualJena.java @@ -254,8 +254,8 @@ public class IndividualJena extends IndividualImpl implements Individual { if (!s.getSubject().canAs(OntResource.class) || !s.getObject().canAs(OntResource.class)) { continue; } - Individual subj = new IndividualJena((OntResource) s.getSubject().as(OntResource.class), webappDaoFactory); - Individual obj = new IndividualJena((OntResource) s.getObject().as(OntResource.class), webappDaoFactory); + Individual subj = new IndividualJena(s.getSubject().as(OntResource.class), webappDaoFactory); + Individual obj = new IndividualJena(s.getObject().as(OntResource.class), webappDaoFactory); ObjectProperty op = webappDaoFactory.getObjectPropertyDao().getObjectPropertyByURI(s.getPredicate().getURI()); if (subj != null && obj != null && op != null) { ObjectPropertyStatement ops = new ObjectPropertyStatementImpl(); @@ -287,7 +287,7 @@ public class IndividualJena extends IndividualImpl implements Individual { RDFNode value = values.nextNode(); if (value.canAs(OntResource.class)) { relatedIndividuals.add( - new IndividualJena((OntResource) value.as(OntResource.class), webappDaoFactory) ); + new IndividualJena(value.as(OntResource.class), webappDaoFactory) ); } } } finally { @@ -305,7 +305,7 @@ public class IndividualJena extends IndividualImpl implements Individual { try { RDFNode value = ind.getPropertyValue(ind.getModel().getProperty(propertyURI)); if (value != null && value.canAs(OntResource.class)) { - return new IndividualJena((OntResource) value.as(OntResource.class), webappDaoFactory); + return new IndividualJena(value.as(OntResource.class), webappDaoFactory); } else { return null; } @@ -582,11 +582,11 @@ public class IndividualJena extends IndividualImpl implements Individual { int rv = 0; try { if( val1 instanceof String ) - rv = collator.compare( ((String)val1) , ((String)val2) ); + rv = collator.compare(val1 , val2); //rv = ((String)val1).compareTo((String)val2); else if( val1 instanceof Date ) { - DateTime dt1 = new DateTime((Date)val1); - DateTime dt2 = new DateTime((Date)val2); + DateTime dt1 = new DateTime(val1); + DateTime dt2 = new DateTime(val2); rv = dt1.compareTo(dt2); } else diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualSDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualSDB.java index a12bd2fbe..05c224030 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualSDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualSDB.java @@ -478,8 +478,7 @@ public class IndividualSDB extends IndividualImpl implements Individual { Individual subj = null; try { subj = new IndividualSDB( - ((OntResource) s.getSubject().as(OntResource.class)) - .getURI(), + s.getSubject().as(OntResource.class).getURI(), this.dwf, datasetMode, webappDaoFactory); } catch (IndividualNotFoundException e) { // leave null subject @@ -487,8 +486,7 @@ public class IndividualSDB extends IndividualImpl implements Individual { Individual obj = null; try { obj = new IndividualSDB( - ((OntResource) s.getObject().as(OntResource.class)) - .getURI(), + s.getObject().as(OntResource.class).getURI(), this.dwf, datasetMode, webappDaoFactory); } catch (IndividualNotFoundException e) { // leave null object @@ -548,8 +546,7 @@ public class IndividualSDB extends IndividualImpl implements Individual { if (value.canAs(OntResource.class)) { relatedIndividuals.add( new IndividualSDB( - ((OntResource) value.as(OntResource.class)) - .getURI(), + value.as(OntResource.class).getURI(), this.dwf, datasetMode, webappDaoFactory) ); @@ -588,7 +585,7 @@ public class IndividualSDB extends IndividualImpl implements Individual { if (value != null && value.canAs(OntResource.class)) { try { return new IndividualSDB( - ((OntResource) value.as(OntResource.class)).getURI(), + value.as(OntResource.class).getURI(), dwf, datasetMode, webappDaoFactory); } catch (IndividualNotFoundException e) { return null; @@ -1045,8 +1042,8 @@ public class IndividualSDB extends IndividualImpl implements Individual { rv = collator.compare( ((String)val1) , ((String)val2) ); //rv = ((String)val1).compareTo((String)val2); else if( val1 instanceof Date ) { - DateTime dt1 = new DateTime((Date)val1); - DateTime dt2 = new DateTime((Date)val2); + DateTime dt1 = new DateTime(val1); + DateTime dt2 = new DateTime(val2); rv = dt1.compareTo(dt2); } else diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDao.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDao.java index 8bdd4fd00..bec886cd9 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDao.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaBaseDao.java @@ -12,7 +12,6 @@ import java.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.Set; import org.apache.commons.logging.Log; @@ -23,7 +22,6 @@ import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.iri.IRI; import com.hp.hpl.jena.iri.IRIFactory; -import com.hp.hpl.jena.iri.Violation; import com.hp.hpl.jena.ontology.DatatypeProperty; import com.hp.hpl.jena.ontology.ObjectProperty; import com.hp.hpl.jena.ontology.OntClass; @@ -749,10 +747,10 @@ public class JenaBaseDao extends JenaBaseDaoCon { if (label != null && label.length() > 0) { - String existingValue = ontRes.getLabel((String) getDefaultLanguage()); + String existingValue = ontRes.getLabel(getDefaultLanguage()); if (existingValue == null || !existingValue.equals(label)) { - ontRes.setLabel(label, (String) getDefaultLanguage()); + ontRes.setLabel(label, getDefaultLanguage()); } } else { ontRes.removeAll(RDFS.label); @@ -910,7 +908,7 @@ public class JenaBaseDao extends JenaBaseDaoCon { if (iri.hasViolation(false) ) { String errorStr = ("Bad URI: "+ uri + "\nOnly well-formed absolute URIrefs can be included in RDF/XML output: " - + ((Violation)iri.violations(false).next()).getShortMessage()); + + (iri.violations(false).next()).getShortMessage()); return errorStr; } else { return null; @@ -933,7 +931,7 @@ public class JenaBaseDao extends JenaBaseDaoCon { String idStr = vitroURIStr.split("#")[1]; RDFNode rdfNode = ontModel.getRDFNode(Node.createAnon(AnonId.create(idStr))); if ( (rdfNode != null) && (rdfNode.canAs(OntClass.class)) ) { - cls = (OntClass) rdfNode.as(OntClass.class); + cls = rdfNode.as(OntClass.class); } } else { try { @@ -1006,7 +1004,7 @@ public class JenaBaseDao extends JenaBaseDaoCon { StmtIterator stmtIt = getOntModel().listStatements((Resource)null, prop, value); while (stmtIt.hasNext()) { Statement stmt = stmtIt.nextStatement(); - possibleSubjectSet.add((Resource)stmt.getSubject()); + possibleSubjectSet.add(stmt.getSubject()); } Iterator possibleSubjectIt = possibleSubjectSet.iterator(); @@ -1016,7 +1014,7 @@ public class JenaBaseDao extends JenaBaseDaoCon { boolean hasAlternatePath = false; while (stmtIt.hasNext()) { Statement stmt = stmtIt.nextStatement(); - if (stmt.getObject().isResource() && possibleSubjectSet.contains((Resource)stmt.getObject())) { + if (stmt.getObject().isResource() && possibleSubjectSet.contains(stmt.getObject())) { hasAlternatePath = true; break; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaChangeListener.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaChangeListener.java index 47d040fc1..9304d99a7 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaChangeListener.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaChangeListener.java @@ -8,7 +8,6 @@ import java.util.HashSet; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.openjena.riot.RiotException; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelChangedListener; @@ -17,7 +16,6 @@ import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.StmtIterator; import edu.cornell.mannlib.vitro.webapp.rdfservice.ChangeListener; -import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase; import edu.cornell.mannlib.vitro.webapp.servlet.setup.SimpleReasonerSetup; /** diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaModelUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaModelUtils.java index 93900a7a7..f271542e9 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaModelUtils.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/JenaModelUtils.java @@ -95,7 +95,7 @@ public class JenaModelUtils { .getRootClasses(); for (Iterator rootClassIt = rootClasses.iterator(); rootClassIt.hasNext(); ) { - VClass rootClass = (VClass) rootClassIt.next(); + VClass rootClass = rootClassIt.next(); Individual classGroup = modelForClassgroups.createIndividual( wadf.getDefaultNamespace() + "vitroClassGroup" + rootClass.getLocalName(), classGroupClass); @@ -108,7 +108,7 @@ public class JenaModelUtils { for (Iterator childIt = myWebappDaoFactory.getVClassDao() .getAllSubClassURIs(rootClass.getURI()).iterator(); childIt.hasNext(); ) { - String childURI = (String) childIt.next(); + String childURI = childIt.next(); Resource childClass = modelForClassgroupAnnotations .getResource(childURI); if (!modelForClassgroupAnnotations.contains( diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyDaoJena.java index d8560682f..3bfae5f3c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyDaoJena.java @@ -92,7 +92,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp p.setNamespace(op.getNameSpace()); p.setLocalName(op.getLocalName()); OntologyDao oDao=getWebappDaoFactory().getOntologyDao(); - Ontology o = (Ontology)oDao.getOntologyByURI(p.getNamespace()); + Ontology o = oDao.getOntologyByURI(p.getNamespace()); if (o==null) { if (!VitroVocabulary.vitroURI.equals(p.getNamespace())) { log.debug("propertyFromOntProperty(): no ontology object found for the namespace "+p.getNamespace()); @@ -180,7 +180,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp Statement stmt = it.nextStatement(); RDFNode obj; if( stmt != null && (obj = stmt.getObject()) != null && obj.isURIResource() ){ - Resource res = (Resource)obj.as(Resource.class); + Resource res = obj.as(Resource.class); if( res != null && res.getURI() != null ){ BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI()); if( roleFromModel != null && @@ -199,7 +199,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp Statement stmt = it.nextStatement(); RDFNode obj; if( stmt != null && (obj = stmt.getObject()) != null && obj.isURIResource() ){ - Resource res = (Resource)obj.as(Resource.class); + Resource res = obj.as(Resource.class); if( res != null && res.getURI() != null ){ BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI()); if( roleFromModel != null && @@ -259,7 +259,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp while (opIt.hasNext()) { Resource res = (Resource) opIt.next(); if ( (res.canAs(OntProperty.class)) && (!NONUSER_NAMESPACES.contains(res.getNameSpace())) ) { - props.add(propertyFromOntProperty((OntProperty)res.as(OntProperty.class))); + props.add(propertyFromOntProperty(res.as(OntProperty.class))); } } } finally { @@ -298,7 +298,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp while(it.hasNext()){ ObjectPropertyStatement objPropertyStmt = (ObjectPropertyStatement)it.next(); if (hash.containsKey(objPropertyStmt.getPropertyURI())) { - ObjectProperty p = (ObjectProperty) hash.get(objPropertyStmt.getPropertyURI()); + ObjectProperty p = hash.get(objPropertyStmt.getPropertyURI()); p.addObjectPropertyStatement(objPropertyStmt); } else { OntProperty op = getOntModel().getOntProperty(objPropertyStmt.getPropertyURI()); @@ -603,7 +603,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp while(restIt.hasNext()) { Resource restRes = restIt.next(); if (restRes.canAs(OntResource.class)) { - OntResource restOntRes = (OntResource) restRes.as(OntResource.class); + OntResource restOntRes = restRes.as(OntResource.class); smartRemove(restOntRes, ontModel); } } @@ -627,7 +627,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp while(restIt.hasNext()) { Resource restRes = restIt.next(); if (restRes.canAs(OntResource.class)) { - OntResource restOntRes = (OntResource) restRes.as(OntResource.class); + OntResource restOntRes = restRes.as(OntResource.class); smartRemove(restOntRes, ontModel); } } @@ -660,7 +660,7 @@ public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectProp while (propIt.hasNext()) { Resource res = (Resource) propIt.next(); if (res.canAs(OntProperty.class)) { - com.hp.hpl.jena.ontology.OntProperty op = (com.hp.hpl.jena.ontology.OntProperty) res.as(OntProperty.class); + com.hp.hpl.jena.ontology.OntProperty op = res.as(OntProperty.class); boolean isRoot = false; Iterator parentIt = op.listSuperProperties(); if (parentIt != null) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java index 82b6e566f..4c67580bd 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/ObjectPropertyStatementDaoJena.java @@ -99,7 +99,7 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec ClosableIterator propIt = ind.listProperties(); try { while (propIt.hasNext()) { - Statement st = (Statement) propIt.next(); + Statement st = propIt.next(); if (st.getObject().isResource() && !(NONUSER_NAMESPACES.contains(st.getPredicate().getNameSpace()))) { try { @@ -173,7 +173,7 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec try { int count = 0; while ( (opsIt.hasNext()) && ((endIndex<0) || (count propIt = ind.listProperties(); try { while (propIt.hasNext()) { - Statement st = (Statement) propIt.next(); + Statement st = propIt.next(); if (st.getObject().isResource() && !(NONUSER_NAMESPACES.contains(st.getPredicate().getNameSpace()))) { try { ObjectPropertyStatement objPropertyStmt = new ObjectPropertyStatementImpl(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/OntologyDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/OntologyDaoJena.java index 067a29cf2..94a5b97f0 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/OntologyDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/OntologyDaoJena.java @@ -2,10 +2,8 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena; -import java.text.Collator; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import com.hp.hpl.jena.ontology.OntModel; @@ -16,7 +14,6 @@ import com.hp.hpl.jena.util.iterator.ClosableIterator; import edu.cornell.mannlib.vitro.webapp.beans.Ontology; import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao; -import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; public class OntologyDaoJena extends JenaBaseDao implements OntologyDao { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PageDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PageDaoJena.java index e552e20c8..e8ac4392e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PageDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PageDaoJena.java @@ -8,7 +8,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.HashMap; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyDaoJena.java index d91d2dd0a..e34797ba7 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyDaoJena.java @@ -34,7 +34,6 @@ import com.hp.hpl.jena.rdf.model.Statement; import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.sparql.resultset.ResultSetMem; -import com.hp.hpl.jena.util.iterator.ClosableIterator; import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.RDFS; @@ -151,7 +150,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao { List directSubproperties = getSubPropertyURIs(propertyURI); Iterator it=directSubproperties.iterator(); while(it.hasNext()){ - String uri = (String)it.next(); + String uri = it.next(); if (!subtree.contains(uri)) { subtree.add(uri); getAllSubPropertyURIs(uri,subtree); @@ -192,7 +191,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao { List directSuperproperties = getSuperPropertyURIs(propertyURI,true); Iterator it=directSuperproperties.iterator(); while(it.hasNext()){ - String uri = (String)it.next(); + String uri = it.next(); if (!subtree.contains(uri)) { subtree.add(uri); getAllSuperPropertyURIs(uri,subtree); @@ -342,13 +341,13 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao { if (targetProp != null) { - StmtIterator stmtIter = ontModel.listStatements((Resource) null, OWL.onProperty, (RDFNode) targetProp); + StmtIterator stmtIter = ontModel.listStatements((Resource) null, OWL.onProperty, targetProp); while (stmtIter.hasNext()) { Statement statement = stmtIter.next(); if ( statement.getSubject().canAs(OntClass.class) ) { - classURISet.addAll(getRelatedClasses((OntClass) statement.getSubject().as(OntClass.class))); + classURISet.addAll(getRelatedClasses(statement.getSubject().as(OntClass.class))); } else { log.warn("getClassesWithRestrictionOnProperty: Unexpected use of onProperty: it is not applied to a class"); } @@ -661,7 +660,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao { // TODO: check if restriction is something like // maxCardinality 0 or allValuesFrom owl:Nothing, // in which case the property is NOT applicable! - Restriction rest = (Restriction) relatedClass.as(Restriction.class); + Restriction rest = relatedClass.as(Restriction.class); OntProperty onProperty = rest.getOnProperty(); if (onProperty != null) { Resource[] ranges = new Resource[2]; @@ -726,7 +725,7 @@ public class PropertyDaoJena extends JenaBaseDao implements PropertyDao { rangeClassURI = PSEUDO_BNODE_NS + rangeRes.getId() .toString(); } else { - rangeClassURI = (String) rangeRes.getURI(); + rangeClassURI = rangeRes.getURI(); } pi.setRangeClassURI(rangeClassURI); VClass range = getWebappDaoFactory().getVClassDao() diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyGroupDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyGroupDaoJena.java index 6bb652094..2d713d3f3 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyGroupDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyGroupDaoJena.java @@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena; import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.ListIterator; @@ -16,7 +15,6 @@ import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; import com.hp.hpl.jena.ontology.Individual; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModelSpec; -import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; @@ -26,7 +24,6 @@ import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.util.iterator.ClosableIterator; import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl; -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.dao.DataPropertyDao; @@ -228,7 +225,7 @@ public class PropertyGroupDaoJena extends JenaBaseDao implements PropertyGroupDa try { Individual groupInd = ontModel.getIndividual(group.getURI()); try { - groupInd.setLabel(group.getName(), (String) getDefaultLanguage()); + groupInd.setLabel(group.getName(), getDefaultLanguage()); } catch (Exception e) { log.error("error updating name for "+groupInd.getURI()); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyInstanceDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyInstanceDaoJena.java index b1517700d..e03271273 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyInstanceDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PropertyInstanceDaoJena.java @@ -7,27 +7,18 @@ import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Map; -import java.util.Set; -import com.hp.hpl.jena.ontology.ObjectProperty; -import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntProperty; -import com.hp.hpl.jena.ontology.Restriction; import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.ResourceFactory; import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.rdf.model.StmtIterator; import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.vocabulary.OWL; import com.hp.hpl.jena.vocabulary.RDF; -import com.hp.hpl.jena.vocabulary.RDFS; import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement; @@ -35,7 +26,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance; import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstanceIface; import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao; -import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualDeletionEvent; import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualUpdateEvent; public class PropertyInstanceDaoJena extends PropertyDaoJena implements @@ -58,7 +48,7 @@ public class PropertyInstanceDaoJena extends PropertyDaoJena implements Property pred = tboxModel.getProperty(propertyURI); OntProperty invPred = null; if (pred.canAs(OntProperty.class)) { - invPred = ((OntProperty)pred.as(OntProperty.class)).getInverse(); + invPred = pred.as(OntProperty.class).getInverse(); } Resource objRes = ontModel.getResource(objectURI); if ( (subjRes != null) && (pred != null) && (objRes != null) ) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDataset.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDataset.java index 61cd2b58c..6517b495f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDataset.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDataset.java @@ -8,7 +8,6 @@ import java.util.Iterator; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.query.Dataset; import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.shared.Lock; import com.hp.hpl.jena.sparql.core.DatasetGraph; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDatasetGraph.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDatasetGraph.java index ca0dfa80f..23f9aaff2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDatasetGraph.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceDatasetGraph.java @@ -10,10 +10,6 @@ import java.util.List; import com.hp.hpl.jena.graph.Graph; import com.hp.hpl.jena.graph.Node; import com.hp.hpl.jena.graph.Triple; -import com.hp.hpl.jena.query.Query; -import com.hp.hpl.jena.query.QueryExecution; -import com.hp.hpl.jena.query.QueryExecutionFactory; -import com.hp.hpl.jena.query.QueryFactory; import com.hp.hpl.jena.query.QuerySolution; import com.hp.hpl.jena.query.ResultSet; import com.hp.hpl.jena.shared.Lock; @@ -21,7 +17,6 @@ import com.hp.hpl.jena.shared.LockMRSW; import com.hp.hpl.jena.sparql.core.DatasetGraph; import com.hp.hpl.jena.sparql.core.Quad; import com.hp.hpl.jena.sparql.resultset.JSONInput; -import com.hp.hpl.jena.sparql.resultset.ResultSetMem; import com.hp.hpl.jena.sparql.util.Context; import com.hp.hpl.jena.util.iterator.SingletonIterator; import com.hp.hpl.jena.util.iterator.WrappedIterator; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceGraphBulkUpdater.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceGraphBulkUpdater.java index 4cf036c2a..8a1170204 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceGraphBulkUpdater.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceGraphBulkUpdater.java @@ -4,7 +4,6 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; -import java.io.InputStream; import java.util.Iterator; import java.util.List; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceModelMaker.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceModelMaker.java index de822941c..004eadbb9 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceModelMaker.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/RDFServiceModelMaker.java @@ -305,7 +305,7 @@ public class RDFServiceModelMaker implements ModelMaker { List graphNames = rdfService.getGraphURIs(); Iterator nameIt = graphNames.iterator(); while (nameIt.hasNext()) { - String name = (String) nameIt.next(); + String name = nameIt.next(); metadataModel.add(dbResource,metadataModel.getProperty( HAS_NAMED_MODEL_URI),name); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoJena.java index e26729272..9252c994f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoJena.java @@ -98,11 +98,11 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { labelStr += "some values from "; } if (fillerRes.canAs(OntClass.class)) { - OntClass avf = (OntClass) fillerRes.as(OntClass.class); + OntClass avf = fillerRes.as(OntClass.class); labelStr += getLabelForClass(avf,withPrefix,forPickList); } else { try { - labelStr += getLabelOrId( (OntResource) fillerRes.as(OntResource.class)); + labelStr += getLabelOrId(fillerRes.as(OntResource.class)); } catch (Exception e) { labelStr += "???"; } @@ -113,9 +113,9 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { RDFNode fillerNode = hvRest.getHasValue(); try { if (fillerNode.isResource()) { - labelStr += getLabelOrId((OntResource)fillerNode.as(OntResource.class)); + labelStr += getLabelOrId(fillerNode.as(OntResource.class)); } else { - labelStr += ((Literal) fillerNode.as(Literal.class)).getLexicalForm(); + labelStr += fillerNode.as(Literal.class).getLexicalForm(); } } catch (Exception e) { labelStr += "???"; @@ -138,10 +138,10 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { String labelStr = "("; if (cls.isComplementClass()) { labelStr += "not "; - ComplementClass ccls = (ComplementClass) cls.as(ComplementClass.class); + ComplementClass ccls = cls.as(ComplementClass.class); labelStr += getLabelForClass(ccls.getOperand(),withPrefix,forPickList); } else if (cls.isIntersectionClass()) { - IntersectionClass icls = (IntersectionClass) cls.as(IntersectionClass.class); + IntersectionClass icls = cls.as(IntersectionClass.class); for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) { OntClass operand = (OntClass) operandIt.next(); labelStr += getLabelForClass(operand,withPrefix,forPickList); @@ -150,7 +150,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { } } } else if (cls.isUnionClass()) { - UnionClass icls = (UnionClass) cls.as(UnionClass.class); + UnionClass icls = cls.as(UnionClass.class); for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) { OntClass operand = (OntClass) operandIt.next(); labelStr += getLabelForClass(operand,withPrefix,forPickList); @@ -169,7 +169,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { } else { if (withPrefix || forPickList) { OntologyDao oDao=getWebappDaoFactory().getOntologyDao(); - Ontology o = (Ontology)oDao.getOntologyByURI(cls.getNameSpace()); + Ontology o = oDao.getOntologyByURI(cls.getNameSpace()); if (o!=null) { if (withPrefix) { return(o.getPrefix()==null?(o.getName()==null?"unspec:"+getLabelOrId(cls):o.getName()+":"+getLabelOrId(cls)):o.getPrefix()+":"+getLabelOrId(cls)); @@ -208,7 +208,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { while(restIt.hasNext()) { Resource restRes = restIt.next(); if (restRes.canAs(OntResource.class)) { - OntResource restOntRes = (OntResource) restRes.as(OntResource.class); + OntResource restOntRes = restRes.as(OntResource.class); smartRemove(restOntRes, ontModel); } } @@ -216,7 +216,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { while(restIt.hasNext()) { Resource restRes = restIt.next(); if (restRes.canAs(OntResource.class)) { - OntResource restOntRes = (OntResource) restRes.as(OntResource.class); + OntResource restOntRes = restRes.as(OntResource.class); smartRemove(restOntRes, ontModel); } } @@ -400,7 +400,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { List directSubclasses = getSubClassURIs(classURI); Iterator it=directSubclasses.iterator(); while(it.hasNext()){ - String uri = (String)it.next(); + String uri = it.next(); if (!subtree.contains(uri)) { subtree.add(uri); getAllSubClassURIs(uri,subtree); @@ -423,7 +423,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { while (superClassIt.hasNext()) { Statement stmt = superClassIt.nextStatement(); if (stmt.getObject().canAs(OntResource.class)) { - OntResource superRes = (OntResource) stmt.getObject().as(OntResource.class); + OntResource superRes = stmt.getObject().as(OntResource.class); String test = getClassURIStr(superRes); superclassURIs.add(test); } @@ -442,7 +442,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { List directSuperclasses = getSuperClassURIs(classURI, true); Iterator it=directSuperclasses.iterator(); while(it.hasNext()){ - String uri = (String)it.next(); + String uri = it.next(); if (!subtree.contains(uri)) { subtree.add(uri); getAllSuperClassURIs(uri,subtree); @@ -459,7 +459,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { while (classIt.hasNext()) { try { Individual classInd = classIt.next(); - OntClass cls = (OntClass) classInd.as(OntClass.class); + OntClass cls = classInd.as(OntClass.class); if (!cls.isAnon() && !(NONUSER_NAMESPACES.contains(cls.getNameSpace()))) { classes.add(new VClassJena(cls,getWebappDaoFactory())); } @@ -724,17 +724,17 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { Statement axStmt = (Statement) axStmtIt.next(); OntResource subjOntRes = null; if (axStmt.getSubject().canAs(OntResource.class)) { - subjOntRes = (OntResource) axStmt.getSubject().as(OntResource.class); + subjOntRes = axStmt.getSubject().as(OntResource.class); } if ( (subjOntRes != null) && (subjSuperclasses.contains(getClassURIStr(subjOntRes))) && (axStmt.getPredicate().equals(RDFS.subClassOf) || (axStmt.getPredicate().equals(OWL.equivalentClass))) ) { if (restRes.canAs(AllValuesFromRestriction.class)) { - AllValuesFromRestriction avfRest = (AllValuesFromRestriction) restRes.as(AllValuesFromRestriction.class); + AllValuesFromRestriction avfRest = restRes.as(AllValuesFromRestriction.class); Resource avf = avfRest.getAllValuesFrom(); if (avf.canAs(OntClass.class)) { - superclass = (OntClass) avfRest.getAllValuesFrom().as(OntClass.class); + superclass = avfRest.getAllValuesFrom().as(OntClass.class); } } } @@ -818,8 +818,8 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { while (annotIt.hasNext()) { try { Statement annot = (Statement) annotIt.next(); - Resource cls = (Resource) annot.getSubject(); - VClass vcw = (VClass) getVClassByURI(cls.getURI()); + Resource cls = annot.getSubject(); + VClass vcw = getVClassByURI(cls.getURI()); if (vcw != null) { boolean classIsInstantiated = false; if (getIndividualCount) { @@ -926,7 +926,7 @@ public class VClassDaoJena extends JenaBaseDao implements VClassDao { OntClass ontCls = ontModel.createClass(cls.getURI()); try { if (cls.getName() != null && cls.getName().length() > 0) { - ontCls.setLabel(cls.getName(), (String) getDefaultLanguage()); + ontCls.setLabel(cls.getName(), getDefaultLanguage()); } else { ontCls.removeAll(RDFS.label); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoSDB.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoSDB.java index a5cb04e47..abe8d0bbd 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoSDB.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoSDB.java @@ -2,6 +2,9 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena; + +import com.hp.hpl.jena.ontology.AnnotationProperty; +import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.query.Dataset; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; @@ -59,9 +62,9 @@ public class VClassDaoSDB extends VClassDaoJena { try { while (annotIt.hasNext()) { try { - Statement annot = (Statement) annotIt.nextStatement(); - Resource cls = (Resource) annot.getSubject(); - VClass vcw = (VClass) getVClassByURI(cls.getURI()); + Statement annot = (Statement) annotIt.next(); + Resource cls = annot.getSubject(); + VClass vcw = getVClassByURI(cls.getURI()); if (vcw != null) { boolean classIsInstantiated = false; if (getIndividualCount) { diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupCache.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupCache.java index cf8387a06..40e0eaddd 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupCache.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupCache.java @@ -4,10 +4,8 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; @@ -33,7 +31,6 @@ import com.hp.hpl.jena.vocabulary.RDFS; import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; -import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupDaoJena.java index d45fa222e..37bcf9434 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassGroupDaoJena.java @@ -14,11 +14,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; -import com.hp.hpl.jena.ontology.DatatypeProperty; import com.hp.hpl.jena.ontology.Individual; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModelSpec; -import com.hp.hpl.jena.rdf.model.Literal; import com.hp.hpl.jena.rdf.model.ModelFactory; import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.rdf.model.ResourceFactory; @@ -32,7 +30,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.InsertException; import edu.cornell.mannlib.vitro.webapp.dao.VClassDao; import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch; @@ -82,7 +79,7 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao { ClosableIterator groupIt = getOntModel().listIndividuals(CLASSGROUP); try { while (groupIt.hasNext()) { - Individual groupInd = (Individual) groupIt.next(); + Individual groupInd = groupIt.next(); VClassGroup group = groupFromGroupIndividual(groupInd); if (group!=null) { groups.add(group); @@ -94,7 +91,7 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao { Collections.sort(groups); Iterator groupsIt = groups.iterator(); while (groupsIt.hasNext()) { - VClassGroup group = (VClassGroup) groupsIt.next(); + VClassGroup group = groupsIt.next(); map.put(group.getPublicName(), group); } return map; @@ -140,7 +137,7 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao { ClosableIterator groupIt = getOntModel().listIndividuals(CLASSGROUP); try { while (groupIt.hasNext()) { - Individual grp = (Individual) groupIt.next(); + Individual grp = groupIt.next(); VClassGroup vgrp = groupFromGroupIndividual(grp); if (vgrp != null) { groups.add(vgrp); @@ -247,7 +244,7 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao { int removedGroupsCount = 0; ListIterator it = groups.listIterator(); while(it.hasNext()){ - VClassGroup group = (VClassGroup) it.next(); + VClassGroup group = it.next(); List classes = group.getVitroClassList(); if( classes == null || classes.size() < 1 ){ removedGroupsCount++; @@ -283,7 +280,7 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao { try { Individual groupInd = ontModel.getIndividual(vcg.getURI()); try { - groupInd.setLabel(vcg.getPublicName(), (String) getDefaultLanguage()); + groupInd.setLabel(vcg.getPublicName(), getDefaultLanguage()); } catch (Exception e) { log.error("error updating name for "+groupInd.getURI()); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassJena.java index 1715eeec9..c4db19dd2 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassJena.java @@ -324,7 +324,7 @@ public class VClassJena extends VClass { Statement stmt = it.nextStatement(); RDFNode obj; if( stmt != null && (obj = stmt.getObject()) != null && obj.isURIResource() ){ - Resource res = (Resource)obj.as(Resource.class); + Resource res = obj.as(Resource.class); if( res != null && res.getURI() != null ){ BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI()); if( roleFromModel != null && @@ -358,7 +358,7 @@ public class VClassJena extends VClass { Statement stmt = it.nextStatement(); RDFNode obj; if( stmt != null && (obj = stmt.getObject()) != null && obj.isURIResource() ){ - Resource res = (Resource)obj.as(Resource.class); + Resource res = obj.as(Resource.class); if( res != null && res.getURI() != null ){ BaseResourceBean.RoleLevel roleFromModel = BaseResourceBean.RoleLevel.getRoleByUri(res.getURI()); if( roleFromModel != null && diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaSpecialModelMaker.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaSpecialModelMaker.java index 4dd2cfcc3..1feb261f9 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaSpecialModelMaker.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VitroJenaSpecialModelMaker.java @@ -2,8 +2,6 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena; -import java.util.HashMap; - import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; @@ -14,7 +12,6 @@ import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.rdf.model.Model; import com.hp.hpl.jena.rdf.model.ModelMaker; import com.hp.hpl.jena.rdf.model.ModelReader; -import com.hp.hpl.jena.rdf.model.Resource; import com.hp.hpl.jena.util.iterator.ExtendedIterator; /** diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java index f519824a1..6ec54c82e 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/WebappDaoFactoryJena.java @@ -11,7 +11,6 @@ import java.util.Set; import com.hp.hpl.jena.iri.IRI; import com.hp.hpl.jena.iri.IRIFactory; -import com.hp.hpl.jena.iri.Violation; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.ontology.OntResource; @@ -184,7 +183,7 @@ public class WebappDaoFactoryJena implements WebappDaoFactory { IRI iri = factory.create( uriStr ); if (iri.hasViolation(false) ) { validURI = false; - errorMsg += ((Violation)iri.violations(false).next()) + errorMsg += (iri.violations(false).next()) .getShortMessage() + " "; } else if (checkUniqueness) { OntModel ontModel = ontModelSelector.getFullModel(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/pellet/ObjectPropertyStatementPatternFactory.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/pellet/ObjectPropertyStatementPatternFactory.java index ad7ac82f8..57fb8f900 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/pellet/ObjectPropertyStatementPatternFactory.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/pellet/ObjectPropertyStatementPatternFactory.java @@ -2,15 +2,9 @@ package edu.cornell.mannlib.vitro.webapp.dao.jena.pellet; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - import com.hp.hpl.jena.rdf.model.Property; import com.hp.hpl.jena.rdf.model.Resource; -import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.ObjectPropertyStatementPattern; - public class ObjectPropertyStatementPatternFactory { //private static Set patternSet = new HashSet(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/pellet/PelletListener.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/pellet/PelletListener.java index 2a2e1fda1..58be08c6d 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/pellet/PelletListener.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/pellet/PelletListener.java @@ -320,9 +320,9 @@ public class PelletListener implements ModelChangedListener { try { if ( ( ((Resource)stmt.getObject()).equals(RDFS.Resource) ) ) { reject = true; - } else if ( ( ((Resource)stmt.getSubject()).equals(OWL.Nothing) ) ) { + } else if ( ( stmt.getSubject().equals(OWL.Nothing) ) ) { reject = true; - } else if ( ( ((Resource)stmt.getObject()).equals(OWL.Nothing) ) ) { + } else if ( ( stmt.getObject().equals(OWL.Nothing) ) ) { reject = true; } } catch (Exception e) {} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3Map.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3Map.java index 6612cf8a0..4900cba6f 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3Map.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3Map.java @@ -2,27 +2,11 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils; -import java.lang.reflect.Constructor; import java.util.HashMap; -import java.util.Map; - -import javax.servlet.ServletContext; - -import net.sf.json.JSONObject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.rdf.model.RDFNode; -import com.hp.hpl.jena.rdf.model.ResourceFactory; -import com.hp.hpl.jena.rdf.model.StmtIterator; - -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3; -import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetter; - /* * This class determines what n3 should be returned for a particular data getter and can be overwritten or extended in VIVO. */ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3Utils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3Utils.java index a4dbacd0b..64a64b36c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3Utils.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/edit/n3editing/configuration/preprocessors/utils/ProcessDataGetterN3Utils.java @@ -4,25 +4,12 @@ package edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocess import java.lang.reflect.Constructor; import java.util.HashMap; -import java.util.Map; - -import javax.servlet.ServletContext; import net.sf.json.JSONObject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.rdf.model.RDFNode; -import com.hp.hpl.jena.rdf.model.ResourceFactory; -import com.hp.hpl.jena.rdf.model.StmtIterator; - -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext; -import edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.utils.ProcessDataGetterN3; -import edu.cornell.mannlib.vitro.webapp.utils.dataGetter.DataGetter; - /* * This class determines what n3 should be returned for a particular data getter and can be overwritten or extended in VIVO. */ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/email/FreemarkerEmailFactory.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/email/FreemarkerEmailFactory.java index bedeab160..05e3c7a51 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/email/FreemarkerEmailFactory.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/email/FreemarkerEmailFactory.java @@ -61,8 +61,8 @@ public class FreemarkerEmailFactory { FreemarkerEmailFactory factory = getFactory(vreq); FreemarkerConfiguration fConfig = FreemarkerConfigurationLoader .getConfig(vreq); - return new FreemarkerEmailMessage(fConfig, factory.getEmailSession(), - factory.getReplyToAddress()); + return new FreemarkerEmailMessage(vreq, fConfig, + factory.getEmailSession(), factory.getReplyToAddress()); } /** diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/email/FreemarkerEmailMessage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/email/FreemarkerEmailMessage.java index db7356ed4..6fab17daa 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/email/FreemarkerEmailMessage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/email/FreemarkerEmailMessage.java @@ -27,8 +27,10 @@ import javax.mail.internet.MimeMultipart; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerConfiguration; import edu.cornell.mannlib.vitro.webapp.web.directives.EmailDirective; +import freemarker.core.Environment; import freemarker.template.Template; import freemarker.template.TemplateException; @@ -47,7 +49,8 @@ public class FreemarkerEmailMessage { private static final Log log = LogFactory .getLog(FreemarkerEmailMessage.class); - private final Session session; + private final VitroRequest vreq; + private final Session mailSession; private final FreemarkerConfiguration config; private final List recipients = new ArrayList(); @@ -63,9 +66,10 @@ public class FreemarkerEmailMessage { /** * Package access - should only be created by the factory. */ - FreemarkerEmailMessage(FreemarkerConfiguration fConfig, Session session, - InternetAddress replyToAddress) { - this.session = session; + FreemarkerEmailMessage(VitroRequest vreq, FreemarkerConfiguration fConfig, + Session mailSession, InternetAddress replyToAddress) { + this.vreq = vreq; + this.mailSession = mailSession; this.replyToAddress = replyToAddress; this.config = fConfig; } @@ -141,7 +145,13 @@ public class FreemarkerEmailMessage { try { Template template = config.getTemplate(templateName); - template.process(bodyMap, new StringWriter()); + + Environment env = template.createProcessingEnvironment(bodyMap, + new StringWriter()); + env.setCustomAttribute("request", vreq); + env.setCustomAttribute("context", vreq.getSession() + .getServletContext()); + env.process(); } catch (TemplateException e) { log.error(e, e); } catch (IOException e) { @@ -151,7 +161,7 @@ public class FreemarkerEmailMessage { public boolean send() { try { - MimeMessage msg = new MimeMessage(session); + MimeMessage msg = new MimeMessage(mailSession); msg.setReplyTo(new Address[] { replyToAddress }); if (fromAddress == null) { @@ -199,11 +209,11 @@ public class FreemarkerEmailMessage { bodyPart.setContent(textBody, type); content.addBodyPart(bodyPart); } - - public String getReplyToAddress() { - return replyToAddress.getAddress(); - } - + + public String getReplyToAddress() { + return replyToAddress.getAddress(); + } + private T nonNull(T value, T defaultValue) { return (value == null) ? defaultValue : value; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java index f1d7a6e71..3f58cd191 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/VitroRequestPrep.java @@ -11,6 +11,7 @@ import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_MODEL_P import static edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary.USE_TBOX_MODEL_PARAM; import java.io.IOException; +import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -47,10 +48,14 @@ import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.FilterFactory; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.HideFromDisplayByPolicyFilter; import edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.VitroFilters; import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext; +import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph; import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroModelSource; import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena; import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB; +import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringRDFService; +import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringUtils; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; +import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel; import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase; /** @@ -133,6 +138,22 @@ public class VitroRequestPrep implements Filter { log.debug("Found a WebappDaoFactory in the session and using it for this request"); } + // Set up the DisplayModel, with language filtering if appropriate. + OntModel displayModel; + Object displayModelObject = req.getSession().getAttribute(DISPLAY_ONT_MODEL); + if (displayModelObject instanceof OntModel) { + displayModel = (OntModel) displayModelObject; + } else { + displayModel = (OntModel) _context.getAttribute(DISPLAY_ONT_MODEL); + } + + if (Boolean.valueOf(ConfigurationProperties.getBean(vreq).getProperty( + "RDFService.languageFilter", "true"))) { + displayModel = LanguageFilteringUtils.wrapOntModelInALanguageFilter(displayModel, req); + } + vreq.setAttribute(DISPLAY_ONT_MODEL, displayModel); + + //Do model switching and replace the WebappDaoFactory with //a different version if requested by parameters wdf = checkForModelSwitching(vreq, wdf); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/WebappDaoFactorySDBPrep.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/WebappDaoFactorySDBPrep.java index 4bb7fda8e..5dd3652f7 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/WebappDaoFactorySDBPrep.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/filters/WebappDaoFactorySDBPrep.java @@ -3,10 +3,7 @@ package edu.cornell.mannlib.vitro.webapp.filters; import java.io.IOException; -import java.util.ArrayList; -import java.util.Enumeration; import java.util.List; -import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -22,6 +19,7 @@ import javax.servlet.http.HttpServletRequest; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntModelSpec; import com.hp.hpl.jena.query.Dataset; import com.hp.hpl.jena.rdf.model.ModelFactory; @@ -38,6 +36,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactorySDB.SDBDatasetM import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFService; import edu.cornell.mannlib.vitro.webapp.rdfservice.RDFServiceFactory; import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringRDFService; +import edu.cornell.mannlib.vitro.webapp.rdfservice.filter.LanguageFilteringUtils; import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.RDFServiceUtils; public class WebappDaoFactorySDBPrep implements Filter { @@ -88,18 +87,10 @@ public class WebappDaoFactorySDBPrep implements Filter { String defaultNamespace = (String) _ctx.getAttribute("defaultNamespace"); WebappDaoFactory wadf = null; VitroRequest vreq = new VitroRequest((HttpServletRequest) request); - - List langs = new ArrayList(); + + log.debug("Accept-Language: " + vreq.getHeader("Accept-Language")); + List langs = LanguageFilteringUtils.localesToLanguages(vreq.getLocales()); - log.debug("Accept-Language: " + vreq.getHeader("Accept-Language")); - Enumeration locs = vreq.getLocales(); - while (locs.hasMoreElements()) { - Locale locale = locs.nextElement(); - langs.add(locale.toString().replace("_", "-")); - } - if (langs.isEmpty()) { - langs.add("en"); - } WebappDaoFactoryConfig config = new WebappDaoFactoryConfig(); config.setDefaultNamespace(defaultNamespace); config.setPreferredLanguages(langs); @@ -110,12 +101,14 @@ public class WebappDaoFactorySDBPrep implements Filter { RDFService unfilteredRDFService = factory.getShortTermRDFService(); RDFService rdfService = null; - if (!"false".equals( - ConfigurationProperties.getBean(vreq).getProperty( - "RDFService.languageFilter", "true"))) { - rdfService = new LanguageFilteringRDFService(unfilteredRDFService, langs); + if (Boolean.valueOf(ConfigurationProperties.getBean(vreq).getProperty( + "RDFService.languageFilter", "true"))) { + rdfService = new LanguageFilteringRDFService(unfilteredRDFService, langs); + oms = LanguageFilteringUtils.replaceDisplayModelInSelector(oms, + LanguageFilteringUtils.wrapOntModelInALanguageFilter(oms.getDisplayModel(), request)); + baseOms = LanguageFilteringUtils.replaceDisplayModelInSelector(baseOms, oms.getDisplayModel()); } else { - rdfService = unfilteredRDFService; + rdfService = unfilteredRDFService; } Dataset dataset = new RDFServiceDataset(rdfService); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/I18nBundle.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/I18nBundle.java index 7ea5acc3d..44b930089 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/I18nBundle.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/I18nBundle.java @@ -39,8 +39,9 @@ public class I18nBundle { public I18nBundle(String bundleName, ResourceBundle resources) { this(bundleName, resources, MESSAGE_KEY_NOT_FOUND); } - - private I18nBundle(String bundleName, ResourceBundle resources, String notFoundMessage) { + + private I18nBundle(String bundleName, ResourceBundle resources, + String notFoundMessage) { if (bundleName == null) { throw new IllegalArgumentException("bundleName may not be null"); } @@ -49,20 +50,22 @@ public class I18nBundle { } if (resources == null) { throw new NullPointerException("resources may not be null."); - }if (notFoundMessage == null) { + } + if (notFoundMessage == null) { throw new NullPointerException("notFoundMessage may not be null."); } this.bundleName = bundleName; this.resources = resources; this.notFoundMessage = notFoundMessage; } - + public String text(String key, Object... parameters) { - log.debug("Asking for '" + key + "' from bundle '" + bundleName + "'"); String textString; if (resources.containsKey(key)) { textString = resources.getString(key); + log.debug("In '" + bundleName + "', " + key + "='" + textString + + "')"); return formatString(textString, parameters); } else { String message = MessageFormat.format(notFoundMessage, bundleName, diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/VitroResourceBundle.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/VitroResourceBundle.java index c9b2b2acb..93a7131ca 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/VitroResourceBundle.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/i18n/VitroResourceBundle.java @@ -53,6 +53,23 @@ public class VitroResourceBundle extends ResourceBundle { // Factory method // ---------------------------------------------------------------------- + /** + * Returns the bundle for the for foo_ba_RR, providing that + * foo_ba_RR.properties exists in the I18n area of either the theme or the + * application. + * + * If the desired file doesn't exist in either location, return null. + * Usually, this does not indicate a problem but only that we were looking + * for too specific a bundle. For example, if the base name of the bundle is + * "all" and the locale is "en_US", we will likely return null on the search + * for all_en_US.properties, and all_en.properties, but will return a full + * bundle for all.properties. + * + * Of course, if all.properties doesn't exist either, then we have a + * problem, but that will be reported elsewhere. + * + * @return the populated bundle or null. + */ public static VitroResourceBundle getBundle(String bundleName, ServletContext ctx, String appI18nPath, String themeI18nPath, Control control) { @@ -60,7 +77,7 @@ public class VitroResourceBundle extends ResourceBundle { return new VitroResourceBundle(bundleName, ctx, appI18nPath, themeI18nPath, control); } catch (FileNotFoundException e) { - log.debug(e); + log.debug(e.getMessage()); return null; } catch (Exception e) { log.warn(e, e); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/filter/LanguageFilteringRDFService.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/filter/LanguageFilteringRDFService.java index 1df269857..936462153 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/filter/LanguageFilteringRDFService.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/filter/LanguageFilteringRDFService.java @@ -8,8 +8,10 @@ import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; +import java.util.Enumeration; import java.util.Iterator; import java.util.List; +import java.util.Locale; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -368,17 +370,20 @@ public class LanguageFilteringRDFService implements RDFService { int index = langs.indexOf(lang); if (index >= 0) { + log.debug("languageIndex for '" + lang + "' is " + index); return index; } if (lang.length() > 2) { index = langs.indexOf(lang.substring(0, 2)); if (index >= 0) { + log.debug("languageIndex for '" + lang + "' is " + index + inexactMatchPenalty); return index + inexactMatchPenalty; } } if (lang.isEmpty()) { + log.debug("languageIndex for '" + lang + "' is " + noLanguage); return noLanguage; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/filter/LanguageFilteringUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/filter/LanguageFilteringUtils.java new file mode 100644 index 000000000..aae04c1b5 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/rdfservice/filter/LanguageFilteringUtils.java @@ -0,0 +1,81 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.rdfservice.filter; + +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Locale; + +import javax.servlet.ServletRequest; + +import com.hp.hpl.jena.ontology.OntModel; +import com.hp.hpl.jena.ontology.OntModelSpec; +import com.hp.hpl.jena.rdf.model.ModelFactory; + +import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelector; +import edu.cornell.mannlib.vitro.webapp.dao.jena.OntModelSelectorImpl; +import edu.cornell.mannlib.vitro.webapp.dao.jena.RDFServiceGraph; +import edu.cornell.mannlib.vitro.webapp.rdfservice.impl.jena.model.RDFServiceModel; + +/** + * Some methods that will come in handy when dealing with Language Filtering + */ +public class LanguageFilteringUtils { + + /** + * Take an Enumeration of Locale objects, such as we might get from a + * request, and convert to a List of langauage strings, such as are needed + * by the LanguageFilteringRDFService. + * + * While converting, change all underscores (as in Locale names) to hyphens + * (as in RDF language specifiers). + */ + public static List localesToLanguages(Enumeration locales) { + List langs = new ArrayList<>(); + while (locales.hasMoreElements()) { + Locale locale = (Locale) locales.nextElement(); + langs.add(locale.toString().replace("_", "-")); + } + if (langs.isEmpty()) { + langs.add("en"); + } + return langs; + + } + + /** + * Make a new OntModelSelector that containing a new display model and all + * of the other models in the original OntModelSelector. + */ + public static OntModelSelector replaceDisplayModelInSelector( + OntModelSelector oldOms, OntModel newDisplayModel) { + OntModelSelectorImpl newOms = new OntModelSelectorImpl(); + newOms.setABoxModel(oldOms.getABoxModel()); + newOms.setApplicationMetadataModel(oldOms.getApplicationMetadataModel()); + newOms.setDisplayModel(newDisplayModel); + newOms.setFullModel(oldOms.getFullModel()); + newOms.setTBoxModel(oldOms.getTBoxModel()); + newOms.setUserAccountsModel(oldOms.getUserAccountsModel()); + return newOms; + } + + /** + * Add a Language Filtering layer to an OntModel by treating it as an RDFService. + */ + public static OntModel wrapOntModelInALanguageFilter(OntModel rawModel, + ServletRequest req) { + /** This is some nasty layering. Could we do this more easily? */ + List languages = localesToLanguages(req.getLocales()); + return ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, + RDFServiceGraph.createRDFServiceModel( + new RDFServiceGraph( + new LanguageFilteringRDFService( + new RDFServiceModel(rawModel), languages)))); + } + + private LanguageFilteringUtils() { + // Nothing to instantiate + } + +} diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java index d85ba6ada..7889a825a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/search/controller/PagedSearchController.java @@ -211,7 +211,8 @@ public class PagedSearchController extends FreemarkerHttpServlet { Map body = new HashMap(); - String classGroupParam = vreq.getParameter(PARAM_CLASSGROUP); + String classGroupParam = vreq.getParameter(PARAM_CLASSGROUP); + log.debug("Query text is \""+ classGroupParam + "\""); boolean classGroupFilterRequested = false; if (!StringUtils.isEmpty(classGroupParam)) { VClassGroup grp = grpDao.getGroupByURI(classGroupParam); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/WebappDaoSetup.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/WebappDaoSetup.java index 5ad2fb4ce..b55cba9fd 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/WebappDaoSetup.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/servlet/setup/WebappDaoSetup.java @@ -94,17 +94,10 @@ public class WebappDaoSetup extends JenaDataSourceSetupBase setStartupDataset(dataset, ctx); // ABox assertions - Model aboxAssertions = dataset.getNamedModel( - JenaDataSourceSetupBase.JENA_DB_MODEL); - baseOms.setABoxModel( - ModelFactory.createOntologyModel( - OntModelSpec.OWL_MEM, aboxAssertions)); + baseOms.setABoxModel(ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, dataset.getNamedModel(JenaDataSourceSetupBase.JENA_DB_MODEL))); // ABox inferences - Model aboxInferences = dataset.getNamedModel( - JenaDataSourceSetupBase.JENA_INF_MODEL); - inferenceOms.setABoxModel(ModelFactory.createOntologyModel( - OntModelSpec.OWL_MEM, aboxInferences)); + inferenceOms.setABoxModel(ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, dataset.getNamedModel(JenaDataSourceSetupBase.JENA_INF_MODEL))); // TBox assertions try { @@ -115,15 +108,11 @@ public class WebappDaoSetup extends JenaDataSourceSetupBase if (tboxAssertionsDB != null) { long startTime = System.currentTimeMillis(); - System.out.println( - "Copying cached tbox assertions into memory"); + log.info("Copying cached tbox assertions into memory"); tboxAssertions.add(tboxAssertionsDB); - System.out.println((System.currentTimeMillis() - startTime) - / 1000 + " seconds to load tbox assertions"); + log.info((System.currentTimeMillis() - startTime)/ 1000 + " seconds to load tbox assertions"); + tboxAssertions.getBaseModel().register(new ModelSynchronizer(tboxAssertionsDB)); } - - tboxAssertions.getBaseModel().register(new ModelSynchronizer( - tboxAssertionsDB)); baseOms.setTBoxModel(tboxAssertions); } catch (Throwable e) { @@ -139,15 +128,15 @@ public class WebappDaoSetup extends JenaDataSourceSetupBase if (tboxInferencesDB != null) { long startTime = System.currentTimeMillis(); - System.out.println( + log.info( "Copying cached tbox inferences into memory"); tboxInferences.add(tboxInferencesDB); System.out.println((System.currentTimeMillis() - startTime) / 1000 + " seconds to load tbox inferences"); + + tboxInferences.getBaseModel().register(new ModelSynchronizer( + tboxInferencesDB)); } - - tboxInferences.getBaseModel().register(new ModelSynchronizer( - tboxInferencesDB)); inferenceOms.setTBoxModel(tboxInferences); } catch (Throwable e) { log.error("Unable to load tbox inference cache from DB", e); @@ -155,7 +144,6 @@ public class WebappDaoSetup extends JenaDataSourceSetupBase } // union ABox - Model m = ModelFactory.createUnion( baseOms.getABoxModel(), inferenceOms.getABoxModel()); m = ModelFactory.createModelForGraph( @@ -167,8 +155,7 @@ public class WebappDaoSetup extends JenaDataSourceSetupBase unionOms.setABoxModel(unionABoxModel); // union TBox - m = ModelFactory.createUnion( - baseOms.getTBoxModel(), inferenceOms.getTBoxModel()); + m = ModelFactory.createUnion(baseOms.getTBoxModel(), inferenceOms.getTBoxModel()); m = ModelFactory.createModelForGraph( new SpecialBulkUpdateHandlerGraph( m.getGraph(), diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/IndividualsForClassesDataGetter.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/IndividualsForClassesDataGetter.java index c4787acfb..f8e51c9ff 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/IndividualsForClassesDataGetter.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/IndividualsForClassesDataGetter.java @@ -5,7 +5,6 @@ package edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -17,22 +16,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONObject; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.RDFNode; -import com.hp.hpl.jena.rdf.model.ResourceFactory; -import com.hp.hpl.jena.rdf.model.Statement; -import com.hp.hpl.jena.rdf.model.StmtIterator; - -import edu.cornell.mannlib.vitro.webapp.beans.Individual; import edu.cornell.mannlib.vitro.webapp.beans.VClass; import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup; import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; -import edu.cornell.mannlib.vitro.webapp.controller.freemarker.IndividualListController; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; -import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.PageDao; -import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; -import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext; import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache; import edu.cornell.mannlib.vitro.webapp.web.templatemodels.VClassGroupTemplateModel; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/solr/SolrQueryUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/solr/SolrQueryUtils.java index c90281377..608ae0efc 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/solr/SolrQueryUtils.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/solr/SolrQueryUtils.java @@ -190,6 +190,26 @@ public class SolrQueryUtils { } } + public static SolrQuery getRandomQuery(List vclassUris, int page, int pageSize){ + String queryText = ""; + + try { + queryText = makeMultiClassQuery(vclassUris); + log.debug("queryText is " + queryText); + SolrQuery query = new SolrQuery(queryText); + + //page count starts at 1, row count starts at 0 + query.setStart( page ).setRows( pageSize ); + + log.debug("Query is " + query.toString()); + return query; + + } catch (Exception ex){ + log.error("Could not make the Solr query",ex); + return new SolrQuery(); + } + } + public static String makeMultiClassQuery( List vclassUris){ List queryTypes = new ArrayList(); try { @@ -217,4 +237,16 @@ public class SolrQueryUtils { return results; } + public static IndividualListQueryResults buildAndExecuteRandomVClassQuery( + List vclassURIs, int page, int pageSize, + ServletContext context, IndividualDao indDao) + throws SolrServerException { + SolrQuery query = SolrQueryUtils.getRandomQuery(vclassURIs, page, pageSize); + IndividualListQueryResults results = IndividualListQueryResults.runQuery(query, indDao, context); + log.debug("Executed solr query for " + vclassURIs); + if (results.getIndividuals().isEmpty()) { + log.debug("entities list is null for vclass " + vclassURIs); + } + return results; + } } diff --git a/webapp/themes/vitro/images/filteredSearch.gif b/webapp/themes/vitro/images/filteredSearch.gif new file mode 100644 index 000000000..16bb82be2 Binary files /dev/null and b/webapp/themes/vitro/images/filteredSearch.gif differ diff --git a/webapp/themes/vitro/images/filteredSearchActive.gif b/webapp/themes/vitro/images/filteredSearchActive.gif new file mode 100644 index 000000000..8ef75fbeb Binary files /dev/null and b/webapp/themes/vitro/images/filteredSearchActive.gif differ diff --git a/webapp/themes/vitro/images/limit-search.png b/webapp/themes/vitro/images/limit-search.png new file mode 100644 index 000000000..9eabf8cd0 Binary files /dev/null and b/webapp/themes/vitro/images/limit-search.png differ diff --git a/webapp/themes/vitro/images/search-field-and-button.gif b/webapp/themes/vitro/images/search-field-and-button.gif new file mode 100644 index 000000000..3b672288e Binary files /dev/null and b/webapp/themes/vitro/images/search-field-and-button.gif differ diff --git a/webapp/themes/vitro/templates/page-home.ftl b/webapp/themes/vitro/templates/page-home.ftl index a052acfe2..0e3ab91f4 100644 --- a/webapp/themes/vitro/templates/page-home.ftl +++ b/webapp/themes/vitro/templates/page-home.ftl @@ -1,7 +1,7 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> <@widget name="login" include="assets" /> -<#include "browse-classgroups.ftl"> +<#import "lib-home-page.ftl" as lh> @@ -36,17 +36,14 @@
+
filter search @@ -57,22 +54,18 @@ <@widget name="login" /> - - <#--<@allClassGroups vClassGroups! />--> - -
-

Stats

- - -
+ + + <@lh.allClassGroups vClassGroups! /> <#include "footer.ftl"> + \ No newline at end of file diff --git a/webapp/web/css/vitro.css b/webapp/web/css/vitro.css index ea8b9cac4..54e42a6c3 100644 --- a/webapp/web/css/vitro.css +++ b/webapp/web/css/vitro.css @@ -251,6 +251,7 @@ p#mngLabelsText { /* SEARCH HOME------> */ #search-home { margin-top: 2em; + width: 570px; } #search-home h3 { @@ -341,11 +342,10 @@ a.filter-search { margin-top: 1em; width: 921px; height: 213px; - float: left; + clear: both; } -#home-stats h4 { +.home-sections h4 { margin-top: 0; - width: 64px; height: 34px; font-size: 18px; text-align: center; @@ -353,6 +353,9 @@ a.filter-search { padding: 0; line-height: 35px; } +#home-stats h4 { + width: 102px; +} #stats { margin: 0 auto; width: 875px; diff --git a/webapp/web/i18n/all.properties b/webapp/web/i18n/all.properties new file mode 100644 index 000000000..72f4b4935 --- /dev/null +++ b/webapp/web/i18n/all.properties @@ -0,0 +1,366 @@ +# +# Text strings for the controllers and templates +# +# Default (English) +# +save_changes = Save changes +cancel_link = Cancel +cancel_title = cancel +required_fields = required fields +or = or +alt_error_alert = Error alert icon +alt_confirmation = Confirmation icon + +email_address = Email address +first_name = First name +last_name = Last name +roles = Roles +status = Status + +ascending_order = ascending order +descending_order = descending order +select_one = Select one + +type_more_characters = type more characters +no_match = no match + +request_failed = Request failed. Please contact your system administrator. + +# +# Image upload pages +# +upload_page_title = Upload image +upload_page_title_with_name = Upload image for {0} +upload_heading = Photo Upload + +replace_page_title = Replace image +replace_page_title_with_name = Replace image for {0} + +crop_page_title = Crop image +crop_page_title_with_name = Crop image for {0} + +current_photo = Current Photo +upload_photo = Upload a photo +replace_photo = Replace Photo +photo_types = (JPEG, GIF or PNG) +maximum_file_size = Maximum file size: {0} megabytes +minimum_image_dimensions = Minimum image dimensions: {0} x {1} pixels + +cropping_caption = Your profile photo will look like the image below. +cropping_note = To make adjustments, you can drag around and resize the photo to the right. \ + When you are happy with your photo click the "Save Photo" button. + +alt_thumbnail_photo = Individual photo +alt_image_to_crop = Image to be cropped +alt_preview_crop = Preview of photo cropped + +delete_link = Delete photo +submit_upload = Upload photo +submit_save = Save photo + +confirm_delete = Are you sure you want to delete this photo? + +imageUpload.errorNoURI = No entity URI was provided +imageUpload.errorUnrecognizedURI = This URI is not recognized as belonging to anyone: ''{0}'' +imageUpload.errorNoImageForCropping = There is no image file to be cropped. +imageUpload.errorImageTooSmall = The uploaded image should be at least {0} pixels high and {1} pixels wide. +imageUpload.errorUnknown = Sorry, we were unable to process the photo you provided. Please try another photo. +imageUpload.errorFileTooBig = Please upload an image smaller than {0} megabytes. +imageUpload.errorUnrecognizedFileType = ''{0}'' is not a recognized image file type. Please upload JPEG, GIF, or PNG files only. +imageUpload.errorNoPhotoSelected = Please browse and select a photo. +imageUpload.errorBadMultipartRequest = Failed to parse the multi-part request for uploading an image. +imageUpload.errorFormFieldMissing = The form did not contain a ''{0}'' field." + +# +# User Accounts pages +# +account_management = Account Management +user_accounts_link = User accounts +user_accounts_title = user accounts + +login_count = Login count +last_login = Last Login + +add_new_account = Add new account +edit_account = Edit account +external_auth_only = Externally Authenticated Only +reset_password = Reset password +reset_password_note = Note: Instructions for resetting the password will \ + be emailed to the address entered above. The password will not \ + be reset until the user follows the link provided in this email. +new_password = New password +confirm_password = Confirm new password +minimum_password_length = Minimum of {0} characters in length. +leave_password_unchanged = Leaving this blank means that the password will not be changed. +confirm_initial_password = Confirm initial password + +new_account_1 = A new account for +new_account_2 = was successfully created. +new_account_title = new account +new_account_notification = A notification email has been sent to {0} \ + with instructions for activating the account and creating a password. +updated_account_1 = The account for +updated_account_2 = has been updated. +updated_account_title = updated account +updated_account_notification = A confirmation email has been sent to {0} \ + with instructions for resetting a password. \ + The password will not be reset until the user follows the link provided in this email. +deleted_accounts = Deleted {0} {0, choice, 0#accounts |1#account |1 + + {1} + + +

+ {2} {3} +

+ +

+ Congratulations! +

+ +

+ We have created your new account on {0}, associated with {4}. +

+ +

+ If you did not request this new account you can safely ignore this email. + This request will expire if not acted upon for 30 days. +

+ +

+ Click the link below to create your password for your new account using our secure server. +

+ +

+ {5} +

+ +

+ If the link above doesn't work, you can copy and paste the link directly into your browser's address bar. +

+ +

+ Thanks! +

+ + diff --git a/webapp/web/i18n/files/accountCreatedEmail.txt b/webapp/web/i18n/files/accountCreatedEmail.txt new file mode 100644 index 000000000..4dcd900c8 --- /dev/null +++ b/webapp/web/i18n/files/accountCreatedEmail.txt @@ -0,0 +1,17 @@ +{2} {3} + +Congratulations! + +We have created your new account on {0}, +associated with {4}. + +If you did not request this new account you can safely ignore this email. +This request will expire if not acted upon for 30 days. + +Paste the link below into your browser's address bar to create your password +for your new account using our secure server. + +{5} + +Thanks! + diff --git a/webapp/web/i18n/files/accountCreatedExternalOnlyEmail.html b/webapp/web/i18n/files/accountCreatedExternalOnlyEmail.html new file mode 100644 index 000000000..164bf87ae --- /dev/null +++ b/webapp/web/i18n/files/accountCreatedExternalOnlyEmail.html @@ -0,0 +1,22 @@ + + + ${1} + + +

+ ${2} ${3} +

+ +

+ Congratulations! +

+ +

+ We have created your new VIVO account associated with ${4}. +

+ +

+ Thanks! +

+ + diff --git a/webapp/web/i18n/files/accountCreatedExternalOnlyEmail.txt b/webapp/web/i18n/files/accountCreatedExternalOnlyEmail.txt new file mode 100644 index 000000000..c55cb3f9a --- /dev/null +++ b/webapp/web/i18n/files/accountCreatedExternalOnlyEmail.txt @@ -0,0 +1,9 @@ +${2} ${3} + +Congratulations! + +We have created your new VIVO account associated with +${4}. + +Thanks! + diff --git a/webapp/web/i18n/files/accountEmailChanged.html b/webapp/web/i18n/files/accountEmailChanged.html new file mode 100644 index 000000000..5a2e51e50 --- /dev/null +++ b/webapp/web/i18n/files/accountEmailChanged.html @@ -0,0 +1,19 @@ + + + {1} + + +

+ Hi, {2} ${3} +

+ +

+ You recently changed the email address associated with + ${2} ${3} +

+ +

+ Thank you. +

+ + diff --git a/webapp/web/i18n/files/accountEmailChanged.txt b/webapp/web/i18n/files/accountEmailChanged.txt new file mode 100644 index 000000000..5f560dca1 --- /dev/null +++ b/webapp/web/i18n/files/accountEmailChanged.txt @@ -0,0 +1,6 @@ +Hi, {2} {3} + +You recently changed the email address associated with +{2} {3} + +Thank you. diff --git a/webapp/web/i18n/files/accountFirstTimeExternal.html b/webapp/web/i18n/files/accountFirstTimeExternal.html new file mode 100644 index 000000000..61dca7f3c --- /dev/null +++ b/webapp/web/i18n/files/accountFirstTimeExternal.html @@ -0,0 +1,22 @@ + + + {1} + + +

+ {2} {3} +

+ +

+ Congratulations! +

+ +

+ We have created your new {0} account associated with {4}. +

+ +

+ Thanks! +

+ + diff --git a/webapp/web/i18n/files/accountFirstTimeExternal.txt b/webapp/web/i18n/files/accountFirstTimeExternal.txt new file mode 100644 index 000000000..1cb60552b --- /dev/null +++ b/webapp/web/i18n/files/accountFirstTimeExternal.txt @@ -0,0 +1,8 @@ +{2} {3} + +Congratulations! + +We have created your new {0} account associated with +{4} + +Thanks! diff --git a/webapp/web/i18n/files/passwordCreatedEmail.html b/webapp/web/i18n/files/passwordCreatedEmail.html new file mode 100644 index 000000000..15cf8bb0d --- /dev/null +++ b/webapp/web/i18n/files/passwordCreatedEmail.html @@ -0,0 +1,22 @@ + + + {1} + + +

+ {2} {3} +

+ +

+ Password successfully created. +

+ +

+ Your new password associated with {4} has been created. +

+ +

+ Thank you. +

+ + diff --git a/webapp/web/i18n/files/passwordCreatedEmail.txt b/webapp/web/i18n/files/passwordCreatedEmail.txt new file mode 100644 index 000000000..dbd9e9da0 --- /dev/null +++ b/webapp/web/i18n/files/passwordCreatedEmail.txt @@ -0,0 +1,8 @@ +{2} {3} + +Password successfully created. + +Your new password associated with {4} +has been created. + +Thank you. diff --git a/webapp/web/i18n/files/passwordRequestPending.html b/webapp/web/i18n/files/passwordRequestPending.html new file mode 100644 index 000000000..bd20cb392 --- /dev/null +++ b/webapp/web/i18n/files/passwordRequestPending.html @@ -0,0 +1,34 @@ + + + {1} + + +

+ Dear {2} {3}: +

+ +

+ We have received a request to reset the password for your {0} account ({4}). +

+ +

+ Please follow the instructions below to proceed with your password reset. +

+ +

+ If you did not request this new account you can safely ignore this email. + This request will expire if not acted upon within 30 days. +

+ +

+ Click on the link below or paste it into your browser's address bar to reset your password + using our secure server. +

+ +

+ {5} +

+ +

Thank you!

+ + diff --git a/webapp/web/i18n/files/passwordRequestPending.txt b/webapp/web/i18n/files/passwordRequestPending.txt new file mode 100644 index 000000000..e8c92b5f2 --- /dev/null +++ b/webapp/web/i18n/files/passwordRequestPending.txt @@ -0,0 +1,16 @@ +Dear {2} {3}: + +We have received a request to reset the password for your {0} account +({4}). + +Please follow the instructions below to proceed with your password reset. + +If you did not request this new account you can safely ignore this email. +This request will expire if not acted upon within 30 days. + +Paste the link below into your browser's address bar to reset your password +using our secure server. + +{5} + +Thank you! diff --git a/webapp/web/i18n/files/passwordResetComplete.html b/webapp/web/i18n/files/passwordResetComplete.html new file mode 100644 index 000000000..bfa756f15 --- /dev/null +++ b/webapp/web/i18n/files/passwordResetComplete.html @@ -0,0 +1,22 @@ + + + {1} + + +

+ {2} {3} +

+ +

+ Password successfully changed. +

+ +

+ Your new password associated with {4} has been changed. +

+ +

+ Thank you. +

+ + diff --git a/webapp/web/i18n/files/passwordResetComplete.txt b/webapp/web/i18n/files/passwordResetComplete.txt new file mode 100644 index 000000000..99503085c --- /dev/null +++ b/webapp/web/i18n/files/passwordResetComplete.txt @@ -0,0 +1,8 @@ +{2} {3} + +Password successfully changed. + +Your new password associated with {4} +has been changed. + +Thank you. diff --git a/webapp/web/i18n/files/passwordResetPending.html b/webapp/web/i18n/files/passwordResetPending.html new file mode 100644 index 000000000..bd20cb392 --- /dev/null +++ b/webapp/web/i18n/files/passwordResetPending.html @@ -0,0 +1,34 @@ + + + {1} + + +

+ Dear {2} {3}: +

+ +

+ We have received a request to reset the password for your {0} account ({4}). +

+ +

+ Please follow the instructions below to proceed with your password reset. +

+ +

+ If you did not request this new account you can safely ignore this email. + This request will expire if not acted upon within 30 days. +

+ +

+ Click on the link below or paste it into your browser's address bar to reset your password + using our secure server. +

+ +

+ {5} +

+ +

Thank you!

+ + diff --git a/webapp/web/i18n/files/passwordResetPending.txt b/webapp/web/i18n/files/passwordResetPending.txt new file mode 100644 index 000000000..5d34952f3 --- /dev/null +++ b/webapp/web/i18n/files/passwordResetPending.txt @@ -0,0 +1,16 @@ +Dear {2} {3}: + +We have received a request to reset the password for your {0} account +({4}). + +Please follow the instructions below to proceed with your password reset. + +If you did not request this new account you can safely ignore this email. +This request will expire if not acted upon within 30 days. + +Paste the link below into your browser's address bar to reset your password +using our secure server. + +{5} + +Thank you! \ No newline at end of file diff --git a/webapp/web/js/account/accountUtils.js b/webapp/web/js/account/accountUtils.js index 134009f61..26b0f75aa 100644 --- a/webapp/web/js/account/accountUtils.js +++ b/webapp/web/js/account/accountUtils.js @@ -45,7 +45,7 @@ $(document).ready(function(){ if (countAccount == 0){ return false; }else{ - var answer = confirm( 'Are you sure you want to delete ' + ((countAccount > 1) ? 'these accounts' : 'this account') +'?'); + var answer = confirm( ((countAccount > 1) ? confirm_delete_account_plural : confirm_delete_account_singular) +'?'); return answer; } }); diff --git a/webapp/web/js/imageUpload/imageUploadUtils.js b/webapp/web/js/imageUpload/imageUploadUtils.js index 0364689a1..2a2775d1c 100644 --- a/webapp/web/js/imageUpload/imageUploadUtils.js +++ b/webapp/web/js/imageUpload/imageUploadUtils.js @@ -4,7 +4,7 @@ $(document).ready(function(){ // Confirmation alert for photo deletion in image upload and individual templates $('#photoUploadDefaultImage a.thumbnail, a.delete-mainImage').click(function(){ - var answer = confirm('Are you sure you want to delete this photo?'); + var answer = confirm(i18n_confirmDelete); return answer; }); }); \ No newline at end of file diff --git a/webapp/web/js/individual/manageLabelsForIndividual.js b/webapp/web/js/individual/manageLabelsForIndividual.js index c51597d91..73a63cad8 100644 --- a/webapp/web/js/individual/manageLabelsForIndividual.js +++ b/webapp/web/js/individual/manageLabelsForIndividual.js @@ -37,6 +37,11 @@ var manageLabels = { $('input#submit').click( function() { manageLabels.processLabel(manageLabels.selectedRadio); + $('span.or').hide(); + $('a.cancel').hide(); + $('span#indicator').removeClass('hidden'); + $('input.submit').addClass('disabledSubmit'); + $('input.submit').attr('disabled', 'disabled'); }); }, @@ -70,11 +75,19 @@ var manageLabels = { complete: function(request, status) { if (status == 'success') { + $('span.or').show(); + $('a.cancel').show(); + $('span#indicator').addClass('hidden'); window.location = $('a.cancel').attr('href'); } else { alert('Error processing request: the unchecked labels could not be deleted.'); selectedRadio.removeAttr('checked'); + $('span.or').show(); + $('a.cancel').show(); + $('span#indicator').addClass('hidden'); + $('input.submit').removeClass('disabledSubmit'); + $('input.submit').attr('disabled', ''); } } }); diff --git a/webapp/web/js/individual/propertyGroupControls.js b/webapp/web/js/individual/propertyGroupControls.js index 6da441d5f..f71dc4daf 100644 --- a/webapp/web/js/individual/propertyGroupControls.js +++ b/webapp/web/js/individual/propertyGroupControls.js @@ -5,7 +5,7 @@ $(document).ready(function(){ $.extend(this, individualLocalName); adjustFontSize(); padSectionBottoms(); - retrieveLocalStorage(); + checkLocationHash(); // ensures that shorter property group sections don't cause the page to "jump around" // when the tabs are clicked @@ -59,6 +59,43 @@ $(document).ready(function(){ }); } + // If users click a marker on the home page map, they are taken to the profile + // page of the corresponding country. The url contains the word "Research" in + // the location hash. Use this to select the Research tab, which displays the + // researchers who have this countru as a geographic focus. + function checkLocationHash() { + if ( location.hash ) { + // remove the trailing white space + location.hash = location.hash.replace(/\s+/g, ''); + if ( location.hash.indexOf("map") >= 0 ) { + // get the name of the group that contains the geographicFocusOf property. + var tabName = $('h3#geographicFocusOf').parent('article').parent('div').attr("id"); + tabName = tabName.replace("Group",""); + tabNameCapped = tabName.charAt(0).toUpperCase() + tabName.slice(1); + // if the name of the first tab section = tabName we don't have to do anything; + // otherwise, select the correct tab and deselect the first one + var $firstTab = $('li.clickable').first(); + if ( $firstTab.text() != tabNameCapped ) { + // select the correct tab + $('li[groupName="' + tabName + '"]').removeClass("nonSelectedGroupTab clickable"); + $('li[groupName="' + tabName + '"]').addClass("selectedGroupTab clickable"); + // deselect the first tab + $firstTab.removeClass("selectedGroupTab clickable"); + $firstTab.addClass("nonSelectedGroupTab clickable"); + $('section.property-group:visible').hide(); + // show the selected tab section + $('section#' + tabName).show(); + } + } + else { + retrieveLocalStorage(); + } + } + else { + retrieveLocalStorage(); + } + } + // Next two functions -- keep track of which property group tab was selected, // so if we return from a custom form or a related individual, even via the back button, // the same property group will be selected as before. @@ -96,15 +133,16 @@ $(document).ready(function(){ } function retrieveLocalStorage() { + var localName = this.individualLocalName; var selectedTab = amplify.store(individualLocalName); if ( selectedTab != undefined ) { var groupName = selectedTab[0]; - // unlikely, but it's possible a tab that was previously selected and stored won't be displayed - // because the object properties would have been deleted (in non-edit mode). So ensure that the tab in local - // storage has been rendered on the page. + // unlikely, but it's possible a tab that was previously selected and stored won't be + // displayed because the object properties would have been deleted (in non-edit mode). + // So ensure that the tab in local storage has been rendered on the page. if ( $("ul.propertyTabsList li[groupName='" + groupName + "']").length ) { // if the selected tab is the default first one, don't do anything if ( $('li.clickable').first().attr("groupName") != groupName ) { @@ -129,14 +167,14 @@ $(document).ready(function(){ } } // if there are so many tabs that they wrap to a second line, adjust the font size to - //prevent wrapping + // prevent wrapping function adjustFontSize() { var width = 0; $('ul.propertyTabsList li').each(function() { width += $(this).outerWidth(); }); if ( width < 922 ) { - var diff = 926-width; + var diff = 925-width; $('ul.propertyTabsList li:last-child').css('width', diff + 'px'); } else { @@ -156,19 +194,25 @@ $(document).ready(function(){ else if ( diff > 130 && diff < 175 ) { $('ul.propertyTabsList li').css('font-size', "0.8em"); } - else if ( diff > 175 && diff < 260 ) { + else if ( diff > 175 && diff < 240 ) { $('ul.propertyTabsList li').css('font-size', "0.73em"); } - else { + else if ( diff > 240 && diff < 280 ) { $('ul.propertyTabsList li').css('font-size', "0.7em"); } + else if ( diff > 280 && diff < 310 ) { + $('ul.propertyTabsList li').css('font-size', "0.675em"); + } + else { + $('ul.propertyTabsList li').css('font-size', "0.65em"); + } // get the new width var newWidth = 0 $('ul.propertyTabsList li').each(function() { newWidth += $(this).outerWidth(); }); - var newDiff = 926-newWidth; + var newDiff = 925-newWidth; $('ul.propertyTabsList li:last-child').css('width', newDiff + 'px'); } } diff --git a/webapp/web/js/vitroUtils.js b/webapp/web/js/vitroUtils.js old mode 100755 new mode 100644 index e9b345abb..76b84d8c5 --- a/webapp/web/js/vitroUtils.js +++ b/webapp/web/js/vitroUtils.js @@ -10,15 +10,10 @@ $(document).ready(function(){ // fade in flash-message when user logs out jQuery('section#flash-message').css('display', 'none').fadeIn(1500); - ///////////////////////////// // Home search fiter // Toggle filter select list - var $searchFilterList = $('#filter-search-nav'); - var $selectedFilter; - var $queryToSend; - var $queryToSendAll = true; var $isFilterOpen = false; console.log("Filter is open = " + $isFilterOpen); @@ -63,15 +58,14 @@ $(document).ready(function(){ ev.preventDefault(); if ($(this).text() == 'All') { - $queryToSendAll = true; //Selected filter feedback $('.search-filter-selected').text(''); + $('input[name="classgroup"]').val(''); console.log("ALL"); } else { - //Selected filter feedback $('.search-filter-selected').text($(this).text()).fadeIn('slow'); - $queryToSendAll = false; + $('input[name="classgroup"]').val($(this).children("a").attr("title")); } //Hide filter select list @@ -82,10 +76,7 @@ $(document).ready(function(){ $('a.filter-search').removeClass('filter-active'); $('a.filter-search').addClass('filter-default'); - - $selectedFilter = $(this).text(); $isFilterOpen = false; - console.log("$queryToSend " + $selectedFilter); }); }); @@ -118,18 +109,4 @@ $(document).ready(function(){ console.log("HIDE input value ") ; }); - - $('#search-homepage').submit(function(){ - - if ($queryToSendAll) { - $filterType = ''; - }else { - $filterType = '&classgroup=http://vivoweb.org/ontology/vitroClassGroup' + $selectedFilter; - } - - $queryToSend = 'querytext=' + $('input.search-homepage').val() + $filterType; - console.log("Query to send: " + $queryToSend); - - return false; - }); -}); \ No newline at end of file +}); diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-acctCreatedEmail.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-acctCreatedEmail.ftl index 35bb89956..a855f13c8 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-acctCreatedEmail.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-acctCreatedEmail.ftl @@ -2,67 +2,22 @@ <#-- Confirmation that an account has been created. --> -<#assign subject = "Your ${siteName} account has been created." /> +<#assign strings = i18n() /> -<#assign html> - - - ${subject} - - -

- ${userAccount.firstName} ${userAccount.lastName} -

- -

- Congratulations! -

- -

- We have created your new account on ${siteName}, associated with ${userAccount.emailAddress}. -

- -

- If you did not request this new account you can safely ignore this email. - This request will expire if not acted upon for 30 days. -

- -

- Click the link below to create your password for your new account using our secure server. -

- -

- ${passwordLink} -

- -

- If the link above doesn't work, you can copy and paste the link directly into your browser's address bar. -

- -

- Thanks! -

- - - +<#assign subject = strings.account_created(siteName) /> -<#assign text> -${userAccount.firstName} ${userAccount.lastName} +<#assign html = strings.account_created_email_html(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress, + passwordLink) /> -Congratulations! - -We have created your new account on ${siteName}, -associated with ${userAccount.emailAddress}. - -If you did not request this new account you can safely ignore this email. -This request will expire if not acted upon for 30 days. - -Paste the link below into your browser's address bar to create your password -for your new account using our secure server. - -${passwordLink} - -Thanks! - +<#assign text = strings.account_created_email_text(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress, + passwordLink) /> <@email subject=subject html=html text=text /> \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-acctCreatedExternalOnlyEmail.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-acctCreatedExternalOnlyEmail.ftl index df2959656..a6bc6f0e9 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-acctCreatedExternalOnlyEmail.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-acctCreatedExternalOnlyEmail.ftl @@ -2,42 +2,18 @@ <#-- Confirmation that an account has been created. --> -<#assign subject = "Your ${siteName} account has been created." /> +<#assign subject = strings.account_created(siteName) /> -<#assign html> - - - ${subject} - - -

- ${userAccount.firstName} ${userAccount.lastName} -

- -

- Congratulations! -

- -

- We have created your new VIVO account associated with ${userAccount.emailAddress}. -

- -

- Thanks! -

- - - +<#assign html = strings.account_created_external_email_html(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress) /> -<#assign text> -${userAccount.firstName} ${userAccount.lastName} - -Congratulations! - -We have created your new VIVO account associated with -${userAccount.emailAddress}. - -Thanks! - +<#assign text = string.account_created_external_email_text(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress) /> <@email subject=subject html=html text=text /> \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-add.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-add.ftl index 26f1eee4a..9ec2e5a22 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-add.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-add.ftl @@ -2,71 +2,54 @@ <#-- Template for adding a user account --> -

> Add new account

+<#assign strings = i18n() /> +

> ${strings.add_new_account}

<#if errorEmailIsEmpty??> - <#assign errorMessage = "You must supply an email address." /> + <#assign errorMessage = strings.error_no_email /> + <#elseif errorEmailInUse??> + <#assign errorMessage = strings.error_email_already_exists /> + <#elseif errorEmailInvalidFormat??> + <#assign errorMessage = strings.error_invalid_email(emailAddress) /> + <#elseif errorExternalAuthIdInUse??> + <#assign errorMessage = strings.error_external_auth_already_exists /> + <#elseif errorFirstNameIsEmpty??> + <#assign errorMessage = strings.error_no_first_name /> + <#elseif errorLastNameIsEmpty??> + <#assign errorMessage = strings.error_no_last_name /> + <#elseif errorNoRoleSelected??> + <#assign errorMessage = strings.error_no_role /> + <#elseif errorPasswordIsEmpty??> + <#assign errorMessage = strings.error_no_password /> + <#elseif errorPasswordIsWrongLength??> + <#assign errorMessage = strings.error_password_length(minimumLength, maximumLength) /> + <#elseif errorPasswordsDontMatch??> + <#assign errorMessage = strings.error_password_mismatch /> - - <#if errorEmailInUse??> - <#assign errorMessage = "An account with that email address already exists." /> - - - <#if errorEmailInvalidFormat??> - <#assign errorMessage = "'${emailAddress}' is not a valid email address." /> - - - <#if errorExternalAuthIdInUse??> - <#assign errorMessage = "An account with that external authorization ID already exists." /> - - - <#if errorFirstNameIsEmpty??> - <#assign errorMessage = "You must supply a first name." /> - - - <#if errorLastNameIsEmpty??> - <#assign errorMessage = "You must supply a last name." /> - - - <#if errorNoRoleSelected??> - <#assign errorMessage = "You must select a role." /> - - - <#if errorPasswordIsEmpty??> - <#assign errorMessage = "No password supplied." /> - - - <#if errorPasswordIsWrongLength??> - <#assign errorMessage = "Password must be between ${minimumLength} and ${maximumLength} characters." /> - - - <#if errorPasswordsDontMatch??> - <#assign errorMessage = "Passwords do not match." /> - - + <#if errorMessage?has_content>
- + - + - + <#include "userAccounts-associateProfilePanel.ftl"> -

checked />Externally Authenticated Only

-

Roles *

+

checked />${strings.external_auth_only}

+

${strings.roles} *

<#list roles as role> @@ -74,25 +57,21 @@ <#if emailIsEnabled??> -

- Note: An email will be sent to the address entered above - notifying that an account has been created. - It will include instructions for activating the account and creating a password. -

+

${strings.new_account_note}

<#else>
- + -

Minimum of ${minimumLength} characters in length.

+

${strings.minimum_password_length}

- +
-

or Cancel

+

${strings.or} ${strings.cancel_link}

-

* required fields

+

* ${strings.required_fields}

diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-associateProfilePanel.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-associateProfilePanel.ftl index f75ef2856..3cf0bedff 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-associateProfilePanel.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-associateProfilePanel.ftl @@ -2,20 +2,22 @@ <#-- Template for setting the account reference field, which can also associate a profile with the user account --> +<#assign strings = i18n() /> + ${stylesheets.add('', '')}
<#if showAssociation??> - + - This Identifier is already in use. -

Can be used to associate the account with the user's profile via the matching property.

+ ${strings.auth_id_in_use} +

${strings.auth_id_explanation}

<#else> - + - This Identifier is already in use. + ${strings.auth_id_in_use}
@@ -24,10 +26,10 @@ ${stylesheets.add('

- + - (verify this match) - (change profile) + (${strings.verify_this_match}) + (${strings.change_profile})

@@ -37,16 +39,16 @@ ${stylesheets.add('

- +

-

- or -

+

- ${strings.or} -

- + - + -

Minimum of ${minimumLength} characters in length.

+

${strings.minimum_password_length(minimumLength)}

- + -

+

-

* required fields

+

* ${strings.required_fields}

diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-edit.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-edit.ftl index e5b348fdc..a871b8090 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-edit.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-edit.ftl @@ -2,75 +2,58 @@ <#-- Template for editing a user account --> -

> Edit account

+<#assign strings = i18n() /> +

> ${strings.edit_account}

<#if errorEmailIsEmpty??> - <#assign errorMessage = "You must supply an email address." /> - - - <#if errorEmailInUse??> - <#assign errorMessage = "An account with that email address already exists." /> - - - <#if errorEmailInvalidFormat??> - <#assign errorMessage = "'${emailAddress}' is not a valid email address." /> - - - <#if errorExternalAuthIdInUse??> - <#assign errorMessage = "An account with that external authorization ID already exists." /> - - - <#if errorFirstNameIsEmpty??> - <#assign errorMessage = "You must supply a first name." /> - - - <#if errorLastNameIsEmpty??> - <#assign errorMessage = "You must supply a last name." /> - - - <#if errorNoRoleSelected??> - <#assign errorMessage = "You must select a role." /> - - - <#if errorPasswordIsEmpty??> - <#assign errorMessage = "No password supplied." /> - - - <#if errorPasswordIsWrongLength??> - <#assign errorMessage = "Password must be between ${minimumLength} and ${maximumLength} characters." /> - - - <#if errorPasswordsDontMatch??> - <#assign errorMessage = "Passwords do not match." /> + <#assign errorMessage = strings.error_no_email /> + <#elseif errorEmailInUse??> + <#assign errorMessage = strings.error_email_already_exists /> + <#elseif errorEmailInvalidFormat??> + <#assign errorMessage = strings.error_invalid_email(emailAddress) /> + <#elseif errorExternalAuthIdInUse??> + <#assign errorMessage = strings.error_external_auth_already_exists /> + <#elseif errorFirstNameIsEmpty??> + <#assign errorMessage = strings.error_no_first_name /> + <#elseif errorLastNameIsEmpty??> + <#assign errorMessage = strings.error_no_last_name /> + <#elseif errorNoRoleSelected??> + <#assign errorMessage = strings.error_no_role /> + <#elseif errorPasswordIsEmpty??> + <#assign errorMessage = strings.error_no_password /> + <#elseif errorPasswordIsWrongLength??> + <#assign errorMessage = strings.error_password_length(minimumLength, maximumLength) /> + <#elseif errorPasswordsDontMatch??> + <#assign errorMessage = strings.error_password_mismatch /> <#if errorMessage?has_content>
- + - + - + <#if externalAuthPermitted??> <#include "userAccounts-associateProfilePanel.ftl"> -

checked />Externally Authenticated Only

+

checked />${strings.external_auth_only}

<#if roles?has_content> -

Roles *

+

${strings.roles} *

<#list roles as role> @@ -81,29 +64,25 @@ <#if emailIsEnabled??>
class="hidden" role="region"> checked /> - + -

- Note: Instructions for resetting the password will - be emailed to the address entered above. The password will not - be reset until the user follows the link provided in this email. -

+

${strings.reset_password_note}

<#else>
class="hidden" role="region"> - + -

Minimum of ${minimumLength} characters in length.
- Leaving this blank means that the password will not be changed.

+

${strings.minimum_password_length(minimumLength)}
+ ${strings.leave_password_unchanged}

- +
-

or Cancel

+

${strings.or} ${strings.cancel_link}

-

* required fields

+

* ${strings.required_fields}

diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-firstTimeExternal.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-firstTimeExternal.ftl index a1f725bca..96bdb70eb 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-firstTimeExternal.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-firstTimeExternal.ftl @@ -2,59 +2,55 @@ <#-- Template for creating an account for the first time an external user logs in. --> -

First time log in

+<#assign strings = i18n() /> + +

${strings.first_time_login}

<#if errorEmailIsEmpty??> - <#assign errorMessage = "You must supply an email address." /> + <#assign errorMessage = strings.error_no_email /> + <#elseif errorEmailInUse??> + <#assign errorMessage = strings.error_email_already_exists /> + <#elseif errorEmailInvalidFormat??> + <#assign errorMessage = strings.error_invalid_email(emailAddress) /> + <#elseif errorFirstNameIsEmpty??> + <#assign errorMessage = strings.error_no_first_name /> + <#elseif errorLastNameIsEmpty??> + <#assign errorMessage = strings.error_no_last_name /> - - <#if errorEmailInUse??> - <#assign errorMessage = "An account with that email address already exists." /> - - - <#if errorEmailInvalidFormat??> - <#assign errorMessage = "'${emailAddress}' is not a valid email address." /> - - - <#if errorFirstNameIsEmpty??> - <#assign errorMessage = "You must supply a first name." /> - - - <#if errorLastNameIsEmpty??> - <#assign errorMessage = "You must supply a last name." /> - - + <#if errorMessage?has_content>
-

Please provide your contact information to finish creating your account.

+

${strings.please_provide_contact_information}

- + - + - + <#if emailIsEnabled??> -

- Note: An email will be sent to the address entered above notifying - that an account has been created. -

+

${strings.first_time_login_note}

-

or Cancel

+

+ ${strings.or} + ${strings.cancel_link} +

+ +

* ${strings.required_fields}

diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-firstTimeExternalEmail.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-firstTimeExternalEmail.ftl index a7b6cae83..247cc42b4 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-firstTimeExternalEmail.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-firstTimeExternalEmail.ftl @@ -2,42 +2,20 @@ <#-- Confirmation that an account has been created for an externally-authenticated user. --> -<#assign subject = "Your ${siteName} account has been created." /> +<#assign strings = i18n() /> -<#assign html> - - - ${subject} - - -

- ${userAccount.firstName} ${userAccount.lastName} -

- -

- Congratulations! -

- -

- We have created your new VIVO account associated with ${userAccount.emailAddress}. -

- -

- Thanks! -

- - - +<#assign subject = strings.account_created(siteName) /> -<#assign text> -${userAccount.firstName} ${userAccount.lastName} +<#assign html = strings.first_time_external_email_html(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress) /> -Congratulations! - -We have created your new VIVO account associated with -${userAccount.emailAddress}. - -Thanks! - +<#assign text = strings.first_time_external_email_text(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress) /> <@email subject=subject html=html text=text /> \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-list.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-list.ftl index 70b9c3e60..d9c5aa06c 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-list.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-list.ftl @@ -4,20 +4,19 @@ <#import "userAccounts-accountsNav.ftl" as p> +<#assign strings = i18n() /> +
-

User accounts |

+

${strings.user_accounts_link} |

<#if newUserAccount?? > @@ -25,14 +24,10 @@ <#if updatedUserAccount?? > @@ -40,7 +35,7 @@ <#if deletedAccountCount?? > @@ -48,7 +43,7 @@
<#if roleFilterUri?has_content> - View all accounts + ${strings.view_all_accounts}
@@ -68,7 +63,7 @@
- + <#else> @@ -156,7 +151,7 @@ <#if account.editUrl != ""> - ${account.emailAddress} + ${account.emailAddress} <#else> ${account.emailAddress} @@ -185,5 +180,10 @@ <@p.accountsNav />
+ + ${stylesheets.add('')} ${scripts.add('')} \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-myAccount.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-myAccount.ftl index 27add004a..8f8c8bd00 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-myAccount.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-myAccount.ftl @@ -2,58 +2,48 @@ <#-- Template for editing a user account --> -

My account

+<#assign strings = i18n() /> + +

${strings.myAccount_heading}

<#if errorEmailIsEmpty??> - <#assign errorMessage = "You must supply an email address." /> + <#assign errorMessage = strings.error_no_email /> + <#elseif errorEmailInUse??> + <#assign errorMessage = strings.error_email_already_exists /> + <#elseif errorEmailInvalidFormat??> + <#assign errorMessage = strings.error_invalid_email(emailAddress) /> + <#elseif errorFirstNameIsEmpty??> + <#assign errorMessage = strings.error_no_first_name /> + <#elseif errorLastNameIsEmpty??> + <#assign errorMessage = strings.error_no_last_name /> + <#elseif errorNoRoleSelected??> + <#assign errorMessage = strings.error_no_role /> + <#elseif errorPasswordIsEmpty??> + <#assign errorMessage = strings.error_no_password /> + <#elseif errorPasswordIsWrongLength??> + <#assign errorMessage = strings.error_password_length(minimumLength, maximumLength) /> + <#elseif errorPasswordsDontMatch??> + <#assign errorMessage = strings.error_password_mismatch /> - - <#if errorEmailInUse??> - <#assign errorMessage = "An account with that email address already exists." /> - - - <#if errorEmailInvalidFormat??> - <#assign errorMessage = "'${emailAddress}' is not a valid email address." /> - - - <#if errorFirstNameIsEmpty??> - <#assign errorMessage = "You must supply a first name." /> - - - <#if errorLastNameIsEmpty??> - <#assign errorMessage = "You must supply a last name." /> - - - <#if errorPasswordIsEmpty??> - <#assign errorMessage = "No password supplied." /> - - - <#if errorPasswordIsWrongLength??> - <#assign errorMessage = "Password must be between ${minimumLength} and ${maximumLength} characters." /> - - - <#if errorPasswordsDontMatch??> - <#assign errorMessage = "Passwords do not match." /> - - + <#if errorMessage?has_content> <#if confirmChange??> - <#assign confirmMessage = "Your changes have been saved." /> + <#assign confirmMessage = strings.myAccount_confirm_changes /> <#if confirmEmailSent??> - <#assign confirmMessage = "Your changes have been saved. A confirmation email has been sent to ${emailAddress}." /> + <#assign confirmMessage = strings.myAccount_confirm_changes_plus_note(emailAddress) /> <#if confirmMessage?has_content> @@ -63,30 +53,34 @@ <#include "userAccounts-myProxiesPanel.ftl"> - + -

Note: if email changes, a confirmation email will
be sent to the new email address entered above.

+

${strings.email_change_will_be_confirmed}

- + - + <#if !externalAuth??> - + -

Minimum of ${minimumLength} characters in length.
If left blank, the password will not be changed.

+

${strings.minimum_password_length(minimumLength)}
${strings.leave_password_unchanged}

- + -

or Cancel

+

+ + ${strings.or} + ${strings.cancel_link} +

-

* required fields

+

* ${strings.required_fields}

diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl index 8c27c659f..02edecc87 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-myProxiesPanel.ftl @@ -2,15 +2,21 @@ <#-- Template for setting the account reference field, which can also associate a profile with the user account --> +<#assign strings = i18n() /> +
-

Who can edit my profile

+

${strings.who_can_edit_profile}

- - + + + -

 

+

+   +

${myAccountUri}

-

Selected editors:

+

${strings.selected_editors}:

<#-- Magic ul that holds all of the proxy data and the template that shows how to display it. -->
    @@ -35,7 +41,7 @@

    %label% | %classLabel%
    - Remove selection + ${strings.remove_selection}

    diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordCreatedEmail.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordCreatedEmail.ftl index 4177027ab..1a4941549 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordCreatedEmail.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordCreatedEmail.ftl @@ -2,42 +2,20 @@ <#-- Confirmation that an password has been created. --> -<#assign subject = "Your ${siteName} password has successfully been created." /> +<#assign strings = i18n() /> -<#assign html> - - - ${subject} - - -

    - ${userAccount.firstName} ${userAccount.lastName} -

    - -

    - Password successfully created. -

    - -

    - Your new password associated with ${userAccount.emailAddress} has been created. -

    - -

    - Thank you. -

    - - - +<#assign subject = strings.password_created_subject(siteName) /> -<#assign text> -${userAccount.firstName} ${userAccount.lastName} +<#assign html = strings.password_created_email_html(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress) /> -Password successfully created. - -Your new password associated with ${userAccount.emailAddress} -has been created. - -Thank you. - +<#assign text = strings.password_created_email_text(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress) /> <@email subject=subject html=html text=text /> \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordResetCompleteEmail.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordResetCompleteEmail.ftl index 8fd529c79..8badf9f3b 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordResetCompleteEmail.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordResetCompleteEmail.ftl @@ -2,42 +2,20 @@ <#-- Confirmation that a password has been reset. --> -<#assign subject = "Your ${siteName} password changed." /> +<#assign strings = i18n() /> -<#assign html> - - - ${subject} - - -

    - ${userAccount.firstName} ${userAccount.lastName} -

    - -

    - Password successfully changed. -

    - -

    - Your new password associated with ${userAccount.emailAddress} has been changed. -

    - -

    - Thank you. -

    - - - +<#assign subject = strings.password_reset_complete_subject(siteName) /> -<#assign text> -${userAccount.firstName} ${userAccount.lastName} +<#assign html = strings.password_reset_complete_email_html(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress) /> -Password successfully changed. - -Your new password associated with ${userAccount.emailAddress} -has been changed. - -Thank you. - +<#assign text = strings.password_reset_complete_email_text(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress) /> <@email subject=subject html=html text=text /> \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordResetPendingEmail.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordResetPendingEmail.ftl index d6fcc59a2..e02bdfd9a 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordResetPendingEmail.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-passwordResetPendingEmail.ftl @@ -2,60 +2,22 @@ <#-- Confirmation email for user account password reset --> -<#assign subject = "${siteName} reset password request" /> +<#assign strings = i18n() /> -<#assign html> - - - ${subject} - - -

    - Dear ${userAccount.firstName} ${userAccount.lastName}: -

    - -

    - We have received a request to reset the password for your ${siteName} account (${userAccount.emailAddress}). -

    - -

    - Please follow the instructions below to proceed with your password reset. -

    - -

    - If you did not request this new account you can safely ignore this email. - This request will expire if not acted upon within 30 days. -

    - -

    - Click on the link below or paste it into your browser's address bar to reset your password - using our secure server. -

    - -

    ${passwordLink}

    - -

    Thank you!

    - - - +<#assign subject = strings.password_reset_pending_subject(siteName) /> -<#assign text> -Dear ${userAccount.firstName} ${userAccount.lastName}: - -We have received a request to reset the password for your ${siteName} account -(${userAccount.emailAddress}). +<#assign html = strings.password_reset_pending_email_html(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress, + passwordLink) /> -Please follow the instructions below to proceed with your password reset. - -If you did not request this new account you can safely ignore this email. -This request will expire if not acted upon within 30 days. - -Paste the link below into your browser's address bar to reset your password -using our secure server. - -${passwordLink} - -Thank you! - +<#assign text = strings.password_reset_pending_email_text(siteName, + subject, + userAccount.firstName, + userAccount.lastName, + userAccount.emailAddress, + passwordLink) /> <@email subject=subject html=html text=text /> \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/accounts/userAccounts-resetPassword.ftl b/webapp/web/templates/freemarker/body/accounts/userAccounts-resetPassword.ftl index d7630d5fb..0ca4be7b6 100644 --- a/webapp/web/templates/freemarker/body/accounts/userAccounts-resetPassword.ftl +++ b/webapp/web/templates/freemarker/body/accounts/userAccounts-resetPassword.ftl @@ -2,45 +2,43 @@ <#-- Template for adding a user account --> -

    Reset your Password

    +<#assign strings = i18n() /> -

    Please enter your new password for ${userAccount.emailAddress}

    +

    ${strings.reset_your_password}

    - <#if errorPasswordIsEmpty??> - <#assign errorMessage = "No password supplied." /> - - - <#if errorPasswordIsWrongLength??> - <#assign errorMessage = "Password must be between ${minimumLength} and ${maximumLength} characters." /> - - - <#if errorPasswordsDontMatch??> - <#assign errorMessage = "Passwords do not match." /> - - - <#if errorMessage?has_content> - - +

    ${strings.enter_new_password(userAccount.emailAddress)}

    + +<#if errorPasswordIsEmpty??> + <#assign errorMessage = strings.error_no_password /> +<#elseif errorPasswordIsWrongLength??> + <#assign errorMessage = strings.error_password_length(minimumLength, maximumLength) /> +<#elseif errorPasswordsDontMatch??> + <#assign errorMessage = strings.error_password_mismatch /> + + +<#if errorMessage?has_content> + +
    - + -

    Minimum of ${minimumLength} characters in length.

    +

    ${strings.minimum_password_length(minimumLength)}

    - + -

    +

    -

    * required fields

    +

    * ${strings.required_fields}

    diff --git a/webapp/web/templates/freemarker/body/admin/admin-restrictLogins.ftl b/webapp/web/templates/freemarker/body/admin/admin-restrictLogins.ftl index bcea8f669..54f217d77 100644 --- a/webapp/web/templates/freemarker/body/admin/admin-restrictLogins.ftl +++ b/webapp/web/templates/freemarker/body/admin/admin-restrictLogins.ftl @@ -4,26 +4,26 @@

    Restrict Logins

    <#if messageAlreadyRestricted??> - <#assign errorMessage = "Logins are already restricted." /> + <#assign errorMessage = "${i18n().logins_already_restricted}" /> <#if messageAlreadyOpen??> - <#assign errorMessage = "Logins are already not restricted." /> + <#assign errorMessage = "${i18n().logins_not_already_restricted}" /> <#if errorMessage?has_content> <#if messageRestricting??> - <#assign successMessage = "Logins are now restricted." /> + <#assign successMessage = "${i18n().logins_restricted}" /> <#if messageOpening??> - <#assign successMessage = "Logins are no longer restricted." /> + <#assign successMessage = "${i18n().logins_not_restricted}" /> <#if successMessage?has_content> @@ -36,9 +36,9 @@
    <#if restricted == true>

    Logins are restricted

    -

    Remove Restrictions

    +

    ${i18n().remove_restrictions}

    <#else>

    Logins are open to all

    -

    Restrict Logins

    +

    ${i18n().Restrict Logins}

    diff --git a/webapp/web/templates/freemarker/body/admin/admin-showAuth.ftl b/webapp/web/templates/freemarker/body/admin/admin-showAuth.ftl index 6a7c981f4..467cec196 100644 --- a/webapp/web/templates/freemarker/body/admin/admin-showAuth.ftl +++ b/webapp/web/templates/freemarker/body/admin/admin-showAuth.ftl @@ -7,24 +7,24 @@ ${stylesheets.add('Authorization Info
    -

    Current user

    +

    ${i18n().current_user}

    <#if currentUser?has_content> - - - - - + + + + + <#list currentUser.permissionSetUris as role> - + <#else> - +
    URI:${currentUser.uri}
    First name:${currentUser.firstName}
    Last name:${currentUser.lastName}
    Email:${currentUser.emailAddress}
    External Auth ID:${currentUser.externalAuthId}
    Login count:${currentUser.loginCount}
    ${i18n().first_name}:${currentUser.firstName}
    ${i18n().last_name}:${currentUser.lastName}
    ${i18n().email_Address}:${currentUser.emailAddress}
    ${i18n().external_auth_id}:${currentUser.externalAuthId}
    ${i18n().login_count}:${currentUser.loginCount}
    Role:${role}
    ${i18n().role}:${role}
    Not logged in
    ${i18n().not_logged_in}
    -

    Identifiers:

    +

    ${i18n().identifiers}:

    <#list identifiers as identifier> @@ -34,11 +34,11 @@ ${stylesheets.add('

    - AssociatedIndividuals: + ${i18n().associated_individuals}: <#if matchingProperty??> - (match by ${matchingProperty}) + (${i18n().match_by(matchingProperty)}) <#else> - (matching property is not defined) + (${i18n().matching_prop_not_defined})

    @@ -47,18 +47,18 @@ ${stylesheets.add(' <#if associatedIndividual.editable> - + <#else> - + <#else> - +
    ${associatedIndividual.uri}May edit${i18n().may_edit}May not edit${i18n().may_not_edit}
    none
    ${i18n().none}
    -

    Identifier factories:

    +

    ${i18n().identifier_factories}:

    <#list factories as factory> @@ -67,7 +67,7 @@ ${stylesheets.add('
    -

    Policies:

    +

    ${i18n().policies}:

    <#list policies as policy> @@ -76,7 +76,7 @@ ${stylesheets.add('
    -

    Authenticator:

    +

    ${i18n().authenticator}:

    diff --git a/webapp/web/templates/freemarker/body/admin/admin-showThreads.ftl b/webapp/web/templates/freemarker/body/admin/admin-showThreads.ftl index 6b2b9a127..d9b5d8e38 100644 --- a/webapp/web/templates/freemarker/body/admin/admin-showThreads.ftl +++ b/webapp/web/templates/freemarker/body/admin/admin-showThreads.ftl @@ -17,15 +17,15 @@ table.threadInfo th { -

    Background Threads

    +

    ${i18n().background_threads}

    <#list threads as threadInfo>
    ${authenticator}
    - - - - + + + +
    Name${threadInfo.name}
    WorkLevel${threadInfo.workLevel}
    Since${threadInfo.since}
    Flags${threadInfo.flags}
    ${i18n().name}${threadInfo.name}
    ${i18n().work_level}${threadInfo.workLevel}
    ${i18n().since}${threadInfo.since}
    ${i18n().flags}${threadInfo.flags}
    \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/admin/searchIndex.ftl b/webapp/web/templates/freemarker/body/admin/searchIndex.ftl index ab5ee849e..cfee9e280 100644 --- a/webapp/web/templates/freemarker/body/admin/searchIndex.ftl +++ b/webapp/web/templates/freemarker/body/admin/searchIndex.ftl @@ -4,40 +4,40 @@ Template for the page that controls the updating or rebuilding of the Search Index. --> -

    Search Index Status

    +

    ${i18n().search_index_status}

    <#if !indexIsConnected> <#elseif worklevel == "IDLE"> -

    The search indexer is idle.

    +

    ${i18n().search_indexer_idle}

    <#if hasPreviousBuild??> -

    The most recent update was at ${since?string("hh:mm:ss a, MMMM dd, yyyy")}

    +

    ${i18n().most_recent_update} ${since?string("hh:mm:ss a, MMMM dd, yyyy")}

    - - Reset the search index and re-populate it. + + ${i18n().reset_search_index}

    <#elseif totalToDo == 0> -

    Preparing to rebuild the search index.

    -

    since ${since?string("hh:mm:ss a, MMMM dd, yyyy")}, elapsed time ${elapsed}

    +

    ${i18n().preparing_to_rebuild_index}

    +

    ${i18n().since_elapsed_time(since?string("hh:mm:ss a, MMMM dd, yyyy"),elapsed)}

    <#else> -

    ${currentTask} the search index.

    -

    since ${since?string("hh:mm:ss a, MMMM dd, yyyy")}, elapsed time ${elapsed}, estimated total time ${expected}

    -

    Completed ${completedCount} out of ${totalToDo} index records.

    +

    ${i18n().current_task(currentTask)}

    +

    ${i18n().since_elapsed_time_est_total(since?string("hh:mm:ss a, MMMM dd, yyyy"),elapsed,expected)}

    +

    ${i18n().index_recs_completed(completedCount,totalToDo)}

    diff --git a/webapp/web/templates/freemarker/body/admin/startupStatus-display.ftl b/webapp/web/templates/freemarker/body/admin/startupStatus-display.ftl index f55cb53fc..1d8288d33 100644 --- a/webapp/web/templates/freemarker/body/admin/startupStatus-display.ftl +++ b/webapp/web/templates/freemarker/body/admin/startupStatus-display.ftl @@ -35,9 +35,9 @@ ${stylesheets.add('')} <#if status.errorItems?has_content> -

    Fatal error

    +

    ${i18n().fatal_error}

    -

    ${applicationName} detected a fatal error during startup.

    +

    ${i18n().fatal_error_detected(applicationName)}

    - + \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/classGroups.ftl b/webapp/web/templates/freemarker/body/classGroups.ftl index 9d12507d7..ab5307be4 100644 --- a/webapp/web/templates/freemarker/body/classGroups.ftl +++ b/webapp/web/templates/freemarker/body/classGroups.ftl @@ -8,6 +8,9 @@
    <#list classGroups as classGroup> + <#assign groupSize = classGroup.classes?size > + <#assign classCount = 0 > + <#assign splitGroup = false> <#-- Only render classgroups that have at least one populated class --> <#if (classGroup.individualCount > 0)>
    @@ -17,6 +20,14 @@ <#-- Only render populated classes --> <#if (class.individualCount > 0)>
  • ${class.name} (${class.individualCount})
  • + <#assign classCount = classCount + 1 > + + <#if (classCount > 34) && !splitGroup > + <#assign splitGroup = true > +
+
+

${classGroup.displayName} (cont'd)

+
@@ -29,7 +40,7 @@ ${headScripts.add('')} diff --git a/webapp/web/templates/freemarker/body/imageUpload/imageUpload-replaceImage.ftl b/webapp/web/templates/freemarker/body/imageUpload/imageUpload-replaceImage.ftl index d8850d188..cc5a9b7bd 100644 --- a/webapp/web/templates/freemarker/body/imageUpload/imageUpload-replaceImage.ftl +++ b/webapp/web/templates/freemarker/body/imageUpload/imageUpload-replaceImage.ftl @@ -7,30 +7,36 @@ ${scripts.add(' diff --git a/webapp/web/templates/freemarker/body/individual/individual-help.ftl b/webapp/web/templates/freemarker/body/individual/individual-help.ftl index 6929787c8..09efeeacf 100644 --- a/webapp/web/templates/freemarker/body/individual/individual-help.ftl +++ b/webapp/web/templates/freemarker/body/individual/individual-help.ftl @@ -2,6 +2,6 @@ <#-- Template for help on individual page --> -

Individual not found:

+

${i18n().individual_not_found}

-

id is the id of the entity to query for. netid also works.

\ No newline at end of file +

${i18n().entity_to_query_for}

\ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/individual/individual-menu.ftl b/webapp/web/templates/freemarker/body/individual/individual-menu.ftl index 9819b280a..222d0d6fd 100644 --- a/webapp/web/templates/freemarker/body/individual/individual-menu.ftl +++ b/webapp/web/templates/freemarker/body/individual/individual-menu.ftl @@ -13,7 +13,7 @@ var menuItemData = []; -

Menu Ordering

+

${i18n().menu_ordering}

<#-- List the menu items --> @@ -33,8 +33,8 @@
@@ -44,7 +44,7 @@ <#assign groupNameHtmlId = p.createPropertyGroupHtmlId(groupName) >

${groupName?capitalize}

<#else> -

Properties

+

${i18n().properties_capitalized}

<#-- List the properties in the group --> diff --git a/webapp/web/templates/freemarker/body/partials/individual/individual-property-group-tabs.ftl b/webapp/web/templates/freemarker/body/partials/individual/individual-property-group-tabs.ftl index e4c4a594c..f14ce8a8c 100644 --- a/webapp/web/templates/freemarker/body/partials/individual/individual-property-group-tabs.ftl +++ b/webapp/web/templates/freemarker/body/partials/individual/individual-property-group-tabs.ftl @@ -15,8 +15,8 @@ <#--the function replaces spaces in the name with underscores, also called for the property group menu--> <#assign groupNameHtmlId = p.createPropertyGroupHtmlId(groupName) > <#else> - <#assign groupName = "Properties"> - <#assign groupNameHtmlId = "properties" > + <#assign groupName = "${i18n().properties_capitalized}"> + <#assign groupNameHtmlId = "${i18n().properties}" > <#if tabCount = 1 >
  • ${groupName?capitalize}
  • @@ -28,7 +28,7 @@ <#if (propertyGroups.all?size > 1) > -
  • View All
  • +
  • ${i18n().view_all}
  •  
  • @@ -38,8 +38,8 @@ <#assign verbose = (verbosePropertySwitch.currentValue)!false>
    @@ -49,7 +49,7 @@ <#assign groupNameHtmlId = p.createPropertyGroupHtmlId(groupName) > <#else> - +
    <#-- List the properties in the group --> diff --git a/webapp/web/templates/freemarker/body/partials/individual/individual-propertyGroupMenu.ftl b/webapp/web/templates/freemarker/body/partials/individual/individual-propertyGroupMenu.ftl index a7b7bf618..28603bb28 100644 --- a/webapp/web/templates/freemarker/body/partials/individual/individual-propertyGroupMenu.ftl +++ b/webapp/web/templates/freemarker/body/partials/individual/individual-propertyGroupMenu.ftl @@ -18,7 +18,7 @@ <#assign groupnameHtmlId = p.createPropertyGroupHtmlId(groupname) > <#-- capitalize will capitalize each word in the name; cap_first only the first. We may need a custom function to capitalize all except function words. --> -
  • ${groupname?capitalize}
  • +
  • ${groupname?capitalize}
  • diff --git a/webapp/web/templates/freemarker/body/partials/individual/propStatement-default.ftl b/webapp/web/templates/freemarker/body/partials/individual/propStatement-default.ftl index 631af8bcd..6377a922e 100644 --- a/webapp/web/templates/freemarker/body/partials/individual/propStatement-default.ftl +++ b/webapp/web/templates/freemarker/body/partials/individual/propStatement-default.ftl @@ -6,4 +6,4 @@ is also used to generate the property statement during a deletion. --> -${statement.label!statement.localName!} +${statement.label!statement.localName!} diff --git a/webapp/web/templates/freemarker/body/partials/individual/propStatement-simple.ftl b/webapp/web/templates/freemarker/body/partials/individual/propStatement-simple.ftl index 997619703..47c138c01 100644 --- a/webapp/web/templates/freemarker/body/partials/individual/propStatement-simple.ftl +++ b/webapp/web/templates/freemarker/body/partials/individual/propStatement-simple.ftl @@ -1,5 +1,4 @@ <#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> <#-- Simple object property statement template --> - -${statement.name!} +${statement.name!} diff --git a/webapp/web/templates/freemarker/lib/lib-home-page.ftl b/webapp/web/templates/freemarker/lib/lib-home-page.ftl new file mode 100644 index 000000000..e184a1cac --- /dev/null +++ b/webapp/web/templates/freemarker/lib/lib-home-page.ftl @@ -0,0 +1,75 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#-- Macros used to build the statistical information on the home page --> + +<#-- Get the classgroups so they can be used to qualify searches --> +<#macro allClassGroupNames classGroups> + <#list classGroups as group> + <#-- Only display populated class groups --> + <#if (group.individualCount > 0)> +
  • ${group.displayName?capitalize}
  • + + + + +<#-- builds the "stats" section of the home page, i.e., class group counts --> +<#macro allClassGroups classGroups> + <#-- Loop through classGroups first so we can account for situations when all class groups are empty --> + <#assign selected = 'class="selected" ' /> + <#assign classGroupList> +
    +

    Statistics

    + +
    + + + <#-- Display the class group browse only if we have at least one populated class group --> + <#if firstPopulatedClassGroup??> + ${classGroupList} + <#else> +

    There is currently no content in the system, or you need to create class groups and assign your classes to them.

    + + <#if user.loggedIn> + <#if user.hasSiteAdminAccess> +

    You can add content and manage this site from the Site Administration page.

    + + <#else> +

    Please log in to manage content.

    + + + + diff --git a/webapp/web/templates/freemarker/page/partials/languageSelector.ftl b/webapp/web/templates/freemarker/page/partials/languageSelector.ftl index cddb02a9f..2109f1912 100644 --- a/webapp/web/templates/freemarker/page/partials/languageSelector.ftl +++ b/webapp/web/templates/freemarker/page/partials/languageSelector.ftl @@ -9,14 +9,12 @@ <#-- This is included by identity.ftl --> <#if selectLocale??>
  • -
    - <#list selectLocale.locales as locale> - - <#if locale_has_next>| - -
    + <#list selectLocale.locales as locale> + + ${locale.label} + + <#if locale_has_next>| +