NIHVIVO-2317 NIHVIVO-2318 removing vitro namespace properties from editing and various Java classes and interfaces

This commit is contained in:
brianjlowe 2011-07-05 19:14:16 +00:00
parent 9c469cef6b
commit 6e4fcedb6c
87 changed files with 178 additions and 3918 deletions

View file

@ -52,24 +52,15 @@ public class PropertyRestrictionPolicyHelper {
private static final Collection<String> PERMITTED_EXCEPTIONS = Arrays
.asList(new String[] {
VitroVocabulary.MONIKER,
VitroVocabulary.BLURB,
VitroVocabulary.DESCRIPTION,
VitroVocabulary.MODTIME,
VitroVocabulary.TIMEKEY,
VitroVocabulary.CITATION,
VitroVocabulary.IND_MAIN_IMAGE,
VitroVocabulary.LINK,
VitroVocabulary.PRIMARY_LINK,
VitroVocabulary.ADDITIONAL_LINK,
VitroVocabulary.LINK_ANCHOR,
VitroVocabulary.LINK_URL,
VitroVocabulary.KEYWORD_INDIVIDUALRELATION,
VitroVocabulary.KEYWORD_INDIVIDUALRELATION_INVOLVESKEYWORD,
VitroVocabulary.KEYWORD_INDIVIDUALRELATION_INVOLVESINDIVIDUAL,
VitroVocabulary.KEYWORD_INDIVIDUALRELATION_MODE });
VitroVocabulary.LINK_URL });
/**
* The bean is attached to the ServletContext using this attribute name.

View file

@ -36,17 +36,5 @@ public interface DataPropertyStatement {
public void setLanguage(String language);
public Date getSunrise();
public void setSunrise(Date sunrise);
public Date getSunset();
public void setSunset(Date sunset);
/*
public String getQualifier();
public void setQualifier(String qualifier);
*/
public String getString();
}

View file

@ -8,19 +8,15 @@ import java.util.Date;
* a class representing an particular instance of a data property
*
*/
public class DataPropertyStatementImpl implements VitroTimeWindowedResource, DataPropertyStatement
public class DataPropertyStatementImpl implements DataPropertyStatement
{
private Individual individual = null;
private String individualURI = null;
private String data = null;
private String datapropURI = null;
private String datatypeURI = null;
private String language = null;
private Date sunrise = null;
private Date sunset = null;
//private String qualifier = null;
private String language = null;
public DataPropertyStatementImpl(){
}
@ -84,30 +80,6 @@ public class DataPropertyStatementImpl implements VitroTimeWindowedResource, Dat
this.language = language;
}
public Date getSunrise() {
return sunrise;
}
public void setSunrise(Date sunrise) {
this.sunrise = sunrise;
}
public Date getSunset() {
return sunset;
}
public void setSunset(Date sunset) {
this.sunset = sunset;
}
/*
public String getQualifier() {
return qualifier;
}
public void setQualifier(String qualifier) {
this.qualifier = qualifier;
}
*/
public String getString(){
String out = "instance of dataprop: " + datapropURI;

View file

@ -17,7 +17,7 @@ import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
* Date: Oct 18, 2007
* Time: 3:08:33 PM
*/
public interface Individual extends ResourceBean, VitroTimeWindowedResource, Comparable<Individual> {
public interface Individual extends ResourceBean, Comparable<Individual> {
String getName();
void setName(String in);
@ -31,15 +31,6 @@ public interface Individual extends ResourceBean, VitroTimeWindowedResource, Com
String getVClassURI();
void setVClassURI(String in);
//Date getSunrise();
void setSunrise(Date in);
//Date getSunset();
void setSunset(Date in);
Date getTimekey();
void setTimekey(Date in);
Timestamp getModTime();
void setModTime(Timestamp in);
@ -92,24 +83,6 @@ public interface Individual extends ResourceBean, VitroTimeWindowedResource, Com
List<DataPropertyStatement> getExternalIds();
void setExternalIds(List<DataPropertyStatement> externalIds);
String getMoniker();
void setMoniker(String in);
String getDescription();
void setDescription(String in);
String getAnchor();
void setAnchor(String in);
String getBlurb();
void setBlurb(String in);
int getStatusId();
void setStatusId(int in);
String getStatus();
void setStatus(String s);
void setMainImageUri(String mainImageUri);
String getMainImageUri();
@ -117,22 +90,6 @@ public interface Individual extends ResourceBean, VitroTimeWindowedResource, Com
String getThumbUrl();
boolean hasThumb();
String getUrl();
void setUrl(String url);
List<Link> getLinksList();
void setLinksList(List<Link> linksList);
Link getPrimaryLink();
void setPrimaryLink(Link link);
List<String> getKeywords();
void setKeywords(List<String> keywords);
String getKeywordString();
List<Keyword> getKeywordObjects();
void setKeywordObjects(List<Keyword> keywords);
void sortForDisplay();
JSONObject toJSON() throws JSONException;

View file

@ -2,17 +2,25 @@
package edu.cornell.mannlib.vitro.webapp.beans;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import org.json.JSONException;
import org.json.JSONObject;
import edu.cornell.mannlib.vitro.webapp.filestorage.model.ImageInfo;
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
import java.lang.reflect.Method;
import java.sql.Timestamp;
import java.text.Collator;
import java.util.*;
/**
* Represents a single entity record.
*/
@ -31,9 +39,6 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
protected VClass vClass = null;
protected List<VClass> directVClasses = null;
protected List<VClass> allVClasses = null;
protected Date sunrise = null;
protected Date sunset = null;
protected Date timekey = null;
protected Timestamp modTime = null;
protected List <ObjectProperty>propertyList = null;
protected List<ObjectProperty> populatedObjectPropertyList = null;
@ -46,19 +51,8 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
protected List <ObjectPropertyStatement>rangeEnts2Ents = null;
protected List <DataPropertyStatement>externalIds = null;
protected String moniker = null;
protected String url = null;
protected String description = null;
protected String anchor = null;
protected String blurb = null;
protected String mainImageUri = NOT_INITIALIZED;
protected ImageInfo imageInfo = null;
protected int statusId = 0;
protected String status = null;
protected List <Link>linksList = null;
protected Link primaryLink = null;
protected List<String> keywords=null;
protected List<Keyword> keywordObjects=null;
protected Float searchBoost;
/** indicates if sortForDisplay has been called */
@ -86,23 +80,10 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
public String getRdfsLabel(){ return rdfsLabel; }
public void setRdfsLabel(String s){ rdfsLabel = s; }
// private String modTime = null;
// public String getModtime(){return modTime;}
// public void setModtime(String in){modTime=in;}
public String getVClassURI(){return vClassURI;}
public void setVClassURI(String in){vClassURI=in;}
public Date getSunrise(){return sunrise;}
public void setSunrise(Date in){sunrise=in;}
public Date getSunset(){return sunset;}
public void setSunset(Date in){sunset=in;}
public Date getTimekey(){return timekey;}
public void setTimekey(Date in){timekey=in;}
/**
* Returns the last time this object was changed in the model.
* Notice Java API craziness: Timestamp is a subclass of Date
@ -271,26 +252,6 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
public void setExternalIds(List<DataPropertyStatement> externalIds){
this.externalIds = externalIds;
}
public String getMoniker(){return moniker;}
public void setMoniker(String in){moniker=in;}
public String getDescription(){return description;}
public void setDescription(String in){description=in;}
public String getAnchor(){return anchor;}
public void setAnchor(String in){anchor=in;}
public String getBlurb(){return blurb;}
public void setBlurb(String in){blurb=in;}
public int getStatusId(){return statusId;}
public void setStatusId(int in){statusId=in;}
public String getStatus() {return status;}
public void setStatus(String s) {status=s; }
@Override
public String getMainImageUri() {
@ -313,61 +274,6 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
return "thumbUrl";
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public List<Link> getLinksList() {
return linksList;
}
public void setLinksList(List <Link>linksList) {
this.linksList = linksList;
}
public Link getPrimaryLink() {
return primaryLink;
}
public void setPrimaryLink(Link link) {
primaryLink = link;
}
public List<String> getKeywords() { return keywords; }
public void setKeywords(List<String> keywords) {this.keywords = keywords;}
public String getKeywordString(){
String rv = "";
List keywords=getKeywords();
if (getKeywords()!=null){
Iterator<String> it1 = getKeywords().iterator();
TreeSet<String> keywordSet = new TreeSet<String>(new Comparator<String>() {
public int compare( String first, String second ) {
if (first==null) {
return 1;
}
if (second==null) {
return -1;
}
Collator collator = Collator.getInstance();
return collator.compare(first,second);
}
});
while( it1.hasNext() ){
keywordSet.add(it1.next());
}
Iterator<String> it2 = keywordSet.iterator();
while (it2.hasNext()) {
rv+= it2.next();
if( it2.hasNext())
rv+=", ";
}
}
return rv;
}
public List<Keyword> getKeywordObjects() { return keywordObjects; }
public void setKeywordObjects(List<Keyword> keywords) {this.keywordObjects = keywords;}
public Float getSearchBoost() { return searchBoost; }
public void setSearchBoost(Float boost) { searchBoost = boost; }
@ -421,8 +327,6 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
if( "name".equalsIgnoreCase(fieldName) )
return getName();
if( "timekey".equalsIgnoreCase(fieldName) )
return getTimekey();
//not one of the more common ones, try reflection

View file

@ -7,10 +7,6 @@ public interface ObjectPropertyStatement {
public String toString();
public String getDescription();
public void setDescription(String description);
public boolean isSubjectOriented();
public void setSubjectOriented(boolean subjectOriented);
@ -19,10 +15,6 @@ public interface ObjectPropertyStatement {
public void setSubjectURI(String subjectURI);
public String getQualifier();
public void setQualifier(String qualifier);
public String getObjectURI();
public void setObjectURI(String objectURI);
@ -43,14 +35,6 @@ public interface ObjectPropertyStatement {
public void setPropertyURI(String URI);
public void setSunrise(Date date);
public Date getSunrise();
public void setSunset(Date date);
public Date getSunset();
public PropertyInstance toPropertyInstance();
}

View file

@ -9,7 +9,7 @@ import java.util.Date;
* a class representing a particular instance of an object property
*
*/
public class ObjectPropertyStatementImpl implements VitroTimeWindowedResource, ObjectPropertyStatement
public class ObjectPropertyStatementImpl implements ObjectPropertyStatement
{
private String subjectURI = null;
private Individual subject = null;
@ -41,22 +41,6 @@ public class ObjectPropertyStatementImpl implements VitroTimeWindowedResource, O
return "Object Property Statements: "+dom+" "+prop+" to "+ran+" "+orent;
}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#getDescription()
*/
public String getDescription() {
return description;
}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#setDescription(java.lang.String)
*/
public void setDescription(String description) {
this.description = description;
}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#isSubjectOriented()
*/
@ -87,22 +71,6 @@ public class ObjectPropertyStatementImpl implements VitroTimeWindowedResource, O
this.subjectURI = subjectURI;
}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#getQualifier()
*/
public String getQualifier() {
return qualifier;
}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#setQualifier(java.lang.String)
*/
public void setQualifier(String qualifier) {
this.qualifier = qualifier;
}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#getObjectURI()
*/
@ -196,32 +164,6 @@ public class ObjectPropertyStatementImpl implements VitroTimeWindowedResource, O
}
}
private Date sunrise = null;
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#setSunrise(java.util.Date)
*/
public void setSunrise(Date date) {
sunrise = date;
}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#getSunrise()
*/
public Date getSunrise(){
return sunrise;
}
private Date sunset = null;
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#setSunset(java.util.Date)
*/
public void setSunset(Date date) {
sunset = date;
}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#getSunset()
*/
public Date getSunset(){ return sunset; }
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement#toPropertyInstance()
*/
@ -231,7 +173,6 @@ public class ObjectPropertyStatementImpl implements VitroTimeWindowedResource, O
pi.setPropertyURI(propertyURI);
pi.setSubjectEntURI(subjectURI);
pi.setObjectEntURI(objectURI);
pi.setQualifier(qualifier);
pi.setSubjectSide(subjectOriented);
return pi;
}

View file

@ -14,9 +14,6 @@ public class PropertyInstance implements PropertyInstanceIface, Comparable<Prope
private String propertyURI = null;
private String objectEntURI = null;
private String subjectEntURI = null;
private String qualifier = null;
private Date sunrise = null;
private Date sunset = null;
private String subjectName = null;
private String objectName = null;
@ -86,18 +83,6 @@ public class PropertyInstance implements PropertyInstanceIface, Comparable<Prope
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.beans.PropertyInstanceIface#getQualifier()
*/
public String getQualifier(){return qualifier;}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.beans.PropertyInstanceIface#getSunrise()
*/
public Date getSunrise(){return sunrise;}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.beans.PropertyInstanceIface#getSunset()
*/
public Date getSunset(){return sunset;}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.beans.PropertyInstanceIface#getDomainSide()
*/
public boolean getSubjectSide(){return subjectSide;}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.beans.PropertyInstanceIface#getDomainQuickEditJsp()
@ -156,18 +141,6 @@ public class PropertyInstance implements PropertyInstanceIface, Comparable<Prope
* @see edu.cornell.mannlib.vitro.beans.PropertyInstanceIface#setRangePublic(java.lang.String)
*/
public void setRangePublic(String in){rangePublic=in;}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.beans.PropertyInstanceIface#setQualifier(java.lang.String)
*/
public void setQualifier(String in){qualifier=in;}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.beans.PropertyInstanceIface#setSunrise(java.util.Date)
*/
public void setSunrise(Date in){sunrise=in;}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.beans.PropertyInstanceIface#setSunset(java.util.Date)
*/
public void setSunset(Date in){sunset=in;}
/* (non-Javadoc)
* @see edu.cornell.mannlib.vitro.beans.PropertyInstanceIface#setDomainSide(boolean)
*/

View file

@ -10,9 +10,6 @@ public interface PropertyInstanceIface {
public abstract String getPropertyURI();
public abstract String getObjectEntURI();
public abstract String getSubjectEntURI();
public abstract String getQualifier();
public abstract Date getSunrise();
public abstract Date getSunset();
// entities
public abstract String getSubjectName();
@ -56,12 +53,6 @@ public interface PropertyInstanceIface {
public abstract void setRangePublic(String in);
public abstract void setQualifier(String in);
public abstract void setSunrise(Date in);
public abstract void setSunset(Date in);
public abstract void setSubjectSide(boolean in);
public abstract void setDomainQuickEditJsp(String in);

View file

@ -1,10 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.beans;
import java.util.Date;
public interface VitroTimeWindowedResource {
public Date getSunrise() ;
public Date getSunset() ;
}

View file

@ -89,20 +89,7 @@ public class CloneEntityServlet extends BaseEditController {
}
} else {
ind.setName("CLONE OF "+ind.getName());
}
String timeKeyStr = request.getParameter("timekey");
if (timeKeyStr!=null && !timeKeyStr.equals("")) {
Date timekey = parseStringToDate(timeKeyStr);
if (timekey!=null) {
ind.setTimekey(timekey);
}
}
// specify other values that do NOT want to be carried over from the existing Individual
ind.setSunrise(new DateTime().toDate());
// cannot set these values to null because they will still be copies
ind.setBlurb("");
ind.setDescription("");
}
String cloneURI=individualDao.insertNewIndividual(ind);
if (cloneURI == null){ log.error("Error inserting cloned individual"); return; }

View file

@ -30,15 +30,11 @@ import edu.cornell.mannlib.vitro.webapp.beans.ApplicationBean;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Keyword;
import edu.cornell.mannlib.vitro.webapp.beans.KeywordIndividualRelation;
import edu.cornell.mannlib.vitro.webapp.beans.PropertyInstance;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordIndividualRelationDao;
import edu.cornell.mannlib.vitro.webapp.dao.PropertyInstanceDao;
public class EntityEditController extends BaseEditController {
@ -77,11 +73,9 @@ public class EntityEditController extends BaseEditController {
request.setAttribute("entity",ent);
ArrayList<String> results = new ArrayList<String>();
int colCount = 6;
int colCount = 4;
results.add("Name");
results.add("moniker");
results.add("class");
results.add("blurb");
results.add("display level");
results.add("edit level");
results.add("last updated");
@ -100,8 +94,6 @@ public class EntityEditController extends BaseEditController {
rName = "[resource]";
}
results.add(rName);
String rMoniker = (ent.getMoniker()==null) ? "unspecified" : ent.getMoniker();
results.add(rMoniker);
String classStr = "";
List<VClass> classList = inferredEnt.getVClasses(false);
@ -123,10 +115,7 @@ public class EntityEditController extends BaseEditController {
}
}
results.add(classStr);
String rBlurb = (ent.getBlurb()==null) ? "" : ent.getBlurb();
results.add(rBlurb);
results.add(ent.getHiddenFromDisplayBelowRoleLevel() == null ? "unspecified" : ent.getHiddenFromDisplayBelowRoleLevel().getLabel());
results.add(ent.getProhibitedFromUpdateBelowRoleLevel() == null ? "unspecified" : ent.getProhibitedFromUpdateBelowRoleLevel().getLabel());
@ -157,11 +146,7 @@ public class EntityEditController extends BaseEditController {
}
OptionMap.put("externalIds", externalIdOptionList);
} catch (Exception e) {e.printStackTrace();}
try {
OptionMap.put("ExtraURL", FormUtils.makeOptionListFromBeans(ent.getLinksList(), "URI", "Anchor", null, null, false));
} catch (Exception e) {e.printStackTrace();}
List classGroups = vreq.getFullWebappDaoFactory().getVClassGroupDao().getPublicGroupsWithVClasses(true,true,false); // order by displayRank, include uninstantiated classes, don't count the individuals
Iterator classGroupIt = classGroups.iterator();
ListOrderedMap optGroupMap = new ListOrderedMap();
@ -201,28 +186,6 @@ public class EntityEditController extends BaseEditController {
}
foo.setOptionLists(OptionMap);
List<Option> existingKeywordRelations = new LinkedList();
KeywordIndividualRelationDao kirDao = vreq.getFullWebappDaoFactory().getKeys2EntsDao();
KeywordDao kDao = vreq.getFullWebappDaoFactory().getKeywordDao();
List kirs = kirDao.getKeywordIndividualRelationsByIndividualURI(ent.getURI());
if (kirs != null) {
Iterator kirIt = kirs.iterator();
while (kirIt.hasNext()) {
KeywordIndividualRelation kir = (KeywordIndividualRelation) kirIt.next();
if (kir.getKeyId() > 0) {
Keyword k = kDao.getKeywordById(kir.getKeyId());
if (k != null) {
Option kOpt = new Option();
kOpt.setValue(kir.getURI());
kOpt.setBody(k.getTerm()+" ("+kir.getMode()+")");
existingKeywordRelations.add(kOpt);
}
}
}
}
foo.getOptionLists().put("existingKeywordRelations",existingKeywordRelations);
epo.setFormObject(foo);

View file

