[VIVO-1031] Minor cleanup
This commit is contained in:
parent
a5084a614c
commit
c8818932a4
1 changed files with 16 additions and 42 deletions
|
@ -87,6 +87,7 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
WebappDaoFactorySDB wadf,
|
WebappDaoFactorySDB wadf,
|
||||||
Model initModel) {
|
Model initModel) {
|
||||||
this.individualURI = individualURI;
|
this.individualURI = individualURI;
|
||||||
|
this.webappDaoFactory = wadf;
|
||||||
this.dwf = datasetWrapperFactory;
|
this.dwf = datasetWrapperFactory;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -113,7 +114,6 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
OntModelSpec.OWL_MEM, model);
|
OntModelSpec.OWL_MEM, model);
|
||||||
this.ind = ontModel.createOntResource(individualURI);
|
this.ind = ontModel.createOntResource(individualURI);
|
||||||
setUpURIParts(ind);
|
setUpURIParts(ind);
|
||||||
this.webappDaoFactory = wadf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndividualSDB(String individualURI,
|
public IndividualSDB(String individualURI,
|
||||||
|
@ -124,17 +124,15 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
this.individualURI = individualURI;
|
this.individualURI = individualURI;
|
||||||
this.datasetMode = datasetMode;
|
this.datasetMode = datasetMode;
|
||||||
this.dwf = datasetWrapperFactory;
|
this.dwf = datasetWrapperFactory;
|
||||||
|
this.webappDaoFactory = wadf;
|
||||||
|
|
||||||
if (skipInitialization) {
|
if (skipInitialization) {
|
||||||
OntModel ontModel = ModelFactory.createOntologyModel(
|
OntModel ontModel = ModelFactory.createOntologyModel(
|
||||||
OntModelSpec.OWL_MEM);
|
OntModelSpec.OWL_MEM);
|
||||||
this.ind = ontModel.createOntResource(individualURI);
|
this.ind = ontModel.createOntResource(individualURI);
|
||||||
} else {
|
} else {
|
||||||
DatasetWrapper w = getDatasetWrapper();
|
|
||||||
Dataset dataset = w.getDataset();
|
|
||||||
try {
|
try {
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
String getStatements =
|
||||||
String getStatements =
|
|
||||||
"CONSTRUCT " +
|
"CONSTRUCT " +
|
||||||
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
|
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
|
||||||
"> ?ooo \n" +
|
"> ?ooo \n" +
|
||||||
|
@ -142,18 +140,10 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
|
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
|
||||||
"> ?ooo } \n" +
|
"> ?ooo } \n" +
|
||||||
"}";
|
"}";
|
||||||
model = QueryExecutionFactory.create(
|
|
||||||
QueryFactory.create(getStatements), dataset)
|
model = ModelFactory.createDefaultModel();
|
||||||
.execConstruct();
|
webappDaoFactory.getRDFService().sparqlConstructQuery(getStatements, model);
|
||||||
} finally {
|
} catch (RDFServiceException e) {
|
||||||
if (dataset == null) {
|
|
||||||
throw new RuntimeException("dataset is null");
|
|
||||||
} else if (dataset.getLock() == null) {
|
|
||||||
throw new RuntimeException("dataset lock is null");
|
|
||||||
}
|
|
||||||
|
|
||||||
dataset.getLock().leaveCriticalSection();
|
|
||||||
w.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OntModel ontModel = ModelFactory.createOntologyModel(
|
OntModel ontModel = ModelFactory.createOntologyModel(
|
||||||
|
@ -166,22 +156,15 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
this.ind = ontModel.createOntResource(individualURI);
|
this.ind = ontModel.createOntResource(individualURI);
|
||||||
}
|
}
|
||||||
setUpURIParts(ind);
|
setUpURIParts(ind);
|
||||||
this.webappDaoFactory = wadf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean noTriplesFor(String individualURI) {
|
private boolean noTriplesFor(String individualURI) {
|
||||||
DatasetWrapper w = getDatasetWrapper();
|
try {
|
||||||
Dataset dataset = w.getDataset();
|
return !webappDaoFactory.getRDFService().sparqlAskQuery("ASK { <" + individualURI + "> ?p ?o }");
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
} catch (RDFServiceException rse) {
|
||||||
try {
|
}
|
||||||
return !dataset.asDatasetGraph().contains(com.hp.hpl.jena.graph.Node.ANY,
|
|
||||||
NodeFactory.createURI(individualURI),
|
return true;
|
||||||
com.hp.hpl.jena.graph.Node.ANY,
|
|
||||||
com.hp.hpl.jena.graph.Node.ANY);
|
|
||||||
} finally {
|
|
||||||
dataset.getLock().leaveCriticalSection();
|
|
||||||
w.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static final boolean SKIP_INITIALIZATION = true;
|
static final boolean SKIP_INITIALIZATION = true;
|
||||||
|
@ -415,20 +398,11 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
"ASK { " +
|
"ASK { " +
|
||||||
" <" + individualURI + "> <http://vitro.mannlib.cornell.edu/ns/vitro/public#mainImage> ?mainImage . \n" +
|
" <" + individualURI + "> <http://vitro.mannlib.cornell.edu/ns/vitro/public#mainImage> ?mainImage . \n" +
|
||||||
" ?mainImage <http://vitro.mannlib.cornell.edu/ns/vitro/public#thumbnailImage> ?thumbImage . }\n" ;
|
" ?mainImage <http://vitro.mannlib.cornell.edu/ns/vitro/public#thumbnailImage> ?thumbImage . }\n" ;
|
||||||
DatasetWrapper w = getDatasetWrapper();
|
try{
|
||||||
Dataset dataset = w.getDataset();
|
_hasThumb = webappDaoFactory.getRDFService().sparqlAskQuery(ask);
|
||||||
dataset.getLock().enterCriticalSection(Lock.READ);
|
|
||||||
QueryExecution qexec = null;
|
|
||||||
try{
|
|
||||||
qexec = QueryExecutionFactory.create(QueryFactory.create(ask), dataset);
|
|
||||||
_hasThumb = qexec.execAsk();
|
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
_hasThumb = false;
|
_hasThumb = false;
|
||||||
log.error(ex,ex);
|
log.error(ex,ex);
|
||||||
}finally{
|
|
||||||
if(qexec!=null) qexec.close();
|
|
||||||
dataset.getLock().leaveCriticalSection();
|
|
||||||
w.close();
|
|
||||||
}
|
}
|
||||||
return _hasThumb;
|
return _hasThumb;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue