27
28
import org.vivoweb.harvester.util.repo.JenaConnect;
28
29
import org.vivoweb.harvester.util.repo.MemJenaConnect;
29
30
import org.vivoweb.harvester.util.repo.TDBJenaConnect;
31
import org.apache.commons.lang.time.StopWatch;
30
32
import com.hp.hpl.jena.query.Dataset;
31
33
import com.hp.hpl.jena.query.Query;
32
34
import com.hp.hpl.jena.query.QueryExecution;
424
426
* @throws IOException error connecting to the models
426
428
private Set<Map<String, String>> buildSolutionSet() throws IOException {
430
StopWatch stopWatch = new StopWatch();
427
432
if (this.matchThreshold != null) {
428
433
return buildFilterSolutionSet();
430
435
ResultSet rs = getResultSet();
436
Set<String> runNames = this.vivoPredicates.keySet();
432
437
Set<Map<String, String>> solSet = getNewSolSet();
435
440
log.info("No Results Found");
437
442
log.info("Building Record Set");
438
444
Map<String, String> tempMap;
439
for(QuerySolution solution : IterableAdaptor.adapt(rs)) {
446
for (QuerySolution solution : IterableAdaptor.adapt(rs)) {
448
log.trace("solution "+rs.getRowNumber());
440
450
String sinputuri = solution.getResource("sInput").getURI();
441
451
String svivouri = solution.getResource("sVivo").getURI();
442
452
log.trace("Potential Match: <" + sinputuri + "> to <" + svivouri + ">");
443
453
tempMap = new HashMap<String, String>();
444
454
tempMap.put("sInput", sinputuri);
445
455
tempMap.put("sVivo", svivouri);
446
for(String runName : this.vivoPredicates.keySet()) {
447
//log.trace("adding runName to tempMap: "+ runName);
457
for (String runName : runNames) {
448
458
RDFNode os = solution.get("os_" + runName);
449
459
RDFNode op = solution.get("op_" + runName);
450
addRunName(tempMap, runName, os, op);
451
//log.trace("Added runName");
460
addRunName(tempMap, runName, os, op);
456
466
log.info("Finished building Record Set");
457
467
log.info("Added this many records: "+ solSet.size());
470
log.trace("BuildSolutionSet took this much time: "+stopWatch.getTime());
468
480
log.trace("buildFilterSolutionSet");
469
481
Set<Map<String, String>> matchSet = Match.match(this.matchThreshold.floatValue(), this.scoreJena);
470
482
Set<Map<String, String>> solSet = getNewSolSet();
471
if(matchSet.isEmpty()) {
484
if (matchSet.isEmpty()) {
472
485
log.info("No Results Found");
474
487
log.info("Building Record Set");
475
488
Map<String, String> tempMap;
476
for(Map<String, String> entry : matchSet) {
489
for (Map<String, String> entry : matchSet) {
477
490
String sinputuri = entry.get("sInputURI");
478
491
String svivouri = entry.get("sVivoURI");
479
492
log.trace("Potential Match: <" + sinputuri + "> to <" + svivouri + ">");
482
495
Resource sInput = this.inputJena.getJenaModel().getResource(sinputuri);
483
496
tempMap.put("sVivo", svivouri);
484
497
Resource sVivo = this.vivoJena.getJenaModel().getResource(svivouri);
485
for(String runName : this.vivoPredicates.keySet()) {
486
//log.trace("adding runName to tempMap: "+ runName);
498
for (String runName : this.vivoPredicates.keySet()) {
487
500
Property os_runName = this.inputJena.getJenaModel().getProperty(this.inputPredicates.get(runName));
488
501
Statement os_stmnt = sInput.getProperty(os_runName);
489
502
RDFNode os = null;
490
if(os_stmnt != null) {
503
if (os_stmnt != null) {
491
504
os = os_stmnt.getObject();
493
506
Property op_runName = this.vivoJena.getJenaModel().getProperty(this.vivoPredicates.get(runName));
494
507
Statement op_stmnt = sVivo.getProperty(op_runName);
495
508
RDFNode op = null;
496
if(op_stmnt != null) {
509
if (op_stmnt != null) {
497
510
op = op_stmnt.getObject();
500
513
addRunName(tempMap, runName, os, op);
501
//log.trace("Added runName");
503
//log.trace("Add tempMap to solSet");
504
517
solSet.add(tempMap);
506
519
log.info("Finished building Record Set");