Search in sources :

Example 1 with PackageCostPerUseDataAttributes

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())));
}
Also used : PackageCostPerUse(org.folio.rest.jaxrs.model.PackageCostPerUse) PackageCostPerUseDataAttributes(org.folio.rest.jaxrs.model.PackageCostPerUseDataAttributes) CostAnalysis(org.folio.rest.jaxrs.model.CostAnalysis)

Aggregations

CostAnalysis (org.folio.rest.jaxrs.model.CostAnalysis)1 PackageCostPerUse (org.folio.rest.jaxrs.model.PackageCostPerUse)1 PackageCostPerUseDataAttributes (org.folio.rest.jaxrs.model.PackageCostPerUseDataAttributes)1