~svwilliams/vivo-harvester/master

« back to all changes in this revision

Viewing changes to src/main/java/org/vivoweb/harvester/score/Score.java

  • Committer: John Fereira
  • Date: 2016-08-16 12:26:32 UTC
  • Revision ID: git-v1:d1625380926739f28dc2ab267521312d04d33f80
clean up log.trace output

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
import java.util.ArrayList;
10
10
import java.util.Comparator;
11
11
import java.util.HashMap;
 
12
import java.util.Iterator;
12
13
import java.util.List;
13
14
import java.util.Map;
14
15
import java.util.Set;
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
425
427
         */
426
428
        private Set<Map<String, String>> buildSolutionSet() throws IOException {
 
429
                 
 
430
                StopWatch stopWatch = new StopWatch();
 
431
                stopWatch.start();
427
432
                if (this.matchThreshold != null) {
428
433
                        return buildFilterSolutionSet();
429
434
                }
430
435
                ResultSet rs = getResultSet();
431
 
             
 
436
            Set<String> runNames = this.vivoPredicates.keySet();
432
437
                Set<Map<String, String>> solSet = getNewSolSet();
433
438
                 
434
 
                if(!rs.hasNext()) {
 
439
                if (!rs.hasNext()) {
435
440
                        log.info("No Results Found");
436
441
                } else {
437
442
                        log.info("Building Record Set");
 
443
                         
438
444
                        Map<String, String> tempMap;
439
 
                        for(QuerySolution solution : IterableAdaptor.adapt(rs)) {
 
445
                        
 
446
                        for (QuerySolution solution : IterableAdaptor.adapt(rs)) { 
 
447
                                 
 
448
                                log.trace("solution "+rs.getRowNumber());
 
449
                        
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);
 
456
                                 
 
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); 
452
461
                                }
453
462
                                
454
 
                                solSet.add(tempMap);
 
463
                                solSet.add(tempMap); 
 
464
                                 
455
465
                        }
456
466
                        log.info("Finished building Record Set");
457
467
                        log.info("Added this many records: "+ solSet.size());
458
468
                }
 
469
                stopWatch.stop();
 
470
                log.trace("BuildSolutionSet took this much time: "+stopWatch.getTime());
459
471
                return solSet;
460
472
        }
461
473
        
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()) {
 
483
                
 
484
                if (matchSet.isEmpty()) {
472
485
                        log.info("No Results Found");
473
486
                } else {
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()) {
 
499
                                         
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();
492
505
                                        }
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();
498
511
                                        }
499
512
                                        
500
513
                                        addRunName(tempMap, runName, os, op);
501
 
                                        //log.trace("Added runName");
 
514
                                         
502
515
                                }
503
 
                                //log.trace("Add tempMap to solSet");
 
516
                                 
504
517
                                solSet.add(tempMap);
505
518
                        }
506
519
                        log.info("Finished building Record Set");