}
return drl.toString();
}
private BuilderResult validateScoreCard( final ScoreCardModel model ) {
final BuilderResult builderResult = new BuilderResult();
if ( StringUtils.isBlank( model.getFactName() ) ) {
builderResult.addLine( createBuilderResultLine( "Fact Name is empty.",
"Setup Parameters" ) );
}
if ( StringUtils.isBlank( model.getFieldName() ) ) {
builderResult.addLine( createBuilderResultLine( "Resultant Score Field is empty.",
"Setup Parameters" ) );
}
if ( model.getCharacteristics().size() == 0 ) {
builderResult.addLine( createBuilderResultLine( "No Characteristics Found.",
"Characteristics" ) );
}
int ctr = 1;
for ( final Characteristic c : model.getCharacteristics() ) {
String characteristicName = "Characteristic ('#" + ctr + "')";
if ( StringUtils.isBlank( c.getName() ) ) {
builderResult.addLine( createBuilderResultLine( "Name is empty.",
characteristicName ) );
} else {
characteristicName = "Characteristic ('" + c.getName() + "')";
}
if ( StringUtils.isBlank( c.getFact() ) ) {
builderResult.addLine( createBuilderResultLine( "Fact is empty.",
characteristicName ) );
}
if ( StringUtils.isBlank( c.getField() ) ) {
builderResult.addLine( createBuilderResultLine( "Characteristic Field is empty.",
characteristicName ) );
} else if ( StringUtils.isBlank( c.getDataType() ) ) {
builderResult.addLine( createBuilderResultLine( "Internal Error (missing datatype).",
characteristicName ) );
}
if ( c.getAttributes().size() == 0 ) {
builderResult.addLine( createBuilderResultLine( "No Attributes Found.",
characteristicName ) );
}
if ( model.isUseReasonCodes() ) {
if ( StringUtils.isBlank( model.getReasonCodeField() ) ) {
builderResult.addLine( createBuilderResultLine( "Resultant Reason Codes Field is empty.",
characteristicName ) );
}
if ( !"none".equalsIgnoreCase( model.getReasonCodesAlgorithm() ) ) {
builderResult.addLine( createBuilderResultLine( "Baseline Score is not specified.",
characteristicName ) );
}
}
int attrCtr = 1;
for ( final Attribute attribute : c.getAttributes() ) {
final String attributeName = "Attribute ('#" + attrCtr + "')";
if ( StringUtils.isBlank( attribute.getOperator() ) ) {
builderResult.addLine( createBuilderResultLine( "Attribute Operator is empty.",
attributeName ) );
}
if ( StringUtils.isBlank( attribute.getValue() ) ) {
builderResult.addLine( createBuilderResultLine( "Attribute Value is empty.",
attributeName ) );
}
if ( model.isUseReasonCodes() ) {
if ( StringUtils.isBlank( c.getReasonCode() ) ) {
if ( StringUtils.isBlank( attribute.getReasonCode() ) ) {
builderResult.addLine( createBuilderResultLine( "Reason Code must be set at either attribute or characteristic.",
attributeName ) );
}
}
}
attrCtr++;