use of org.apache.nifi.repository.schema.NamedValue in project nifi by apache.
the class LookupTableEventRecord method createLookupValue.
private NamedValue createLookupValue(final String literalValue, final Map<String, Integer> lookup) {
if (literalValue == null) {
final Map<RecordField, Object> lookupValues = Collections.singletonMap(LookupTableEventRecordFields.NO_VALUE, EventFieldNames.NO_VALUE);
final Record record = new FieldMapRecord(lookupValues, LookupTableEventSchema.NO_VALUE_SCHEMA);
final NamedValue namedValue = new NamedValue(EventFieldNames.NO_VALUE, record);
return namedValue;
}
final Integer index = lookup.get(literalValue);
if (index == null) {
final Map<RecordField, Object> lookupValues = Collections.singletonMap(LookupTableEventRecordFields.EXPLICIT_STRING, literalValue);
final Record record = new FieldMapRecord(lookupValues, LookupTableEventSchema.EXPLICIT_STRING_SCHEMA);
final NamedValue namedValue = new NamedValue(EventFieldNames.EXPLICIT_VALUE, record);
return namedValue;
} else {
final Map<RecordField, Object> lookupValues = Collections.singletonMap(LookupTableEventRecordFields.LOOKUP_VALUE, index);
final Record record = new FieldMapRecord(lookupValues, LookupTableEventSchema.LOOKUP_VALUE_SCHEMA);
final NamedValue namedValue = new NamedValue(EventFieldNames.LOOKUP_VALUE, record);
return namedValue;
}
}
use of org.apache.nifi.repository.schema.NamedValue in project nifi by apache.
the class RepositoryRecordUpdate method getFieldValue.
@Override
public Object getFieldValue(final String fieldName) {
if (RepositoryRecordSchema.REPOSITORY_RECORD_UPDATE_V2.equals(fieldName)) {
String actionType = (String) fieldMap.getFieldValue(RepositoryRecordSchema.ACTION_TYPE);
if (RepositoryRecordType.CONTENTMISSING.name().equals(actionType)) {
actionType = RepositoryRecordType.DELETE.name();
}
final UpdateType updateType = UpdateType.valueOf(actionType);
final String actionName;
switch(updateType) {
case CREATE:
case UPDATE:
actionName = RepositoryRecordSchema.CREATE_OR_UPDATE_ACTION;
break;
case DELETE:
actionName = RepositoryRecordSchema.DELETE_ACTION;
break;
case SWAP_IN:
actionName = RepositoryRecordSchema.SWAP_IN_ACTION;
break;
case SWAP_OUT:
actionName = RepositoryRecordSchema.SWAP_OUT_ACTION;
break;
default:
return null;
}
return new NamedValue(actionName, fieldMap);
}
return null;
}
use of org.apache.nifi.repository.schema.NamedValue in project nifi by apache.
the class LookupTableEventRecord method createExplicitSameOrNoneValue.
private NamedValue createExplicitSameOrNoneValue(final Record newValue, final Record oldValue, final Supplier<Record> recordSupplier) {
if (newValue == null || EventFieldNames.NO_VALUE.equals(newValue.getSchema().getFields().get(0).getFieldName())) {
final Map<RecordField, Object> lookupValues = Collections.singletonMap(LookupTableEventRecordFields.NO_VALUE, EventFieldNames.NO_VALUE);
final Record record = new FieldMapRecord(lookupValues, LookupTableEventSchema.NO_VALUE_SCHEMA);
final NamedValue namedValue = new NamedValue(EventFieldNames.NO_VALUE, record);
return namedValue;
} else if (newValue.equals(oldValue)) {
final Map<RecordField, Object> lookupValues = Collections.singletonMap(LookupTableEventRecordFields.UNCHANGED_VALUE, EventFieldNames.UNCHANGED_VALUE);
final Record record = new FieldMapRecord(lookupValues, LookupTableEventSchema.UNCHANGED_VALUE_SCHEMA);
final NamedValue namedValue = new NamedValue(EventFieldNames.UNCHANGED_VALUE, record);
return namedValue;
}
final Record record = recordSupplier.get();
final NamedValue namedValue = new NamedValue(EventFieldNames.EXPLICIT_VALUE, record);
return namedValue;
}
Aggregations