initial work on VIVO-60

Merge branch 'develop' of https://github.com/vivo-project/Vitro into develop

Conflicts:
	webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/VClassDaoSDB.java
This commit is contained in:
brianjlowe 2013-05-14 16:04:40 -04:00
commit b5b39638a1
149 changed files with 2033 additions and 1419 deletions

View file

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

View file

@ -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;
}
}
/**

View file

@ -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 {

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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();

View file

@ -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;
}
}

View file

@ -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();

View file

@ -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();

View file

@ -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");
}
}

View file

@ -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();

View file

@ -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");
}
}

View file

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

View file

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

View file

@ -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<String, List<FileItem>> map = (Map<String, List<FileItem>>) 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<FileItem> 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;

View file

@ -182,8 +182,19 @@ public class IndividualListController extends FreemarkerHttpServlet {
}
return rvMap;
}
public static Map<String,Object> getRandomResultsForVClass(String vclassURI, int page, int pageSize, IndividualDao indDao, ServletContext context) {
Map<String,Object> rvMap = new HashMap<String,Object>();
try{
List<String> 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<String> vclassUris, IndividualDao indDao, ServletContext context) {

View file

@ -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<Pattern,String> 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<String,Object> values = getValues(ind, displayOntModel,jenaOntModel, getValuesFromRequest(/*?*/) );
String template = getTemplate(ind, displayOntModel);
return new TemplateResponseValues(template, values);
}
private Map<String,Object>getValuesFromRequest(){
// 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<String,Object> getValues(Individual ind, OntModel displayOntModel, OntModel assertionModel, Map<String,Object> baseValues){
if( ind == null ) return Collections.emptyMap();
/* Figure out what ValueFactories are specified in the display ontology for this individual. */
Set<ValueFactory> valueFactories = new HashSet<ValueFactory>();
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<String,Object> values = new HashMap<String,Object>();
values.putAll(baseValues);
for(ValueFactory vf : valueFactories){
values.putAll( vf.getValues(assertionModel, values));
}
return values;
}
protected Set<ValueFactory> 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<String,String> config);
Map<String,Object> getValues(OntModel model, Map<String,Object> values);
}
private class NavigationURLPatternListener extends StatementListener {
private Map<Pattern,String> urlPatternToURI;
public synchronized Map<Pattern,String> 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<Pattern,String> 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<Pattern,String> buildUrlPatternToURI(){
OntModel displayModel = (OntModel)getServletContext().getAttribute("displayOntModel");
Map<Pattern,String> map = new HashMap<Pattern,String>();
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();
}
}
}

View file

@ -180,7 +180,7 @@ class IndividualResponseBuilder {
private boolean getprofilePageTypesFlag() {
String property = ConfigurationProperties.getBean(vreq).getProperty(
"MultiViews.profilePageTypes");
"multiViews.profilePageTypes");
return "enabled".equals(property);
}

View file

@ -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<String> 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<String, Object> modelMap = new HashMap<String, Object>();
modelMap.put("individual",
new IndividualTemplateModel(individual, vreq));
modelMap.put("vclass", vclassName);
ShortViewService svs = ShortViewServiceSetup.getService(ctx);
return svs.renderShortView(individual, ShortViewContext.BROWSE,
modelMap, vreq);
}
}

View file

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

View file

@ -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<String, Object> 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<String,Object> 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<String,Object> 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;
}
}

View file

@ -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) {

View file

@ -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;

View file

@ -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()))

View file

@ -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 {

View file

@ -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<Statement> getChangedStmts(Model assertions, Model retractions){
List<Statement> changedStmts = new LinkedList<Statement>();
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) ){

View file

@ -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;

View file

@ -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;

View file

@ -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<VClass> 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();

View file

@ -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());

View file

@ -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

View file

@ -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

View file

@ -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<Resource> 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;
}

View file

@ -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;
/**

View file

@ -95,7 +95,7 @@ public class JenaModelUtils {
.getRootClasses();
for (Iterator<VClass> 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<String> 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(

View file

@ -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) {

View file

@ -99,7 +99,7 @@ public class ObjectPropertyStatementDaoJena extends JenaBaseDao implements Objec
ClosableIterator<Statement> 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<endIndex)) ) {
Statement stmt = (Statement) opsIt.next();
Statement stmt = opsIt.next();
if (stmt.getObject().isResource()) {
++count;
if (startIndex<0 || startIndex<=count) {

View file

@ -102,7 +102,7 @@ public class ObjectPropertyStatementDaoSDB extends
ClosableIterator<Statement> 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();

View file

@ -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 {

View file

@ -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;

View file

@ -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<String> directSubproperties = getSubPropertyURIs(propertyURI);
Iterator<String> 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<String> directSuperproperties = getSuperPropertyURIs(propertyURI,true);
Iterator<String> 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()

View file

@ -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());
}

View file

@ -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) ) {

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -305,7 +305,7 @@ public class RDFServiceModelMaker implements ModelMaker {
List<String> graphNames = rdfService.getGraphURIs();
Iterator<String> 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);
}

View file

@ -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<String> directSubclasses = getSubClassURIs(classURI);
Iterator<String> 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<String> directSuperclasses = getSuperClassURIs(classURI, true);
Iterator<String> 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);
}

View file

@ -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) {

View file

@ -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;

View file

@ -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<Individual> 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<VClassGroup> 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<Individual> 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<VClassGroup> it = groups.listIterator();
while(it.hasNext()){
VClassGroup group = (VClassGroup) it.next();
VClassGroup group = it.next();
List<VClass> 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());
}

View file

@ -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 &&

View file

@ -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;
/**

View file

@ -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();

View file

@ -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<ObjectPropertyStatementPattern> patternSet = new HashSet<ObjectPropertyStatementPattern>();

View file

@ -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) {}

View file

@ -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.
*/

View file

@ -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.
*/

View file

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

View file

@ -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<Recipient> recipients = new ArrayList<Recipient>();
@ -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> T nonNull(T value, T defaultValue) {
return (value == null) ? defaultValue : value;
}

View file

@ -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);

View file

@ -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<String> langs = new ArrayList<String>();
log.debug("Accept-Language: " + vreq.getHeader("Accept-Language"));
List<String> langs = LanguageFilteringUtils.localesToLanguages(vreq.getLocales());
log.debug("Accept-Language: " + vreq.getHeader("Accept-Language"));
Enumeration<Locale> 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);

View file

@ -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,

View file

@ -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);

View file

@ -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;
}

View file

@ -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<String> localesToLanguages(Enumeration<?> locales) {
List<String> 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<String> 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
}
}

View file

@ -211,7 +211,8 @@ public class PagedSearchController extends FreemarkerHttpServlet {
Map<String, Object> body = new HashMap<String, Object>();
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);

View file

@ -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(),

View file

@ -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;

View file

