NIHVIVO-3 code for getUnusedURI in permanent URI tool updated.

This commit is contained in:
ass92 2010-07-13 12:31:50 +00:00
parent 1ff00fa92f
commit 4b2da00daf

View file

@ -949,17 +949,19 @@ public class JenaIngestController extends BaseEditController {
} }
private String getUnusedURI(String newNamespace){ private String getUnusedURI(String newNamespace){
String uri = null; String uri = null;
SimpleOntModelSelector getModel = new SimpleOntModelSelector();
OntModel fullModel = getModel.getABoxModel();
Random random = new Random(); Random random = new Random();
Resource res = null; boolean resourcePresent=true;
boolean check=true; OntModel vitroJenaModel = (OntModel) getServletContext().getAttribute("baseOntModel");
log.info("Going into loop"); log.info("Going into loop");
Resource res = null;
do{ do{
uri = newNamespace + "individual" + random.nextInt(); uri = newNamespace + "individual" + random.nextInt();
res = fullModel.getResource(uri); res = vitroJenaModel.getResource(uri);
check = fullModel.containsResource(res); StmtIterator stmtItr1 = vitroJenaModel.listStatements(res,(Property)null,(RDFNode)null);
}while(check==true); if(!stmtItr1.hasNext()){
resourcePresent=false;
}
}while(resourcePresent);
log.info("url assigned"); log.info("url assigned");
res.removeAll((Property)null); res.removeAll((Property)null);
return uri; return uri;