public SimpleSetSegmentPredicate(SimpleSetPredicate predicate) { this.setType = predicate.getArray().getType(); this.operator = predicate.getBooleanOperator(); this.baseFieldName = predicate.getField(); this.setValuesString = predicate.getArray().getContent(); this.valueCount = predicate.getArray().getN(); this.valuesList = getValueObjects(); if (this.valueCount != null && this.valueCount.intValue() != this.valuesList.size()) { throw new IllegalStateException("PMML-SimpleSetPredicate: Number of values found (" +valuesList.size()+") does not equal number of values declared (" +this.valueCount+")"); } if (this.operator == null || (!this.operator.equals("isIn") && !this.operator.equals("isNotIn"))) { throw new IllegalStateException("PMML-SimpleSetPredicate: booleanOperator was not one of the allowed values (\"isIn\" or \"isNotIn\")"); } }
public static String extractFieldNameFromCharacteristic(Characteristic c) { String field = ""; Attribute scoreAttribute = c.getAttributes().get(0); if (scoreAttribute.getSimplePredicate() != null) { field = scoreAttribute.getSimplePredicate().getField(); } else if (scoreAttribute.getSimpleSetPredicate() != null) { field = scoreAttribute.getSimpleSetPredicate().getField(); } else if (scoreAttribute.getCompoundPredicate() != null) { Object predicate = scoreAttribute.getCompoundPredicate().getSimplePredicatesAndCompoundPredicatesAndSimpleSetPredicates().get(0); if (predicate instanceof SimplePredicate){ field = ((SimplePredicate)predicate).getField(); } else if (predicate instanceof SimpleSetPredicate){ field = ((SimpleSetPredicate)predicate).getField(); } } return field; }