use of org.folio.rest.jaxrs.model.CostAnalysis 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())));
}
use of org.folio.rest.jaxrs.model.CostAnalysis in project mod-kb-ebsco-java by folio-org.
the class ResourceCostPerUseConverter method convert.
@Override
public ResourceCostPerUse convert(@NotNull ResourceCostPerUseResult source) {
ResourceCostPerUse resourceCostPerUse = new ResourceCostPerUse().withResourceId(IdParser.resourceIdToString(source.getResourceId())).withType(ResourceCostPerUse.Type.RESOURCE_COST_PER_USE);
var ucTitleCostPerUse = source.getUcTitleCostPerUse();
if (ucTitleCostPerUse.getUsage() == null || ucTitleCostPerUse.getUsage().getPlatforms() == null) {
return resourceCostPerUse;
}
List<SpecificPlatformUsage> specificPlatformUsages = getAllPlatformUsages(ucTitleCostPerUse.getUsage());
var usage = new Usage().withTotals(new UsageTotals());
var analysis = new CostAnalysis();
switch(source.getPlatformType()) {
case PUBLISHER:
setPublisherUsage(specificPlatformUsages, usage);
analysis.setPublisherPlatforms(getCostAnalysisAttributes(ucTitleCostPerUse, usage.getTotals().getPublisher()));
break;
case NON_PUBLISHER:
setNonPublisherUsage(specificPlatformUsages, usage);
analysis.setNonPublisherPlatforms(getCostAnalysisAttributes(ucTitleCostPerUse, usage.getTotals().getNonPublisher()));
break;
default:
setPublisherUsage(specificPlatformUsages, usage);
setNonPublisherUsage(specificPlatformUsages, usage);
usage.setPlatforms(specificPlatformUsages);
usage.getTotals().setAll(getTotalUsage(specificPlatformUsages));
analysis.setPublisherPlatforms(getCostAnalysisAttributes(ucTitleCostPerUse, usage.getTotals().getPublisher()));
analysis.setNonPublisherPlatforms(getCostAnalysisAttributes(ucTitleCostPerUse, usage.getTotals().getNonPublisher()));
analysis.setAllPlatforms(getCostAnalysisAttributes(ucTitleCostPerUse, usage.getTotals().getAll()));
break;
}
return resourceCostPerUse.withAttributes(new ResourceCostPerUseDataAttributes().withUsage(usage).withAnalysis(analysis).withParameters(convertParameters(source.getConfiguration())));
}
Aggregations