Search in sources :

Example 1 with Constants

use of io.atlasmap.v2.Constants 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)

Example 2 with Constants

use of io.atlasmap.v2.Constants in project atlasmap by atlasmap.

the class AtlasTestData method generateAtlasMapping.

public static AtlasMapping generateAtlasMapping() {
    AtlasMapping mapping = AtlasModelFactory.createAtlasMapping();
    mapping.setName("generated.mapping." + UUID.randomUUID().toString().replace('-', '.'));
    mapping.getProperties().getProperty().addAll(generateAtlasProperties());
    mapping.setConstants(new Constants());
    return mapping;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Constants(io.atlasmap.v2.Constants)

Aggregations

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