Search in sources :

Example 1 with NamedValue

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;
    }
}
Also used : FieldMapRecord(org.apache.nifi.repository.schema.FieldMapRecord) RecordField(org.apache.nifi.repository.schema.RecordField) Record(org.apache.nifi.repository.schema.Record) StandardProvenanceEventRecord(org.apache.nifi.provenance.StandardProvenanceEventRecord) FieldMapRecord(org.apache.nifi.repository.schema.FieldMapRecord) ProvenanceEventRecord(org.apache.nifi.provenance.ProvenanceEventRecord) NamedValue(org.apache.nifi.repository.schema.NamedValue)

Example 2 with 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;
}
Also used : NamedValue(org.apache.nifi.repository.schema.NamedValue) UpdateType(org.wali.UpdateType)

Example 3 with NamedValue

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;
}
Also used : FieldMapRecord(org.apache.nifi.repository.schema.FieldMapRecord) RecordField(org.apache.nifi.repository.schema.RecordField) Record(org.apache.nifi.repository.schema.Record) StandardProvenanceEventRecord(org.apache.nifi.provenance.StandardProvenanceEventRecord) FieldMapRecord(org.apache.nifi.repository.schema.FieldMapRecord) ProvenanceEventRecord(org.apache.nifi.provenance.ProvenanceEventRecord) NamedValue(org.apache.nifi.repository.schema.NamedValue) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

NamedValue (org.apache.nifi.repository.schema.NamedValue)3 ProvenanceEventRecord (org.apache.nifi.provenance.ProvenanceEventRecord)2 StandardProvenanceEventRecord (org.apache.nifi.provenance.StandardProvenanceEventRecord)2 FieldMapRecord (org.apache.nifi.repository.schema.FieldMapRecord)2 Record (org.apache.nifi.repository.schema.Record)2 RecordField (org.apache.nifi.repository.schema.RecordField)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 UpdateType (org.wali.UpdateType)1