Search in sources :

Example 1 with ConstantModule

use of io.atlasmap.core.ConstantModule in project atlasmap by atlasmap.

the class AtlasField method readConstant.

/**
 * Reads the constant.
 * @param name name
 * @return read field
 * @throws AtlasException unexpected error
 */
public AtlasField readConstant(String name) throws AtlasException {
    ConstantModule module = session.getConstantModule();
    List<Constant> constants = session.getMapping().getConstants().getConstant();
    for (Constant constant : constants) {
        if (constant.getName() != null && constant.getName().equals(name)) {
            Field sourceField = module.createField();
            sourceField.setName(constant.getName());
            sourceField.setFieldType(constant.getFieldType());
            sourceField.setValue(constant.getValue());
            session.head().setSourceField(sourceField);
            module.readSourceValue(session);
            setRawField(sourceField);
            return this;
        }
    }
    throw new AtlasException(String.format("Constant '%s' not found", name));
}
Also used : PropertyField(io.atlasmap.v2.PropertyField) Field(io.atlasmap.v2.Field) ConstantModule(io.atlasmap.core.ConstantModule) Constant(io.atlasmap.v2.Constant) AtlasException(io.atlasmap.api.AtlasException)

Aggregations

AtlasException (io.atlasmap.api.AtlasException)1 ConstantModule (io.atlasmap.core.ConstantModule)1 Constant (io.atlasmap.v2.Constant)1 Field (io.atlasmap.v2.Field)1 PropertyField (io.atlasmap.v2.PropertyField)1