1 23 24 package org.hammurapi.results.persistent.jdbc; 25 26 import java.lang.reflect.InvocationHandler ; 27 import java.lang.reflect.Method ; 28 import java.lang.reflect.Proxy ; 29 import java.sql.PreparedStatement ; 30 import java.sql.ResultSet ; 31 import java.sql.SQLException ; 32 import java.util.ArrayList ; 33 import java.util.Collection ; 34 import java.util.Date ; 35 import java.util.HashMap ; 36 import java.util.HashSet ; 37 import java.util.Iterator ; 38 import java.util.LinkedList ; 39 import java.util.List ; 40 import java.util.Map ; 41 import java.util.Set ; 42 import java.util.TreeMap ; 43 44 import org.hammurapi.HammurapiException; 45 import org.hammurapi.HammurapiMeasurement; 46 import org.hammurapi.HammurapiRuntimeException; 47 import org.hammurapi.Inspector; 48 import org.hammurapi.InspectorDescriptor; 49 import org.hammurapi.SimpleViolation; 50 import org.hammurapi.Violation; 51 import org.hammurapi.Waiver; 52 import org.hammurapi.WaiverSet; 53 import org.hammurapi.results.Annotation; 54 import org.hammurapi.results.InspectorSummary; 55 import org.hammurapi.results.persistent.jdbc.sql.AggregatedResultsInspectorViolations; 56 import org.hammurapi.results.persistent.jdbc.sql.AggregatedResultsMetric; 57 import org.hammurapi.results.persistent.jdbc.sql.AggregatedResultsMetricMeasurement; 58 import org.hammurapi.results.persistent.jdbc.sql.MeasurementImpl; 59 import org.hammurapi.results.persistent.jdbc.sql.ResultsEngine; 60 import org.hammurapi.results.persistent.jdbc.sql.ViolationImpl; 61 import org.hammurapi.results.persistent.jdbc.sql.ViolationJoined; 62 63 import com.pavelvlasov.config.ConfigurationException; 64 import com.pavelvlasov.convert.Converter; 65 import com.pavelvlasov.metrics.Metric; 66 import com.pavelvlasov.persistence.PersistenceException; 67 import com.pavelvlasov.review.Signed; 68 import com.pavelvlasov.review.SimpleSourceMarker; 69 import com.pavelvlasov.review.SourceMarker; 70 import com.pavelvlasov.sql.Parameterizer; 71 import com.pavelvlasov.sql.RowProcessor; 72 import com.pavelvlasov.sql.RowProcessorEx; 73 74 79 public class AggregatedResults extends BasicResults implements org.hammurapi.results.AggregatedResults { 80 protected static final byte VIOLATION = 0; 81 protected static final byte WAIVED_VIOLATION = 1; 82 protected static final byte WARNING = 2; 83 84 AggregatedResults(WaiverSet waiverSet, ResultsFactory factory) throws SQLException { 85 super(factory); 86 this.waiverSet=waiverSet; 87 id=factory.nextPK("RESULT"); 88 factory.addToCache(this); 89 date=new Date (); 90 factory.getSQLProcessor().processUpdate( 91 "INSERT INTO RESULT (ID, TYPE, RESULT_DATE, CODEBASE) VALUES (?, ?, ?, 0)", 92 new Parameterizer() { 93 public void parameterize(PreparedStatement ps) throws SQLException { 94 ps.setInt(1, id); 95 ps.setString(2, AggregatedResults.this.getClass().getName()); 96 ps.setDate(3, new java.sql.Date (date.getTime())); 97 } 98 }); 99 100 factory.getSQLProcessor().processUpdate( 102 "INSERT INTO RESULT_NET (PARENT, CHILD) VALUES (?,?)", 103 new Parameterizer() { 104 public void parameterize(PreparedStatement ps) throws SQLException { 105 ps.setInt(1, id); 106 ps.setInt(2, id); 107 } 108 }); 109 110 factory.getSQLProcessor().processUpdate( 112 "INSERT INTO KINDRED (ANCESTOR, DESCENDANT) VALUES (?, ?)", 113 new Parameterizer() { 114 public void parameterize(PreparedStatement ps) throws SQLException { 115 ps.setInt(1, id); 116 ps.setInt(2, id); 117 } 118 }); 119 } 120 121 126 public AggregatedResults(int id, ResultsFactory factory) throws SQLException { 127 super(id, factory); 128 } 129 130 136 public Waiver addViolation(final Violation violation) throws HammurapiException { 137 final Waiver ret = waiverSet==null ? null : waiverSet.requestWaiver(violation, false); 138 try { 139 ResultsEngine resultsEngine = factory.getResultsEngine(); 140 if (ret==null) { 141 severitySummary=null; 142 InspectorDescriptor descriptor = insertViolation(violation, VIOLATION, null); 143 ++violationsNumber; 144 resultsEngine.updateAggregatedResultsViolations(violationsNumber, id); 145 146 final int severity = descriptor.getSeverity().intValue(); 147 if (maxSeverity==null || maxSeverity.intValue()>severity) { 148 maxSeverity=new Integer (severity); 149 resultsEngine.updateAggregatedResultsMaxSeverity((short) severity, id); 150 } 151 152 155 if (severity>0 && severity<5) { 156 violationLevel+=Math.pow(10, 1-descriptor.getSeverity().doubleValue()); 157 resultsEngine.setViolationLevel(violationLevel, getId()); 158 } 159 } else { 160 ++waivedViolationsNumber; 161 resultsEngine.incWaivedViolations(getId()); 162 } 163 } catch (SQLException e) { 164 throw new HammurapiException(e); 165 } 166 return ret; 167 } 168 169 protected interface ViolationConfigurator { 170 void setViolationInfo(org.hammurapi.results.persistent.jdbc.sql.Violation sqlViolation) throws SQLException ; 171 } 172 173 protected InspectorDescriptor insertViolation(final Violation violation, byte type, ViolationConfigurator configurator) { 174 InspectorDescriptor descriptor = violation.getDescriptor(); 175 try { 176 maybeInsertInspector(descriptor); 177 178 ViolationImpl sqlViolation=new ViolationImpl(true); 179 sqlViolation.setId(factory.getSQLProcessor().nextPK("PRIMARY_KEY", "VIOLATION")); 180 sqlViolation.setViolationType(type); 181 182 sqlViolation.setResultId(getId()); 183 sqlViolation.setReportId(factory.getReportId()); 184 if (descriptor!=null) { 185 sqlViolation.setInspector(descriptor.getName()); } 187 188 String message = violation.getMessage(); 189 if (message!=null) { 190 sqlViolation.setMessageId(new Integer (factory.addMessage(message))); } 192 193 SourceMarker source = violation.getSource(); 194 if (source!=null) { 195 sqlViolation.setSourceId(source.getSourceId()); sqlViolation.setLine(source.getLine()); sqlViolation.setCol(source.getColumn()); 199 if (source instanceof Signed) { 200 String signature = ((Signed) source).getSignature(); 201 if (signature!=null && signature.startsWith(source.getSourceURL())) { 202 sqlViolation.setSignaturePostfix(signature.substring(source.getSourceURL().length())); } 204 } 205 } 206 207 if (configurator!=null) { 208 configurator.setViolationInfo(sqlViolation); 209 } 210 211 factory.getResultsEngine().insertViolation(sqlViolation); 212 } catch (SQLException e1) { 213 throw new HammurapiRuntimeException(e1); 214 } 215 return descriptor; 216 } 217 218 public void addWarning(Violation warning) { 219 insertViolation(warning, WARNING, null); 220 hasWarnings=true; 221 } 222 223 private Set metricIds=new HashSet (); 224 225 private class MetricEntry { 226 int meid; 227 String name; 228 229 public MetricEntry(int id, String name) { 230 super(); 231 this.meid = id; 232 this.name = name; 233 } 234 235 public boolean equals(Object obj) { 236 return obj instanceof MetricEntry && ((MetricEntry) obj).meid==meid && ((MetricEntry) obj).name.equals(name); 237 } 238 239 public int hashCode() { 240 return meid ^ name.hashCode(); 241 } 242 } 243 244 public void addMetric(final SourceMarker source, final String name, final double value) { 245 try { 246 ResultsEngine engine = factory.getResultsEngine(); 247 MetricEntry metricEntry = new MetricEntry(getId(), name); 248 if (!metricIds.contains(metricEntry)) { 249 org.hammurapi.results.persistent.jdbc.sql.Metric dbMetric = engine.getMetric(getId(), name); 250 if (dbMetric==null) { 251 engine.insertMetric(getId(), name); 252 } 253 metricIds.add(metricEntry); 254 } 255 256 MeasurementImpl measurement = new MeasurementImpl(true); 257 measurement.setId(factory.getSQLProcessor().nextPK("PRIMARY_KEY", "MEASUREMENT")); 258 if (source!=null) { 259 measurement.setCol(source.getColumn()); 260 measurement.setLine(source.getLine()); 261 measurement.setSource(source.getSourceURL()); 262 } 263 measurement.setResultId(getId()); 264 measurement.setMeasurementValue(value); 265 measurement.setName(name); 266 engine.insertMeasurement(measurement); 267 268 metrics=null; 269 } catch (SQLException e) { 270 throw new HammurapiRuntimeException(e); 271 } 272 } 273 274 private Map metrics; 275 276 public Map getMetrics() { 277 if (metrics==null) { 278 metrics=new TreeMap (); 279 Iterator it=factory.getResultsEngine().getAggregatedResultsMetric(id).iterator(); 280 while (it.hasNext()) { 281 final AggregatedResultsMetric arm=(AggregatedResultsMetric) it.next(); 282 metrics.put(arm.getName(), new Metric() { 283 284 public int getNumber() { 285 return arm.getMeasurements(); 286 } 287 288 public double getMin() { 289 return arm.getMinValue(); 290 } 291 292 public double getMax() { 293 return arm.getMaxValue(); 294 } 295 296 public double getAvg() { 297 return arm.getTotalValue()/arm.getMeasurements(); 298 } 299 300 public double getTotal() { 301 return arm.getTotalValue(); 302 } 303 304 public void add(double measurement, long time) { 305 throw new UnsupportedOperationException ("Read-only"); 306 } 307 308 public void add(Metric metric) { 309 throw new UnsupportedOperationException ("Read-only"); 310 } 311 312 public double getDeviation() { 313 return 0; 315 } 316 317 private Collection measurements; 318 319 public Collection getMeasurements() { 320 if (measurements==null) { 321 try { 323 measurements=factory.getResultsEngine().getAggregatedResultsMetricMeasurement( 325 id, 326 arm.getName(), 327 new ArrayList (), 328 new Converter() { 329 330 public Object convert(Object source) { 331 final AggregatedResultsMetricMeasurement armm=(AggregatedResultsMetricMeasurement) source; 332 return new HammurapiMeasurement() { 333 SourceMarker source=new SourceMarker() { 334 335 public int getLine() { 336 return armm.getLine(); 337 } 338 339 public int getColumn() { 340 return armm.getCol(); 341 } 342 343 public String getSourceURL() { 344 return armm.getSource(); 345 } 346 347 public Integer getSourceId() { 348 return null; 349 } 350 351 }; 352 353 public SourceMarker getSource() { 354 return source; 355 } 356 357 public double getValue() { 358 return armm.getMeasurementValue(); 359 } 360 361 public long getTime() { 362 return 0; 363 } 364 }; 365 } 366 367 }); 368 } catch (SQLException e) { 369 throw new HammurapiRuntimeException("Cannot create metric measurement: "+e, e); 370 } 371 } 372 return measurements; 373 } 374 375 public String getName() { 376 return arm.getName(); 377 } 378 379 }); 380 } 381 } 382 return metrics; 383 } 384 385 public void aggregate(final org.hammurapi.results.AggregatedResults agregee) { 386 final AggregatedResults unWrapped = factory.unWrap(agregee); 387 codeBase+=agregee.getCodeBase(); 388 reviews+=agregee.getReviewsNumber(); 389 violationsNumber+=agregee.getViolationsNumber(); 390 waivedViolationsNumber+=agregee.getWaivedViolationsNumber(); 391 violationLevel+=agregee.getViolationLevel(); 392 hasWarnings|=agregee.hasWarnings(); 393 394 try { 395 Number ams=agregee.getMaxSeverity(); 396 if (ams!=null && (maxSeverity==null || maxSeverity.intValue()>ams.intValue())) { 397 maxSeverity=ams; 398 factory.getResultsEngine().updateAggregatedResultsMaxSeverity(ams.shortValue(), id); 399 } 400 401 final Parameterizer parameterizer = new Parameterizer() { 402 public void parameterize(PreparedStatement ps) throws SQLException { 403 idParameterizer.parameterize(ps); 404 ps.setInt(2, unWrapped.getId()); 405 } 406 }; 407 408 factory.getSQLProcessor().processSelect( 409 "SELECT * FROM RESULT_NET WHERE PARENT=? AND CHILD=?", 410 parameterizer, 411 new RowProcessorEx() { 412 public void onEmptyResultSet() throws SQLException { 413 factory.getSQLProcessor().processUpdate( 414 "INSERT INTO RESULT_NET (PARENT, CHILD) VALUES (?,?)", 415 parameterizer); 416 } 417 418 public boolean process(ResultSet rs) { 419 return false; 421 } 422 }); 423 424 factory.getSQLProcessor().processUpdate( 425 "INSERT INTO KINDRED (ANCESTOR, DESCENDANT) " + 426 "SELECT A.ANCESTOR, D.DESCENDANT FROM KINDRED A, KINDRED D WHERE A.DESCENDANT=? AND D.ANCESTOR=? ", 427 new Parameterizer() { 429 public void parameterize(PreparedStatement ps) throws SQLException { 430 ps.setInt(1, getId()); 431 ps.setInt(2, unWrapped.getId()); 432 } 433 }); 434 } catch (SQLException e) { 435 throw new HammurapiRuntimeException(e); 436 } 437 } 438 439 443 public void setReviewsNumber(final long reviews) { 444 this.reviews = reviews; 445 try { 446 factory.getSQLProcessor().processUpdate( 447 "UPDATE RESULT SET REVIEWS=? WHERE ID=?", 448 new Parameterizer() { 449 public void parameterize(PreparedStatement ps) throws SQLException { 450 ps.setLong(1, reviews); 451 ps.setInt(2, getId()); 452 } 453 }); 454 } catch (SQLException e) { 455 throw new HammurapiRuntimeException(e); 456 } 457 } 458 459 public void setCodeBase(final long codeBase) { 460 this.codeBase=codeBase; 461 try { 462 factory.getSQLProcessor().processUpdate( 463 "UPDATE RESULT SET CODEBASE=? WHERE ID=?", 464 new Parameterizer() { 465 public void parameterize(PreparedStatement ps) throws SQLException { 466 ps.setLong(1, codeBase); 467 ps.setInt(2, getId()); 468 } 469 }); 470 } catch (SQLException e) { 471 throw new HammurapiRuntimeException(e); 472 } 473 } 474 475 public void addAnnotation(Annotation annotation) { 476 try { 477 final String handle=factory.getStorage().put(annotation); 478 factory.getSQLProcessor().processUpdate( 479 "INSERT INTO ANNOTATION (RESULT_ID, HANDLE) VALUES (?, ?)", 480 new Parameterizer() { 481 public void parameterize(PreparedStatement ps) throws SQLException { 482 idParameterizer.parameterize(ps); 483 ps.setString(2, handle); 484 } 485 }); 486 } catch (SQLException e) { 487 throw new HammurapiRuntimeException(e); 488 } catch (PersistenceException e) { 489 throw new HammurapiRuntimeException(e); 490 } 491 } 492 493 public Collection getAnnotations() { 494 final Collection ret=new LinkedList (); 495 try { 496 factory.getSQLProcessor().processSelect( 497 "SELECT HANDLE FROM ANNOTATION WHERE RESULT_ID=?", 498 idParameterizer, 499 new RowProcessor() { 500 public boolean process(ResultSet rs) throws SQLException { 501 try { 502 ret.add(factory.getStorage().get(rs.getString("HANDLE"))); 503 } catch (PersistenceException e) { 504 throw new HammurapiRuntimeException(e); 505 } 506 return true; 507 } 508 }); 509 } catch (SQLException e) { 510 throw new HammurapiRuntimeException(e); 511 } 512 return ret; 513 } 514 515 private WaiverSet waiverSet; 516 517 521 protected void maybeInsertInspector(final InspectorDescriptor descriptor) throws SQLException { 522 if (descriptor!=null) { 523 factory.getSQLProcessor().processSelect( 524 "SELECT * FROM INSPECTOR WHERE REPORT_ID=? AND NAME=?", 525 new Parameterizer() { 526 public void parameterize(PreparedStatement preparedStatement) throws SQLException { 527 preparedStatement.setInt(1, factory.getReportId()); 528 preparedStatement.setString(2, descriptor.getName()); 529 } 530 }, 531 532 new RowProcessorEx() { 533 public boolean process(ResultSet resultSet) { 534 return false; 535 } 536 537 public void onEmptyResultSet() throws SQLException { 538 factory.getSQLProcessor().processUpdate( 539 "INSERT INTO INSPECTOR (REPORT_ID, NAME, SEVERITY, DESCRIPTION, CONFIG_INFO) VALUES (?, ?, ?, ?, ?)", 540 new Parameterizer() { 541 public void parameterize(PreparedStatement ps) throws SQLException { 542 ps.setInt(1, factory.getReportId()); 543 ps.setString(2, descriptor.getName()); 544 ps.setShort(3, descriptor.getSeverity().shortValue()); 545 ps.setString(4, descriptor.getDescription()); 546 try { 547 Inspector inspector = descriptor.getInspector(); 548 if (inspector!=null) { 549 ps.setString(5, inspector.getConfigInfo()); 550 } 551 } catch (ConfigurationException e) { 552 throw new HammurapiRuntimeException("Can't obtain inspector configuration info", e); 553 } 554 } 555 }); 556 } 557 }); 558 } 559 } 560 561 private Map severitySummary; 562 563 public Map getSeveritySummary() { 564 if (severitySummary==null) { 565 severitySummary=new TreeMap (); 566 Iterator it=factory.getResultsEngine().getAggregatedResultsSeveritySummary(id).iterator(); 567 while (it.hasNext()) { 568 Number severity=(Number ) it.next(); 569 severitySummary.put(severity, createInspectorSummaryMapProxy(severity)); 570 } 571 } 572 return severitySummary; 573 } 574 575 public Collection getWarnings() { 576 try { 577 return factory.getResultsEngine().getAllWarningsJoined(getId(), new LinkedList (), violationConverter); 578 } catch (SQLException e) { 579 throw new HammurapiRuntimeException(e); 580 } 581 } 582 583 private Map createInspectorSummaryMapProxy(final Number severity) { 584 return (Map ) Proxy.newProxyInstance( 585 getClass().getClassLoader(), 586 new Class [] {Map .class}, 587 new InvocationHandler () { 588 589 private Map target; 590 591 public Object invoke(Object proxy, Method method, Object [] args) throws Throwable { 592 if (target==null) { 593 target=instantiateInspectorSummaryMap(severity); 594 } 595 return method.invoke(target, args); 596 } 597 }); 598 } 599 600 604 private Map instantiateInspectorSummaryMap(final Number severity) { 605 class InspectorInfo { 606 String name; 607 String description; 608 String configInfo; 609 610 InspectorInfo(org.hammurapi.results.persistent.jdbc.sql.Inspector arim) { 611 name=arim.getName(); 612 description=arim.getDescription(); 613 configInfo=arim.getConfigInfo(); 614 } 615 616 public boolean equals(Object obj) { 617 if (obj==this) { 618 return true; 619 } else if (obj instanceof InspectorInfo) { 620 InspectorInfo otherInfo=(InspectorInfo) obj; 621 return equalStrings(name, otherInfo.name) 622 && equalStrings(description, otherInfo.description) 623 && equalStrings(configInfo, otherInfo.configInfo); 624 } else { 625 return super.equals(obj); 626 } 627 } 628 629 boolean equalStrings(String a, String b) { 630 if (a==null) { 631 return b==null; 632 } 633 634 return a.equals(b); 635 } 636 637 public int hashCode() { 638 return (name==null ? 0 : name.hashCode()) ^ (description==null ? 0 : description.hashCode()) ^ (configInfo==null ? 0 : configInfo.hashCode()); 639 } 640 } 641 642 final Map infoMap=new HashMap (); 643 644 Iterator it=factory.getResultsEngine().getAggregatedResultsInspectorSummary(id, severity.shortValue()).iterator(); 645 while (it.hasNext()) { 646 org.hammurapi.results.persistent.jdbc.sql.Inspector arim=(org.hammurapi.results.persistent.jdbc.sql.Inspector) it.next(); 647 InspectorInfo inspectorInfo=new InspectorInfo(arim); 648 Set ids=(Set ) infoMap.get(inspectorInfo); 649 if (ids==null) { 650 ids=new HashSet (); 651 infoMap.put(inspectorInfo, ids); 652 } 653 654 ids.add(new Integer (arim.getReportId())); 655 } 656 657 final Map map=new TreeMap (); 658 it=infoMap.entrySet().iterator(); 659 while (it.hasNext()) { 660 Map.Entry entry=(Map.Entry ) it.next(); 661 InspectorInfo info=(InspectorInfo) entry.getKey(); 662 Set ids = (Set ) entry.getValue(); 663 StringBuffer sb=new StringBuffer (); 664 Iterator iit=ids.iterator(); 665 while (iit.hasNext()) { 666 sb.append(iit.next()); 667 if (iit.hasNext()) { 668 sb.append(","); 669 } 670 } 671 672 map.put(info.name+" ["+sb.toString()+"]", 673 createInspectorSummary( 674 severity, 675 info.name, 676 info.description, 677 info.configInfo, 678 sb.toString())); 679 } 680 681 return map; 682 } 683 684 691 private InspectorSummary createInspectorSummary( 692 final Number severity, 693 final String inspectorName, 694 final String description, 695 final String configInfo, 696 final String inspectorReportIds) 697 { 698 return new InspectorSummary() { 699 700 public String getDescription() { 701 return description; 702 } 703 704 private List locations; 705 706 public List getLocations() { 707 if (locations==null) { 708 locations=new ArrayList (); 709 Iterator it=factory.getResultsEngine().getAggregatedResultsInspectorViolations(id, inspectorName).iterator(); 710 while (it.hasNext()) { 711 final AggregatedResultsInspectorViolations ariv=(AggregatedResultsInspectorViolations) it.next(); 712 locations.add(new SourceMarker() { 713 714 public int getLine() { 715 return ariv.getLine(); 716 } 717 718 public int getColumn() { 719 return ariv.getCol(); 720 } 721 722 public String getSourceURL() { 723 if (ariv.getCompilationUnitPackage()==null || ariv.getCompilationUnitPackage().length()==0) { 724 return ariv.getCompilationUnitName(); 725 } 726 727 return ariv.getCompilationUnitPackage().replace('.','/')+'/'+ariv.getCompilationUnitName(); 728 } 729 730 public Integer getSourceId() { 731 return ariv.getSourceId(); 732 } 733 734 }); 735 } 736 } 737 738 return locations; 739 } 740 741 public int getLocationsCount() { 742 return getLocations().size(); 743 } 744 745 public String getName() { 746 return inspectorName; 747 } 748 749 public Number getSeverity() { 750 return severity; 751 } 752 753 public String getConfigInfo() { 754 return configInfo; 755 } 756 757 public int compareTo(Object o) { 758 if (o instanceof InspectorSummary) { 759 return inspectorName.compareTo(((InspectorSummary) o).getName()); 760 } else if (o instanceof Comparable ) { 761 return -((Comparable ) o).compareTo(this); 762 } else { 763 return this.hashCode()-o.hashCode(); 764 } 765 } 766 767 public String getVersion() { 768 return inspectorReportIds; 769 } 770 771 private int baseLineLocationsCount=-1; 772 773 public int getBaseLineLocationsCount() { 774 if (baseLineLocationsCount==-1 && baseLineId!=null) { 775 try { 776 baseLineLocationsCount=factory.getResultsEngine().getAggregatedResultsInspectorViolationsCount(baseLineId.intValue(), inspectorName); 777 } catch (SQLException e) { 778 throw new HammurapiRuntimeException(e); 779 } 780 } 781 return baseLineLocationsCount; 782 } 783 }; 784 } 785 786 protected Converter violationConverter=new Converter() { 787 public Object convert(Object o) { 788 final ViolationJoined vj=(ViolationJoined) o; 789 String path; 790 if (vj.getCompilationUnitPackage()==null || vj.getCompilationUnitPackage().length()==0) { 791 path=vj.getCompilationUnitName(); 792 } else { 793 path=vj.getCompilationUnitPackage().replace('.','/')+'/'+vj.getCompilationUnitName(); 794 } 795 return new SimpleViolation( 796 new SimpleSourceMarker(vj.getCol(), vj.getLine(), path, vj.getSourceId()), 797 vj.getMessage(), 798 factory.getInspectorDescriptor(vj.getInspector())); 799 } 800 }; 801 802 private Integer baseLineId; 803 804 public WaiverSet getWaiverSet() { 805 return waiverSet; 806 } 807 808 public void commit() throws HammurapiException { 809 try { 810 factory.getResultsEngine().commit(getId()); 811 } catch (SQLException e) { 812 throw new HammurapiException(e); 813 } 814 } 815 816 public boolean isNew() { 817 try { 818 return factory.getResultsEngine().getAggregateResultsIsNew(id)>0; 819 } catch (SQLException e) { 820 throw new HammurapiRuntimeException(e); 821 } 822 } 823 824 private BasicResults baseLine; 825 826 public org.hammurapi.results.BasicResults getBaseLine() { 827 if (baseLineId!=null && baseLine==null) { 828 try { 829 baseLine=new BasicResults(baseLineId.intValue(), factory); 830 } catch (SQLException e) { 831 throw new HammurapiRuntimeException(e); 832 } 833 } 834 835 return baseLine; 836 } 837 838 841 void setBaseLineId(Integer baseLineId) { 842 this.baseLineId=baseLineId; 843 } 844 } 845 | Popular Tags |