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

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