@ -172,8 +172,6 @@ public class EntityRetryController extends BaseEditController {
hash.put("VClassURI", optList);
}
hash.put("Moniker", getMonikerOptionsList(individualForEditing, ewDao));
hash.put("HiddenFromDisplayBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getDisplayOptionsList(individualForEditing));
hash.put("ProhibitedFromUpdateBelowRoleLevelUsingRoleUri",RoleLevelOptionsSetup.getUpdateOptionsList(individualForEditing));
@ -279,20 +277,6 @@ public class EntityRetryController extends BaseEditController {
DateFormat dateOnlyFormat = new SimpleDateFormat("yyyy-MM-dd");
String html = FormUtils.htmlFormFromBean(individualForEditing,action,epo,foo,epo.getBadValueMap());
if (individualForEditing.getSunrise() != null)
foo.getValues().put("Sunrise", dateOnlyFormat.format(individualForEditing.getSunrise()));
if (individualForEditing.getSunset() != null)
foo.getValues().put("Sunset", minutesOnlyDateFormat.format(individualForEditing.getSunset()));
if (individualForEditing.getTimekey() != null)
foo.getValues().put("Timekey", minutesOnlyDateFormat.format(individualForEditing.getTimekey()));
HashMap defaultsHash = new HashMap();
if (action.equals("insert")) {
Calendar cal = Calendar.getInstance(TimeZone.getDefault());
defaultsHash.put("Sunrise", minutesOnlyDateFormat.format(cal.getTime()));
defaultsHash.put("Sunset", "9999-12-31");
}
epo.setDefaultValueMap(defaultsHash);
List cList = new ArrayList();
cList.add(new IndividualDataPropertyStatementProcessor());
@ -327,24 +311,6 @@ public class EntityRetryController extends BaseEditController {
}
}
private List<Option> getMonikerOptionsList(Individual entity,
IndividualDao indDao) {
ArrayList<Option> monikerOpts = new ArrayList<Option>();
monikerOpts.add(new Option("", "none", (entity.getMoniker() == null)));
if (entity.getVClassURI() != null) {
List<String> monikers = indDao.monikers(entity.getVClassURI());
if (monikers != null) {
for (String moniker : monikers) {
monikerOpts.add(new Option(
moniker, moniker,
moniker.equals(entity.getMoniker())));
}
}
}
monikerOpts.add(new Option("", "[new moniker]"));
return monikerOpts;
}
public void doGet (HttpServletRequest request, HttpServletResponse response) {
doPost(request, response);

View file

@ -1,199 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.edit;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.FormObject;
import edu.cornell.mannlib.vedit.beans.Option;
import edu.cornell.mannlib.vedit.controller.BaseEditController;
import edu.cornell.mannlib.vedit.util.FormUtils;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.EditIndividuals;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Keyword;
import edu.cornell.mannlib.vitro.webapp.beans.KeywordIndividualRelation;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordIndividualRelationDao;
import edu.cornell.mannlib.vitro.webapp.edit.listener.impl.KeywordSearchReindexer;
public class Keys2EntsRetryController extends BaseEditController {
private static final Log log = LogFactory.getLog(Keys2EntsRetryController.class.getName());
public void doPost (HttpServletRequest req, HttpServletResponse response) {
if (!isAuthorizedToDisplayPage(req, response, new Actions(new EditIndividuals()))) {
return;
}
VitroRequest request = new VitroRequest(req);
//create an EditProcessObject for this and put it in the session
EditProcessObject epo = super.createEpo(request);
boolean isDashboardForm=false;
String action = "insert";
if ("dashboardDelete".equals(request.getParameter("action"))){
action = "delete"; // will change -- ignore for now
isDashboardForm=true;
} else if ("dashboardInsert".equals(request.getParameter("action"))){
isDashboardForm=true;
}
KeywordIndividualRelationDao k2eDao = request.getFullWebappDaoFactory().getKeys2EntsDao();
epo.setDataAccessObject(k2eDao);
KeywordDao kDao = request.getFullWebappDaoFactory().getKeywordDao();
IndividualDao eDao = request.getFullWebappDaoFactory().getIndividualDao();
KeywordIndividualRelation objectForEditing = new KeywordIndividualRelation();
String uri = request.getParameter("uri");
if (uri != null) {
try {
objectForEditing = k2eDao.getKeywordIndividualRelationByURI(uri);
action = "update";
} catch (NullPointerException e) {
log.error("Could not find KeywordIndividualRelation "+uri);
}
}
String individualURI = request.getParameter("individualURI");
Individual ent = null;
HashMap<String,List<Option>> optionMap = new HashMap<String,List<Option>>();
List<Option> entList = new LinkedList<Option>();
Option entOpt = null;
if (individualURI != null) {
objectForEditing.setEntURI(individualURI);
ent = eDao.getIndividualByURI(objectForEditing.getEntURI());
if (ent==null) {
log.error("cannot find entity via URI '"+individualURI+"'");
throw new Error("cannot find entity via URI '"+individualURI+"' in Keys2EntsRetryController");
}
entOpt = new Option(ent.getURI(),ent.getName(),true);
} else {
entOpt = new Option("-1", "Error: the entity must be specified", false);
}
entList.add(entOpt);
optionMap.put("EntId",entList);
/*
List<KeywordIndividualRelation> k2iList = null;
if (action.equals("remove")){
k2iList = k2eDao.getKeywordIndividualRelationsByIndividualURI(individualURI);
} */
epo.setOriginalBean(objectForEditing);
populateBeanFromParams(objectForEditing, request);
//set up any listeners
List changeListenerList = new LinkedList();
changeListenerList.add(new KeywordSearchReindexer());
epo.setChangeListenerList(changeListenerList);
//set the getMethod so we can retrieve a new bean after we've inserted it
try {
Class[] args = new Class[1];
args[0] = String.class;
epo.setGetMethod(k2eDao.getClass().getDeclaredMethod("getKeywordIndividualRelationByURI",args));
} catch (NoSuchMethodException e) {
log.error("Keys2EntsRetryController could not find the getKeywordIndividualRelationByURI method");
}
FormObject foo = new FormObject();
if (isDashboardForm && action.equals("delete")) {
List<Option> existingKeywordRelations = new LinkedList();
KeywordIndividualRelationDao kirDao = request.getFullWebappDaoFactory().getKeys2EntsDao();
List kirs = kirDao.getKeywordIndividualRelationsByIndividualURI(ent.getURI());
if (kirs != null) {
Iterator kirIt = kirs.iterator();
while (kirIt.hasNext()) {
KeywordIndividualRelation kir = (KeywordIndividualRelation) kirIt.next();
if (kir.getKeyId() > 0) {
Keyword k = kDao.getKeywordById(kir.getKeyId());
if (k != null) {
Option kOpt = new Option();
kOpt.setValue(kir.getURI());
kOpt.setBody(k.getTerm()+" ("+kir.getMode()+")");
existingKeywordRelations.add(kOpt);
}
}
}
}
//foo.getOptionLists().put("existingKeywordRelations",existingKeywordRelations);
optionMap.put("KeyId",existingKeywordRelations);
//optionMap.put("KeyId",FormUtils.makeOptionListFromBeans((List)ent.getKeywordObjects(), "Id", "Term", Integer.toString(objectForEditing.getKeyId()), null));
action = "update"; //reset for processing
} else {
optionMap.put("KeyId",FormUtils.makeOptionListFromBeans((List)kDao.getAllKeywords(), "Id", "Term", Integer.toString(objectForEditing.getKeyId()), null));
}
List modeOptionList = new LinkedList();
String VISIBLE = "visible";
Option visibleOption = new Option(VISIBLE);
if (isDashboardForm){
visibleOption.setSelected(true);
} else {
String HIDDEN = "hidden";
Option hiddenOption = new Option(HIDDEN);
if (objectForEditing.getMode().equalsIgnoreCase(HIDDEN)) {
hiddenOption.setSelected(true);
} else /*if (objectForEditing.getMode().equalsIgnoreCase(VISIBLE))*/ { //make this the default
visibleOption.setSelected(true);
}
modeOptionList.add(hiddenOption);
}
modeOptionList.add(visibleOption);
optionMap.put("Mode", modeOptionList);
foo.setOptionLists(optionMap);
epo.setFormObject(foo);
String html = FormUtils.htmlFormFromBean(objectForEditing,action,foo);
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
request.setAttribute("formHtml",html);
request.setAttribute("bodyJsp","/templates/edit/formBasic.jsp");
if (isDashboardForm) {
request.setAttribute("formJsp","/templates/edit/specific/keys2ents_dashboard_retry.jsp");
} else {
request.setAttribute("formJsp","/templates/edit/specific/keys2ents_retry.jsp");
}
request.setAttribute("scripts","/templates/edit/formBasic.js");
request.setAttribute("title","Individual-Keyword Link Editing Form");
request.setAttribute("_action",action);
request.setAttribute("unqualifiedClassName","Keys2Ents");
setRequestAttributes(request,epo);
try {
rd.forward(request, response);
} catch (Exception e) {
log.error("Keys2EntsRetryController could not forward to view.");
log.error(e.getMessage());
log.error(e.getStackTrace());
}
}
public void doGet (HttpServletRequest request, HttpServletResponse response) {
doPost(request, response);
}
}

View file

@ -1,67 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.edit;
import java.util.HashMap;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.FormObject;
import edu.cornell.mannlib.vedit.controller.BaseEditController;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.EditIndividuals;
import edu.cornell.mannlib.vitro.webapp.beans.Keyword;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
public class KeywordEditController extends BaseEditController {
private static final Log log = LogFactory.getLog(KeywordEditController.class.getName());
public void doPost (HttpServletRequest request, HttpServletResponse response) {
if (!isAuthorizedToDisplayPage(request, response, new Actions(new EditIndividuals()))) {
return;
}
VitroRequest vreq = new VitroRequest(request);
// we need to extract the keyword id from a Fetch parameter
String linkwhereId = request.getParameter("linkwhere");
String theKeywordId = linkwhereId.substring(15,linkwhereId.length()-1);
int kwId = Integer.decode(theKeywordId);
Keyword k = vreq.getFullWebappDaoFactory().getKeywordDao().getKeywordById(kwId);
EditProcessObject epo = super.createEpo(request);
FormObject foo = new FormObject();
HashMap OptionMap = new HashMap();
foo.setOptionLists(OptionMap);
epo.setFormObject(foo);
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
request.setAttribute("epoKey",epo.getKey());
request.setAttribute("keyword", k);
request.setAttribute("bodyJsp","/templates/edit/specific/keyterms_edit.jsp");
request.setAttribute("title","Keyword Control Panel");
request.setAttribute("css", "<link rel=\"stylesheet\" type=\"text/css\" href=\""+vreq.getAppBean().getThemeDir()+"css/edit.css\"/>");
try {
rd.forward(request, response);
} catch (Exception e) {
log.error("KeywordEditController could not forward to view.");
log.error(e.getMessage());
log.error(e.getStackTrace());
}
}
public void doGet (HttpServletRequest request, HttpServletResponse response) {
doPost(request,response);
}
}

View file

@ -1,204 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.edit;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.FormObject;
import edu.cornell.mannlib.vedit.beans.Option;
import edu.cornell.mannlib.vedit.controller.BaseEditController;
import edu.cornell.mannlib.vedit.listener.ChangeListener;
import edu.cornell.mannlib.vedit.util.FormUtils;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.EditIndividuals;
import edu.cornell.mannlib.vitro.webapp.beans.Keyword;
import edu.cornell.mannlib.vitro.webapp.beans.KeywordIndividualRelation;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordIndividualRelationDao;
import edu.cornell.mannlib.vitro.webapp.edit.listener.impl.KeywordSearchReindexer;
import edu.cornell.mannlib.vitro.webapp.edit.validator.impl.KeywordStemmerAndValidator;
public class KeywordRetryController extends BaseEditController {
private static final Log log = LogFactory.getLog(KeywordRetryController.class.getName());
public void doPost (HttpServletRequest req, HttpServletResponse response) {
if (!isAuthorizedToDisplayPage(req, response, new Actions(new EditIndividuals()))) {
return;
}
VitroRequest request = new VitroRequest(req);
//create an EditProcessObject for this and put it in the session
EditProcessObject epo = super.createEpo(request);
/*for testing*/
Keyword testMask = new Keyword();
epo.setBeanClass(Keyword.class);
epo.setBeanMask(testMask);
KeywordDao kDao = request.getFullWebappDaoFactory().getKeywordDao();
epo.setDataAccessObject(kDao);
epo.getAdditionalDaoMap().put("KeywordIndividualRelationDao", request.getFullWebappDaoFactory().getKeys2EntsDao());
String action="insert";
Keyword keywordForEditing = null;
if (!epo.getUseRecycledBean()){
if (request.getParameter("id") != null) {
int id = Integer.parseInt(request.getParameter("id"));
if (id > 0) {
try {
keywordForEditing = kDao.getKeywordById(id);
action = "update";
} catch (NullPointerException e) {
log.error("Need to implement 'record not found' error message.");
}
}
} else {
keywordForEditing = new Keyword();
keywordForEditing.setType("keyword");
keywordForEditing.setOrigin("unspecified"); // may be reset below
keywordForEditing.setSource("unspecified"); // may be reset below
}
epo.setOriginalBean(keywordForEditing);
} else {
keywordForEditing = (Keyword) epo.getNewBean();
keywordForEditing.setType("keyword");
keywordForEditing.setOrigin("unspecified"); // may be reset below
keywordForEditing.setSource("unspecified"); // may be reset below
}
//make a simple mask for the class's id
Object[] simpleMaskPair = new Object[2];
simpleMaskPair[0]="Id";
simpleMaskPair[1]=Integer.valueOf(keywordForEditing.getId());
epo.getSimpleMask().add(simpleMaskPair);
//set up any validators
LinkedList lnList = new LinkedList();
lnList.add(new KeywordStemmerAndValidator(epo,kDao));
epo.getValidatorMap().put("Term",lnList);
//set up any listeners
String entityURI = request.getParameter("individualURI");
if (entityURI != null && request.getParameter("mode") != null) {
List listenerList = new LinkedList();
listenerList.add(new newKeywordToEntityLinker(entityURI, request.getParameter("mode")));
listenerList.add(new KeywordSearchReindexer());
epo.setChangeListenerList(listenerList);
}
//set the getMethod so we can retrieve a new bean after we've inserted it
try {
Class[] args = new Class[1];
args[0] = int.class;
epo.setGetMethod(kDao.getClass().getDeclaredMethod("getKeywordById",args));
} catch (NoSuchMethodException e) {
log.error("KeywordRetryController could not find the getKeywordById method");
}
FormObject foo = new FormObject();
boolean useShortForm=false;
if ("dashboardCreate".equals(request.getParameter("action"))) {
keywordForEditing.setOrigin("user-added");
keywordForEditing.setSource("user-added");
useShortForm=true;
} else if ("editorCreate".equals(request.getParameter("action"))) {
keywordForEditing.setOrigin("curator-added");
keywordForEditing.setSource("curator-added");
useShortForm=true;
} else {
HashMap OptionMap = new HashMap();
List originsList = kDao.getAllOrigins();
List originsOptList = new LinkedList();
originsOptList.add(new Option("","[new origin]",false));
Iterator originsIt = originsList.iterator();
while (originsIt.hasNext()) {
String optStr = (String)originsIt.next();
boolean selected = (keywordForEditing.getOrigin()==null) ? false : keywordForEditing.getOrigin().equals(optStr);
Option opt = new Option(optStr, optStr, selected);
originsOptList.add(opt);
}
OptionMap.put("Origin", originsOptList);
foo.setOptionLists(OptionMap);
}
foo.setErrorMap(epo.getErrMsgMap());
epo.setFormObject(foo);
String html = FormUtils.htmlFormFromBean(keywordForEditing,action,foo,epo.getBadValueMap());
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
request.setAttribute("formHtml",html);
request.setAttribute("bodyJsp","/templates/edit/formBasic.jsp");
if (useShortForm) {
request.setAttribute("formJsp","/templates/edit/specific/keyterms_dashboard_retry.jsp");
} else {
request.setAttribute("formJsp","/templates/edit/specific/keyterms_retry.jsp");
}
request.setAttribute("scripts","/templates/edit/formBasic.js");
request.setAttribute("title","Keyword Editing Form");
request.setAttribute("_action",action);
request.setAttribute("unqualifiedClassName","Keyword");
setRequestAttributes(request,epo);
try {
rd.forward(request, response);
} catch (Exception e) {
log.error("KeywordRetryController could not forward to view.");
log.error(e.getMessage());
log.error(e.getStackTrace());
}
}
public void doGet (HttpServletRequest request, HttpServletResponse response) {
doPost(request, response);
}
public class newKeywordToEntityLinker implements ChangeListener {
// should be a better way to do this
// cascading deletes should be implemented differently
String entityURI = null;
String mode = "hidden";
private newKeywordToEntityLinker(String entityURI, String mode) {
this.entityURI = entityURI;
this.mode = mode;
}
public void doInserted(Object newObj, EditProcessObject epo) {
Keyword k = (Keyword) newObj;
KeywordIndividualRelation k2e = new KeywordIndividualRelation();
k2e.setKeyId(k.getId());
k2e.setEntURI(entityURI);
k2e.setMode(mode);
((KeywordIndividualRelationDao)epo.getAdditionalDaoMap().get("KeywordIndividualRelationDao")).insertNewKeywordIndividualRelation(k2e);
}
public void doUpdated(Object oldObj, Object newObj, EditProcessObject epo) {
// nothing required
}
public void doDeleted(Object oldObj, EditProcessObject epo) {
// nothing required
}
}
}

View file

@ -1,146 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.controller.edit;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.beans.FormObject;
import edu.cornell.mannlib.vedit.beans.Option;
import edu.cornell.mannlib.vedit.controller.BaseEditController;
import edu.cornell.mannlib.vedit.util.FormUtils;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions;
import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.EditIndividuals;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Link;
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.LinksDao;
import edu.cornell.mannlib.vitro.webapp.dao.LinktypeDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
public class LinkRetryController extends BaseEditController {
private static final Log log = LogFactory.getLog(LinkRetryController.class.getName());
public void doPost (HttpServletRequest req, HttpServletResponse response) {
if (!isAuthorizedToDisplayPage(req, response, new Actions(new EditIndividuals()))) {
return;
}
VitroRequest request = new VitroRequest(req);
//create an EditProcessObject for this and put it in the session
EditProcessObject epo = super.createEpo(request);
request.setAttribute("epo",epo);
/*for testing*/
Link testMask = new Link();
epo.setBeanClass(Link.class);
epo.setBeanMask(testMask);
String action = "insert";
WebappDaoFactory wadf = (request.getAssertionsWebappDaoFactory() != null)
? request.getAssertionsWebappDaoFactory()
: request.getFullWebappDaoFactory();
LinksDao lDao = wadf.getLinksDao();
epo.setDataAccessObject(lDao);
LinktypeDao ltDao = wadf.getLinktypeDao();
IndividualDao eDao = wadf.getIndividualDao();
Link linkForEditing = null;
if (!epo.getUseRecycledBean()){
String linkUri = request.getParameter("uri");
if (linkUri != null) {
try {
linkForEditing = lDao.getLinkByURI(linkUri);
action = "update";
} catch (NullPointerException e) {
log.error("Need to implement 'record not found' error message.");
}
} else {
linkForEditing = new Link();
if (request.getParameter("entityUri") != null) {
try {
linkForEditing.setEntityURI(request.getParameter("entityUri"));
} catch (NumberFormatException e) {
// oh well; it was worth a shot
}
}
}
epo.setOriginalBean(linkForEditing);
} else {
linkForEditing = (Link) epo.getNewBean();
action = "update";
log.error("using newBean");
}
//set up any listeners
//set the getMethod so we can retrieve a new bean after we've inserted it
try {
Class[] args = new Class[1];
args[0] = int.class;
epo.setGetMethod(lDao.getClass().getDeclaredMethod("getLinkById",args));
} catch (NoSuchMethodException e) {
log.error("LinkRetryController could not find the namespaceById method in the facade");
}
FormObject foo = new FormObject();
HashMap OptionMap = new HashMap();
List entityList = new LinkedList();
if (linkForEditing.getEntityURI() != null) {
Individual theEnt = eDao.getIndividualByURI(linkForEditing.getEntityURI());
entityList.add(new Option(theEnt.getURI(),theEnt.getName(),true));
} else {
entityList.add(new Option ("", "Error: the entity must be specified", true));
}
OptionMap.put("EntityId",entityList);
List linkTypeOptList = FormUtils.makeOptionListFromBeans(ltDao.getAllLinktypes(), "URI", "Type", linkForEditing.getTypeURI(),"");
linkTypeOptList.add(0,new Option("","unspecified"));
OptionMap.put("TypeURI", linkTypeOptList);
foo.setOptionLists(OptionMap);
foo.setErrorMap(epo.getErrMsgMap());
epo.setFormObject(foo);
String html = FormUtils.htmlFormFromBean(linkForEditing,action,foo,epo.getBadValueMap());
RequestDispatcher rd = request.getRequestDispatcher(Controllers.BASIC_JSP);
request.setAttribute("formHtml",html);
request.setAttribute("bodyJsp","/templates/edit/formBasic.jsp");
request.setAttribute("formJsp","/templates/edit/specific/links_retry.jsp");
request.setAttribute("scripts","/templates/edit/formBasic.js");
request.setAttribute("title","Hyperlink Editing Form");
request.setAttribute("_action",action);
request.setAttribute("unqualifiedClassName","Link");
setRequestAttributes(request,epo);
try {
rd.forward(request, response);
} catch (Exception e) {
log.error("NamespaceRetryController could not forward to view.");
log.error(e.getMessage());
log.error(e.getStackTrace());
}
}
public void doGet (HttpServletRequest request, HttpServletResponse response) {
doPost(request, response);
}
}

View file

@ -54,10 +54,21 @@ public class ObjectPropertyStatementRetryController extends BaseEditController {
Class[] classarray = {PropertyInstanceIface.class};
try {
epo.setInsertMethod(PropertyInstanceDao.class.getMethod("insertProp", classarray));
epo.setUpdateMethod(epo.getInsertMethod());
} catch (NoSuchMethodException nsme) {
log.error("Unable to find "+PropertyInstanceDao.class.getName()+".insertProp("+PropertyInstanceIface.class.getName()+")");
}
try {
epo.setDeleteMethod(
PropertyInstanceDao.class.getMethod(
"deletePropertyInstance", classarray));
} catch(NoSuchMethodException nsme) {
log.error("Unable to find "+PropertyInstanceDao.class.getName()+
".deletePropertyInstance("+
PropertyInstanceIface.class.getName()+")");
}
String action = "insert";
PropertyInstanceDao piDao = vreq.getFullWebappDaoFactory().getPropertyInstanceDao();

View file

@ -61,7 +61,6 @@ public class IndividualsListingController extends BaseEditController {
results.add("XX");
results.add("Individual");
results.add("class");
results.add("moniker");
if (inds != null && inds.size()>0) {
Iterator indsIt = inds.iterator();
@ -93,9 +92,6 @@ public class IndividualsListingController extends BaseEditController {
results.add(vclassURI);
}
String monikerStr = (ind.getMoniker() != null) ? ind.getMoniker() : "unspecified";
results.add(monikerStr);
}
} else {
results.add("XX");
@ -104,14 +100,11 @@ public class IndividualsListingController extends BaseEditController {
request.setAttribute("results",results);
request.setAttribute("columncount",new Integer(4));
request.setAttribute("columncount",new Integer(3));
request.setAttribute("suppressquery","true");
request.setAttribute("title", "Individuals in Class "+ ( (vc != null) ? vc.getName() : vclassURI ) );
request.setAttribute("bodyJsp", Controllers.HORIZONTAL_JSP);
// request.setAttribute("horizontalJspAddButtonUrl", Controllers.RETRY_URL);
// request.setAttribute("horizontalJspAddButtonText", "Add new individual");
// request.setAttribute("horizontalJspAddButtonControllerParam", "Individual");
// new individual button
List <ButtonForm> buttons = new ArrayList<ButtonForm>();
HashMap<String,String> newIndividualParams=new HashMap<String,String>();

View file

@ -111,7 +111,7 @@ public class IndividualController extends FreemarkerHttpServlet {
return doHelp();
}
if( individual == null || checkForHidden(vreq, individual) || checkForSunset(vreq, individual)){
if( individual == null ){
return doNotFound(vreq);
}
@ -255,7 +255,6 @@ public class IndividualController extends FreemarkerHttpServlet {
IndividualDao iwDao = vreq.getWebappDaoFactory().getIndividualDao();
individual.setKeywords(iwDao.getKeywordsForIndividualByMode(individual.getURI(),"visible"));
individual.sortForDisplay();
return new IndividualTemplateModel(individual, vreq);
@ -582,18 +581,6 @@ public class IndividualController extends FreemarkerHttpServlet {
return null;
}
@SuppressWarnings("unused")
private boolean checkForSunset(VitroRequest vreq, Individual entity) {
// TODO Auto-generated method stub
return false;
}
@SuppressWarnings("unused")
private boolean checkForHidden(VitroRequest vreq, Individual entity){
// TODO Auto-generated method stub
return false;
}
/**
* If this entity represents a File Bytestream, get its alias URL so we can

View file

@ -146,7 +146,9 @@ public class RDFUploadController extends BaseEditController {
OntModel tboxChangeModel=null;
Model aboxChangeModel=null;
if (tboxModel != null) {
tboxChangeModel = xutil.extractTBox(uploadModel);
boolean AGGRESSIVE = true;
tboxChangeModel = xutil.extractTBox(uploadModel, AGGRESSIVE);
// aggressively seek all statements that are part of the TBox
tboxstmtCount = operateOnModel(
request.getFullWebappDaoFactory(),
tboxModel,tboxChangeModel,

View file

@ -107,19 +107,6 @@ public interface IndividualDao extends ObjectSourceIface {
void fillVClassForIndividual(Individual individual);
List<String> monikers(String vclassURI);
List<String> getKeywordsForIndividual(String individualURI);
List<String> getKeywordsForIndividualByMode(String individualURI,
String modeStr);
List<Keyword> getKeywordObjectsForIndividual(String individualURI);
String getNetId(String entityURI);
String getStatus(String entityURI);
/**
* Standard way to get a new URI that is not yet used.
* @param individual, may be null
@ -130,12 +117,4 @@ public interface IndividualDao extends ObjectSourceIface {
EditLiteral getLabelEditLiteral(String individualUri);
@Deprecated
public abstract Individual getIndividualByExternalId(int externalIdType,
String externalIdValue);
@Deprecated
Individual getIndividualByExternalId(int externalIdType,
String externalIdValue,
String vClassURI);
}

View file

@ -1,30 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.dao;
import edu.cornell.mannlib.vitro.webapp.beans.Keyword;
import java.util.List;
/**
* Created by IntelliJ IDEA.
* User: bdc34
* Date: Apr 18, 2007
* Time: 3:18:29 PM
* To change this template use File | Settings | File Templates.
*/
public interface KeywordDao {
Keyword getKeywordById(int id);
List<Keyword> getAllKeywords();
List<Keyword> getKeywordsByStem(String stem);
int insertNewKeyword(Keyword k);
void updateKeyword(Keyword k);
void deleteKeyword(Keyword keyword);
List /*String*/ getAllOrigins();
}

View file

@ -1,26 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.dao;
import java.util.List;
import edu.cornell.mannlib.vitro.webapp.beans.KeywordIndividualRelation;
/**
* Created by IntelliJ IDEA.
* User: bdc34
* Date: Apr 18, 2007
* Time: 3:17:51 PM
* To change this template use File | Settings | File Templates.
*/
public interface KeywordIndividualRelationDao {
KeywordIndividualRelation getKeywordIndividualRelationByURI(String URI);
List<KeywordIndividualRelation> getKeywordIndividualRelationsByIndividualURI(String individualURI);
String insertNewKeywordIndividualRelation(KeywordIndividualRelation k);
void updateKeywordIndividualRelation(KeywordIndividualRelation k);
void deleteKeywordIndividualRelation(KeywordIndividualRelation k);
}

View file

@ -42,7 +42,6 @@ public class VitroVocabulary {
// properties found on the beans
public static final String DESCRIPTION = vitroURI+"description";
public static final String DESCRIPTION_ANNOT = vitroURI + "descriptionAnnot";
public static final String PUBLIC_DESCRIPTION_ANNOT = vitroURI + "publicDescriptionAnnot";
public static final String SHORTDEF = vitroURI+"shortDef";
@ -68,32 +67,21 @@ public class VitroVocabulary {
public static final String NOBODY = "http://vitro.mannlib.cornell.edu/ns/vitro/role#nobody";
public static final String SEARCH_BOOST_ANNOT = vitroURI + "searchBoostAnnot";
public static final String SUNRISE = vitroURI+"sunrise";
public static final String SUNSET = vitroURI+"sunset";
public static final String DEPENDENT_RESORUCE = "http://vivoweb.org/ontology/core#DependentResource";
//////////////////////////////////////////
public static final String CURATOR_NOTE = vitroURI+"curatorNote";
public static final String MONIKER = vitroURI+"moniker";
public static final String BLURB = vitroURI+"blurb";
public static final String CLASSGROUP = vitroURI+"ClassGroup";
public static final String IN_CLASSGROUP = vitroURI+"inClassGroup";
public static final String MODTIME = vitroURI+"modTime";
public static final String TIMEKEY = vitroURI+"timekey";
public static final String DISPLAY_RANK = vitroURI+"displayRank";
public static final String DISPLAY_RANK_ANNOT = vitroURI+"displayRankAnnot";
public static final String DISPLAY_LIMIT = vitroURI+"displayLimitAnnot";
public static final String CITATION = vitroURI+"citation";
// ================== property related =================================
@ -102,8 +90,6 @@ public class VitroVocabulary {
public static final String PROPERTY_OBJECTINDIVIDUALSORTPROPERTY = vitroURI+"objectIndividualSortProperty";
public static final String PROPERTY_FULLPROPERTYNAMEANNOT = vitroURI+"fullPropertyNameAnnot";
public static final String PROPERTY_CUSTOMSEARCHVIEWANNOT = vitroURI+"customSearchViewAnnot";
//public static final String PROPERTY_SELFEDITPROHIBITEDANNOT = vitroURI+"selfEditProhibitedAnnot";
//public static final String PROPERTY_CURATOREDITPROHIBITEDANNOT = vitroURI+"curatorEditProhibitedAnnot";
public static final String PROPERTY_CUSTOMENTRYFORMANNOT = vitroURI+"customEntryFormAnnot";
public static final String PROPERTY_CUSTOMDISPLAYVIEWANNOT = vitroURI+"customDisplayViewAnnot";
public static final String PROPERTY_CUSTOMSHORTVIEWANNOT = vitroURI+"customShortViewAnnot";
@ -116,19 +102,6 @@ public class VitroVocabulary {
public static final String SKIP_EDIT_FORM = vitroURI + "skipEditForm";
public static final String PROPERTY_STUBOBJECTPROPERTYANNOT = vitroURI + "stubObjectPropertyAnnot";
public static final String PROPERTY_COLLATEBYSUBCLASSANNOT = vitroURI + "collateBySubclassAnnot";
// ================== keyword related ==================================
public static final String KEYWORD = vitroURI+"Keyword";
public static final String KEYWORD_STEM = vitroURI+"keywordStem";
public static final String KEYWORD_TYPE = vitroURI+"keywordType";
public static final String KEYWORD_SOURCE = vitroURI+"keywordSource";
public static final String KEYWORD_ORIGIN = vitroURI+"keywordOrigin";
public static final String KEYWORD_COMMENTS = vitroURI+"keywordComment";
public static final String KEYWORD_INDIVIDUALRELATION = vitroURI+"KeywordRelation";
public static final String KEYWORD_INDIVIDUALRELATION_INVOLVESKEYWORD = vitroURI+"involvesKeyword";
public static final String KEYWORD_INDIVIDUALRELATION_INVOLVESINDIVIDUAL = vitroURI+"involvesIndividual";
public static final String KEYWORD_INDIVIDUALRELATION_MODE = vitroURI+"keywordMode";
// ================== link related =====================================

View file

@ -111,12 +111,6 @@ public interface WebappDaoFactory {
public ApplicationDao getApplicationDao();
public KeywordIndividualRelationDao getKeys2EntsDao();
public KeywordDao getKeywordDao();
public LinksDao getLinksDao();
public LinktypeDao getLinktypeDao();
public UserAccountsDao getUserAccountsDao();
public VClassGroupDao getVClassGroupDao();

View file

@ -53,14 +53,6 @@ public class DataPropertyStatementFiltering implements DataPropertyStatement {
public String getDatapropURI() {
return innerStmt.getDatapropURI();
}
public Date getSunrise() {
return innerStmt.getSunrise();
}
public Date getSunset() {
return innerStmt.getSunset();
}
public String getString() {
return innerStmt.getString();
@ -89,13 +81,5 @@ public class DataPropertyStatementFiltering implements DataPropertyStatement {
public void setDatapropURI(String datapropURI) {
innerStmt.setDatapropURI(datapropURI);
}
public void setSunrise(Date date) {
innerStmt.setSunrise(date);
}
public void setSunset(Date date) {
innerStmt.setSunset(date);
}
}

View file

@ -63,25 +63,6 @@ class IndividualDaoFiltering extends BaseFiltering implements IndividualDao{
return null;
}
@Deprecated
public Individual getIndividualByExternalId(int externalIdType,
String externalIdValue, String classURI) {
Individual ind = innerIndividualDao.getIndividualByExternalId(externalIdType,externalIdValue,classURI);
if( ind != null && filters.getIndividualFilter().fn(ind) )
return new IndividualFiltering(ind, filters );
else
return null;
}
@Deprecated
public Individual getIndividualByExternalId(int externalIdType,
String externalIdValue) {
Individual ind = innerIndividualDao.getIndividualByExternalId(externalIdType,externalIdValue);
if( ind != null && filters.getIndividualFilter().fn(ind))
return new IndividualFiltering(ind,filters);
else
return null;
}
public void fillVClassForIndividual(Individual individual) {
innerIndividualDao.fillVClassForIndividual(individual);
}
@ -192,31 +173,6 @@ class IndividualDaoFiltering extends BaseFiltering implements IndividualDao{
innerIndividualDao.markModified(individual);
}
public List<String> getKeywordsForIndividual(String individualURI) {
return innerIndividualDao.getKeywordsForIndividual(individualURI);
}
public List<String> getKeywordsForIndividualByMode(String individualURI,
String modeStr) {
return innerIndividualDao.getKeywordsForIndividualByMode(individualURI,modeStr);
}
public List<Keyword> getKeywordObjectsForIndividual(String individualURI) {
return innerIndividualDao.getKeywordObjectsForIndividual(individualURI);
}
public String getNetId(String entityURI) {
return innerIndividualDao.getNetId(entityURI);
}
public String getStatus(String entityURI) {
return innerIndividualDao.getStatus(entityURI);
}
public List monikers(String vclassURI) {
return innerIndividualDao.monikers(vclassURI);
}
public String toString(){
return "IndividualDaoFiltering filter: " + filters.getIndividualFilter().toString() + "\n" +
"InnerDao: " + innerIndividualDao.toString();
@ -230,7 +186,6 @@ class IndividualDaoFiltering extends BaseFiltering implements IndividualDao{
return innerIndividualDao.getUnusedURI(individual);
}
@Override
public EditLiteral getLabelEditLiteral(String individualUri) {
return innerIndividualDao.getLabelEditLiteral(individualUri);

View file

@ -210,21 +210,6 @@ public class IndividualFiltering implements Individual {
return _innerIndividual.equals(obj);
}
@Override
public String getAnchor() {
return _innerIndividual.getAnchor();
}
@Override
public String getBlurb() {
return _innerIndividual.getBlurb();
}
@Override
public String getDescription() {
return _innerIndividual.getDescription();
}
@Override
public List<DataPropertyStatement> getExternalIds() {
return _innerIndividual.getExternalIds();
@ -251,26 +236,6 @@ public class IndividualFiltering implements Individual {
return _innerIndividual.getThumbUrl();
}
@Override
public List<String> getKeywords() {
return _innerIndividual.getKeywords();
}
@Override
public String getKeywordString() {
return _innerIndividual.getKeywordString();
}
@Override
public List<Link> getLinksList() {
return _innerIndividual.getLinksList();
}
@Override
public Link getPrimaryLink() {
return _innerIndividual.getPrimaryLink();
}
@Override
public String getLocalName() {
return _innerIndividual.getLocalName();
@ -281,11 +246,6 @@ public class IndividualFiltering implements Individual {
return _innerIndividual.getModTime();
}
@Override
public String getMoniker() {
return _innerIndividual.getMoniker();
}
@Override
public String getName() {
return _innerIndividual.getName();
@ -301,43 +261,11 @@ public class IndividualFiltering implements Individual {
return _innerIndividual.getNamespace();
}
@Override
public String getStatus() {
return _innerIndividual.getStatus();
}
@Override
public int getStatusId() {
return _innerIndividual.getStatusId();
}
@Override
public Date getSunrise() {
return _innerIndividual.getSunrise();
}
@Override
public Date getSunset() {
return _innerIndividual.getSunset();
}
@Override
public Date getTimekey() {
return _innerIndividual.getTimekey();
}
@Override
public String getURI() {
return _innerIndividual.getURI();
}
@Override
public String getUrl() {
return _innerIndividual.getUrl();
}
@Override
public VClass getVClass() {
return _innerIndividual.getVClass();
@ -353,16 +281,6 @@ public class IndividualFiltering implements Individual {
return _innerIndividual.hashCode();
}
@Override
public void setAnchor(String in) {
_innerIndividual.setAnchor(in);
}
@Override
public void setBlurb(String in) {
_innerIndividual.setBlurb(in);
}
@Override
public void setDatatypePropertyList(List<DataProperty> datatypePropertyList) {
_innerIndividual.setDatatypePropertyList(datatypePropertyList);
@ -372,11 +290,6 @@ public class IndividualFiltering implements Individual {
public void setPopulatedDataPropertyList(List<DataProperty> dataPropertyList) {
_innerIndividual.setPopulatedDataPropertyList(dataPropertyList);
}
@Override
public void setDescription(String in) {
_innerIndividual.setDescription(in);
}
@Override
public void setObjectPropertyStatements(List<ObjectPropertyStatement> list) {
@ -397,22 +310,7 @@ public class IndividualFiltering implements Individual {
public void setMainImageUri(String mainImageUri) {
_innerIndividual.setMainImageUri(mainImageUri);
}
@Override
public void setKeywords(List<String> keywords) {
_innerIndividual.setKeywords(keywords);
}
@Override
public void setLinksList(List<Link> linksList) {
_innerIndividual.setLinksList(linksList);
}
@Override
public void setPrimaryLink(Link link) {
_innerIndividual.setPrimaryLink(link);
}
@Override
public void setLocalName(String localName) {
_innerIndividual.setLocalName(localName);
@ -423,11 +321,6 @@ public class IndividualFiltering implements Individual {
_innerIndividual.setModTime(in);
}
@Override
public void setMoniker(String in) {
_innerIndividual.setMoniker(in);
}
@Override
public void setName(String in) {
_innerIndividual.setName(in);
@ -447,42 +340,12 @@ public class IndividualFiltering implements Individual {
public void setPopulatedObjectPropertyList(List<ObjectProperty> propertyList) {
_innerIndividual.setPopulatedObjectPropertyList(propertyList);
}
@Override
public void setStatus(String s) {
_innerIndividual.setStatus(s);
}
@Override
public void setStatusId(int in) {
_innerIndividual.setStatusId(in);
}
@Override
public void setSunrise(Date in) {
_innerIndividual.setSunrise(in);
}
@Override
public void setSunset(Date in) {
_innerIndividual.setSunset(in);
}
@Override
public void setTimekey(Date in) {
_innerIndividual.setTimekey(in);
}
@Override
public void setURI(String URI) {
_innerIndividual.setURI(URI);
}
@Override
public void setUrl(String url) {
_innerIndividual.setUrl(url);
}
@Override
public void setVClass(VClass class1) {
_innerIndividual.setVClass(class1);
@ -493,20 +356,11 @@ public class IndividualFiltering implements Individual {
_innerIndividual.setVClassURI(in);
}
// public void shallowCopy(Individual target) {
// _innerIndividual.shallowCopy(target);
// }
@Override
public void sortForDisplay() {
_innerIndividual.sortForDisplay();
}
@Override
public List<Keyword> getKeywordObjects() {
return _innerIndividual.getKeywordObjects();
}
@Override
public List<VClass> getVClasses() {
return _innerIndividual.getVClasses();
@ -532,11 +386,6 @@ public class IndividualFiltering implements Individual {
_innerIndividual.setDataPropertyMap(propertyMap);
}
@Override
public void setKeywordObjects(List<Keyword> keywords) {
_innerIndividual.setKeywordObjects(keywords);
}
@Override
public void setObjectPropertyMap(Map<String, ObjectProperty> propertyMap) {
_innerIndividual.setObjectPropertyMap(propertyMap);

View file

@ -44,10 +44,6 @@ public class ObjectPropertyStatementFiltering implements ObjectPropertyStatement
return innerStmt.toString();
}
public String getDescription() {
return innerStmt.getDescription();
}
public String getObjectURI() {
return innerStmt.getObjectURI();
}
@ -56,30 +52,14 @@ public class ObjectPropertyStatementFiltering implements ObjectPropertyStatement
return innerStmt.getPropertyURI();
}
public String getQualifier() {
return innerStmt.getQualifier();
}
public String getSubjectURI() {
return innerStmt.getSubjectURI();
}
public Date getSunrise() {
return innerStmt.getSunrise();
}
public Date getSunset() {
return innerStmt.getSunset();
}
public boolean isSubjectOriented() {
return innerStmt.isSubjectOriented();
}
public void setDescription(String description) {
innerStmt.setDescription(description);
}
public void setObject(Individual object) {
innerStmt.setObject(object);
}
@ -96,10 +76,6 @@ public class ObjectPropertyStatementFiltering implements ObjectPropertyStatement
innerStmt.setPropertyURI(URI);
}
public void setQualifier(String qualifier) {
innerStmt.setQualifier(qualifier);
}
public void setSubject(Individual subject) {
innerStmt.setSubject(subject);
}
@ -112,12 +88,4 @@ public class ObjectPropertyStatementFiltering implements ObjectPropertyStatement
innerStmt.setSubjectURI(subjectURI);
}
public void setSunrise(Date date) {
innerStmt.setSunrise(date);
}
public void setSunset(Date date) {
innerStmt.setSunset(date);
}
}

View file

@ -13,10 +13,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyStatementDao;
import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordIndividualRelationDao;
import edu.cornell.mannlib.vitro.webapp.dao.LinksDao;
import edu.cornell.mannlib.vitro.webapp.dao.LinktypeDao;
import edu.cornell.mannlib.vitro.webapp.dao.MenuDao;
import edu.cornell.mannlib.vitro.webapp.dao.NamespaceDao;
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
@ -168,22 +164,6 @@ public class WebappDaoFactoryFiltering implements WebappDaoFactory {
return innerWebappDaoFactory.getUserURI();
}
public KeywordIndividualRelationDao getKeys2EntsDao() {
return innerWebappDaoFactory.getKeys2EntsDao();
}
public KeywordDao getKeywordDao() {
return innerWebappDaoFactory.getKeywordDao();
}
public LinksDao getLinksDao() {
return innerWebappDaoFactory.getLinksDao();
}
public LinktypeDao getLinktypeDao() {
return innerWebappDaoFactory.getLinktypeDao();
}
public ApplicationDao getApplicationDao() {
return innerWebappDaoFactory.getApplicationDao();
}

View file

@ -60,29 +60,10 @@ public class VitroFilterUtils {
private final Comparator<? super Individual> comparator;
public EntitySortTransform( String fieldName, boolean ascending){
if ( "timekey".equalsIgnoreCase( fieldName )){
if( ascending )
comparator = timekeyComp;
else
comparator = timekeyCompDesc;
} else if ( "sunset".equalsIgnoreCase( fieldName )){
if( ascending )
comparator = sunsetComp;
else
comparator = sunsetCompDesc;
} else if ( "sunrise".equalsIgnoreCase( fieldName )){
if( ascending )
comparator = sunriseComp;
else
comparator = sunriseCompDesc;
} else {
if( ascending )
comparator = nameComp;
else
comparator = nameCompDesc;
}
}
@Override
@ -91,57 +72,6 @@ public class VitroFilterUtils {
return individuals;
}
private static Comparator<? super Individual> timekeyComp =
new Comparator<Individual>(){
@Override
public int compare(Individual o1, Individual o2) {
Date time1 = o1.getTimekey();
Date time2 = o2.getTimekey();
if( time1 == null && time2 == null )
return 0;
if( time1 == null )
return 1;
if( time2 == null)
return -1;
return time1.compareTo(time2);
}
@Override
public String toString(){ return "timekeyComp"; }
};
private static Comparator<? super Individual> sunsetComp =
new Comparator<Individual>(){
@Override
public int compare(Individual o1, Individual o2) {
Date time1 = o1.getSunset();
Date time2 = o2.getSunset();
if( time1 == null && time2 == null )
return 0;
if( time1 == null )
return 1;
if( time2 == null)
return -1;
return time1.compareTo(time2);
}
@Override
public String toString(){ return "sunsetComp"; }
};
private static Comparator<? super Individual> sunriseComp =
new Comparator<Individual>(){
@Override
public int compare(Individual o1, Individual o2) {
Date time1 = o1.getSunrise();
Date time2 = o2.getSunrise();
if( time1 == null && time2 == null )
return 0;
if( time1 == null )
return 1;
if( time2 == null)
return -1;
return time1.compareTo(time2);
}
@Override
public String toString(){ return "sunriseComp"; }
};
private static Comparator<? super Individual> nameComp =
new Comparator<Individual>(){
// return ((Individual)o1).getName().compareTo(((Individual)o2).getName());
@ -164,57 +94,6 @@ public class VitroFilterUtils {
public String toString(){ return "nameComp"; }
};
private static Comparator<? super Individual> timekeyCompDesc =
new Comparator<Individual>(){
@Override
public int compare(Individual o1, Individual o2) {
Date time1 = o1.getTimekey();
Date time2 = o2.getTimekey();
if( time1 == null && time2 == null )
return 0;
if( time1 == null )
return -1;
if( time2 == null)
return 1;
return time2.compareTo(time1);
}
@Override
public String toString(){ return "timkeyCompDesc"; }
};
private static Comparator<? super Individual> sunsetCompDesc =
new Comparator<Individual>(){
@Override
public int compare(Individual o1, Individual o2) {
Date time1 = o1.getSunset();
Date time2 = o2.getSunset();
if( time1 == null && time2 == null )
return 0;
if( time1 == null )
return -1;
if( time2 == null)
return 1;
return time2.compareTo(time1);
}
@Override
public String toString(){ return "sunsetCompDesc"; }
};
private static Comparator<? super Individual> sunriseCompDesc =
new Comparator<Individual>(){
@Override
public int compare(Individual o1, Individual o2) {
Date time1 = o1.getSunrise();
Date time2 = o2.getSunrise();
if( time1 == null && time2 == null )
return 0;
if( time1 == null )
return -1;
if( time2 == null)
return 1;
return time2.compareTo(time1);
}
@Override
public String toString(){ return "sunriseCompDesc"; }
};
private static Comparator<? super Individual> nameCompDesc =
new Comparator<Individual>(){
@Override

View file

@ -89,6 +89,7 @@ public class DataPropertyStatementDaoSDB extends DataPropertyStatementDaoJena
boolean addToList = /*allowAnyNameSpace ? st.getObject().canAs(Literal.class) :*/ st.getObject().isLiteral() &&
(
(RDF.value.equals(st.getPredicate()) || VitroVocabulary.value.equals(st.getPredicate().getURI()))
|| this.MONIKER.equals(st.getPredicate())
|| !(NONUSER_NAMESPACES.contains(st.getPredicate().getNameSpace()))
);
if( addToList )

View file

@ -2,12 +2,10 @@
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
@ -50,11 +48,9 @@ import com.hp.hpl.jena.vocabulary.RDFS;
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Keyword;
import edu.cornell.mannlib.vitro.webapp.beans.KeywordIndividualRelation;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualCreationEvent;
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.IndividualDeletionEvent;
@ -260,49 +256,13 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
ind.addRDFType(ResourceFactory.createResource(vc.getURI()));
}
}
addPropertyStringValue(ind,MONIKER,ent.getMoniker(),ontModel);
addPropertyStringValue(ind,BLURB,ent.getBlurb(),ontModel);
addPropertyStringValue(ind,DESCRIPTION,ent.getDescription(),ontModel);
addPropertyDateTimeValue(ind,SUNRISE,ent.getSunrise(), ontModel);
addPropertyDateTimeValue(ind,SUNSET,ent.getSunset(), ontModel);
addPropertyDateTimeValue(ind,TIMEKEY,ent.getTimekey(), ontModel);
addPropertyDateTimeValue(ind,MODTIME,Calendar.getInstance().getTime(),ontModel);
if (ent.getMainImageUri() != null) {
addPropertyResourceURIValue(ind, IND_MAIN_IMAGE, ent.getMainImageUri());
}
if (ent.getAnchor()!= null && ent.getAnchor().length()>0 && LINK != null) {
com.hp.hpl.jena.ontology.Individual primaryLink = ontModel.createIndividual(entURI+"_primaryLink", LINK);
primaryLink.addProperty(RDF.type, LINK);
if (log.isTraceEnabled()) {
log.trace("added RDF type Link to primary link in insertNewIndividual() for new individual "+ent.getName());
}
addPropertyStringValue(primaryLink, LINK_ANCHOR, ent.getAnchor(),ontModel);
addPropertyStringValue(primaryLink, LINK_URL,ent.getUrl(),ontModel);
ind.addProperty(PRIMARY_LINK,primaryLink);
}
}
if( ent.getSearchBoost() != null ) {
addPropertyFloatValue(ind,SEARCH_BOOST_ANNOT, ent.getSearchBoost(), ontModel);
}
/* 2009-01-27 hold off on individual-level filtering for now
ind.removeAll(HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
if (HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT != null && ent.getHiddenFromDisplayBelowRoleLevel() != null) { // only need to add if present
try {
ind.addProperty(HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT, ResourceFactory.createResource(ent.getHiddenFromDisplayBelowRoleLevel().getURI()));
} catch (Exception e) {
log.error("error adding HiddenFromDisplayBelowRoleLevel annotation to individual "+ent.getURI());
}
}
ind.removeAll(PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
if (PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT != null && ent.getProhibitedFromUpdateBelowRoleLevel() != null) { // only need to add if present
try {
ind.addProperty(PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT, ResourceFactory.createResource(ent.getProhibitedFromUpdateBelowRoleLevel().getURI()));
} catch (Exception e) {
log.error("error adding ProhibitedFromUpdateBelowRoleLevel annotation to individual "+ent.getURI());
}
}
*/
} catch (Exception e) {
log.error("Exception inserting individual: ",e);
}
@ -323,37 +283,19 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
}
private void initInd(Individual ent) {
ent.getAnchor();
ent.getBlurb();
ent.getClass();
ent.getVClasses(false);
ent.getDataPropertyList();
ent.getDataPropertyStatements();
ent.getDescription();
ent.getExternalIds();
ent.getMainImageUri();
ent.getImageUrl();
ent.getThumbUrl();
ent.getKeywords();
ent.getKeywordString();
ent.getLinksList();
ent.getPrimaryLink();
ent.getModTime();
ent.getMoniker();
ent.getName();
ent.getNamespace();
ent.getObjectPropertyList();
ent.getStatus();
ent.getStatusId();
ent.getSunrise();
ent.getSunset();
ent.getTimekey();
ent.getUrl();
ent.getVClassURI();
ent.getVClass();
ent.getVClassURI();
//ent.getHiddenFromDisplayBelowRoleLevel();
//ent.getProhibitedFromUpdateBelowRoleLevel();
}
public int updateIndividual(Individual ent, OntModel ontModel) {
@ -402,83 +344,11 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
ind.addRDFType(ResourceFactory.createResource(uri));
}
}
updatePropertyStringValue(ind,MONIKER,ent.getMoniker(),ontModel);
updatePropertyStringValue(ind,BLURB,ent.getBlurb(),ontModel);
updatePropertyStringValue(ind,DESCRIPTION,ent.getDescription(),ontModel);
updatePropertyDateTimeValue(ind,SUNRISE,ent.getSunrise(), ontModel);
updatePropertyDateTimeValue(ind,SUNSET,ent.getSunset(), ontModel);
updatePropertyDateTimeValue(ind,TIMEKEY,ent.getTimekey(), ontModel);
updatePropertyDateTimeValue(ind,MODTIME,Calendar.getInstance().getTime(),ontModel);
updatePropertyResourceURIValue(ind, IND_MAIN_IMAGE, ent.getMainImageUri(), ontModel);
if (ent.getAnchor()!= null && ent.getAnchor().length()>0) {
if (LINK != null && PRIMARY_LINK != null) {
boolean updatedExisting = false;
try {
Resource primaryLink = (Resource) ind.getPropertyValue(PRIMARY_LINK);
if (primaryLink != null) {
if (log.isTraceEnabled()) {
log.trace("Modifying the primary link to entity "+ent.getName());
}
updatePropertyStringValue(primaryLink, LINK_ANCHOR, ent.getAnchor(), ontModel);
updatePropertyStringValue(primaryLink, LINK_URL, ent.getUrl(), ontModel);
updatedExisting = true;
}
} catch (Exception e) {}
if (!updatedExisting) {
if (log.isTraceEnabled()) {
log.trace("Adding a primary link to entity "+ent.getName());
}
ind.removeAll(PRIMARY_LINK);
com.hp.hpl.jena.ontology.Individual primaryLink = LINK.createIndividual(ent.getURI()+"_primaryLink");
primaryLink.addProperty(RDF.type, LINK);
addPropertyStringValue(primaryLink, LINK_ANCHOR, ent.getAnchor(), ontModel);
addPropertyStringValue(primaryLink, LINK_URL,ent.getUrl(), ontModel);
ind.addProperty(PRIMARY_LINK,primaryLink);
}
}
} else {
ind.removeAll(PRIMARY_LINK);
}
if( ent.getSearchBoost() != null ) {
updatePropertyFloatValue(ind, SEARCH_BOOST_ANNOT, ent.getSearchBoost(), ontModel);
}
/*
if (HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT != null) {
try {
ind.removeAll(HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
if (ent.getHiddenFromDisplayBelowRoleLevel()!=null) {
String badURIErrorStr = checkURI(ent.getHiddenFromDisplayBelowRoleLevel().getURI());
if (badURIErrorStr == null) {
ind.addProperty(HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT, ResourceFactory.createResource(ent.getHiddenFromDisplayBelowRoleLevel().getURI()));
} else {
log.error(badURIErrorStr);
}
}
} catch (Exception e) {
log.error("error linking individual "+ent.getURI()+" to HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL edit role");
}
} else {
log.error("vitro:hiddenFromDisplayBelowRoleLevelAnnot property not found in RBox");
}
if (PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT != null) {
try {
ind.removeAll(PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
if (ent.getProhibitedFromUpdateBelowRoleLevel()!=null) {
String badURIErrorStr = checkURI(ent.getProhibitedFromUpdateBelowRoleLevel().getURI());
if (badURIErrorStr == null) {
ind.addProperty(PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT, ResourceFactory.createResource(ent.getProhibitedFromUpdateBelowRoleLevel().getURI()));
} else {
log.error(badURIErrorStr);
}
}
} catch (Exception e) {
log.error("error linking individual "+ent.getURI()+" to PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL edit role");
}
} else {
log.error("vitro:prohibitedFromUpdateBelowRoleLevelAnnot property not found in RBox");
}
*/
return 0;
} else {
return 1;
@ -569,89 +439,6 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
entity.setVClass(getWebappDaoFactory().getVClassDao().getVClassByURI(entity.getVClassURI()));
}
public List<String> monikers( String typeURI ) {
getOntModel().enterCriticalSection(Lock.READ);
try {
HashSet<String> monikers = new HashSet<String>();
OntClass cls = getOntModel().getOntClass(typeURI);
ResIterator inds = getOntModel().listSubjectsWithProperty(
RDF.type, ResourceFactory.createResource(typeURI));
while (inds.hasNext()) {
Resource ind = inds.nextResource();
if (MONIKER != null) {
Iterator<Statement> monikerIt = ind.listProperties(MONIKER);
while (monikerIt.hasNext()) {
Statement monikerStmt = monikerIt.next();
monikers.add(((Literal)monikerStmt.getObject()).getString());
}
}
}
List<String> monikerList = new ArrayList<String>();
if (monikers.size()>0) {
Iterator<String> monikerIt = monikers.iterator();
while (monikerIt.hasNext()) {
monikerList.add(monikerIt.next());
}
Collections.sort(monikerList,new Comparator<String>() {
public int compare( String first, String second ) {
if (first==null) {
return 1;
}
if (second==null) {
return -1;
}
Collator collator = Collator.getInstance();
return collator.compare(first,second);
}
});
return monikerList;
}
else
return null;
} finally {
getOntModel().leaveCriticalSection();
}
}
public List<String> getKeywordsForIndividual(String entityURI) {
KeywordDao kDao = getWebappDaoFactory().getKeywordDao();
List<String> keywords = new LinkedList<String>();
List<KeywordIndividualRelation> kirs = getWebappDaoFactory().getKeys2EntsDao().getKeywordIndividualRelationsByIndividualURI(entityURI);
Iterator<KeywordIndividualRelation> kirsIt = kirs.iterator();
while (kirsIt.hasNext()) {
Keyword keyword = kDao.getKeywordById(kirsIt.next().getKeyId());
keywords.add(keyword.getTerm());
}
return keywords;
}
public List<String> getKeywordsForIndividualByMode(String entityURI, String modeStr) {
KeywordDao kDao = getWebappDaoFactory().getKeywordDao();
List<String> keywords = new LinkedList<String>();
List<KeywordIndividualRelation> kirs = getWebappDaoFactory().getKeys2EntsDao().getKeywordIndividualRelationsByIndividualURI(entityURI);
Iterator<KeywordIndividualRelation> kirsIt = kirs.iterator();
while (kirsIt.hasNext()) {
KeywordIndividualRelation kir = kirsIt.next();
if (kir.getMode().equalsIgnoreCase(modeStr)) {
Keyword keyword = kDao.getKeywordById(kir.getKeyId());
keywords.add(keyword.getTerm());
}
}
return keywords;
}
public List<Keyword> getKeywordObjectsForIndividual(String entityURI) {
KeywordDao kDao = getWebappDaoFactory().getKeywordDao();
List<Keyword> keywords = new LinkedList<Keyword>();
List<KeywordIndividualRelation> kirs = getWebappDaoFactory().getKeys2EntsDao().getKeywordIndividualRelationsByIndividualURI(entityURI);
Iterator<KeywordIndividualRelation> kirsIt = kirs.iterator();
while (kirsIt.hasNext()) {
Keyword keyword = kDao.getKeywordById(kirsIt.next().getKeyId());
keywords.add(keyword);
}
return keywords;
}
/**
* In Jena it can be difficult to get an object with a given dataproperty if
* you do not care about the datatype or lang of the literal. Use this
@ -822,24 +609,6 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao {
return inds;
}
@Deprecated
public Individual getIndividualByExternalId(int externalIdType, String externalIdValue ) {
return null;
}
@Deprecated
public Individual getIndividualByExternalId(int externalIdType, String externalIdValue, String vClassURI) {
return null;
}
public String getNetId(String entityURI) {
return null;
}
public String getStatus(String entityURI) {
return null;
}
public Iterator<String> getAllOfThisTypeIterator() {
//this is implemented in IndivdiualSDB
throw new NotImplementedException();

View file

@ -34,7 +34,6 @@ 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.util.iterator.ClosableIterator;
import com.hp.hpl.jena.vocabulary.RDFS;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
@ -50,7 +49,6 @@ public class IndividualDaoSDB extends IndividualDaoJena {
private DatasetWrapperFactory dwf;
private SDBDatasetMode datasetMode;
private WebappDaoFactoryJena wadf;
public IndividualDaoSDB(DatasetWrapperFactory dwf,
SDBDatasetMode datasetMode,
@ -176,10 +174,6 @@ public class IndividualDaoSDB extends IndividualDaoJena {
" ?ind a <" + theClass.getURI() + "> . \n" +
" ?ind <" + RDFS.label.getURI() + "> ?label \n" +
"} \n" +
"UNION { \n" +
" ?ind a <" + theClass.getURI() + "> . \n" +
" ?ind <" + VitroVocabulary.MONIKER + "> ?moniker \n" +
"} \n" +
"} ORDER BY ?ind ?label";
ResultSet rs =QueryExecutionFactory.create(
QueryFactory.create(query), dataset)
@ -194,13 +188,12 @@ public class IndividualDaoSDB extends IndividualDaoJena {
continue;
}
if (uri != null && !uri.equals(currRes.getURI())) {
Individual ent = makeIndividual(uri, label, moniker);
Individual ent = makeIndividual(uri, label);
if (ent != null) {
ents.add(ent);
}
uri = currRes.getURI();
label = null;
moniker = null;
} else if (uri == null) {
uri = currRes.getURI();
}
@ -208,12 +201,8 @@ public class IndividualDaoSDB extends IndividualDaoJena {
if (labelLit != null) {
label = labelLit.getLexicalForm();
}
Literal monikerLit = sol.getLiteral("moniker");
if (monikerLit != null) {
moniker = monikerLit.getLexicalForm();
}
if (!rs.hasNext()) {
Individual ent = makeIndividual(uri, label, moniker);
Individual ent = makeIndividual(uri, label);
if (ent != null) {
ents.add(ent);
}
@ -250,7 +239,7 @@ public class IndividualDaoSDB extends IndividualDaoJena {
continue;
}
filteredIndividualList.add(
makeIndividual(currRes.getURI(), null, null));
makeIndividual(currRes.getURI(), null));
}
} finally {
dataset.getLock().leaveCriticalSection();
@ -259,14 +248,11 @@ public class IndividualDaoSDB extends IndividualDaoJena {
return filteredIndividualList;
}
private Individual makeIndividual(String uri,
String label,
String moniker) {
private Individual makeIndividual(String uri, String label) {
Individual ent = new IndividualSDB(uri,
this.dwf, datasetMode, getWebappDaoFactory(),
SKIP_INITIALIZATION);
ent.setName(label);
ent.setMoniker(moniker);
return ent;
}

View file

@ -2,8 +2,6 @@
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.sql.Timestamp;
import java.text.Collator;
import java.util.ArrayList;
@ -153,41 +151,6 @@ public class IndividualJena extends IndividualImpl implements Individual {
}
}
@Deprecated
public int getFlag1Numeric() {
return 1;
}
@Deprecated
public String getFlag1Set() {
return "1";
}
@Deprecated
public String getFlag2Set() {
return "";
}
@Deprecated
public boolean doesFlag1Match(int flagBitMask) {
return true;
}
@Deprecated
public Date getSunrise() {
return null;
}
@Deprecated
public Date getSunset() {
return null;
}
@Deprecated
public Date getTimekey() {
return null;
}
public Timestamp getModTime() {
if (modTime != null) {
return modTime;
@ -205,118 +168,6 @@ public class IndividualJena extends IndividualImpl implements Individual {
}
}
public String getMoniker() {
if (moniker != null) {
return moniker;
} else {
ind.getOntModel().enterCriticalSection(Lock.READ);
try {
moniker = webappDaoFactory.getJenaBaseDao().getPropertyStringValue(ind,webappDaoFactory.getJenaBaseDao().MONIKER);
if (moniker == null) {
//Changing behavior to moniker because it is taking extra time to get the vclass
//alternative if the moniker isn't filled out. That time is wasted if the vclass alternative isn't desired.
//see NIHVIVO-2001
moniker = "";
}
return moniker;
} finally {
ind.getOntModel().leaveCriticalSection();
}
}
}
/* 2009-01-27 hold off on individual-level filtering for now
@Override
public RoleLevel getHiddenFromDisplayBelowRoleLevel(){
if( this.hiddenFromDisplayBelowRoleLevel != null )
return this.hiddenFromDisplayBelowRoleLevel;
OntModel model = ind.getOntModel();
model.enterCriticalSection(Lock.READ);
try {
NodeIterator it = model.listObjectsOfProperty(ind, model.getAnnotationProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT));
if( it == null )
return BaseResourceBean.RoleLevel.values()[0];
BaseResourceBean.RoleLevel role = BaseResourceBean.RoleLevel.values()[0];
while( it.hasNext() ) {
RDFNode node = it.nextNode();
if( node != null && node.isURIResource() ) {
BaseResourceBean.RoleLevel foundRole = BaseResourceBean.RoleLevel.getRoleByUri( node.asNode().getURI() );
if( role.compareTo(foundRole ) < 0 ) { // find the lowest of all levels
role = foundRole;
}
}
}
return this.hiddenFromDisplayBelowRoleLevel = role;
} finally {
model.leaveCriticalSection();
}
}
/**
* this seems like a mismatch with the RDF storage model.
* We could have multiple statements in the model that associated
* the individual with multiple or redundant edit display levels.
*/
/*
@Override
public RoleLevel getProhibitedFromUpdateBelowRoleLevel() {
if( this.prohibitedFromUpdateBelowRoleLevel != null )
return this.prohibitedFromUpdateBelowRoleLevel;
OntModel model = ind.getOntModel();
model.enterCriticalSection(Lock.READ);
try {
NodeIterator it = model.listObjectsOfProperty(ind, model.getAnnotationProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT));
if( it == null )
return BaseResourceBean.RoleLevel.values()[0];
BaseResourceBean.RoleLevel role = BaseResourceBean.RoleLevel.values()[0];
while( it.hasNext() ){
RDFNode node = it.nextNode();
if( node != null && node.isURIResource() ) {
BaseResourceBean.RoleLevel foundRole = BaseResourceBean.RoleLevel.getRoleByUri( node.asNode().getURI() );
if( role.compareTo(foundRole ) < 0 ) // find the lowest of all roles
role = foundRole;
}
}
return this.prohibitedFromUpdateBelowRoleLevel = role;
} finally {
model.leaveCriticalSection();
}
}
*/
public String getBlurb() {
if (this.blurb != null) {
return blurb;
} else {
ind.getOntModel().enterCriticalSection(Lock.READ);
try {
blurb = webappDaoFactory.getJenaBaseDao().getPropertyStringValue(ind,webappDaoFactory.getJenaBaseDao().BLURB);
return blurb;
} finally {
ind.getOntModel().leaveCriticalSection();
}
}
}
public String getDescription() {
if (this.description != null) {
return description;
} else {
ind.getOntModel().enterCriticalSection(Lock.READ);
try {
description = webappDaoFactory.getJenaBaseDao().getPropertyStringValue(ind,webappDaoFactory.getJenaBaseDao().DESCRIPTION);
return description;
} finally {
ind.getOntModel().leaveCriticalSection();
}
}
}
public Float getSearchBoost(){
if( this._searchBoostJena != null ){
return this._searchBoostJena;
@ -380,122 +231,12 @@ public class IndividualJena extends IndividualImpl implements Individual {
return this.imageInfo.getThumbnail().getBytestreamAliasUrl();
}
public String getAnchor() {
if (this.anchor != null) {
return anchor;
} else {
doUrlAndAnchor();
return anchor;
}
}
public String getUrl() {
if (this.url != null) {
return url;
} else {
doUrlAndAnchor();
return url;
}
}
private void doUrlAndAnchor() {
ind.getOntModel().enterCriticalSection(Lock.READ);
try {
if (webappDaoFactory.getJenaBaseDao().PRIMARY_LINK != null) {
Iterator links = ind.listPropertyValues(webappDaoFactory.getJenaBaseDao().PRIMARY_LINK);
if (links.hasNext()) {
try {
com.hp.hpl.jena.ontology.Individual linkInd = ((com.hp.hpl.jena.ontology.Individual)((Resource) links.next()).as(com.hp.hpl.jena.ontology.Individual.class));
if (webappDaoFactory.getJenaBaseDao().LINK_ANCHOR != null) {
try {
Literal l = (Literal) linkInd.getPropertyValue(webappDaoFactory.getJenaBaseDao().LINK_ANCHOR);
if (l != null) {
anchor = l.getString();
}
} catch (ClassCastException e) {}
}
if (webappDaoFactory.getJenaBaseDao().LINK_URL != null) {
try {
Literal l = (Literal) linkInd.getPropertyValue(webappDaoFactory.getJenaBaseDao().LINK_URL);
if (l != null) {
try {
url = URLDecoder.decode(l.getString(), "UTF-8");
} catch (UnsupportedEncodingException use) {}
}
} catch (ClassCastException e) {}
}
} catch (ClassCastException cce) {}
}
}
} finally {
ind.getOntModel().leaveCriticalSection();
}
}
public List <Link> getLinksList() {
if (this.linksList != null) {
return this.linksList;
} else {
try {
webappDaoFactory.getLinksDao().addLinksToIndividual( this );
} catch (Exception e) {
log.debug(this.getClass().getName()+" could not addLinksToIndividual for "+this.getURI());
}
return this.linksList;
}
}
public Link getPrimaryLink() {
if (this.primaryLink != null) {
return this.primaryLink;
} else {
try {
webappDaoFactory.getLinksDao().addPrimaryLinkToIndividual( this );
} catch (Exception e) {
log.debug(this.getClass().getName()+" could not addPrimaryLinkToIndividual for "+this.getURI());
}
return this.primaryLink;
}
}
public List<String> getKeywords() {
if (this.keywords != null) {
return this.keywords;
} else {
try {
this.setKeywords(webappDaoFactory.getIndividualDao().getKeywordsForIndividual(this.getURI()));
} catch (Exception e) {
log.debug(this.getClass().getName()+" could not getKeywords for "+this.getURI());
}
return this.keywords;
}
}
public List<Keyword> getKeywordObjects() {
if (this.keywordObjects != null) {
return this.keywordObjects;
} else {
try {
this.setKeywordObjects(webappDaoFactory.getIndividualDao().getKeywordObjectsForIndividual(this.getURI()));
} catch (Exception e) {
log.error(this.getClass().getName()+" could not get Keyword Objects for "+this.getURI());
}
}
return this.keywordObjects;
}
public List<ObjectPropertyStatement> getObjectPropertyStatements() {
if (this.objectPropertyStatements != null) {
return this.objectPropertyStatements;
} else {
try {
webappDaoFactory.getObjectPropertyStatementDao().fillExistingObjectPropertyStatements(this);
//Iterator stmtIt = this.getObjectPropertyStatements().iterator();
//while (stmtIt.hasNext()) {
// ObjectPropertyStatement stmt = (ObjectPropertyStatement) stmtIt.next();
// stmt.setObject(webappDaoFactory.getIndividualDao().getIndividualByURI(stmt.getObject().getURI()));
//}
} catch (Exception e) {
log.error(this.getClass().getName()+" could not fill existing ObjectPropertyStatements for "+this.getURI(), e);
}

View file

@ -88,15 +88,11 @@ public class IndividualSDB extends IndividualImpl implements Individual {
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
"> ?ooo. \n" +
"<"+individualURI+"> a ?type . \n" +
"<"+individualURI+"> <" + VitroVocabulary.MONIKER +
"> ?moniker \n" +
"} \n" +
"WHERE { \n" +
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
"> ?ooo } \n" +
" UNION { <"+individualURI+"> a ?type } \n" +
" UNION { <"+individualURI+"> <" + VitroVocabulary.MONIKER +
"> ?moniker } \n" +
"} ";
this.model = QueryExecutionFactory.create(
QueryFactory.create(getStatements), initModel)
@ -134,18 +130,11 @@ public class IndividualSDB extends IndividualImpl implements Individual {
"CONSTRUCT " +
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
"> ?ooo. \n" +
// "<"+individualURI+"> a ?type . \n" +
"<"+individualURI+"> <" + VitroVocabulary.MONIKER +
"> ?moniker \n" +
"} WHERE {" +
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
"> ?ooo } \n" +
"UNION { <" +
individualURI+"> <" + VitroVocabulary.MONIKER +
"> ?moniker \n" +
"} \n" +
// "UNION { <"
// + individualURI + "> a ?type } \n" +
"}";
model = QueryExecutionFactory.create(
QueryFactory.create(getStatements), dataset)
@ -278,39 +267,6 @@ public class IndividualSDB extends IndividualImpl implements Individual {
}
}
@Deprecated
public int getFlag1Numeric() {
return 1;
}
@Deprecated
public String getFlag1Set() {
return null;
}
@Deprecated
public String getFlag2Set() {
return null;
}
@Deprecated
public boolean doesFlag1Match(int flagBitMask) {
return true;
}
@Deprecated
public Date getSunrise() {
return null;
}
public Date getSunset() {
return null;
}
public Date getTimekey() {
return null;
}
public Timestamp getModTime() {
if (modTime != null) {
return modTime;
@ -332,62 +288,6 @@ public class IndividualSDB extends IndividualImpl implements Individual {
}
}
public String getMoniker() {
if (moniker != null) {
return moniker;
} else {
ind.getOntModel().enterCriticalSection(Lock.READ);
try {
moniker = webappDaoFactory.getJenaBaseDao()
.getPropertyStringValue(
ind,webappDaoFactory.getJenaBaseDao().MONIKER);
if (moniker == null) {
//Changing behavior to moniker because it is taking extra time to get the vclass
//alternative if the moniker isn't filled out. That time is wasted if the vclass alternative isn't desired.
//see NIHVIVO-2001
moniker = "";
}
return moniker;
} finally {
ind.getOntModel().leaveCriticalSection();
}
}
}
public String getBlurb() {
if (this.blurb != null) {
return blurb;
} else {
constructProperty(ind, VitroVocabulary.BLURB);
ind.getOntModel().enterCriticalSection(Lock.READ);
try {
blurb = webappDaoFactory.getJenaBaseDao().getPropertyStringValue(ind,webappDaoFactory.getJenaBaseDao().BLURB);
return blurb;
} finally {
ind.getOntModel().leaveCriticalSection();
}
}
}
public String getDescription() {
if (this.description != null) {
return description;
} else {
constructProperty(ind, VitroVocabulary.DESCRIPTION);
ind.getOntModel().enterCriticalSection(Lock.READ);
try {
description = webappDaoFactory.getJenaBaseDao()
.getPropertyStringValue(
ind,webappDaoFactory.getJenaBaseDao().DESCRIPTION);
return description;
} finally {
ind.getOntModel().leaveCriticalSection();
}
}
}
private synchronized void constructProperty(OntResource ind, String propertyURI) {
DatasetWrapper w = getDatasetWrapper();
Dataset dataset = w.getDataset();
@ -526,125 +426,6 @@ public class IndividualSDB extends IndividualImpl implements Individual {
}
}
public String getAnchor() {
if (this.anchor != null) {
return anchor;
} else {
doUrlAndAnchor();
return anchor;
}
}
public String getUrl() {
if (this.url != null) {
return url;
} else {
doUrlAndAnchor();
return url;
}
}
private void doUrlAndAnchor() {
Model tempModel = ModelFactory.createDefaultModel();
OntModel ontModel = ModelFactory.createOntologyModel(
OntModelSpec.OWL_MEM);
DatasetWrapper w = getDatasetWrapper();
Dataset dataset = w.getDataset();
dataset.getLock().enterCriticalSection(Lock.READ);
try {
StringBuffer selectPrimaryLinkQueryBuff = new StringBuffer().append(
"SELECT ?url ?anchor \n" ).append(" WHERE { \n").append(
" <" + this.individualURI + "> ").append(
"<" + VitroVocabulary.PRIMARY_LINK + "> " ).append(
"?link . \n").append(
" ?link <" + VitroVocabulary.LINK_URL + "> ?url . \n"
).append(
" ?link <" + VitroVocabulary.LINK_ANCHOR + "> ?anchor . \n"
).append(
"} \n");
QueryExecution qexec = QueryExecutionFactory.create(
QueryFactory.create(selectPrimaryLinkQueryBuff.toString())
, dataset);
try {
ResultSet linkResults = qexec.execSelect();
if (linkResults.hasNext()) {
QuerySolution solution = linkResults.next();
this.setUrl(solution.getLiteral("url").getLexicalForm());
this.setAnchor(solution.getLiteral("anchor")
.getLexicalForm());
}
} finally {
qexec.close();
}
} finally {
tempModel.close();
ontModel.close();
dataset.getLock().leaveCriticalSection();
w.close();
}
}
public List <Link> getLinksList() {
if (this.linksList != null) {
return this.linksList;
} else {
try {
webappDaoFactory.getLinksDao().addLinksToIndividual(this);
} catch (Exception e) {
log.debug(this.getClass().getName() +
" could not addLinksToIndividual for " + this.getURI());
}
return this.linksList;
}
}
public Link getPrimaryLink() {
if (this.primaryLink != null) {
return this.primaryLink;
} else {
try {
webappDaoFactory.getLinksDao().addPrimaryLinkToIndividual(this);
} catch (Exception e) {
log.debug(this.getClass().getName() +
" could not addPrimaryLinkToIndividual for " +
this.getURI());
}
return this.primaryLink;
}
}
public List<String> getKeywords() {
if (this.keywords != null) {
return this.keywords;
} else {
try {
this.setKeywords(webappDaoFactory.getIndividualDao()
.getKeywordsForIndividual(this.getURI()));
} catch (Exception e) {
log.debug(this.getClass().getName() +
" could not getKeywords for " + this.getURI());
}
return this.keywords;
}
}
public List<Keyword> getKeywordObjects() {
if (this.keywordObjects != null) {
return this.keywordObjects;
} else {
try {
this.setKeywordObjects(webappDaoFactory.getIndividualDao()
.getKeywordObjectsForIndividual(this.getURI()));
} catch (Exception e) {
log.error(this.getClass().getName() +
" could not get Keyword Objects for " + this.getURI());
}
}
return this.keywordObjects;
}
public List<ObjectPropertyStatement> getObjectPropertyStatements() {
if (this.objectPropertyStatements != null) {
return this.objectPropertyStatements;

View file

@ -36,31 +36,22 @@ public class JenaBaseDaoCon {
/* ***************** Vitro ontology constants ***************** */
public DatatypeProperty SUNRISE = _constModel.createDatatypeProperty(VitroVocabulary.SUNRISE);
public DatatypeProperty SUNSET = _constModel.createDatatypeProperty(VitroVocabulary.SUNSET);
protected AnnotationProperty DATAPROPERTY_ISEXTERNALID = _constModel.createAnnotationProperty(VitroVocabulary.DATAPROPERTY_ISEXTERNALID);
protected AnnotationProperty HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
//protected AnnotationProperty PROHIBITED_FROM_CREATE_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROHIBITED_FROM_CREATE_BELOW_ROLE_LEVEL_ANNOT);
protected AnnotationProperty PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
//protected AnnotationProperty PROHIBITED_FROM_DELETE_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROHIBITED_FROM_DELETE_BELOW_ROLE_LEVEL_ANNOT);
protected AnnotationProperty SEARCH_BOOST_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.SEARCH_BOOST_ANNOT);
protected AnnotationProperty SEARCH_BOOST_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.SEARCH_BOOST_ANNOT);
protected AnnotationProperty EXAMPLE = _constModel.createAnnotationProperty(VitroVocabulary.EXAMPLE_ANNOT);
protected AnnotationProperty DESCRIPTION_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.DESCRIPTION_ANNOT);
protected AnnotationProperty PUBLIC_DESCRIPTION_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PUBLIC_DESCRIPTION_ANNOT);
protected AnnotationProperty SHORTDEF = _constModel.createAnnotationProperty(VitroVocabulary.SHORTDEF);
protected DatatypeProperty CURATOR_NOTE = _constModel.createDatatypeProperty(VitroVocabulary.CURATOR_NOTE);
protected DatatypeProperty MONIKER = _constModel.createDatatypeProperty(VitroVocabulary.MONIKER);
protected DatatypeProperty DESCRIPTION = _constModel.createDatatypeProperty(VitroVocabulary.DESCRIPTION);
protected DatatypeProperty BLURB = _constModel.createDatatypeProperty(VitroVocabulary.BLURB);
protected OntClass CLASSGROUP = _constModel.createClass(VitroVocabulary.CLASSGROUP);
protected AnnotationProperty IN_CLASSGROUP = _constModel.createAnnotationProperty(VitroVocabulary.IN_CLASSGROUP);
protected DatatypeProperty MODTIME = _constModel.createDatatypeProperty(VitroVocabulary.MODTIME);
protected DatatypeProperty TIMEKEY = _constModel.createDatatypeProperty(VitroVocabulary.TIMEKEY);
protected DatatypeProperty CITATION = _constModel.createDatatypeProperty(VitroVocabulary.CITATION);
protected DatatypeProperty DISPLAY_RANK = _constModel.createDatatypeProperty(VitroVocabulary.DISPLAY_RANK);
protected AnnotationProperty DISPLAY_RANK_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.DISPLAY_RANK_ANNOT);
@ -76,7 +67,6 @@ public class JenaBaseDaoCon {
protected AnnotationProperty PROPERTY_CUSTOMSHORTVIEWANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOMSHORTVIEWANNOT);
protected AnnotationProperty PROPERTY_CUSTOM_LIST_VIEW_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOM_LIST_VIEW_ANNOT);
protected AnnotationProperty PROPERTY_CUSTOMSEARCHVIEWANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOMSEARCHVIEWANNOT);
//protected AnnotationProperty PROPERTY_FORCESTUBDELETIONANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_FORCESTUBDELETIONANNOT);
protected AnnotationProperty PROPERTY_SELECTFROMEXISTINGANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_SELECTFROMEXISTINGANNOT);
protected AnnotationProperty PROPERTY_OFFERCREATENEWOPTIONANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_OFFERCREATENEWOPTIONANNOT);
protected AnnotationProperty PROPERTY_INPROPERTYGROUPANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_INPROPERTYGROUPANNOT);
@ -85,17 +75,6 @@ public class JenaBaseDaoCon {
protected OntClass PROPERTYGROUP = _constModel.createClass(VitroVocabulary.PROPERTYGROUP);
protected OntClass KEYWORD = _constModel.createClass(VitroVocabulary.KEYWORD);
protected DatatypeProperty KEYWORD_STEM = _constModel.createDatatypeProperty(VitroVocabulary.KEYWORD_STEM);
protected DatatypeProperty KEYWORD_TYPE = _constModel.createDatatypeProperty(VitroVocabulary.KEYWORD_TYPE);
protected DatatypeProperty KEYWORD_SOURCE = _constModel.createDatatypeProperty(VitroVocabulary.KEYWORD_SOURCE);
protected DatatypeProperty KEYWORD_ORIGIN = _constModel.createDatatypeProperty(VitroVocabulary.KEYWORD_ORIGIN);
protected DatatypeProperty KEYWORD_COMMENTS = _constModel.createDatatypeProperty(VitroVocabulary.KEYWORD_COMMENTS);
protected OntClass KEYWORD_INDIVIDUALRELATION = _constModel.createClass(VitroVocabulary.KEYWORD_INDIVIDUALRELATION);
protected ObjectProperty KEYWORD_INDIVIDUALRELATION_INVOLVESKEYWORD = _constModel.createObjectProperty(VitroVocabulary.KEYWORD_INDIVIDUALRELATION_INVOLVESKEYWORD);
protected ObjectProperty KEYWORD_INDIVIDUALRELATION_INVOLVESINDIVIDUAL = _constModel.createObjectProperty(VitroVocabulary.KEYWORD_INDIVIDUALRELATION_INVOLVESINDIVIDUAL);
protected DatatypeProperty KEYWORD_INDIVIDUALRELATION_MODE = _constModel.createDatatypeProperty(VitroVocabulary.KEYWORD_INDIVIDUALRELATION_MODE);
protected OntClass LINK = _constModel.createClass(VitroVocabulary.LINK);
protected ObjectProperty PRIMARY_LINK = _constModel.createObjectProperty(VitroVocabulary.PRIMARY_LINK);
protected ObjectProperty ADDITIONAL_LINK = _constModel.createObjectProperty(VitroVocabulary.ADDITIONAL_LINK);
@ -104,22 +83,9 @@ public class JenaBaseDaoCon {
protected DatatypeProperty LINK_TYPE = _constModel.createDatatypeProperty(VitroVocabulary.LINK_TYPE);
protected DatatypeProperty LINK_DISPLAYRANK = _constModel.createDatatypeProperty(VitroVocabulary.LINK_DISPLAYRANK_URL);
// protected OntClass APPLICATION = null;
// protected DatatypeProperty APPLICATION_FLAG1NAME = null;
// protected DatatypeProperty APPLICATION_FLAG2NAME = null;
// protected DatatypeProperty APPLICATION_FLAG3NAME = null;
// protected DatatypeProperty APPLICATION_MINSHAREDPORTALID = null;
// protected DatatypeProperty APPLICATION_MAXSHAREDPORTALID = null;
// protected DatatypeProperty APPLICATION_KEYWORDHEADING = null;
// protected DatatypeProperty APPLICATION_ROOTLOGOTYPEIMAGE = null;
// protected DatatypeProperty APPLICATION_ONLYCURRENT = null;
// protected DatatypeProperty APPLICATION_MAXPORTALID = null;
protected OntClass PORTAL = _constModel.createClass(VitroVocabulary.PORTAL);
protected DatatypeProperty APPLICATION_THEMEDIR = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_THEMEDIR);
protected DatatypeProperty PORTAL_BANNERIMAGE = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_BANNERIMAGE);
//protected DatatypeProperty PORTAL_FLAG2VALUES = null;
//protected DatatypeProperty PORTAL_FLAG1VALUES = null;
protected DatatypeProperty APPLICATION_CONTACTMAIL = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_CONTACTMAIL);
protected DatatypeProperty APPLICATION_CORRECTIONMAIL = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_CORRECTIONMAIL);
protected DatatypeProperty PORTAL_SHORTHAND = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_SHORTHAND);
@ -127,7 +93,6 @@ public class JenaBaseDaoCon {
protected DatatypeProperty APPLICATION_ACKNOWLEGETEXT = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_ACKNOWLEGETEXT);
protected DatatypeProperty PORTAL_BANNERWIDTH = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_BANNERWIDTH);
protected DatatypeProperty PORTAL_BANNERHEIGHT = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_BANNERHEIGHT);
//protected DatatypeProperty PORTAL_FLAG3VALUES = null;
protected DatatypeProperty APPLICATION_COPYRIGHTURL = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_COPYRIGHTURL);
protected DatatypeProperty APPLICATION_COPYRIGHTANCHOR = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_COPYRIGHTANCHOR);
protected DatatypeProperty PORTAL_ROOTBREADCRUMBURL = _constModel.createDatatypeProperty(VitroVocabulary.PORTAL_ROOTBREADCRUMBURL);

View file

@ -102,18 +102,30 @@ public class JenaModelUtils {
return modelForClassgroups;
}
private final OntModelSpec DEFAULT_ONT_MODEL_SPEC = OntModelSpec.OWL_MEM;
public OntModel extractTBox( Model inputModel) {
return extractTBox(inputModel, null);
private final OntModelSpec DEFAULT_ONT_MODEL_SPEC = OntModelSpec.OWL_MEM;
private final boolean NORMAL = false;
private final boolean AGGRESSIVE = true;
public OntModel extractTBox( Model inputModel ) {
return extractTBox(inputModel, null);
}
public OntModel extractTBox( Model inputModel, boolean MODE ) {
Dataset dataset = DatasetFactory.create(inputModel);
return extractTBox(dataset, null, null, MODE);
}
public OntModel extractTBox( Model inputModel, String namespace ) {
Dataset dataset = DatasetFactory.create(inputModel);
return extractTBox( dataset, namespace, null );
return extractTBox( dataset, namespace, null, NORMAL );
}
public OntModel extractTBox( Dataset dataset, String namespace, String graphURI ) {
public OntModel extractTBox( Dataset dataset, String namespace, String graphURI) {
return extractTBox( dataset, namespace, graphURI, NORMAL);
}
public OntModel extractTBox( Dataset dataset, String namespace, String graphURI, boolean mode ) {
OntModel tboxModel = ModelFactory.createOntologyModel(DEFAULT_ONT_MODEL_SPEC);
List<String> queryStrList = new LinkedList<String>();
@ -121,6 +133,7 @@ private final OntModelSpec DEFAULT_ONT_MODEL_SPEC = OntModelSpec.OWL_MEM;
// Use SPARQL DESCRIBE queries to extract the RDF for named ontology entities
queryStrList.add( makeDescribeQueryStr( OWL.Class.getURI(), namespace, graphURI ) );
queryStrList.add( makeDescribeQueryStr( OWL.Restriction.getURI(), namespace, graphURI ) );
queryStrList.add( makeDescribeQueryStr( OWL.ObjectProperty.getURI(), namespace, graphURI ) );
queryStrList.add( makeDescribeQueryStr( OWL.DatatypeProperty.getURI(), namespace, graphURI ) );
queryStrList.add( makeDescribeQueryStr( OWL.AnnotationProperty.getURI(), namespace, graphURI ) );
@ -144,8 +157,56 @@ private final OntModelSpec DEFAULT_ONT_MODEL_SPEC = OntModelSpec.OWL_MEM;
}
}
// Perform possibly-redundant extraction to try ensure we don't miss
// individual axioms floating around. We still might miss things;
// this approach isn't perfect.
if (mode = AGGRESSIVE) {
tboxModel.add(construct(dataset, namespace, graphURI, RDFS.subClassOf));
tboxModel.add(construct(dataset, namespace, graphURI, RDFS.subPropertyOf));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.equivalentClass));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.unionOf));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.intersectionOf));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.complementOf));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.onProperty));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.allValuesFrom));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.someValuesFrom));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.hasValue));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.minCardinality));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.maxCardinality));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.cardinality));
tboxModel.add(construct(dataset, namespace, graphURI, OWL.disjointWith));
}
return tboxModel;
}
private Model construct(Dataset dataset,
String namespace,
String graphURI,
Resource property) {
dataset.getLock().enterCriticalSection(Lock.READ);
try {
StringBuffer buff = new StringBuffer();
buff.append("PREFIX afn: <http://jena.hpl.hp.com/ARQ/function#> \n")
.append("CONSTRUCT { \n")
.append(" ?res <" + property.getURI() + "> ?o WHERE { \n");
if (graphURI != null) {
buff.append(" GRAPH " + graphURI + " { \n");
}
buff.append(" ?res <" + property.getURI() + "> ?o \n");
buff.append(getNamespaceFilter(namespace));
if (graphURI != null) {
buff.append(" } \n");
}
Query constructProp = QueryFactory.create(buff.toString());
QueryExecution qe = QueryExecutionFactory.create(constructProp, dataset);
try {
return qe.execConstruct();
} finally {
qe.close();
}
} finally {
dataset.getLock().leaveCriticalSection();
}
}
private String makeDescribeQueryStr( String typeURI, String namespace ) {
@ -166,31 +227,10 @@ private final OntModelSpec DEFAULT_ONT_MODEL_SPEC = OntModelSpec.OWL_MEM;
.append(" ?res rdf:type <").append(typeURI).append("> . \n");
describeQueryStrBuff
.append(" FILTER (!isBlank(?res)) \n");
if (namespace == null) {
// exclude resources in the Vitro internal namespace or in the
// OWL namespace, but allow all others
describeQueryStrBuff
//.append(" FILTER (afn:namespace(?res) != \"")
//.append("http://vitro.mannlib.cornell.edu/ns/vitro/0.7#")
//.append("\") \n")
.append(" FILTER (afn:namespace(?res) != \"")
.append("http://www.w3.org/2002/07/owl#")
.append("\") \n")
//.append(" FILTER (?res != <")
//.append("http://vitro.mannlib.cornell.edu/ns/vitro/0.7")
//.append(">) \n")
.append(" FILTER (?res != <")
.append("http://www.w3.org/2002/07/owl")
.append(">) \n");
} else {
// limit resources to those in the supplied namespace
describeQueryStrBuff
.append(" FILTER (afn:namespace(?res) = \"")
.append(namespace)
.append("\") \n");
}
.append(" FILTER (!isBlank(?res)) \n")
.append(getNamespaceFilter(namespace));
if (graphURI != null) {
describeQueryStrBuff
.append("} \n");
@ -202,6 +242,28 @@ private final OntModelSpec DEFAULT_ONT_MODEL_SPEC = OntModelSpec.OWL_MEM;
}
private String getNamespaceFilter(String namespace) {
StringBuffer buff = new StringBuffer();
if (namespace == null) {
// exclude resources in the Vitro internal namespace or in the
// OWL namespace, but allow all others
buff
.append(" FILTER (afn:namespace(?res) != \"")
.append("http://www.w3.org/2002/07/owl#")
.append("\") \n")
.append(" FILTER (?res != <")
.append("http://www.w3.org/2002/07/owl")
.append(">) \n");
} else {
// limit resources to those in the supplied namespace
buff
.append(" FILTER (afn:namespace(?res) = \"")
.append(namespace)
.append("\") \n");
}
return buff.toString();
}
public Model extractABox(Model inputModel){
Dataset dataset = DatasetFactory.create(inputModel);
return extractABox(dataset, null, null);
@ -219,8 +281,7 @@ private final OntModelSpec DEFAULT_ONT_MODEL_SPEC = OntModelSpec.OWL_MEM;
//OntModel ontModel = ( inputModel instanceof OntModel )
//? (OntModel)inputModel
//: ModelFactory.createOntologyModel( DEFAULT_ONT_MODEL_SPEC, inputModel );
OntModel ontModel = extractTBox(unionDataset, null, graphURI);
OntModel ontModel = extractTBox(unionDataset, null, graphURI);
try {
ontModel.enterCriticalSection(Lock.READ);

View file

@ -1,212 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.rdf.model.Literal;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.util.iterator.ClosableIterator;
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.beans.IndividualImpl;
import edu.cornell.mannlib.vitro.webapp.beans.Keyword;
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
import edu.cornell.mannlib.vitro.webapp.dao.InsertException;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
public class KeywordDaoJena extends JenaBaseDao implements KeywordDao {
private static final Log log = LogFactory.getLog(KeywordDaoJena.class.getName());
private String KEYWORD_URI_PREFIX = DEFAULT_NAMESPACE + "keyword";
private WebappDaoFactory webappDaoFactory = null;
public KeywordDaoJena(WebappDaoFactoryJena wadf) {
super(wadf);
this.webappDaoFactory = getWebappDaoFactory();
}
public void deleteKeyword(Keyword keyword) {
webappDaoFactory.getIndividualDao().deleteIndividual(KEYWORD_URI_PREFIX+keyword.getId());
}
public List<Keyword> getAllKeywords() {
VClass keywordClass = webappDaoFactory.getVClassDao().getVClassByURI(KEYWORD.getURI());
List keywordInds = webappDaoFactory.getIndividualDao().getIndividualsByVClass(keywordClass);
List keywords = new ArrayList();
Iterator keywordIndIt = keywordInds.iterator();
while (keywordIndIt.hasNext()) {
keywords.add(keywordFromKeywordIndividual((Individual)keywordIndIt.next()));
}
return keywords;
}
public List<Keyword> getKeywordsByStem(String stem) {
List<Keyword> matchingKeywords = new ArrayList<Keyword>();
List<Keyword> all = getAllKeywords();
Iterator<Keyword> allIt = all.iterator();
while (allIt.hasNext()) {
Keyword k = allIt.next();
if (k.getStem()!= null && k.getStem().equalsIgnoreCase(stem)) {
matchingKeywords.add(k);
}
}
return matchingKeywords;
}
public List getAllOrigins() {
List origins = new ArrayList();
HashSet originSet = new HashSet();
getOntModel().enterCriticalSection(Lock.READ);
try {
ClosableIterator stmtIt = getOntModel().listStatements(null, KEYWORD_ORIGIN, (Literal)null);
try {
while (stmtIt.hasNext()) {
Statement stmt = (Statement) stmtIt.next();
Literal lit = (Literal) stmt.getObject();
String originStr = (String)lit.getString();
if (!originSet.contains(originStr)) {
originSet.add(originStr);
}
}
} finally {
stmtIt.close();
}
} finally {
getOntModel().leaveCriticalSection();
}
origins.addAll(originSet);
return origins;
}
public Keyword getKeywordById(int id) {
Individual keywordIndividual = webappDaoFactory.getIndividualDao().getIndividualByURI(KEYWORD_URI_PREFIX+id);
Keyword k = keywordFromKeywordIndividual(keywordIndividual);
k.setId(id);
return k;
}
private Keyword keywordFromKeywordIndividual(Individual keywordIndividual) {
Keyword keyword = new Keyword();
if (keywordIndividual != null) {
keyword.setTerm(keywordIndividual.getName());
keyword.setId(Integer.decode(keywordIndividual.getLocalName().substring(7,keywordIndividual.getLocalName().length())));
try {
keyword.setStem( ((DataPropertyStatement)(webappDaoFactory.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(keywordIndividual, KEYWORD_STEM.getURI()).toArray())[0]).getData() );
} catch (Exception e) {
// e.printStackTrace();
}
try {
keyword.setOrigin( ((DataPropertyStatement)(webappDaoFactory.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(keywordIndividual, KEYWORD_ORIGIN.getURI()).toArray())[0]).getData() );
} catch (Exception e) {
// e.printStackTrace();
}
try {
keyword.setType( ((DataPropertyStatement)(webappDaoFactory.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(keywordIndividual, KEYWORD_TYPE.getURI()).toArray())[0]).getData() );
} catch (Exception e) {
// e.printStackTrace();
}
try {
keyword.setSource( ((DataPropertyStatement)(webappDaoFactory.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(keywordIndividual, KEYWORD_SOURCE.getURI()).toArray())[0]).getData() );
} catch (Exception e) {
// e.printStackTrace();
}
try {
keyword.setComments( ((DataPropertyStatement)(webappDaoFactory.getDataPropertyStatementDao().getDataPropertyStatementsForIndividualByDataPropertyURI(keywordIndividual, KEYWORD_COMMENTS.getURI()).toArray())[0]).getData() );
} catch (Exception e) {
// e.printStackTrace();
}
}
return keyword;
}
public synchronized int insertNewKeyword(Keyword k) {
int kId = -1;
if (k.getId()>0) {
kId = k.getId();
} else {
String term = k.getTerm();
int count = 0;
while ((webappDaoFactory.getIndividualDao().getIndividualByURI(KEYWORD_URI_PREFIX+Math.abs(term.hashCode())) != null) && count < 32) {
term+="a";
log.debug(term);
log.debug(KEYWORD_URI_PREFIX+Math.abs(term.hashCode()));
count++;
}
kId = Math.abs(term.hashCode());
}
Individual keywordIndividual = new IndividualImpl();
keywordIndividual.setURI(KEYWORD_URI_PREFIX+kId);
keywordIndividual.setVClassURI(KEYWORD.getURI());
keywordIndividual.setName(k.getTerm());
String keywordURI = null;
try {
keywordURI = webappDaoFactory.getIndividualDao().insertNewIndividual(keywordIndividual);
} catch (InsertException e) {
log.error(e, e);
}
log.debug("KeywordDaoJena.insertNewKeyword() : "+keywordURI);
DataPropertyStatement stem = new DataPropertyStatementImpl();
log.debug("KeywordDaoJena.insertNewKeyword() stem : "+k.getStem());
stem.setData(k.getStem());
stem.setDatapropURI(KEYWORD_STEM.getURI());
stem.setIndividualURI(keywordURI);
webappDaoFactory.getDataPropertyStatementDao().insertNewDataPropertyStatement(stem);
log.debug("KeywordDaoJena.insertNewKeyword() type : "+k.getType());
DataPropertyStatement type = new DataPropertyStatementImpl();
type.setData(k.getType());
type.setDatapropURI(KEYWORD_TYPE.getURI());
type.setIndividualURI(keywordURI);
webappDaoFactory.getDataPropertyStatementDao().insertNewDataPropertyStatement(type);
log.debug("KeywordDaoJena.insertNewKeyword() source : "+k.getSource());
if (k.getSource()==null || k.getSource().equals("")) {
k.setSource("unspecified");
}
DataPropertyStatement source = new DataPropertyStatementImpl();
source.setData(k.getSource());
source.setDatapropURI(KEYWORD_SOURCE.getURI());
source.setIndividualURI(keywordURI);
webappDaoFactory.getDataPropertyStatementDao().insertNewDataPropertyStatement(source);
log.debug("KeywordDaoJena.insertNewKeyword() origin : "+k.getOrigin());
if (k.getOrigin()==null || k.getOrigin().equals("")) {
k.setOrigin("unspecified");
}
DataPropertyStatement origin = new DataPropertyStatementImpl();
origin.setData(k.getOrigin());
origin.setDatapropURI(KEYWORD_ORIGIN.getURI());
origin.setIndividualURI(keywordURI);
webappDaoFactory.getDataPropertyStatementDao().insertNewDataPropertyStatement(origin);
if (k.getComments()!=null && !k.getComments().equals("")) {
log.debug("KeywordDaoJena.insertNewKeyword() comments : "+k.getComments());
DataPropertyStatement comments = new DataPropertyStatementImpl();
comments.setData(k.getComments());
comments.setDatapropURI(KEYWORD_COMMENTS.getURI());
comments.setIndividualURI(keywordURI);
webappDaoFactory.getDataPropertyStatementDao().insertNewDataPropertyStatement(comments);
}
return kId;
}
public void updateKeyword(Keyword k) {
deleteKeyword(k);
insertNewKeyword(k);
}
}

View file

@ -1,184 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
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.shared.Lock;
import com.hp.hpl.jena.util.iterator.ClosableIterator;
import com.hp.hpl.jena.vocabulary.RDF;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.KeywordIndividualRelation;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordIndividualRelationDao;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
public class KeywordIndividualRelationDaoJena extends JenaBaseDao implements KeywordIndividualRelationDao {
public KeywordIndividualRelationDaoJena(WebappDaoFactoryJena wadf) {
super(wadf);
}
@Override
protected OntModel getOntModel() {
return getOntModelSelector().getABoxModel();
}
public void deleteKeywordIndividualRelation(KeywordIndividualRelation k) {
deleteKeywordIndividualRelation(k,getOntModel());
}
public void deleteKeywordIndividualRelation(KeywordIndividualRelation k, OntModel ontModel) {
ontModel.enterCriticalSection(Lock.WRITE);
try {
com.hp.hpl.jena.ontology.Individual kirInd = ontModel.getIndividual(k.getURI());
if (kirInd != null) {
kirInd.remove();
}
} finally {
ontModel.leaveCriticalSection();
}
if (k.getEntURI() != null) {
Individual ind = getWebappDaoFactory().getIndividualDao().getIndividualByURI(k.getEntURI());
getWebappDaoFactory().getIndividualDao().markModified(ind);
}
}
public KeywordIndividualRelation getKeywordIndividualRelationByURI(String URI) {
com.hp.hpl.jena.ontology.Individual kirInd = getOntModel().getIndividual(URI);
if (kirInd != null) {
return keywordIndividualRelationFromIndividual(kirInd);
} else {
return null;
}
}
public List<KeywordIndividualRelation> getKeywordIndividualRelationsByIndividualURI(String individualURI) {
List kirList = new ArrayList();
if (individualURI == null) {
return kirList;
}
getOntModel().enterCriticalSection(Lock.READ);
try {
Resource individual = ResourceFactory.createResource(individualURI);
if (individual != null) {
ClosableIterator stmtIt = getOntModel().listStatements(null, KEYWORD_INDIVIDUALRELATION_INVOLVESINDIVIDUAL, individual);
try {
while (stmtIt.hasNext()) {
Statement stmt = (Statement) stmtIt.next();
Resource kirRes = stmt.getSubject();
if (kirRes != null) {
boolean checked = false;
ClosableIterator checkIt = kirRes.listProperties(RDF.type);
try {
while (checkIt.hasNext()) {
Statement chk = (Statement) checkIt.next();
if (((Resource)chk.getObject()).getURI().equals(KEYWORD_INDIVIDUALRELATION.getURI())) {
checked = true;
break;
}
}
} finally {
checkIt.close();
}
if (checked) {
com.hp.hpl.jena.ontology.Individual kirInd = getOntModel().getIndividual(kirRes.getURI());
kirList.add(keywordIndividualRelationFromIndividual(kirInd));
}
}
}
} finally {
stmtIt.close();
}
}
} finally {
getOntModel().leaveCriticalSection();
}
return kirList;
}
public String insertNewKeywordIndividualRelation(KeywordIndividualRelation k) {
return insertNewKeywordIndividualRelation(k,getOntModel());
}
public String insertNewKeywordIndividualRelation(KeywordIndividualRelation k, OntModel ontModel) {
ontModel.enterCriticalSection(Lock.WRITE);
String uriToUse = null;
try {
Resource individual = ontModel.getResource(k.getEntURI());
Resource keyword = ontModel.getResource(DEFAULT_NAMESPACE+"keyword"+k.getKeyId());
if (k.getURI() != null) {
uriToUse = k.getURI();
} else {
String dedup = DEFAULT_NAMESPACE+"keywordIndividualRelation_"+k.getKeyId()+"_"+individual.getLocalName();
//while (ontModel.getResource(dedup) != null) {
// dedup += "a";
//}
uriToUse = dedup;
}
OntClass KeywordIndividualRelationOntClass = ontModel.getOntClass(VitroVocabulary.KEYWORD_INDIVIDUALRELATION);
if (KeywordIndividualRelationOntClass != null) {
com.hp.hpl.jena.ontology.Individual tirInd = KeywordIndividualRelationOntClass.createIndividual(uriToUse);
addPropertyResourceValue(tirInd, KEYWORD_INDIVIDUALRELATION_INVOLVESKEYWORD, keyword);
addPropertyResourceValue(tirInd, KEYWORD_INDIVIDUALRELATION_INVOLVESINDIVIDUAL, individual);
addPropertyStringValue(tirInd, KEYWORD_INDIVIDUALRELATION_MODE, k.getMode(), ontModel);
} else {
log.error(VitroVocabulary.KEYWORD_INDIVIDUALRELATION+" class not found");
}
} finally {
ontModel.leaveCriticalSection();
}
if (k.getEntURI() != null) {
Individual ind = getWebappDaoFactory().getIndividualDao().getIndividualByURI(k.getEntURI());
getWebappDaoFactory().getIndividualDao().markModified(ind);
}
return uriToUse;
}
public void updateKeywordIndividualRelation(KeywordIndividualRelation k) {
updateKeywordIndividualRelation(k,getOntModel());
}
public void updateKeywordIndividualRelation(KeywordIndividualRelation k, OntModel ontModel) {
ontModel.enterCriticalSection(Lock.WRITE);
try {
com.hp.hpl.jena.ontology.Individual kirInd = ontModel.getIndividual(k.getURI());
Resource individual = ontModel.getResource(k.getEntURI());
Resource keyword = ontModel.getResource(DEFAULT_NAMESPACE+"keyword"+k.getKeyId());
updatePropertyResourceValue(kirInd, KEYWORD_INDIVIDUALRELATION_INVOLVESKEYWORD, keyword);
updatePropertyResourceValue(kirInd, KEYWORD_INDIVIDUALRELATION_INVOLVESINDIVIDUAL, individual);
updatePropertyStringValue(kirInd, KEYWORD_INDIVIDUALRELATION_MODE, k.getMode(), ontModel);
} finally {
ontModel.leaveCriticalSection();
}
if (k.getEntURI() != null) {
Individual ind = getWebappDaoFactory().getIndividualDao().getIndividualByURI(k.getEntURI());
getWebappDaoFactory().getIndividualDao().markModified(ind);
}
}
private KeywordIndividualRelation keywordIndividualRelationFromIndividual(com.hp.hpl.jena.ontology.Individual ind) {
KeywordIndividualRelation kir = new KeywordIndividualRelation();
kir.setURI(ind.getURI());
try {
kir.setEntURI(((Resource)ind.getPropertyValue(KEYWORD_INDIVIDUALRELATION_INVOLVESINDIVIDUAL)).getURI());
} catch (Exception e) {/* TODO log */}
try {
String keywordLocalName = ((Resource)ind.getPropertyValue(KEYWORD_INDIVIDUALRELATION_INVOLVESKEYWORD)).getLocalName();
kir.setKeyId(Integer.decode(keywordLocalName.substring(7,keywordLocalName.length())));
} catch (Exception e) {/* TODO log */}
kir.setMode(getPropertyStringValue(ind,KEYWORD_INDIVIDUALRELATION_MODE));
return kir;
}
}

View file

@ -1,385 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
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.OntModel;
import com.hp.hpl.jena.rdf.model.Literal;
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.shared.Lock;
import com.hp.hpl.jena.util.iterator.ClosableIterator;
import com.hp.hpl.jena.vocabulary.RDF;
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
import edu.cornell.mannlib.vitro.webapp.beans.Link;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.dao.LinksDao;
public class LinksDaoJena extends JenaBaseDao implements LinksDao {
protected static final Log log = LogFactory.getLog(LinksDaoJena.class.getName());
public LinksDaoJena(WebappDaoFactoryJena wadf) {
super(wadf);
}
@Override
protected OntModel getOntModel() {
return getOntModelSelector().getABoxModel();
}
public void addLinksToIndividual(Individual individual) {
List<Link> linksList = new ArrayList<Link>();
getOntModel().enterCriticalSection(Lock.READ);
try {
Resource entInd = ResourceFactory.createResource(individual.getURI());
if (ADDITIONAL_LINK != null) {
ClosableIterator<Statement> links = getOntModel().listStatements(entInd,ADDITIONAL_LINK,(Resource)null);
try {
while (links.hasNext()) {
try {
Resource linkRes = (Resource) links.next().getObject();
linksList.add(linkFromLinkResource(linkRes, ADDITIONAL_LINK));
} catch (ClassCastException cce) {/*no thanks; we don't want any*/}
}
} finally {
links.close();
}
if (linksList.size()>1) { // sort
Collections.sort(linksList,new Comparator<Link>() {
public int compare( Link first, Link second ) {
if (first==null) {
return 1;
}
if (second==null) {
return -1;
}
Collator collator = Collator.getInstance();
int compval = collator.compare(first.getDisplayRank(),second.getDisplayRank());
if (compval == 0) {
String firstAnchor = first.getAnchor();
String secondAnchor = second.getAnchor();
if (firstAnchor == null) {
if (secondAnchor == null) {
return 0;
}
return 1;
}
if (secondAnchor == null) {
return -1;
}
compval = collator.compare(firstAnchor, secondAnchor);
}
return compval;
}
});
}
individual.setLinksList(linksList);
}
} finally {
getOntModel().leaveCriticalSection();
}
}
public void addPrimaryLinkToIndividual(Individual individual) {
List<Link> linksList = new ArrayList<Link>();
getOntModel().enterCriticalSection(Lock.READ);
try {
com.hp.hpl.jena.ontology.Individual entInd = getOntModel().getIndividual(individual.getURI());
if (PRIMARY_LINK != null) {
ClosableIterator<Statement> links = getOntModel().listStatements(entInd,PRIMARY_LINK,(Resource)null);
try {
while (links.hasNext()) {
try {
Resource linkRes = (Resource) links.next().getObject();
linksList.add(linkFromLinkResource(linkRes,PRIMARY_LINK));
} catch (ClassCastException cce) {/*no thanks; we don't want any*/}
}
} finally {
links.close();
}
if (linksList.size()>1) { // sort
Collections.sort(linksList,new Comparator<Link>() {
public int compare( Link first, Link second ) {
if (first==null) {
return 1;
}
if (second==null) {
return -1;
}
Collator collator = Collator.getInstance();
int compval = collator.compare(first.getDisplayRank(),second.getDisplayRank());
if (compval == 0) {
String firstAnchor = first.getAnchor();
String secondAnchor = second.getAnchor();
if (firstAnchor == null) {
if (secondAnchor == null) {
return 0;
}
return 1;
}
if (secondAnchor == null) {
return -1;
}
compval = collator.compare(firstAnchor, secondAnchor);
}
return compval;
}
});
}
if (linksList.size()>0) {
Iterator<Link> iter = linksList.iterator();
if (iter.hasNext()) { // take the first only
individual.setPrimaryLink(iter.next());
}
}
}
} finally {
getOntModel().leaveCriticalSection();
}
}
public void addLinksToIndividualsInObjectPropertyStatement(List<ObjectPropertyStatement> objectPropertyStatements) {
if (objectPropertyStatements != null) {
Iterator<ObjectPropertyStatement> objectPropertyStatementsIt = objectPropertyStatements.iterator();
while (objectPropertyStatementsIt.hasNext()) {
ObjectPropertyStatement ops = objectPropertyStatementsIt.next();
if (ops.getSubject() != null && ops.getSubject() instanceof Individual)
addLinksToIndividual((Individual)ops.getSubject());
if (ops.getObject() != null && ops.getObject() instanceof Individual)
addLinksToIndividual((Individual)ops.getObject());
}
}
}
public void deleteLink(Link link) {
deleteLink(link,getOntModel());
}
public void deleteLink(Link link, OntModel ontModel) {
ontModel.enterCriticalSection(Lock.WRITE);
try {
Resource linkRes = ontModel.getResource(link.getURI());
if (linkRes != null) {
ontModel.removeAll(linkRes, null, null);
ontModel.removeAll(null, null, linkRes);
}
} finally {
ontModel.leaveCriticalSection();
}
}
public Link getLinkByURI(String URI) {
getOntModel().enterCriticalSection(Lock.READ);
try {
Resource linkRes = getOntModel().getResource(URI);
if (linkRes != null) {
return linkFromLinkResource(linkRes,ADDITIONAL_LINK);
} else {
return null;
}
} finally {
getOntModel().leaveCriticalSection();
}
}
public String insertNewLink(Link link) {
return insertNewLink(link,getOntModel());
}
public String insertNewLink(Link link, OntModel ontModel) {
ontModel.enterCriticalSection(Lock.WRITE);
try {
Resource indRes = ontModel.getResource(link.getEntityURI());
if (indRes == null) {
return null;
}
String linkUri = null;
if (link.getURI() != null && link.getURI().length()>0) {
linkUri = link.getURI();
} else {
linkUri = DEFAULT_NAMESPACE+"link_"+indRes.getLocalName()+link.getAnchor().replaceAll("\\W","");
}
Resource test = ontModel.getResource(linkUri);
int count = 0;
while (test != null) {
++count;
linkUri+="_"+count;
test = ontModel.getIndividual(linkUri);
}
Resource linkRes = ontModel.createResource(linkUri);
linkRes.addProperty(RDF.type, LINK);
if (link.getTypeURI() != null && link.getTypeURI().length()>0) {
try {
linkRes.addProperty(RDF.type, ontModel.getResource(link.getTypeURI()));
} catch (Exception e) {}
}
String urlString = link.getUrl();
try {
urlString = URLEncoder.encode(urlString, "UTF-8");
} catch (UnsupportedEncodingException e) {}
linkRes.addProperty(LINK_URL, urlString, XSDDatatype.XSDanyURI);
linkRes.addProperty(LINK_ANCHOR, link.getAnchor(), XSDDatatype.XSDstring);
linkRes.addProperty(LINK_DISPLAYRANK, ontModel.createTypedLiteral(link.getDisplayRank())); // String for now
ontModel.add(indRes, ADDITIONAL_LINK, linkRes);
return linkUri;
} finally {
ontModel.leaveCriticalSection();
}
}
public void updateLink(Link link) {
updateLink(link,getOntModel());
}
public void updateLink(Link link, OntModel ontModel) {
ontModel.enterCriticalSection(Lock.WRITE);
try {
Resource linkRes = ontModel.getResource(link.getURI());
Resource indRes = ontModel.getResource(link.getEntityURI());
if (linkRes != null) {
linkRes.removeAll(RDF.type); // BJL note: a transactionless DL reasoner might choke on this approach
linkRes.addProperty(RDF.type, LINK);
if (link.getTypeURI() != null && link.getTypeURI().length()>0) {
try {
linkRes.addProperty(RDF.type, ontModel.getResource(link.getTypeURI()));
} catch (Exception e) {e.printStackTrace();}
}
linkRes.removeAll(LINK_URL);
String urlString = link.getUrl();
try {
urlString = URLEncoder.encode(urlString, "UTF-8");
} catch (UnsupportedEncodingException e) {}
linkRes.addProperty(LINK_URL, urlString, XSDDatatype.XSDanyURI);
linkRes.removeAll(LINK_ANCHOR);
linkRes.addProperty(LINK_ANCHOR, link.getAnchor(), XSDDatatype.XSDstring);
if (indRes != null) {
ontModel.removeAll(null, ADDITIONAL_LINK, linkRes);
ontModel.add(indRes, ADDITIONAL_LINK, linkRes);
}
linkRes.removeAll(LINK_DISPLAYRANK);
linkRes.addProperty(LINK_DISPLAYRANK, ontModel.createTypedLiteral(link.getDisplayRank())); // String for now
}
} finally {
ontModel.leaveCriticalSection();
}
}
private Link linkFromLinkResource(Resource linkRes, com.hp.hpl.jena.ontology.ObjectProperty whichLinkProp) {
Link link = new Link();
link.setURI(linkRes.getURI());
ClosableIterator<Statement> typesIt = linkRes.listProperties(RDF.type);
try {
while (typesIt.hasNext()) {
Statement st = typesIt.next();
try {
Resource typeRes = (Resource) st.getObject();
if (!typeRes.getURI().equalsIgnoreCase(LINK.getURI())) { // TODO: remove IgnoreCase ; there because some serializations use "link" instead of "Link"
link.setTypeURI(typeRes.getURI());
}
} catch (ClassCastException e) {}
}
} finally {
typesIt.close();
}
if (LINK_ANCHOR != null) {
try {
ClosableIterator<Statement> anchorStatements = getOntModel().listStatements(linkRes, LINK_ANCHOR, (Literal)null);
try {
if (anchorStatements.hasNext()) {
Literal l = (Literal) anchorStatements.next().getObject();
if (l != null) {
link.setAnchor(l.getString());
}
}
} finally {
anchorStatements.close();
}
} catch (ClassCastException e) {}
}
if (LINK_URL != null) {
try {
ClosableIterator<Statement> UrlStatements = getOntModel().listStatements(linkRes, LINK_URL, (Literal)null);
try {
if (UrlStatements.hasNext()) {
Literal l = (Literal) UrlStatements.next().getObject();
if (l != null) {
if( (l.getDatatype() != null) && XSDDatatype.XSDanyURI.equals(l.getDatatype()) ) {
try {
link.setUrl(URLDecoder.decode(l.getLexicalForm(),"UTF-8"));
} catch (UnsupportedEncodingException use) {}
} else {
link.setUrl(l.getLexicalForm());
}
}
}
} finally {
UrlStatements.close();
}
} catch (ClassCastException e) {}
}
if (LINK_DISPLAYRANK != null) {
try {
ClosableIterator<Statement> rankStatements = getOntModel().listStatements(linkRes, LINK_DISPLAYRANK, (Literal)null);
try {
if (rankStatements.hasNext()) {
Literal l = (Literal) rankStatements.next().getObject();
if (l != null) {
if (l.getDatatype()==XSDDatatype.XSDinteger) {
link.setDisplayRank(String.valueOf(l.getInt()));
} else if (l.getDatatype()==XSDDatatype.XSDstring) {
link.setDisplayRank(l.getString());
} else {
log.debug("unexpected literal datatype; saved as displayRank 10");
link.setDisplayRank("10");
}
}
}
} finally {
rankStatements.close();
}
} catch (ClassCastException e) {}
}
ClosableIterator<Statement> stmtIt = getOntModel().listStatements(null, (com.hp.hpl.jena.rdf.model.Property)whichLinkProp, linkRes); // jena Property, not vitro Property
try {
if (stmtIt.hasNext()) {
Statement stmt = stmtIt.next();
Resource indRes = stmt.getSubject();
link.setEntityURI(indRes.getURI());
ObjectPropertyStatement op = new ObjectPropertyStatementImpl();
op.setPropertyURI(whichLinkProp.getURI()); // "http://vitro.mannlib.cornell.edu/ns/vitro/0.7#additionalLink");
op.setSubjectURI(indRes.getURI());
op.setObjectURI(linkRes.getURI());
link.setObjectPropertyStatement(op);
}
} finally {
stmtIt.close();
}
return link;
}
}

View file

@ -1,53 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.dao.jena;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.shared.Lock;
import com.hp.hpl.jena.util.iterator.ClosableIterator;
import edu.cornell.mannlib.vitro.webapp.beans.Linktype;
import edu.cornell.mannlib.vitro.webapp.dao.LinktypeDao;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
public class LinktypeDaoJena extends JenaBaseDao implements LinktypeDao {
public LinktypeDaoJena(WebappDaoFactoryJena wadf) {
super(wadf);
}
@Override
protected OntModel getOntModel() {
return getOntModelSelector().getABoxModel();
}
public List<Linktype> getAllLinktypes() {
List<Linktype> linkTypes = new LinkedList<Linktype>();
getOntModel().enterCriticalSection(Lock.READ);
try {
OntClass linkClass = getOntModel().getOntClass(LINK.getURI());
ClosableIterator cIt = linkClass.listSubClasses();
try {
while (cIt.hasNext()) {
OntClass lCls = (OntClass) cIt.next();
Linktype lt = new Linktype();
lt.setURI(lCls.getURI());
lt.setType(getLabelOrId(lCls));
linkTypes.add(lt);
}
} finally {
cIt.close();
}
} finally {
getOntModel().leaveCriticalSection();
}
return linkTypes;
}
}

View file

@ -48,7 +48,7 @@ public class PropertyInstanceDaoJena extends JenaBaseDao implements
}
public void deleteObjectPropertyStatement(String subjectURI, String propertyURI, String objectURI) {
deleteObjectPropertyStatement(subjectURI, propertyURI, objectURI, getOntModelSelector().getFullModel());
deleteObjectPropertyStatement(subjectURI, propertyURI, objectURI, getOntModelSelector().getABoxModel());
}
public void deleteObjectPropertyStatement(String subjectURI, String propertyURI, String objectURI, OntModel ontModel) {

View file

@ -42,8 +42,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.DatatypeDao;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayModelDao;
import edu.cornell.mannlib.vitro.webapp.dao.FlagDao;
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordIndividualRelationDao;
import edu.cornell.mannlib.vitro.webapp.dao.LinksDao;
import edu.cornell.mannlib.vitro.webapp.dao.LinktypeDao;
import edu.cornell.mannlib.vitro.webapp.dao.MenuDao;
@ -61,14 +59,11 @@ import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
import edu.cornell.mannlib.vitro.webapp.servlet.setup.JenaDataSourceSetupBase;
import edu.cornell.mannlib.vitro.webapp.dao.jena.PropertyGroupDaoJena;
public class WebappDaoFactoryJena implements WebappDaoFactory {
protected IndividualDao entityWebappDao;
protected FlagDao flagDao;
protected KeywordIndividualRelationDao keys2EntsDao;
protected KeywordDao keywordDao;
protected LinksDao linksDao;
protected LinktypeDao linktypeDao;
protected ApplicationDaoJena applicationDao;
@ -443,34 +438,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
else
return entityWebappDao = new IndividualDaoJena(this);
}
public KeywordIndividualRelationDao getKeys2EntsDao() {
if (keys2EntsDao != null)
return keys2EntsDao;
else
return keys2EntsDao = new KeywordIndividualRelationDaoJena(this);
}
public KeywordDao getKeywordDao() {
if (keywordDao != null)
return keywordDao;
else
return keywordDao = new KeywordDaoJena(this);
}
public LinksDao getLinksDao() {
if (linksDao != null)
return linksDao;
else
return linksDao = new LinksDaoJena(this);
}
public LinktypeDao getLinktypeDao() {
if (linktypeDao != null)
return linktypeDao;
else
return linktypeDao = new LinktypeDaoJena(this);
}
public ApplicationDao getApplicationDao() {
if (applicationDao != null) {
@ -697,10 +664,6 @@ public class WebappDaoFactoryJena implements WebappDaoFactory {
//and tbox model
WebappDaoFactoryJena specialWadfj = new WebappDaoFactoryJena(specialSelector);
entityWebappDao = specialWadfj.getIndividualDao();
keys2EntsDao = specialWadfj.getKeys2EntsDao();
keywordDao = specialWadfj.getKeywordDao();
linksDao = specialWadfj.getLinksDao();
linktypeDao = specialWadfj.getLinktypeDao();
vClassGroupDao = specialWadfj.getVClassGroupDao();
//To allow for testing, add a property group, this will allow
//the unassigned group method section to be executed and main Image to be assigned to that group

View file

@ -62,47 +62,6 @@ public class EntityDWR {
return ind;
}
/**
Gets entities that can be in a propertyId relation with classId but
excludes entity with id of ignoredEntId. If classId < 0 then it the
query is not limited by vclass.
@param propertyId - which relation to get entities for column properties.id
@param ignoredEntId - the entity with this id is excluded from the
result collection. Set to < 0 if you don't want to ignore any entities.
@param classId - if > 0 then only ents with this vClassId or which are subclasses
of this are included in results.
@param domainSide - if true, return RANGE entities of relation, if false return
DOMAIN entities of relation.
@return - Entities that can satisify the property. Only the name and id of the
object will be filled out.
*/
@Deprecated
public Collection getEntitiesByProperties(String propertyURI,
String ignoredEntURI,
String classURI,
boolean domainSide ){
return new LinkedList();
// WebContext ctx = WebContextFactory.get();
// HttpServletRequest req = ctx.getHttpServletRequest();
// VitroRequest vreq = new VitroRequest(req);
// IndividualDao entityWADao = vreq.getWebappDaoFactory().getIndividualDao();
//
// return entityWADao.getIndividualsByProperty(
// propertyURI,ignoredEntURI,classURI,domainSide);
}
/**
* Gets the monikers for a vclass.
*/
public List monikers( String vClassURI ){
WebContext ctx = WebContextFactory.get();
HttpServletRequest req = ctx.getHttpServletRequest();
VitroRequest vreq = new VitroRequest(req);
IndividualDao entityWADao = vreq.getWebappDaoFactory().getIndividualDao();
return entityWADao.monikers( vClassURI );
}
/**
* Gets all of the entities given the vclass.
* This returns a collection of EntityWebapp objects.

View file

@ -82,31 +82,6 @@ public class PropertyDWR {
return wdf.getPropertyInstanceDao().getProperty(subjectURI, predicateURI, objectURI);
}
/**
The following fields are used by this method to write this property
to the object property statement table:
domainEntId
rangeEntId
PropertyId
sunrise - optional
sunset - optional
qualifier - optional
Initially this tries an insert, if that fails then an update is attempted.
@return -1 for error, 0 for no write due to duplicate, > 0 is auto-gen
objectPropertyStatement.id
*/
@Deprecated
public int writeProp(PropertyInstance prop ){
// WebContext ctx = WebContextFactory.get();
// HttpServletRequest req = ctx.getHttpServletRequest();
// VitroRequest vreq = new VitroRequest(req);
//
// return getUnfilteredWebappDaoFactory(vreq).getPropertyInstanceDao().writeProp(prop);
return -1;
}
public int insertProp( PropertyInstance prop) {
WebContext ctx = WebContextFactory.get();
HttpServletRequest req = ctx.getHttpServletRequest();

View file

@ -34,7 +34,7 @@ public class IndividualDataPropertyStatementProcessor implements ChangeListener
}
public void doDeleted(Object oldObj, EditProcessObject epo) {
// sunset all data property statements associated with entity
// do nothing
}
private void processDataprops (EditProcessObject epo) {

View file

@ -304,14 +304,6 @@ public class SelectListGenerator {
if (individuals.size()==0){
log.error("No individuals of type "+vclass.getName()+" to add to pick list in SelectListGenerator.getOptions(); check portal visibility");
optionsMap.put("", "No " + vclass.getName() + " found");
}else{
for( Individual ind : individuals ) {
// note that don't want the individual URI -- the option should hold 2 copies of the moniker //
if (ind.getMoniker()!=null && ind.getMoniker().trim().length()>0) {
optionsMap.put(ind.getMoniker(),ind.getMoniker().trim());
++optionsCount;
}
}
}
}
}

View file

@ -1,69 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.edit.validator.impl;
import java.util.Iterator;
import java.util.List;
import edu.cornell.mannlib.vedit.beans.EditProcessObject;
import edu.cornell.mannlib.vedit.validator.ValidationObject;
import edu.cornell.mannlib.vedit.validator.Validator;
import edu.cornell.mannlib.vitro.webapp.beans.Keyword;
import edu.cornell.mannlib.vitro.webapp.dao.KeywordDao;
import edu.cornell.mannlib.vitro.webapp.edit.listener.impl.KeywordPreProcessor;
import edu.cornell.mannlib.vitro.webapp.utils.Stemmer;
public class KeywordStemmerAndValidator implements Validator {
private int MAX_LENGTH = 32;
private EditProcessObject epo = null;
private KeywordDao kDao = null;
public KeywordStemmerAndValidator(EditProcessObject in, KeywordDao keywordDao) {
this.epo = in;
this.kDao = keywordDao;
}
public ValidationObject validate (Object obj) throws IllegalArgumentException {
ValidationObject vo = new ValidationObject();
if (obj==null || (obj instanceof String && ((String)obj).length()>0)) {
String keywordString = (String) obj;
String stemmedString = Stemmer.StemString(keywordString, MAX_LENGTH);
epo.getPreProcessorList().add(new KeywordPreProcessor(stemmedString));
List<Keyword> matches = kDao.getKeywordsByStem(stemmedString);
if (matches.size() > 0) {
vo.setValid(false);
String suggestionsStr = new String();
Iterator<Keyword> matchesIt = matches.iterator();
boolean first = true;
while (matchesIt.hasNext()) {
Keyword k = matchesIt.next();
if (!matchesIt.hasNext() && !first) {
suggestionsStr += "or ";
}
suggestionsStr += "'"+k.getTerm();
if (matchesIt.hasNext()) {
suggestionsStr += ",' ";
} else {
suggestionsStr += "'";
}
first = false;
}
vo.setMessage("Keyword identified as redundant. Please modify term or consider canceling and instead linking individual to existing keyword "+suggestionsStr);
} else {
vo.setValid(true);
}
} else {
vo.setValid(false);
vo.setMessage("Please enter a keyword.");
}
vo.setValidatedObject(obj);
return vo;
}
}

View file

@ -18,21 +18,11 @@ public class VitroSearchTermNames {
/** time of index in msec since epoc */
public static String INDEXEDTIME= "indexedTime";
/** timekey of entity in yyyymmddhhmm */
public static String TIMEKEY="TIMEKEY";
/** time of sunset/end of entity in yyyymmddhhmm */
public static String SUNSET="SUNSET";
/** time of sunrise/start of entity in yyyymmddhhmm */
public static String SUNRISE="SUNRISE";
/** entity's moniker */
public static String MONIKER="moniker";
/** text for 'full text' search, this is stemmed */
public static String ALLTEXT = "ALLTEXT";
/** text for 'full text' search, this is unstemmed for
* use with wildcards and prefix queries */
public static String ALLTEXTUNSTEMMED = "ALLTEXTUNSTEMMED";
/** keywords */
public static final String KEYWORDS = "KEYWORDS";
/** Does the individual have a thumbnail image? 1=yes 0=no */
public static final String THUMBNAIL = "THUMBNAIL";
/** Should individual be included in full text search results? 1=yes 0=no */

View file

@ -51,10 +51,7 @@ public abstract class VitroHighlighter extends UnaryFunctor<String,String> {
if( ent == null)
return;
ent.setBlurb( this.highlight(ent.getBlurb()));
ent.setName( this.highlight(ent.getName()));
ent.setMoniker( this.highlight(ent.getMoniker()));
ent.setDescription( this.highlight(ent.getDescription()));
Iterator edIt = ent.getDataPropertyStatements().iterator();
while (edIt.hasNext()) {
DataPropertyStatement dataPropertyStmt = (DataPropertyStatement)edIt.next();
@ -68,7 +65,6 @@ public abstract class VitroHighlighter extends UnaryFunctor<String,String> {
object.setName(this.highlight(object.getName()));
}
*/
highlightKeywords(ent);
}
/**
@ -83,21 +79,9 @@ public abstract class VitroHighlighter extends UnaryFunctor<String,String> {
//highlight the name, anchor and moniker and place back in entity object
if( ent.getName() != null )
ent.setName( highlight( stripHtml(ent.getName() )));
if( ent.getAnchor() != null )
ent.setAnchor( highlight( stripHtml(ent.getAnchor() )));
if( ent.getMoniker() != null )
ent.setMoniker( highlight( stripHtml(ent.getMoniker() )));
//make a buffer of text to use the fragmenting hightlighter on
StringBuffer sb = new StringBuffer("");
if(ent.getBlurb() != null){
sb.append(ent.getBlurb());
sb.append(' ');
}
if(ent.getDescription() != null ){
sb.append(ent.getDescription());
sb.append(' ');
}
if(ent.getDataPropertyStatements() != null) {
Iterator edIt = ent.getDataPropertyStatements().iterator();
while (edIt.hasNext()) {
@ -120,22 +104,6 @@ public abstract class VitroHighlighter extends UnaryFunctor<String,String> {
}
}
}
String keywords = ent.getKeywordString();
if( keywords != null )
sb.append(keywords);
ent.setDescription(getHighlightFragments( stripHtml( sb.toString() )));
}
private void highlightKeywords(Individual ent){
List<String> terms = ent.getKeywords();
if( terms == null || terms.size() == 0) return;
List<String> replacement = new ArrayList<String>(terms.size());
for(String term : ent.getKeywords()){
replacement.add( highlight(term ) );
}
ent.setKeywords(replacement);
}
private final String stripHtml(String in){

View file

@ -685,7 +685,6 @@ public class PagedSearchController extends FreemarkerHttpServlet implements Sear
VitroLuceneTermNames.NAME_STEMMED,
VitroLuceneTermNames.NAME_UNSTEMMED,
VitroLuceneTermNames.RDFTYPE,
VitroLuceneTermNames.MONIKER,
VitroLuceneTermNames.ALLTEXT,
VitroLuceneTermNames.ALLTEXTUNSTEMMED,
VitroLuceneTermNames.NAME_LOWERCASE,

View file

@ -52,14 +52,6 @@ public class Entity2LuceneDoc implements Obj2DocIface{
/** time of index in msec since epoc */
public static String INDEXEDTIME= "indexedTime";
/** timekey of entity in yyyymmddhhmm */
public static String TIMEKEY="TIMEKEY";
/** time of sunset/end of entity in yyyymmddhhmm */
public static String SUNSET="SUNSET";
/** time of sunrise/start of entity in yyyymmddhhmm */
public static String SUNRISE="SUNRISE";
/** entity's moniker */
public static String MONIKER="moniker";
/** text for 'full text' search, this is stemmed */
public static String ALLTEXT = "ALLTEXT";
/** text for 'full text' search, this is unstemmed for
@ -67,8 +59,6 @@ public class Entity2LuceneDoc implements Obj2DocIface{
public static String ALLTEXTUNSTEMMED = "ALLTEXTUNSTEMMED";
/** class name for storing context nodes **/
public static final String CONTEXTNODE = "contextNode";
/** keywords */
public static final String KEYWORDS = "KEYWORDS";
/** Does the individual have a thumbnail image? 1=yes 0=no */
public static final String THUMBNAIL = "THUMBNAIL";
/** Should individual be included in full text search results? 1=yes 0=no */
@ -255,13 +245,6 @@ public class Entity2LuceneDoc implements Obj2DocIface{
/* Field contextNodeInformation = new Field(term.CONTEXTNODE, contextNodePropertyValues, Field.Store.YES, Field.Index.ANALYZED );
doc.add(contextNodeInformation);*/
//Moniker
if(ent.getMoniker() != null){
Field moniker = new Field(term.MONIKER, ent.getMoniker(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
doc.add(moniker);
}
//boost for entity
if( ent.getSearchBoost() != null && ent.getSearchBoost() != 0 )
doc.setBoost(ent.getSearchBoost());
@ -273,18 +256,7 @@ public class Entity2LuceneDoc implements Obj2DocIface{
// } else {
// value= (new DateTime()).toString(LuceneIndexer.MODTIME_DATE_FORMAT) ;
// }
// doc.add( new Field(term.MODTIME, value , Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
/* timekey */
// try{
// value = null;
// if( ent.getTimekey() != null ){
// value = (new DateTime(ent.getTimekey().getTime())).toString(LuceneIndexer.DATE_FORMAT);
// doc.add(new Field(term.TIMEKEY, value, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
// }
// }catch(Exception ex){
// log.error("could not save timekey " + ex);
// }
// doc.add( new Field(term.MODTIME, value , Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS));
/* thumbnail */
try{
@ -309,10 +281,6 @@ public class Entity2LuceneDoc implements Obj2DocIface{
String t=null;
value ="";
value+= " "+( ((t=ent.getName()) == null)?"":t );
value+= " "+( ((t=ent.getAnchor()) == null)?"":t);
value+= " "+ ( ((t=ent.getMoniker()) == null)?"":t );
value+= " "+ ( ((t=ent.getDescription()) == null)?"":t );
value+= " "+ ( ((t=ent.getBlurb()) == null)?"":t );
value+= " "+ getKeyterms(ent);
value+= " " + classPublicNames;

View file

@ -254,53 +254,6 @@ public class LuceneSearcher implements Searcher {
close();
}
//bdc34 as of 2009-01-30, getting rid of time windows
// public synchronized Filter getTimeWindowCachingFilter(){
// if( timeWindowCachingFilter == null || timeWinCacheStale() ){
// Filter defaultFilter = new QueryFilter( makeDefaultTimeWindowQuery() );
// timeWindowCachingFilter = new CachingWrapperFilter( defaultFilter );
// timeWinFilterBorn = System.currentTimeMillis();
// log.debug("getTimeWindowCachingFilter() made new cache " + timeWinFilterBorn);
// }
// return timeWindowCachingFilter;
// }
//bdc34 as of 2009-01-30, getting rid of time windows
// private final long timeWinCacheShelfLife = ( 60 * 1000 ) * 1; //in msec
// private boolean timeWinCacheStale(){
// long dt = (System.currentTimeMillis() - timeWinFilterBorn);
// return dt > timeWinCacheShelfLife;
// }
//bdc34 as of 2009-01-30, getting rid of time windows
/**
* Adds a Query that will get doc where the
* SUNSET is > NOW and SUNRISE <= NOW. We'll do
* this by creating two RangeQueries, one to
* check that SUNRISE is between [BEGINNING_OF_TIME, NOW]
* and that SUNSET is between [NOW, END_OF_TIME]
* There don't seem to be any GraterThanQuery
* or LessThanQuery classes in lucene.
*/
// private BooleanQuery makeDefaultTimeWindowQuery(){
// String nowStr = new DateTime().toString(LuceneIndexer.DATE_FORMAT);
//
// Term BEGINNING_OF_TIME = null;
// Term now = new Term(Entity2LuceneDoc.term.SUNRISE,nowStr );
// RangeQuery sunriseBeforeNow = new RangeQuery(BEGINNING_OF_TIME,now, true);
//
// Term END_OF_TIME = null;
// now = new Term(Entity2LuceneDoc.term.SUNSET,nowStr);
// RangeQuery sunsetAfterNow = new RangeQuery(now,END_OF_TIME, false);
//
// BooleanQuery qRv = new BooleanQuery();
// qRv.add( sunriseBeforeNow, BooleanClause.Occur.MUST);
// qRv.add( sunsetAfterNow, BooleanClause.Occur.MUST);
//
// return qRv;
// }
/**
* We need access to the index to make a highligher because
* we need to 'rewrite' the query. That takes any wild cards

View file

@ -7,7 +7,6 @@ import static edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.Vi
import static edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames.CLASSLOCALNAME;
import static edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames.CLASSLOCALNAMELOWERCASE;
import static edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames.CONTEXTNODE;
import static edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames.MONIKER;
import static edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames.NAME_STEMMED;
import static edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames.NAME_UNSTEMMED;
import static edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc.VitroLuceneTermNames.RDFTYPE;
@ -255,7 +254,6 @@ public class LuceneSetup implements javax.servlet.ServletContextListener {
analyzer.addAnalyzer(ALLTEXTUNSTEMMED, new HtmlLowerStopAnalyzer());
analyzer.addAnalyzer(NAME_UNSTEMMED, new HtmlLowerStopAnalyzer());
analyzer.addAnalyzer(NAME_STEMMED, new HtmlLowerStopStemAnalyzer());
analyzer.addAnalyzer(MONIKER, new StandardAnalyzer(Version.LUCENE_29));
analyzer.addAnalyzer(RDFTYPE, new StandardAnalyzer(Version.LUCENE_29));
analyzer.addAnalyzer(CONTEXTNODE, new StandardAnalyzer(Version.LUCENE_29));
analyzer.addAnalyzer(CLASSLOCALNAME, new HtmlLowerStopAnalyzer());

View file

@ -151,9 +151,7 @@ public class IndividualToSolrDocument {
StringBuffer allTextValue = new StringBuffer();
allTextValue.append("");
allTextValue.append(" ");
allTextValue.append(((t=ind.getName()) == null)?"":t);
allTextValue.append(" ");
allTextValue.append(((t=ind.getAnchor()) == null)?"":t);
allTextValue.append(((t=ind.getName()) == null)?"":t);
allTextValue.append(" ");
allTextValue.append(classPublicNames);

View file

@ -17,6 +17,7 @@ import org.apache.solr.client.solrj.impl.XMLResponseParser;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.query.Dataset;
import com.hp.hpl.jena.query.DatasetFactory;
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
@ -73,8 +74,8 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
OntModel abox = ModelContext.getBaseOntModelSelector(context).getABoxModel();
OntModel inferences = (OntModel)context.getAttribute( JenaBaseDao.INFERENCE_ONT_MODEL_ATTRIBUTE_NAME);
Dataset dataset = WebappDaoFactoryJena.makeInMemoryDataset(abox, inferences);
Dataset dataset = DatasetFactory.create(ModelContext.getJenaOntModel(context));
OntModel jenaOntModel = ModelContext.getJenaOntModel(context);
List<DocumentModifier> modifiers = new ArrayList<DocumentModifier>();

View file

@ -65,20 +65,24 @@ public class ListedIndividualTemplateModel extends BaseTemplateModel {
return thumbUrl == null ? null : getUrl(thumbUrl);
}
@Deprecated
public Link getPrimaryLink() {
Link primaryLink = null;
String anchor = individual.getAnchor();
String url = individual.getUrl();
if ( !(StringUtils.isEmpty(anchor)) && !(StringUtils.isEmpty(url)) ) {
primaryLink = new Link();
primaryLink.setAnchor(anchor);
primaryLink.setUrl(url);
}
return primaryLink;
// Link primaryLink = null;
// String anchor = individual.getAnchor();
// String url = individual.getUrl();
// if ( !(StringUtils.isEmpty(anchor)) && !(StringUtils.isEmpty(url)) ) {
// primaryLink = new Link();
// primaryLink.setAnchor(anchor);
// primaryLink.setUrl(url);
// }
// return primaryLink;
return null;
}
@Deprecated
public List<Link> getAdditionalLinks() {
return individual.getLinksList(); // returns an empty list, but not null
// return individual.getLinksList(); // returns an empty list, but not null
return new ArrayList<Link>();
}
public List<Link> getLinks() {
@ -101,8 +105,10 @@ public class ListedIndividualTemplateModel extends BaseTemplateModel {
return individual.getName();
}
@Deprecated
public String getMoniker() {
return individual.getMoniker();
return "";
// return individual.getMoniker();
}
public String getUri() {