@Override public ScanResult beforeScanCheck(Attribute attribute) throws UserError { if (Ontology.ATTRIBUTE_BLOCK_TYPE.isA(attribute.getValueType(), blockType)) { if (exceptBlockType > 0 && Ontology.ATTRIBUTE_BLOCK_TYPE.isA(attribute.getValueType(), exceptBlockType)) { return ScanResult.REMOVE; } else { return ScanResult.KEEP; } } return ScanResult.REMOVE; }
@Override public void init(ParameterHandler operator) throws UserError, ConditionCreationException { blockType = Ontology.ATTRIBUTE_BLOCK_TYPE.mapName(operator.getParameterAsString(PARAMETER_BLOCK_TYPE)); if (blockType < 0 || blockType >= Ontology.BLOCK_TYPE_NAMES.length) { throw new ConditionCreationException("Unknown value type selected."); } String exceptValueTypeName = operator.getParameterAsString(PARAMETER_EXCEPT_BLOCK_TYPE); if (operator.getParameterAsBoolean(PARAMETER_ADD_EXCEPTION)) { exceptBlockType = Ontology.ATTRIBUTE_BLOCK_TYPE.mapName(exceptValueTypeName); if (blockType < 0 || blockType >= Ontology.BLOCK_TYPE_NAMES.length) { throw new ConditionCreationException("Unknown value type selected."); } } else { exceptBlockType = -1; } }
@Override public List<ParameterType> getParameterTypes( ParameterHandler operator, InputPort inPort, int... valueTypes) { List<ParameterType> types = new LinkedList<ParameterType>(); Set<String> valueTypeSet = new LinkedHashSet<String>(); for (String valueTypeName : Ontology.ATTRIBUTE_BLOCK_TYPE.getNames()) { int valueType = Ontology.ATTRIBUTE_BLOCK_TYPE.mapName(valueTypeName); for (int parent : valueTypes) { if (Ontology.ATTRIBUTE_BLOCK_TYPE.isA(valueType, parent)) { valueTypeSet.add(Ontology.ATTRIBUTE_BLOCK_TYPE.mapIndex(valueType)); } } } String[] valueTypeNames = new String[valueTypeSet.size()]; valueTypeNames = valueTypeSet.toArray(valueTypeNames); String[] exceptValueTypeNames = new String[valueTypeSet.size()]; exceptValueTypeNames = valueTypeSet.toArray(valueTypeNames); types.add( new ParameterTypeCategory( PARAMETER_BLOCK_TYPE, "The block type of the attributes.", valueTypeNames, 0, false)); types.add( new ParameterTypeBoolean( PARAMETER_ADD_EXCEPTION, "If enabled, an exception to the specified block type might be specified.", false, true)); ParameterType type = new ParameterTypeCategory( PARAMETER_EXCEPT_BLOCK_TYPE, "Except this block type.", exceptValueTypeNames, exceptValueTypeNames.length - 1, true); type.registerDependencyCondition( new BooleanParameterCondition(operator, PARAMETER_ADD_EXCEPTION, true, true)); types.add(type); return types; }