use of org.folio.rest.mappings.model.OrderMappings 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;
}
use of org.folio.rest.mappings.model.OrderMappings in project mod-gobi by folio-org.
the class PostGobiOrdersHelper method mapToPurchaseOrder.
public CompletableFuture<CompositePurchaseOrder> mapToPurchaseOrder(Document doc) {
final OrderMappings.OrderType orderType = getOrderType(doc);
VertxCompletableFuture<CompositePurchaseOrder> future = new VertxCompletableFuture<>(ctx);
lookupOrderMappings(orderType).thenAccept(ordermappings -> {
logger.info("Using Mappings {}", ordermappings);
new Mapper(ordermappings).map(doc, this).thenAccept(future::complete);
}).exceptionally(e -> {
logger.error("Exception looking up Order mappings", e);
future.completeExceptionally(e);
return null;
});
return future;
}
Aggregations