public void scanElementsFor(InspectionRequest inspectionRequest) { for (ElementScanner<?> scanner : scannerList) { inspectionRequest .getInventory() .addElementList(scanner.scan(inspectionRequest.getInventory())); } }
/** * Checks all {@link IConditionChecker} implementations for which a {@link DynamicPolicyRule} * object exists. * * @throws CheckerCreationException Thrown, if a checker for a {@link AbstractCondition} subclass * couldn't be created. This might happen, if a {@link AbstractCondition} has not been * registered. * @throws PropertyAccessException Thrown, if a property of a SIF Element could not be access. * Most likely because the element doesn't have that property. * @throws NoConditionTargetException Thrown, if a {@link AbstractCondition} object has no target * but is supposed to. * @throws IncompleteConditionException Thrown, if the one of the conditions contained in one of * the policy rules does not contain all information necessary to check it properly. */ public ViolationList run() throws NoConditionTargetException, PropertyAccessException, CheckerCreationException, IncompleteConditionException { // local Variables which are filled from AbstractTestFacility's // properties AbstractPolicyRule rule = this.getTestedPolicyRule(); ViolationList result = new ViolationList(rule, new SameCausingCellGroupor()); InspectionRequest request = this.getTestBay().getInspection(); if (request instanceof DynamicInspectionRequest && this.getTestedPolicyRule() instanceof DynamicPolicyRule) { // local Variables which are filled only if the request is a // DynamicInspectionRequest DynamicInspectionRequest<?> dynRequest = (DynamicInspectionRequest<?>) request; this.dynamicRule = (DynamicPolicyRule) this.getTestedPolicyRule(); Spreadsheet spreadsheet = request.getInventory().getSpreadsheet(); /* * Check invariants if not lazy */ if (!invariantCheckLazy && this.dynamicRule.getInvariants().size() > 0) { checkConditions(this.dynamicRule.getInvariants(), result, spreadsheet); } IDynamicSpreadsheetRunner preparator = new POISpreadsheetPreparator(dynRequest); Spreadsheet preparedSpreadsheet = null; // realize test inputs try { preparedSpreadsheet = preparator.prepare(this.dynamicRule, dynRequest.getExternalSpreadsheet()); } catch (Exception e) { // If an exception occurred propagate it, so it will be displayed for debugging throw new PropertyAccessException(e); } /* * Check invariants if not lazy */ if (!invariantCheckLazy && this.dynamicRule.getInvariants().size() > 0) { checkConditions(this.dynamicRule.getInvariants(), result, preparedSpreadsheet); } preparedSpreadsheet = preparator.evaluate(); /* * Check postconditions and invariants */ if (this.dynamicRule.getPostconditions().size() > 0) { // run check checkConditions(this.dynamicRule.getPostconditions(), result, preparedSpreadsheet); } if (this.dynamicRule.getInvariants().size() > 0) { checkConditions(this.dynamicRule.getInvariants(), result, preparedSpreadsheet); } } return result; }