Changing getAllPossibleDataPropsForIndividual to only call getVClasses once. NIHVIVO-2002
This commit is contained in:
parent
dad29a5516
commit
0c6aa67e06
1 changed files with 66 additions and 56 deletions
|
@ -418,9 +418,10 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||||
public Collection<DataProperty> getAllPossibleDatapropsForIndividual(String individualURI) {
|
public Collection<DataProperty> getAllPossibleDatapropsForIndividual(String individualURI) {
|
||||||
Individual ind = getWebappDaoFactory().getIndividualDao().getIndividualByURI(individualURI);
|
Individual ind = getWebappDaoFactory().getIndividualDao().getIndividualByURI(individualURI);
|
||||||
Collection<DataProperty> dpColl = new ArrayList<DataProperty>();
|
Collection<DataProperty> dpColl = new ArrayList<DataProperty>();
|
||||||
try {
|
List<String> vclassURIs = getVClassURIs(ind);
|
||||||
for (VClass currClass : ind.getVClasses(true)) {
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
for (VClass currClass : ind.getVClasses( DIRECT )) {
|
||||||
List<DataProperty> currList = getDatapropsForClass(currClass.getURI());
|
List<DataProperty> currList = getDatapropsForClass(currClass.getURI());
|
||||||
for (Iterator<DataProperty> dpIter = currList.iterator(); dpIter.hasNext();) {
|
for (Iterator<DataProperty> dpIter = currList.iterator(); dpIter.hasNext();) {
|
||||||
DataProperty dp = (DataProperty) dpIter.next();
|
DataProperty dp = (DataProperty) dpIter.next();
|
||||||
|
@ -444,7 +445,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||||
// now change range datatype based on individual
|
// now change range datatype based on individual
|
||||||
// TODO: rethink all these methods to reduce inefficiency
|
// TODO: rethink all these methods to reduce inefficiency
|
||||||
for (DataProperty dp : dpColl) {
|
for (DataProperty dp : dpColl) {
|
||||||
dp.setRangeDatatypeURI(getRequiredDatatypeURI(ind, dp));
|
dp.setRangeDatatypeURI(getRequiredDatatypeURI(ind, dp, vclassURIs));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ProfileException pe) {
|
} catch (ProfileException pe) {
|
||||||
|
@ -466,20 +467,10 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRequiredDatatypeURI(Individual individual, DataProperty dataprop) {
|
private String getRequiredDatatypeURI(Individual individual, DataProperty dataprop, List<String> vclassURIs) {
|
||||||
OntModel ontModel = getOntModelSelector().getFullModel();
|
OntModel ontModel = getOntModelSelector().getFullModel();
|
||||||
String datatypeURI = dataprop.getRangeDatatypeURI();
|
String datatypeURI = dataprop.getRangeDatatypeURI();
|
||||||
List<String> vclassURIs = null;
|
|
||||||
if (reasoningAvailable()) {
|
|
||||||
vclassURIs = new ArrayList<String>();
|
|
||||||
for (VClass vc : individual.getVClasses(INDIRECT)) {
|
|
||||||
if (vc.getURI() != null) {
|
|
||||||
vclassURIs.add(vc.getURI());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
vclassURIs = getSupertypeURIs(individual);
|
|
||||||
}
|
|
||||||
ontModel.enterCriticalSection(Lock.READ);
|
ontModel.enterCriticalSection(Lock.READ);
|
||||||
try {
|
try {
|
||||||
// get universal restrictions applicable to data property
|
// get universal restrictions applicable to data property
|
||||||
|
@ -521,6 +512,25 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||||
return datatypeURI;
|
return datatypeURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRequiredDatatypeURI(Individual individual, DataProperty dataprop) {
|
||||||
|
return getRequiredDatatypeURI(individual,dataprop,getVClassURIs(individual));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getVClassURIs(Individual individual){
|
||||||
|
List<String> vclassURIs = null;
|
||||||
|
if (reasoningAvailable()) {
|
||||||
|
vclassURIs = new ArrayList<String>();
|
||||||
|
for (VClass vc : individual.getVClasses(INDIRECT)) {
|
||||||
|
if (vc.getURI() != null) {
|
||||||
|
vclassURIs.add(vc.getURI());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vclassURIs = getSupertypeURIs(individual);
|
||||||
|
}
|
||||||
|
return vclassURIs;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean DIRECT = true;
|
private boolean DIRECT = true;
|
||||||
private boolean INDIRECT = !DIRECT;
|
private boolean INDIRECT = !DIRECT;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue