Search in sources :

Example 1 with VendorById

use of org.folio.holdingsiq.model.VendorById in project mod-kb-ebsco-java by folio-org.

the class PackageConverter method convert.

@Override
public Package convert(@NonNull PackageResult result) {
    PackageByIdData packageByIdData = result.getPackageData();
    Titles titles = result.getTitles();
    VendorById vendor = result.getVendor();
    AccessType accessType = result.getAccessType();
    Package packageData = new Package().withData(packageCollectionItemConverter.convert(packageByIdData)).withJsonapi(RestConstants.JSONAPI);
    packageData.getData().withRelationships(createEmptyPackageRelationship()).withType(PACKAGES_TYPE).getAttributes().withProxy(convertToProxy(packageByIdData.getProxy())).withPackageToken(tokenInfoConverter.convert(packageByIdData.getPackageToken())).withTags(result.getTags());
    if (titles != null) {
        packageData.getData().withRelationships(new PackageRelationship().withResources(new HasManyRelationship().withMeta(new MetaDataIncluded().withIncluded(true)).withData(convertResourcesRelationship(packageByIdData, titles))));
        packageData.getIncluded().addAll(resourcesConverter.convert(titles).getData());
    }
    if (vendor != null) {
        packageData.getIncluded().add(vendorConverter.convert(vendor).getData());
        packageData.getData().getRelationships().withProvider(new HasOneRelationship().withData(new RelationshipData().withId(String.valueOf(vendor.getVendorId())).withType(PROVIDERS_TYPE)));
    }
    if (accessType != null) {
        packageData.getIncluded().add(accessType);
        packageData.getData().getRelationships().withAccessType(new HasOneRelationship().withData(new RelationshipData().withId(accessType.getId()).withType(AccessType.Type.ACCESS_TYPES.value())).withMeta(new MetaDataIncluded().withIncluded(true)));
    }
    return packageData;
}
Also used : PackageRelationship(org.folio.rest.jaxrs.model.PackageRelationship) PackageConverterUtils.createEmptyPackageRelationship(org.folio.rest.converter.packages.PackageConverterUtils.createEmptyPackageRelationship) RelationshipData(org.folio.rest.jaxrs.model.RelationshipData) MetaDataIncluded(org.folio.rest.jaxrs.model.MetaDataIncluded) VendorById(org.folio.holdingsiq.model.VendorById) Package(org.folio.rest.jaxrs.model.Package) HasOneRelationship(org.folio.rest.jaxrs.model.HasOneRelationship) Titles(org.folio.holdingsiq.model.Titles) AccessType(org.folio.rest.jaxrs.model.AccessType) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData) HasManyRelationship(org.folio.rest.jaxrs.model.HasManyRelationship)

Example 2 with VendorById

use of org.folio.holdingsiq.model.VendorById in project mod-kb-ebsco-java by folio-org.

the class ResourceResultConverter method convert.

@Override
public List<Resource> convert(@NonNull ResourceResult resourceResult) {
    org.folio.holdingsiq.model.Title rmapiTitle = resourceResult.getTitle();
    PackageByIdData packageData = resourceResult.getPackageData();
    VendorById vendor = resourceResult.getVendor();
    AccessType accessType = resourceResult.getAccessType();
    boolean includeTitle = resourceResult.isIncludeTitle();
    List<CustomerResources> customerResourcesList = rmapiTitle.getCustomerResourcesList();
    boolean titleHasSelectedResources = matchesAny(customerResourcesList, CustomerResources::getIsSelected);
    return mapItems(customerResourcesList, resource -> {
        Resource resultResource = new org.folio.rest.jaxrs.model.Resource().withData(new ResourceCollectionItem().withId(resource.getVendorId() + "-" + resource.getPackageId() + "-" + resource.getTitleId()).withType(ResourceCollectionItem.Type.RESOURCES).withAttributes(commonResourceConverter.createResourceDataAttributes(rmapiTitle, resource)).withRelationships(createEmptyRelationship())).withIncluded(null).withJsonapi(RestConstants.JSONAPI);
        resultResource.getData().getAttributes().setTitleHasSelectedResources(titleHasSelectedResources);
        resultResource.setIncluded(new ArrayList<>());
        if (includeTitle) {
            includeTitle(rmapiTitle, resultResource);
        }
        if (vendor != null) {
            includeVendor(vendor, resultResource);
        }
        if (packageData != null) {
            includePackage(packageData, resultResource);
        }
        if (accessType != null) {
            includeAccessType(accessType, resultResource);
        }
        return resultResource;
    });
}
Also used : Resource(org.folio.rest.jaxrs.model.Resource) ResourceCollectionItem(org.folio.rest.jaxrs.model.ResourceCollectionItem) Resource(org.folio.rest.jaxrs.model.Resource) PackageByIdData(org.folio.holdingsiq.model.PackageByIdData) VendorById(org.folio.holdingsiq.model.VendorById) CustomerResources(org.folio.holdingsiq.model.CustomerResources) AccessType(org.folio.rest.jaxrs.model.AccessType)

Example 3 with VendorById

use of org.folio.holdingsiq.model.VendorById in project mod-kb-ebsco-java by folio-org.

the class ProviderConverter method convert.

@Override
public Provider convert(@NonNull VendorResult result) {
    VendorById vendor = result.getVendor();
    org.folio.holdingsiq.model.Packages packages = result.getPackages();
    TokenInfo vendorToken = vendor.getVendorByIdToken();
    Provider provider = new Provider().withData(new ProviderData().withId(String.valueOf(vendor.getVendorId())).withType(PROVIDERS_TYPE).withAttributes(new ProviderGetDataAttributes().withName(vendor.getVendorName()).withPackagesTotal(vendor.getPackagesTotal()).withPackagesSelected(vendor.getPackagesSelected()).withSupportsCustomPackages(vendor.isCustomer()).withProviderToken(tokenInfoConverter.convert(vendorToken)).withProxy(new Proxy().withId(vendor.getProxy().getId()).withInherited(vendor.getProxy().getInherited())).withTags(result.getTags())).withRelationships(createEmptyProviderRelationships())).withJsonapi(RestConstants.JSONAPI);
    if (packages != null) {
        provider.withIncluded(packagesConverter.convert(packages).getData()).getData().withRelationships(new Relationships().withPackages(new Packages().withMeta(new MetaDataIncluded().withIncluded(true)).withData(convertPackagesRelationship(packages))));
    }
    return provider;
}
Also used : ProviderData(org.folio.rest.jaxrs.model.ProviderData) Proxy(org.folio.rest.jaxrs.model.Proxy) ProviderConverterUtils.createEmptyProviderRelationships(org.folio.rest.converter.providers.ProviderConverterUtils.createEmptyProviderRelationships) Relationships(org.folio.rest.jaxrs.model.Relationships) MetaDataIncluded(org.folio.rest.jaxrs.model.MetaDataIncluded) VendorById(org.folio.holdingsiq.model.VendorById) Packages(org.folio.rest.jaxrs.model.Packages) TokenInfo(org.folio.holdingsiq.model.TokenInfo) ProviderGetDataAttributes(org.folio.rest.jaxrs.model.ProviderGetDataAttributes) Provider(org.folio.rest.jaxrs.model.Provider)

Aggregations

VendorById (org.folio.holdingsiq.model.VendorById)3 PackageByIdData (org.folio.holdingsiq.model.PackageByIdData)2 AccessType (org.folio.rest.jaxrs.model.AccessType)2 MetaDataIncluded (org.folio.rest.jaxrs.model.MetaDataIncluded)2 CustomerResources (org.folio.holdingsiq.model.CustomerResources)1 Titles (org.folio.holdingsiq.model.Titles)1 TokenInfo (org.folio.holdingsiq.model.TokenInfo)1 PackageConverterUtils.createEmptyPackageRelationship (org.folio.rest.converter.packages.PackageConverterUtils.createEmptyPackageRelationship)1 ProviderConverterUtils.createEmptyProviderRelationships (org.folio.rest.converter.providers.ProviderConverterUtils.createEmptyProviderRelationships)1 HasManyRelationship (org.folio.rest.jaxrs.model.HasManyRelationship)1 HasOneRelationship (org.folio.rest.jaxrs.model.HasOneRelationship)1 Package (org.folio.rest.jaxrs.model.Package)1 PackageRelationship (org.folio.rest.jaxrs.model.PackageRelationship)1 Packages (org.folio.rest.jaxrs.model.Packages)1 Provider (org.folio.rest.jaxrs.model.Provider)1 ProviderData (org.folio.rest.jaxrs.model.ProviderData)1 ProviderGetDataAttributes (org.folio.rest.jaxrs.model.ProviderGetDataAttributes)1 Proxy (org.folio.rest.jaxrs.model.Proxy)1 RelationshipData (org.folio.rest.jaxrs.model.RelationshipData)1 Relationships (org.folio.rest.jaxrs.model.Relationships)1