use of org.folio.rest.jaxrs.model.PackageCostPerUseDataAttributes in project mod-kb-ebsco-java by folio-org.
the class PackageCostPerUseConverter method convert.
@Override
public PackageCostPerUse convert(@NotNull PackageCostPerUseResult source) {
var ucPackageCostPerUse = source.getUcPackageCostPerUse();
var titlePackageCost = source.getTitlePackageCostMap();
Double cost;
if (titlePackageCost != null) {
cost = getPackageTitlesTotalCost(titlePackageCost);
} else {
cost = ucPackageCostPerUse.getAnalysis().getCurrent().getCost();
}
var costAnalysis = new CostAnalysis();
var allPlatformUsages = getAllPlatformUsages(ucPackageCostPerUse.getUsage());
switch(source.getPlatformType()) {
case PUBLISHER:
costAnalysis.setPublisherPlatforms(getCostAnalysisAttributes(getPublisherUsages(allPlatformUsages), cost));
break;
case NON_PUBLISHER:
costAnalysis.setNonPublisherPlatforms(getCostAnalysisAttributes(getNonPublisherUsages(allPlatformUsages), cost));
break;
default:
costAnalysis.setPublisherPlatforms(getCostAnalysisAttributes(getPublisherUsages(allPlatformUsages), cost));
costAnalysis.setNonPublisherPlatforms(getCostAnalysisAttributes(getNonPublisherUsages(allPlatformUsages), cost));
costAnalysis.setAllPlatforms(getCostAnalysisAttributes(allPlatformUsages, cost));
}
return new PackageCostPerUse().withPackageId(source.getPackageId()).withType(PackageCostPerUse.Type.PACKAGE_COST_PER_USE).withAttributes(new PackageCostPerUseDataAttributes().withAnalysis(costAnalysis).withParameters(convertParameters(source.getConfiguration())));
}
Aggregations