private void validateReasonCodes() { for (Object obj :scorecard.getExtensionsAndCharacteristicsAndMiningSchemas()){ if (obj instanceof Characteristics){ Characteristics characteristics = (Characteristics)obj; for (Characteristic characteristic : characteristics.getCharacteristics()){ String charReasonCode = characteristic.getReasonCode(); if (charReasonCode == null || StringUtils.isEmpty(charReasonCode)){ for (Attribute attribute : characteristic.getAttributes()){ String newCellRef = createDataTypeCellRef(ScorecardPMMLUtils.getExtensionValue(attribute.getExtensions(), "cellRef"),3); String attrReasonCode = attribute.getReasonCode(); if ( attrReasonCode == null || StringUtils.isEmpty(attrReasonCode)){ parseErrors.add(new ScorecardError(newCellRef, "Attribute is missing Reason Code")); } } } } } } }
public String getPredicate(Attribute attrib) { String predicateText = null; if (attrib.getSimplePredicate() != null) { SimpleSegmentPredicate ssp = new SimpleSegmentPredicate(attrib.getSimplePredicate()); predicateText = ssp.getPredicateRule(); return "( "+predicateText+" )"; } else if (attrib.getSimpleSetPredicate() != null) { SimpleSetSegmentPredicate sssp = new SimpleSetSegmentPredicate(attrib.getSimpleSetPredicate()); return sssp.getPredicateRule(); } else if (attrib.getCompoundPredicate() != null) { CompoundSegmentPredicate csp = new CompoundSegmentPredicate(attrib.getCompoundPredicate()); if (csp.hasSurrogation()) { return getSurrogationPredicateText(csp,-1); } else { return csp.getPredicateRule(); } } else if (attrib.getTrue() != null) { return "( 1 == 1 )"; } else if (attrib.getFalse() != null) { return "( 1 == 0 )"; } throw new IllegalStateException("Unable to determine predicate for Attribute with reason code: "+attrib.getReasonCode()); }