Search in sources :

Example 1 with Field

use of org.folio.rest.mappings.model.Mapping.Field in project mod-gobi by folio-org.

the class MappingHelper method getDefaultMappingForOrderType.

public static Map<Mapping.Field, DataSourceResolver> getDefaultMappingForOrderType(PostGobiOrdersHelper postGobiOrdersHelper, OrderType orderType) {
    Map<Mapping.Field, org.folio.gobi.DataSourceResolver> fieldDataSourceMapping = new EnumMap<>(Mapping.Field.class);
    List<Mapping> mappingsList = defaultMappings.get(orderType).getMappings();
    for (Mapping mapping : mappingsList) {
        Mapping.Field field = mapping.getField();
        org.folio.gobi.DataSourceResolver dataSource = getDS(mapping, fieldDataSourceMapping, postGobiOrdersHelper);
        fieldDataSourceMapping.put(field, dataSource);
    }
    return fieldDataSourceMapping;
}
Also used : Field(org.folio.rest.mappings.model.Mapping.Field) Mapping(org.folio.rest.mappings.model.Mapping) EnumMap(java.util.EnumMap) Field(org.folio.rest.mappings.model.Mapping.Field)

Example 2 with Field

use of org.folio.rest.mappings.model.Mapping.Field in project mod-gobi by folio-org.

the class MappingHelper method extractOrderMappings.

public static Map<Mapping.Field, DataSourceResolver> extractOrderMappings(OrderMappings.OrderType orderType, JsonObject jo, PostGobiOrdersHelper postGobiOrdersHelper) {
    final Map<Mapping.Field, DataSourceResolver> map = new EnumMap<>(Mapping.Field.class);
    final JsonArray configs = jo.getJsonArray("configs");
    if (!configs.isEmpty()) {
        final String mappingsString = configs.getJsonObject(0).getString("value");
        final OrderMappings orderMapping = Json.decodeValue(mappingsString, OrderMappings.class);
        final List<Mapping> orderMappingList = orderMapping.getMappings();
        if (orderMappingList != null) {
            for (Mapping mapping : orderMappingList) {
                logger.info("Mapping exists for type: {} , field: {}", orderType, mapping.getField());
                map.put(mapping.getField(), getDS(mapping, map, postGobiOrdersHelper));
            }
        }
    }
    return map;
}
Also used : JsonArray(io.vertx.core.json.JsonArray) Field(org.folio.rest.mappings.model.Mapping.Field) OrderMappings(org.folio.rest.mappings.model.OrderMappings) Mapping(org.folio.rest.mappings.model.Mapping) EnumMap(java.util.EnumMap)

Aggregations

EnumMap (java.util.EnumMap)2 Mapping (org.folio.rest.mappings.model.Mapping)2 Field (org.folio.rest.mappings.model.Mapping.Field)2 JsonArray (io.vertx.core.json.JsonArray)1 OrderMappings (org.folio.rest.mappings.model.OrderMappings)1