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){
String uri = null;
SimpleOntModelSelector getModel = new SimpleOntModelSelector();
OntModel fullModel = getModel.getABoxModel();
Random random = new Random();
Resource res = null;
boolean check=true;
boolean resourcePresent=true;
OntModel vitroJenaModel = (OntModel) getServletContext().getAttribute("baseOntModel");
log.info("Going into loop");
Resource res = null;
do{
uri = newNamespace + "individual" + random.nextInt();
res = fullModel.getResource(uri);
check = fullModel.containsResource(res);
}while(check==true);
res = vitroJenaModel.getResource(uri);
StmtIterator stmtItr1 = vitroJenaModel.listStatements(res,(Property)null,(RDFNode)null);
if(!stmtItr1.hasNext()){
resourcePresent=false;
}
}while(resourcePresent);
log.info("url assigned");
res.removeAll((Property)null);
return uri;