Search in sources :

Example 1 with Countries

use of com.metabroadcast.common.intl.Countries in project atlas-deer by atlasapi.

the class PolicySerialization method deserialize.

public org.atlasapi.content.Policy deserialize(Policy internal) {
    if (internal == null) {
        return null;
    }
    org.atlasapi.content.Policy policy = new org.atlasapi.content.Policy();
    identifiedSetter.deserialize(policy, internal);
    policy.setAvailabilityStart(toDateTime(internal.getAvailabilityStart()));
    policy.setAvailabilityEnd(toDateTime(internal.getAvailabilityEnd()));
    policy.setDrmPlayableFrom(toDateTime(internal.getDrmPlayableFrom()));
    Set<String> availableCountries = internal.getAvailableCountries();
    if (availableCountries != null) {
        policy.setAvailableCountries(availableCountries.stream().map(Countries::fromCode).collect(Collectors.toSet()));
    }
    policy.setAvailabilityLength(internal.getAvailabilityLength());
    String revenueContract = internal.getRevenueContract();
    if (revenueContract != null) {
        policy.setRevenueContract(org.atlasapi.content.Policy.RevenueContract.fromKey(revenueContract));
    }
    policy.setSubscriptionPackages(internal.getSubscriptionPackages());
    Price internalPrice = internal.getPrice();
    if (internalPrice != null) {
        policy.setPrice(price.deserialize(internalPrice));
    }
    List<Pricing> pricing = internal.getPricing();
    if (pricing != null) {
        policy.setPricing(pricing.stream().map(this.pricing::deserialize).collect(Collectors.toList()));
    }
    Long serviceId = internal.getServiceId();
    if (serviceId != null) {
        policy.setServiceId(Id.valueOf(serviceId));
    }
    Long playerId = internal.getPlayerId();
    if (playerId != null) {
        policy.setPlayerId(Id.valueOf(playerId));
    }
    if (internal.getPlatform() != null) {
        policy.setPlatform(org.atlasapi.content.Policy.Platform.fromKey(internal.getPlatform()));
    }
    if (internal.getNetwork() != null) {
        policy.setNetwork(org.atlasapi.content.Policy.Network.fromKey(internal.getNetwork()));
    }
    policy.setActualAvailabilityStart(toDateTime(internal.getActualAvailabilityStart()));
    return policy;
}
Also used : Policy(org.atlasapi.content.v2.model.pojo.Policy) Countries(com.metabroadcast.common.intl.Countries) Price(org.atlasapi.content.v2.model.pojo.Price) Pricing(org.atlasapi.content.v2.model.pojo.Pricing)

Aggregations

Countries (com.metabroadcast.common.intl.Countries)1 Policy (org.atlasapi.content.v2.model.pojo.Policy)1 Price (org.atlasapi.content.v2.model.pojo.Price)1 Pricing (org.atlasapi.content.v2.model.pojo.Pricing)1