@ -190,6 +190,26 @@ public class SolrQueryUtils {
}
}
public static SolrQuery getRandomQuery(List<String> 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<String> vclassUris){
List<String> queryTypes = new ArrayList<String>();
try {
@ -217,4 +237,16 @@ public class SolrQueryUtils {
return results;
}
public static IndividualListQueryResults buildAndExecuteRandomVClassQuery(
List<String> 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;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -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>
<!DOCTYPE html>
<html lang="en">
@ -36,17 +36,14 @@
<div id="search-home-field">
<input type="text" name="querytext" class="search-homepage" value="${querytext!}" autocapitalize="off" />
<input type="submit" value="Search" class="search" />
<input type="hidden" name="classgroup" class="search-homepage" value="" autocapitalize="off" />
</div>
<a class="filter-search filter-default" href="#" title="Filter search"><span class="displace">filter search</span></a>
<ul id="filter-search-nav">
<li><a class="active" href="">All</a></li>
<li><a href="">People</a></li>
<li><a href="">Organizations</a></li>
<li><a href="">Research</a></li>
<li><a href="">Events</a></li>
<li><a href="">Topics</a></li>
<@lh.allClassGroupNames vClassGroups! />
</ul>
</form>
</fieldset>
@ -57,22 +54,18 @@
<@widget name="login" />
<#--<@allClassGroups vClassGroups! />-->
<section id="home-stats">
<h4>Stats</h4>
<ul id="stats">
<li><a href="#"><p class="stats-count">19<span>k</span></p><p class="stats-type">People</p></a></li>
<li><a href="#"><p class="stats-count">128<span>k</span></p><p class="stats-type">Research</p></a></li>
<li><a href="#"><p class="stats-count">22<span>k</span></p><p class="stats-type">Organizations</p></a></li>
<li><a href="#"><p class="stats-count">29<span>k</span></p><p class="stats-type">Events</p></a></li>
<li><a href="#"><p class="stats-count">1.9<span>k</span></p><p class="stats-type">Topics</p></a></li>
<li><a href="#"><p class="stats-count">6.5<span>k</span></p><p class="stats-type">Activities</p></a></li>
</ul>
</section>
<!-- Statistical information relating to property groups and their classes; displayed horizontally, not vertically-->
<@lh.allClassGroups vClassGroups! />
<#include "footer.ftl">
<script>
// this will ensure that the hidden classgroup input is cleared if the back button is used
// to return to the home page from the search results. Not in vitroUtils.js because that
// gets loaded on every page.
$(document).ready(function(){
$('input[name="classgroup"]').val("");
});
</script>
</body>
</html>

View file

@ -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;

View file

@ -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<accounts}.
enter_new_password = Please enter your new password for {0}
search_accounts_button = Search accounts
accounts_search_results = Search results for
select_account_to_delete = select this account to delete it
click_to_view_account = click to view account details
filter_by_roles = Filter by roles
view_all_accounts = View all accounts
view_all_accounts_title = view all accounts
new_account_note = 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.
initial_password = Initial password
submit_add_new_account = Add new account
account_created = Your {0} account has been created.
account_created_subject Your {0} account has been created.
account_created_email_html = @@file files/accountCreatedEmail.html
account_created_email_text = @@file files/accountCreatedEmail.txt
account_created_external_email_html = @@file files/accountCreatedExternalOnlyEmail.html
account_created_external_email_text = @@file files/accountCreatedExternalOnlyEmail.txt
confirm_delete_account_singular = Are you sure you want to delete this account?
confirm_delete_account_plural = Are you sure you want to delete these accounts?
verify_this_match = verify this match
verify_this_match_title = verify this match
change_profile = change profile
change_profile_title = change profile
auth_matching_id_label = External Auth. ID / Matching ID
auth_id_label = External Authentication ID
auth_id_in_use = This Identifier is already in use.
auth_id_explanation = Can be used to associate the account with the user's profile via the matching property.
associated_profile_label = Associated profile:
select_associated_profile = Select the associated profile
create_associated_profile = Create the associated profile
email_changed_subject = Your {0} email account has been changed.
email_changed_html = @@file files/accountEmailChanged.html
email_changed_text = @@file files/accountEmailChanged.txt
create_your_password = Create your Password
password_created_subject = Your {0} password has successfully been created.
password_created_email_html = @@file files/passwordCreatedEmail.html
password_created_email_text = @@file files/passwordCreatedEmail.txt
password_reset_pending_subject = {0} reset password request
password_reset_pending_email_html = @@file files/passwordResetPending.html
password_reset_pending_email_text = @@file files/passwordResetPending.txt
password_reset_complete_subject = Your {0} password changed.
password_reset_complete_email_html = @@file files/passwordResetComplete.html
password_reset_complete_email_text = @@file files/passwordResetComplete.txt
reset_your_password = Reset your Password
first_time_login = First time log in
create_account = Create account
cant_activate_while_logged_in = You may not activate the account for {0} while you are logged in as {1}.
Please log out and try again.
account_already_activated = The account for {0} has already been activated.
cant_change_password_while_logged_in = You may not reset the password for {0} while you are logged in as {1}. \
Please log out and try again.
password_change_not_pending = The password for {0} has already been reset.
password_changed_subject = Password changed.
account_no_longer_exists = 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.
password_saved = Your password has been saved.
password_saved_please_login = Your password has been saved. Please log in.
please_provide_contact_information = Please provide your contact information to finish creating your account.
first_time_login_note = Note: An email will be sent to the address entered above notifying \
that an account has been created.
first_time_external_email_html = @@file files/accountFirstTimeExternal.html
first_time_external_email_text = @@file files/accountFirstTimeExternal.txt
myAccount_heading = My account
myAccount_confirm_changes = Your changes have been saved.
myAccount_confirm_changes_plus_note = Your changes have been saved. A confirmation email has been sent to {0}.
email_change_will_be_confirmed = Note: if email changes, a confirmation email will be sent to the new email address entered above.
email_changed_subject = "Your VIVO email account has been changed.");
who_can_edit_profile = Who can edit my profile
add_profile_editor = Add profile editor
select_existing_last_name = Select an existing last name
selected_editors = Selected editors
remove_selection = Remove selection
remove_selection_title = remove selection
external_id_not_provided = Login failed - External ID is not found.
external_id_already_in_use = User account already exists for ''{0}''
logins_disabled_for_maintenance = User logins are temporarily disabled while the system is being maintained.
error_no_email = You must supply an email address.
error_email_already_exists = An account with that email address already exists.
error_invalid_email = ''{0}'' is not a valid email address.
error_external_auth_already_exists = An account with that external authorization ID already exists.
error_no_first_name = You must supply a first name.
error_no_last_name = You must supply a last name.
error_no_role = You must select a role.
error_no_password = No password supplied.
error_password_length = Password must be between {0} and {1} characters.
error_password_mismatch = Passwords do not match.
#
# "partial" individual templates ( /templates/freemarker/body/partials/individual )
#
manage_publications = manage publications
manage_grants_and_projects = manage grants & projects
manage_affiliated_people = manage affiliated people
group_name = group name
scroll_to_menus = scroll to property group menus
properties_capitalized = Properties
properties = properties
view_all = View All
name = name
admin_panel = Admin Panel
edit_this_individual = Edit this individual
verbose_status_on = on
verbose_status_off = off
verbose_property_status = Verbose property display is
verbose_control = verbose control
verbose_turn_on = Turn on
verbose_turn_off = Turn off
resource_uri = Resource URI
individual_not_found = Individual not found:
entity_to_query_for = This id is the id of the entity to query for. netid also works.
menu_ordering = Menu Ordering
refresh_page_after_reordering = Refresh page after reordering menu items
display_has_element_error = There was an error in the system. The display:hasElement property could not be retrieved.
return_to = return to {0}
#
# admin templates ( /templates/freemarker/body/admin )
#
logins_already_restricted = Logins are already restricted.
logins_not_already_restricted = Logins are already not restricted.
logins_restricted = Logins are now restricted.
logins_not_restricted = Logins are no longer restricted.
remove_restrictions = Remove Restrictions
restrict_logins = Restrict Logins
error_alert_icon = Error alert icon
current_user = Current user
ext_auth_id = External Auth ID
not_logged_in = Not logged in
identifiers = Identifiers
associated_individuals = Associated Individuals
match_by = match by {0}
matching_prop_not_defined = matching property is not defined
may_edit = May edit
may_not_edit = May not edit
none = none
identifier_factories = Identifier factories
policies = Policies
authenticator = Authenticator
background_threads = Background Threads
name_capitalized = Name
work_level = Work level
since = Since
flags = Flags
search_index_status = Search Index Status
search_index_not_connected = The search index is not connected.
failed = failed
check_startup_status = Check startup status page and/or Tomcat logs for more information.
search_indexer_idle = The search indexer is idle.
most_recent_update = The most recent update was at
rebuild_button = Rebuild
reset_search_index = Reset the search index and re-populate it.
preparing_to_rebuild_index = Preparing to rebuild the search index.
since_elapsed_time = since {0}, elapsed time {1}
current_task = {0} the search index
since_elapsed_time_est_total = since {0}, elapsed time {1}, estimated total time {2}
index_recs_completed = Completed {0} out of {1} index records.
fatal_error = Fatal Error
fatal_error_detected = {0} detected a fatal error during startup.
warning = Warning
warnings_issued = {0} issued warnings during startup.
startup_trace = Startup trace
full_list_startup = The full list of startup events and messages.
startup_status = Startup Status
continue = Continue
#
# contact form templates ( /templates/freemarker/body/contactForm )
#
rejected_spam = REJECTED - SPAM
feedback_thanks_heading = Thank you for your feedback
feedback_thanks_text = Thank you for contacting our curation and development team. We will respond to your inquiry as soon as possible.
return_to_the = Return to the
home_page = home page
from = From
ip_address = IP address
viewing_page = Likely viewing page
comments = Comments
interest_thanks = Thank you for your interest in {0}. Please submit this form with questions, comments, or feedback about the content of this site.
full_name = Full name
comments_questions = Comments, questions, or suggestions
enter_in_security_field = Please enter the letters displayed below into the security field
send_mail = Send Mail
#
# display edit template ( /templates/freemarker/body/displayEdit )
#
display_admin_header = Display Admin and Configuration
#
# error templates ( /templates/freemarker/body/error )
#
we_have_an_error = There was an error in the system.
error_was_reported = This error has been reported to the site administrator.
error_message = Error message
stack_trace = Stack trace
trace_available = full trace available in the vivo log
caused_by = Caused by
requested_url = Requested url
error_occurred = An error occurred on the VIVO site
error_occurred_at = An error occurred on your VIVO site at {0}.
#
# login templates ( /templates/freemarker/body/login )
#
internal_login = Internal Login
no_email_supplied = No email supplied.
no_password_supplied = No password supplied.
logins_temporarily_disabled = User logins are temporarily disabled while the system is being maintained.
incorrect_email_password = Email or Password was incorrect.
password_length = Password must be between 6 and 12 characters.
password_mismatch = Passwords do not match.
new_pwd_matches_existing = Your new password must be different from your existing password.
enter_email_pasword = Enter the email address and password for your internal Vitro account.
change_password = You must change your password to log in.
new_password = New Password
confirm_password = Confirm Password
email_capitalized = Email
password_capitalized = Password
login_button = Log in
fake_external_auth = Fake External Authentication
enter_id_to_login = Enter the userID that you want to sign in as, or click Cancel.
username = Username
submit_button = Submit

View file

@ -0,0 +1,42 @@
#
# Text strings for the controllers and templates
#
# Spanish
#
cancel_link = Cancelar
or = o
alt_error_alert = Icono de alerta con error
#
# Image upload pages
#
upload_page_title = Subir foto
upload_page_title_with_name = Subir imagen para {0}
upload_heading = Subir foto
replace_page_title = Reemplazar imagen
replace_page_title_with_name = Cambie la imagen por {0}
crop_page_title = Recortar imagen
crop_page_title_with_name = Recorte imagen para {0}
current_photo = Foto actual
upload_photo = Suba foto
replace_photo = Reemplace foto
photo_types = (JPEG, GIF, o PNG)
maximum_file_size = Tamaño máximo de archivo: {0} megabytes
minimum_image_dimensions = Dimensiones mínimas de imagen: {0} x {1} pixels
cropping_caption = La foto de tu perfil se verá como la imagen de abajo.
cropping_note = Para realizar ajustes, arrastre alrededor y cambie el tamaño de la foto de la derecha. \
Cuando esté satisfecho con su foto, haga clic en el botón "Guardar foto".
alt_thumbnail_photo = Foto de individuo
alt_image_to_crop = Imagen que desea recortar
alt_preview_crop = Vista previa de la foto recortada
delete_link = Borrar foto
submit_upload = Subir foto
submit_save = Guardar foto
confirm_delete = ¿Seguro que quiere borrar esta foto?

View file

@ -0,0 +1,39 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
{2} {3}
</p>
<p>
<strong>Congratulations!</strong>
</p>
<p>
We have created your new account on {0}, associated with {4}.
</p>
<p>
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.
</p>
<p>
Click the link below to create your password for your new account using our secure server.
</p>
<p>
<a href="{5}" title="password">{5}</a>
</p>
<p>
If the link above doesn't work, you can copy and paste the link directly into your browser's address bar.
</p>
<p>
Thanks!
</p>
</body>
</html>

View file

@ -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!

View file

@ -0,0 +1,22 @@
<html>
<head>
<title>${1}</title>
</head>
<body>
<p>
${2} ${3}
</p>
<p>
<strong>Congratulations!</strong>
</p>
<p>
We have created your new VIVO account associated with ${4}.
</p>
<p>
Thanks!
</p>
</body>
</html>

View file

@ -0,0 +1,9 @@
${2} ${3}
Congratulations!
We have created your new VIVO account associated with
${4}.
Thanks!

View file

@ -0,0 +1,19 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
Hi, {2} ${3}
</p>
<p>
You recently changed the email address associated with
${2} ${3}
</p>
<p>
Thank you.
</p>
</body>
</html>

View file

@ -0,0 +1,6 @@
Hi, {2} {3}
You recently changed the email address associated with
{2} {3}
Thank you.

View file

@ -0,0 +1,22 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
{2} {3}
</p>
<p>
<strong>Congratulations!</strong>
</p>
<p>
We have created your new {0} account associated with {4}.
</p>
<p>
Thanks!
</p>
</body>
</html>

View file

@ -0,0 +1,8 @@
{2} {3}
Congratulations!
We have created your new {0} account associated with
{4}
Thanks!

View file

@ -0,0 +1,22 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
{2} {3}
</p>
<p>
<strong>Password successfully created.</strong>
</p>
<p>
Your new password associated with {4} has been created.
</p>
<p>
Thank you.
</p>
</body>
</html>

View file

@ -0,0 +1,8 @@
{2} {3}
Password successfully created.
Your new password associated with {4}
has been created.
Thank you.

View file

@ -0,0 +1,34 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
Dear {2} {3}:
</p>
<p>
We have received a request to reset the password for your {0} account ({4}).
</p>
<p>
Please follow the instructions below to proceed with your password reset.
</p>
<p>
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.
</p>
<p>
Click on the link below or paste it into your browser's address bar to reset your password
using our secure server.
</p>
<p>
<a href="{5}" title="password">{5}</a>
</p>
<p>Thank you!</p>
</body>
</html>

View file

@ -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!

View file

@ -0,0 +1,22 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
{2} {3}
</p>
<p>
<strong>Password successfully changed.</strong>
</p>
<p>
Your new password associated with {4} has been changed.
</p>
<p>
Thank you.
</p>
</body>
</html>

View file

@ -0,0 +1,8 @@
{2} {3}
Password successfully changed.
Your new password associated with {4}
has been changed.
Thank you.

View file

@ -0,0 +1,34 @@
<html>
<head>
<title>{1}</title>
</head>
<body>
<p>
Dear {2} {3}:
</p>
<p>
We have received a request to reset the password for your {0} account ({4}).
</p>
<p>
Please follow the instructions below to proceed with your password reset.
</p>
<p>
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.
</p>
<p>
Click on the link below or paste it into your browser's address bar to reset your password
using our secure server.
</p>
<p>
<a href="{5}" title="password">{5}</a>
</p>
<p>Thank you!</p>
</body>
</html>

View file

@ -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!

View file

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

View file

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

View file

@ -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', '');
}
}
});

View file

@ -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');
}
}

29
webapp/web/js/vitroUtils.js Executable file → Normal file
View file

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

View file

@ -2,67 +2,22 @@
<#-- Confirmation that an account has been created. -->
<#assign subject = "Your ${siteName} account has been created." />
<#assign strings = i18n() />
<#assign html>
<html>
<head>
<title>${subject}</title>
</head>
<body>
<p>
${userAccount.firstName} ${userAccount.lastName}
</p>
<p>
<strong>Congratulations!</strong>
</p>
<p>
We have created your new account on ${siteName}, associated with ${userAccount.emailAddress}.
</p>
<p>
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.
</p>
<p>
Click the link below to create your password for your new account using our secure server.
</p>
<p>
<a href="${passwordLink}" title="password">${passwordLink}</a>
</p>
<p>
If the link above doesn't work, you can copy and paste the link directly into your browser's address bar.
</p>
<p>
Thanks!
</p>
</body>
</html>
</#assign>
<#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>
<#assign text = strings.account_created_email_text(siteName,
subject,
userAccount.firstName,
userAccount.lastName,
userAccount.emailAddress,
passwordLink) />
<@email subject=subject html=html text=text />

Some files were not shown because too many files have changed in this diff Show more