Search in sources :

Example 1 with CostAnalysis

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

Example 2 with CostAnalysis

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())));
}
Also used : SpecificPlatformUsage(org.folio.rest.jaxrs.model.SpecificPlatformUsage) CostPerUseConverterUtils.getTotalUsage(org.folio.rest.converter.costperuse.CostPerUseConverterUtils.getTotalUsage) Usage(org.folio.rest.jaxrs.model.Usage) CostPerUseConverterUtils.setNonPublisherUsage(org.folio.rest.converter.costperuse.CostPerUseConverterUtils.setNonPublisherUsage) CostPerUseConverterUtils.setPublisherUsage(org.folio.rest.converter.costperuse.CostPerUseConverterUtils.setPublisherUsage) UsageTotals(org.folio.rest.jaxrs.model.UsageTotals) ResourceCostPerUse(org.folio.rest.jaxrs.model.ResourceCostPerUse) SpecificPlatformUsage(org.folio.rest.jaxrs.model.SpecificPlatformUsage) CostAnalysis(org.folio.rest.jaxrs.model.CostAnalysis) ResourceCostPerUseDataAttributes(org.folio.rest.jaxrs.model.ResourceCostPerUseDataAttributes)

Aggregations

CostAnalysis (org.folio.rest.jaxrs.model.CostAnalysis)2 CostPerUseConverterUtils.getTotalUsage (org.folio.rest.converter.costperuse.CostPerUseConverterUtils.getTotalUsage)1 CostPerUseConverterUtils.setNonPublisherUsage (org.folio.rest.converter.costperuse.CostPerUseConverterUtils.setNonPublisherUsage)1 CostPerUseConverterUtils.setPublisherUsage (org.folio.rest.converter.costperuse.CostPerUseConverterUtils.setPublisherUsage)1 PackageCostPerUse (org.folio.rest.jaxrs.model.PackageCostPerUse)1 PackageCostPerUseDataAttributes (org.folio.rest.jaxrs.model.PackageCostPerUseDataAttributes)1 ResourceCostPerUse (org.folio.rest.jaxrs.model.ResourceCostPerUse)1 ResourceCostPerUseDataAttributes (org.folio.rest.jaxrs.model.ResourceCostPerUseDataAttributes)1 SpecificPlatformUsage (org.folio.rest.jaxrs.model.SpecificPlatformUsage)1 Usage (org.folio.rest.jaxrs.model.Usage)1 UsageTotals (org.folio.rest.jaxrs.model.UsageTotals)1