merging in changes from NIHVIVO-1191 and NIHVIVO-1195 from the 1.1.1 branch
This commit is contained in:
parent
b02bfa8191
commit
9e1a84e174
2 changed files with 134 additions and 47 deletions
|
@ -60,7 +60,7 @@ public class VClass extends BaseResourceBean implements Comparable<VClass>
|
||||||
public void setQuickEditJsp(String quickEditJsp) { this.quickEditJsp = quickEditJsp; }
|
public void setQuickEditJsp(String quickEditJsp) { this.quickEditJsp = quickEditJsp; }
|
||||||
|
|
||||||
protected Integer displayRank = null;
|
protected Integer displayRank = null;
|
||||||
public int getDisplayRank() { return (displayLimit == null ? -1 : displayLimit); }
|
public int getDisplayRank() { return (displayRank == null ? -1 : displayRank); }
|
||||||
public void setDisplayRank(int displayRank) { this.displayRank = displayRank; }
|
public void setDisplayRank(int displayRank) { this.displayRank = displayRank; }
|
||||||
|
|
||||||
protected String groupURI = null;
|
protected String groupURI = null;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import com.hp.hpl.jena.ontology.AllValuesFromRestriction;
|
import com.hp.hpl.jena.ontology.AllValuesFromRestriction;
|
||||||
|
import com.hp.hpl.jena.ontology.AnnotationProperty;
|
||||||
import com.hp.hpl.jena.ontology.CardinalityRestriction;
|
import com.hp.hpl.jena.ontology.CardinalityRestriction;
|
||||||
import com.hp.hpl.jena.ontology.ComplementClass;
|
import com.hp.hpl.jena.ontology.ComplementClass;
|
||||||
import com.hp.hpl.jena.ontology.HasValueRestriction;
|
import com.hp.hpl.jena.ontology.HasValueRestriction;
|
||||||
|
@ -33,6 +34,7 @@ import com.hp.hpl.jena.rdf.model.Resource;
|
||||||
import com.hp.hpl.jena.rdf.model.Statement;
|
import com.hp.hpl.jena.rdf.model.Statement;
|
||||||
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
import com.hp.hpl.jena.rdf.model.StmtIterator;
|
||||||
import com.hp.hpl.jena.shared.Lock;
|
import com.hp.hpl.jena.shared.Lock;
|
||||||
|
import com.hp.hpl.jena.util.iterator.ClosableIterator;
|
||||||
import com.hp.hpl.jena.vocabulary.RDFS;
|
import com.hp.hpl.jena.vocabulary.RDFS;
|
||||||
|
|
||||||
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
|
import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean;
|
||||||
|
@ -42,6 +44,7 @@ import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -50,18 +53,24 @@ public class VClassJenaTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
// NIHVIVO-1157 introduced VClassJena.java, a lazy-loading version of VClass.java.
|
// NIHVIVO-1157 introduced VClassJena.java, a lazy-loading version of VClass.java.
|
||||||
// Per instructions from Brian L., this test tests that for onw randomly selected Class,
|
// Per instructions from Brian L., this test tests that for one randomly selected Class,
|
||||||
// the getter methods in VClassJena return the same values as would have been
|
// the getter methods in VClassJena return the same values as would have been
|
||||||
// returned by the pre-NIHVIVO-1157 VClass (which would have been set by the
|
// returned by the pre-NIHVIVO-1157 VClass (which would have been set by the
|
||||||
// (now deleted) vClassWebappFromOntClass inner class in VClassDaoJena).
|
// (now deleted) vClassWebappFromOntClass inner class in VClassDaoJena).
|
||||||
|
//
|
||||||
|
// Note: I think this might be a better test (at least easier to read, and
|
||||||
|
// maybe more stable) if the values returned by the VClassJena getter methods
|
||||||
|
// are tested against hard-coded values (which could be set now based on the
|
||||||
|
// model code)
|
||||||
|
|
||||||
public void correctValues(){
|
public void correctValues(){
|
||||||
|
|
||||||
// 1. create a model and populate it with the data for one class
|
// 1. create a model and populate it with the data for one class
|
||||||
// 2. populate a VClass instance as it would have been populated pre-NIHVIVO-1157
|
// 2. retrieve the OntClass for the target class by URI
|
||||||
// 3. populate a VClassJena instance with the current system code
|
// 3. populate a VClass instance from the OntClass instance, as it would have been
|
||||||
// 4. verify that the getter methods on the VClassJena and VClass instances return the same values
|
// populated pre-NIHVIVO-1157 (with the deleted vClassWebappFromOntClass, copied here)
|
||||||
|
// 4. populate a VClassJena instance as is done with the current application code
|
||||||
|
// 5. verify that the getter methods on the VClassJena and VClass instances return the same values
|
||||||
|
|
||||||
String class1URI = "http://test.vivo/AcademicDegree";
|
String class1URI = "http://test.vivo/AcademicDegree";
|
||||||
|
|
||||||
|
@ -91,25 +100,31 @@ public class VClassJenaTest {
|
||||||
|
|
||||||
WebappDaoFactoryJena wadf = new WebappDaoFactoryJena(ontModel);
|
WebappDaoFactoryJena wadf = new WebappDaoFactoryJena(ontModel);
|
||||||
|
|
||||||
// Populate a VClass instance...
|
// Populate a VClass instance...old style
|
||||||
|
|
||||||
VClassDaoJena vcdj = (VClassDaoJena) wadf.getVClassDao();
|
VClass vClass = vClassWebappFromOntClass(class1,wadf);
|
||||||
VClass vClass = new VClass();
|
|
||||||
|
|
||||||
|
// Populate a VClassJena instance...modern style
|
||||||
//VClass vClass = vcdj.getVClassByURI(class1URI);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Populate a VClassJena instance...
|
|
||||||
|
|
||||||
VClassJena vClassJena = new VClassJena(class1, wadf);
|
VClassJena vClassJena = new VClassJena(class1, wadf);
|
||||||
|
|
||||||
|
|
||||||
// Check that the getters from the VClass and the VClassJena return the same values
|
// Check that the getters from the VClass and the VClassJena return the same values
|
||||||
//Assert.assertEquals(vClassJena.getName(), vClass.getName());
|
|
||||||
|
|
||||||
|
|
||||||
|
Assert.assertEquals(vClassJena.getName(), vClass.getName());
|
||||||
|
Assert.assertEquals(vClassJena.getLocalNameWithPrefix(), vClass.getLocalNameWithPrefix());
|
||||||
|
Assert.assertEquals(vClassJena.getPickListName(), vClass.getPickListName());
|
||||||
|
Assert.assertEquals(vClassJena.getExample(), vClass.getExample());
|
||||||
|
Assert.assertEquals(vClassJena.getDescription(), vClass.getDescription());
|
||||||
|
Assert.assertEquals(vClassJena.getShortDef(), vClass.getShortDef());
|
||||||
|
Assert.assertEquals(vClassJena.getDisplayRank(), vClass.getDisplayRank());
|
||||||
|
Assert.assertEquals(vClassJena.getGroupURI(), vClass.getGroupURI());
|
||||||
|
Assert.assertEquals(vClassJena.getCustomEntryForm(), vClass.getCustomEntryForm());
|
||||||
|
Assert.assertEquals(vClassJena.getCustomShortView(), vClass.getCustomShortView());
|
||||||
|
Assert.assertEquals(vClassJena.getCustomSearchView(), vClass.getCustomSearchView());
|
||||||
|
Assert.assertEquals(vClassJena.getSearchBoost(), vClass.getSearchBoost());
|
||||||
|
Assert.assertEquals(vClassJena.getHiddenFromDisplayBelowRoleLevel(), vClass.getHiddenFromDisplayBelowRoleLevel());
|
||||||
|
Assert.assertEquals(vClassJena.getProhibitedFromUpdateBelowRoleLevel(), vClass.getProhibitedFromUpdateBelowRoleLevel());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,17 +139,31 @@ public class VClassJenaTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
// The following class and methods are pre-NIHVIVO-1157 code for
|
// The following class and methods are pre-NIHVIVO-1157 code for
|
||||||
// populating a VClass. Original comments included.
|
// populating a VClass. Original comments included.
|
||||||
|
|
||||||
private VClass vClassWebappFromOntClass(OntClass cls) {
|
private OntModel _constModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
|
||||||
|
protected AnnotationProperty LOCAL_SHORTDEF = _constModel.createAnnotationProperty(VitroVocabulary.SHORTDEF);
|
||||||
|
protected AnnotationProperty LOCAL_DESCRIPTION_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.DESCRIPTION_ANNOT);
|
||||||
|
protected AnnotationProperty LOCAL_DISPLAY_LIMIT = _constModel.createAnnotationProperty(VitroVocabulary.DISPLAY_LIMIT);
|
||||||
|
protected AnnotationProperty LOCAL_EXAMPLE_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.EXAMPLE_ANNOT);
|
||||||
|
protected AnnotationProperty LOCAL_DISPLAY_RANK_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.DISPLAY_RANK_ANNOT);
|
||||||
|
protected AnnotationProperty LOCAL_SEARCH_BOOST_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.SEARCH_BOOST_ANNOT);
|
||||||
|
protected AnnotationProperty LOCAL_PROPERTY_CUSTOMENTRYFORMANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOMENTRYFORMANNOT);
|
||||||
|
protected AnnotationProperty LOCAL_PROPERTY_CUSTOMDISPLAYVIEWANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOMDISPLAYVIEWANNOT);
|
||||||
|
protected AnnotationProperty LOCAL_PROPERTY_CUSTOMSHORTVIEWANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOMSHORTVIEWANNOT);
|
||||||
|
protected AnnotationProperty LOCAL_PROPERTY_CUSTOMSEARCHVIEWANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROPERTY_CUSTOMSEARCHVIEWANNOT);
|
||||||
|
protected AnnotationProperty LOCAL_HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
|
||||||
|
protected AnnotationProperty LOCAL_PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT = _constModel.createAnnotationProperty(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
|
||||||
|
protected AnnotationProperty LOCAL_IN_CLASSGROUP = _constModel.createAnnotationProperty(VitroVocabulary.IN_CLASSGROUP);
|
||||||
|
|
||||||
|
|
||||||
|
private VClass vClassWebappFromOntClass(OntClass cls, WebappDaoFactoryJena wadf) {
|
||||||
VClass vcw = new VClass();
|
VClass vcw = new VClass();
|
||||||
cls.getModel().enterCriticalSection(Lock.READ);
|
cls.getModel().enterCriticalSection(Lock.READ);
|
||||||
vcw.setName(getLabelForClass(cls,false,false));
|
vcw.setName(getLabelForClass(cls,false,false,wadf));
|
||||||
vcw.setLocalNameWithPrefix(getLabelForClass(cls,true,false));
|
vcw.setLocalNameWithPrefix(getLabelForClass(cls,true,false,wadf));
|
||||||
vcw.setPickListName(getLabelForClass(cls,false,true));
|
vcw.setPickListName(getLabelForClass(cls,false,true,wadf));
|
||||||
try {
|
try {
|
||||||
if (cls.isAnon()) {
|
if (cls.isAnon()) {
|
||||||
vcw.setNamespace(VitroVocabulary.PSEUDO_BNODE_NS);
|
vcw.setNamespace(VitroVocabulary.PSEUDO_BNODE_NS);
|
||||||
|
@ -147,26 +176,27 @@ public class VClassJenaTest {
|
||||||
vcw.setLocalName(cls.getLocalName());
|
vcw.setLocalName(cls.getLocalName());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Resource groupRes = (Resource) cls.getPropertyValue(VitroVocabulary.IN_CLASSGROUP);
|
Resource groupRes = (Resource) cls.getPropertyValue(LOCAL_IN_CLASSGROUP);
|
||||||
if (groupRes != null) {
|
if (groupRes != null) {
|
||||||
vcw.setGroupURI(groupRes.getURI());
|
vcw.setGroupURI(groupRes.getURI());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("error retrieving vitro:inClassGroup property value for "+cls.getURI());
|
System.out.println("error retrieving vitro:inClassGroup property value for "+cls.getURI());
|
||||||
}
|
}
|
||||||
vcw.setShortDef(getPropertyStringValue(cls,VitroVocabulary.SHORTDEF));
|
|
||||||
vcw.setExample(getPropertyStringValue(cls,VitroVocabulary.EXAMPLE_ANNOT));
|
vcw.setShortDef(getPropertyStringValue(cls,LOCAL_SHORTDEF));
|
||||||
vcw.setDescription(getPropertyStringValue(cls,VitroVocabulary.DESCRIPTION_ANNOT));
|
vcw.setExample(getPropertyStringValue(cls,LOCAL_EXAMPLE_ANNOT));
|
||||||
vcw.setDisplayLimit(getPropertyNonNegativeIntValue(cls,VitroVocabulary.DISPLAY_LIMIT));
|
vcw.setDescription(getPropertyStringValue(cls,LOCAL_DESCRIPTION_ANNOT));
|
||||||
vcw.setDisplayRank(getPropertyNonNegativeIntValue(cls,VitroVocabulary.DISPLAY_RANK_ANNOT));
|
vcw.setDisplayLimit(getPropertyNonNegativeIntValue(cls,LOCAL_DISPLAY_LIMIT));
|
||||||
vcw.setCustomEntryForm(getPropertyStringValue(cls,VitroVocabulary.PROPERTY_CUSTOMENTRYFORMANNOT));
|
vcw.setDisplayRank(getPropertyNonNegativeIntValue(cls,LOCAL_DISPLAY_RANK_ANNOT));
|
||||||
vcw.setCustomDisplayView(getPropertyStringValue(cls,VitroVocabulary.PROPERTY_CUSTOMDISPLAYVIEWANNOT));
|
vcw.setCustomEntryForm(getPropertyStringValue(cls,LOCAL_PROPERTY_CUSTOMENTRYFORMANNOT));
|
||||||
vcw.setCustomShortView(getPropertyStringValue(cls,VitroVocabulary.PROPERTY_CUSTOMSHORTVIEWANNOT));
|
vcw.setCustomDisplayView(getPropertyStringValue(cls,LOCAL_PROPERTY_CUSTOMDISPLAYVIEWANNOT));
|
||||||
vcw.setCustomSearchView(getPropertyStringValue(cls,VitroVocabulary.PROPERTY_CUSTOMSEARCHVIEWANNOT));
|
vcw.setCustomShortView(getPropertyStringValue(cls,LOCAL_PROPERTY_CUSTOMSHORTVIEWANNOT));
|
||||||
vcw.setSearchBoost(getPropertyFloatValue(cls,VitroVocabulary.SEARCH_BOOST_ANNOT));
|
vcw.setCustomSearchView(getPropertyStringValue(cls,LOCAL_PROPERTY_CUSTOMSEARCHVIEWANNOT));
|
||||||
|
vcw.setSearchBoost(getPropertyFloatValue(cls,LOCAL_SEARCH_BOOST_ANNOT));
|
||||||
|
|
||||||
//There might be multiple HIDDEN_FROM_EDIT_DISPLAY_ANNOT properties, only use the highest
|
//There might be multiple HIDDEN_FROM_EDIT_DISPLAY_ANNOT properties, only use the highest
|
||||||
StmtIterator it = cls.listProperties(VitroVocabulary.HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
|
StmtIterator it = cls.listProperties(LOCAL_HIDDEN_FROM_DISPLAY_BELOW_ROLE_LEVEL_ANNOT);
|
||||||
BaseResourceBean.RoleLevel hiddenRoleLevel = null;
|
BaseResourceBean.RoleLevel hiddenRoleLevel = null;
|
||||||
while( it.hasNext() ){
|
while( it.hasNext() ){
|
||||||
Statement stmt = it.nextStatement();
|
Statement stmt = it.nextStatement();
|
||||||
|
@ -185,7 +215,7 @@ public class VClassJenaTest {
|
||||||
vcw.setHiddenFromDisplayBelowRoleLevel(hiddenRoleLevel);//this might get set to null
|
vcw.setHiddenFromDisplayBelowRoleLevel(hiddenRoleLevel);//this might get set to null
|
||||||
|
|
||||||
//There might be multiple PROHIBITED_FROM_UPDATE_DISPLAY_ANNOT properties, only use the highest
|
//There might be multiple PROHIBITED_FROM_UPDATE_DISPLAY_ANNOT properties, only use the highest
|
||||||
it = cls.listProperties(VitroVocabulary.PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
|
it = cls.listProperties(LOCAL_PROHIBITED_FROM_UPDATE_BELOW_ROLE_LEVEL_ANNOT);
|
||||||
BaseResourceBean.RoleLevel prohibitedRoleLevel = null;
|
BaseResourceBean.RoleLevel prohibitedRoleLevel = null;
|
||||||
while( it.hasNext() ){
|
while( it.hasNext() ){
|
||||||
Statement stmt = it.nextStatement();
|
Statement stmt = it.nextStatement();
|
||||||
|
@ -222,7 +252,7 @@ public class VClassJenaTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getLabelForClass(OntClass cls,boolean withPrefix,boolean forPickList) {
|
public String getLabelForClass(OntClass cls,boolean withPrefix,boolean forPickList,WebappDaoFactoryJena wadf) {
|
||||||
cls.getModel().enterCriticalSection(Lock.READ);
|
cls.getModel().enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
if (cls.isAnon()) {
|
if (cls.isAnon()) {
|
||||||
|
@ -243,7 +273,7 @@ public class VClassJenaTest {
|
||||||
}
|
}
|
||||||
if (fillerRes.canAs(OntClass.class)) {
|
if (fillerRes.canAs(OntClass.class)) {
|
||||||
OntClass avf = (OntClass) fillerRes.as(OntClass.class);
|
OntClass avf = (OntClass) fillerRes.as(OntClass.class);
|
||||||
labelStr += getLabelForClass(avf,withPrefix,forPickList);
|
labelStr += getLabelForClass(avf,withPrefix,forPickList,wadf);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
labelStr += getLabelOrId( (OntResource) fillerRes.as(OntResource.class));
|
labelStr += getLabelOrId( (OntResource) fillerRes.as(OntResource.class));
|
||||||
|
@ -283,12 +313,12 @@ public class VClassJenaTest {
|
||||||
if (cls.isComplementClass()) {
|
if (cls.isComplementClass()) {
|
||||||
labelStr += "not ";
|
labelStr += "not ";
|
||||||
ComplementClass ccls = (ComplementClass) cls.as(ComplementClass.class);
|
ComplementClass ccls = (ComplementClass) cls.as(ComplementClass.class);
|
||||||
labelStr += getLabelForClass(ccls.getOperand(),withPrefix,forPickList);
|
labelStr += getLabelForClass(ccls.getOperand(),withPrefix,forPickList,wadf);
|
||||||
} else if (cls.isIntersectionClass()) {
|
} else if (cls.isIntersectionClass()) {
|
||||||
IntersectionClass icls = (IntersectionClass) cls.as(IntersectionClass.class);
|
IntersectionClass icls = (IntersectionClass) cls.as(IntersectionClass.class);
|
||||||
for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) {
|
for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) {
|
||||||
OntClass operand = (OntClass) operandIt.next();
|
OntClass operand = (OntClass) operandIt.next();
|
||||||
labelStr += getLabelForClass(operand,withPrefix,forPickList);
|
labelStr += getLabelForClass(operand,withPrefix,forPickList,wadf);
|
||||||
if (operandIt.hasNext()) {
|
if (operandIt.hasNext()) {
|
||||||
labelStr += " and ";
|
labelStr += " and ";
|
||||||
}
|
}
|
||||||
|
@ -297,7 +327,7 @@ public class VClassJenaTest {
|
||||||
UnionClass icls = (UnionClass) cls.as(UnionClass.class);
|
UnionClass icls = (UnionClass) cls.as(UnionClass.class);
|
||||||
for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) {
|
for (Iterator operandIt = icls.listOperands(); operandIt.hasNext();) {
|
||||||
OntClass operand = (OntClass) operandIt.next();
|
OntClass operand = (OntClass) operandIt.next();
|
||||||
labelStr += getLabelForClass(operand,withPrefix,forPickList);
|
labelStr += getLabelForClass(operand,withPrefix,forPickList,wadf);
|
||||||
if (operandIt.hasNext()) {
|
if (operandIt.hasNext()) {
|
||||||
labelStr += " or ";
|
labelStr += " or ";
|
||||||
}
|
}
|
||||||
|
@ -312,7 +342,7 @@ public class VClassJenaTest {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (withPrefix || forPickList) {
|
if (withPrefix || forPickList) {
|
||||||
OntologyDao oDao=getWebappDaoFactory().getOntologyDao();
|
OntologyDao oDao=wadf.getOntologyDao();
|
||||||
Ontology o = (Ontology)oDao.getOntologyByURI(cls.getNameSpace());
|
Ontology o = (Ontology)oDao.getOntologyByURI(cls.getNameSpace());
|
||||||
if (o!=null) {
|
if (o!=null) {
|
||||||
if (withPrefix) {
|
if (withPrefix) {
|
||||||
|
@ -346,13 +376,13 @@ public class VClassJenaTest {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
private final boolean ALSO_TRY_NO_LANG = true;
|
private final boolean ALSO_TRY_NO_LANG = true;
|
||||||
/**
|
/**
|
||||||
* works through list of PREFERRED_LANGUAGES to find an appropriate
|
* works through list of PREFERRED_LANGUAGES to find an appropriate
|
||||||
* label, or NULL if not found.
|
* label, or NULL if not found.
|
||||||
*/
|
*/
|
||||||
/*
|
|
||||||
protected String getLabel(OntResource r){
|
protected String getLabel(OntResource r){
|
||||||
String label = null;
|
String label = null;
|
||||||
r.getOntModel().enterCriticalSection(Lock.READ);
|
r.getOntModel().enterCriticalSection(Lock.READ);
|
||||||
|
@ -402,7 +432,7 @@ public class VClassJenaTest {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Get the local name, bnode or URI of the resource.
|
* Get the local name, bnode or URI of the resource.
|
||||||
*/
|
*/
|
||||||
|
@ -425,4 +455,61 @@ public class VClassJenaTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected String getPropertyStringValue(OntResource res, Property dataprop) {
|
||||||
|
if (dataprop != null) {
|
||||||
|
try {
|
||||||
|
ClosableIterator stateIt = res.getModel().listStatements(res,dataprop,(Literal)null);
|
||||||
|
try {
|
||||||
|
if (stateIt.hasNext())
|
||||||
|
return ((Literal)((Statement)stateIt.next()).getObject()).getString();
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
stateIt.close();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getPropertyNonNegativeIntValue(OntResource res, Property dataprop) {
|
||||||
|
|
||||||
|
if (dataprop != null) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
return ((Literal)res.getPropertyValue(dataprop)).getInt();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Float getPropertyFloatValue(OntResource res, Property prop){
|
||||||
|
if( prop != null ){
|
||||||
|
try{
|
||||||
|
return new Float( ((Literal)res.getPropertyValue(prop)).getFloat() );
|
||||||
|
}catch(Exception e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isBooleanClassExpression(OntClass cls) {
|
||||||
|
return (cls.isComplementClass() || cls.isIntersectionClass() || cls.isUnionClass());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getClassURIStr(Resource cls) {
|
||||||
|
if (cls.isAnon()) {
|
||||||
|
return VitroVocabulary.PSEUDO_BNODE_NS+cls.getId().toString();
|
||||||
|
} else {
|
||||||
|
return cls.getURI();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue