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;
}
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;
}
Aggregations