Merging from branch. Adding getRdfsLabel() to Individual and subclasses. NIHVIVO-836

This commit is contained in:
bdc34 2010-07-21 14:44:36 +00:00
parent 7bb0dc1095
commit d565eca6b6
6 changed files with 221 additions and 0 deletions

View file

@ -19,6 +19,13 @@ public interface Individual extends ResourceBean, VitroTimeWindowedResource, Com
String getName();
void setName(String in);
/**
* Returns an rdfs:label if there is one on the individual. Returns null
* if none can be found. If more than one rdfs:label can be found for the individual
* one of the labels will be returned, which one is undefined.
*/
String getRdfsLabel();
String getVClassURI();
void setVClassURI(String in);

View file

@ -25,6 +25,7 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
protected static final String NOT_INITIALIZED = "__%NOT_INITIALIZED%__";
public String name = null;
protected String rdfsLabel = null;
public String vClassURI = null;
protected VClass vClass = null;
protected List<VClass> directVClasses = null;
@ -81,6 +82,9 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
public String getName(){return name;}
public void setName(String in){name=in;}
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;}

View file

@ -292,6 +292,9 @@ public class IndividualFiltering implements Individual {
return _innerIndividual.getName();
}
public String getRdfsLabel(){
return _innerIndividual.getRdfsLabel();
}
public String getNamespace() {
return _innerIndividual.getNamespace();

View file

@ -50,6 +50,7 @@ public class IndividualJena extends IndividualImpl implements Individual {
private OntResource ind = null;
private WebappDaoFactoryJena webappDaoFactory = null;
private Float _searchBoostJena = null;
private boolean retreivedNullRdfsLabel = false;
public IndividualJena(OntResource ind, WebappDaoFactoryJena wadf) {
this.ind = ind;
@ -81,6 +82,23 @@ public class IndividualJena extends IndividualImpl implements Individual {
}
}
public String getRdfsLabel() {
if (this.rdfsLabel != null) {
return rdfsLabel;
} else if( this.rdfsLabel == null && retreivedNullRdfsLabel ){
return null;
} else {
ind.getOntModel().enterCriticalSection(Lock.READ);
try {
this.rdfsLabel = webappDaoFactory.getJenaBaseDao().getLabel(ind);
retreivedNullRdfsLabel = this.rdfsLabel == null;
return this.rdfsLabel;
} finally {
ind.getOntModel().leaveCriticalSection();
}
}
}
public String getVClassURI() {
if (this.vClassURI != null) {
return vClassURI;