Search in sources :

Example 1 with PkgVersionUrl

use of org.haiku.haikudepotserver.api1.model.pkg.PkgVersionUrl in project haikudepotserver by haiku.

the class PkgApiImpl method createGetPkgResultPkgVersion.

/**
 * <p>Given the persistence model object, this method will construct the DTO to be sent back over the wire.</p>
 */
private GetPkgResult.PkgVersion createGetPkgResultPkgVersion(ObjectContext context, PkgVersion pkgVersion, NaturalLanguage naturalLanguage) {
    Preconditions.checkNotNull(pkgVersion);
    Preconditions.checkNotNull(naturalLanguage);
    GetPkgResult.PkgVersion version = new GetPkgResult.PkgVersion();
    version.isLatest = pkgVersion.getIsLatest();
    version.major = pkgVersion.getMajor();
    version.minor = pkgVersion.getMinor();
    version.micro = pkgVersion.getMicro();
    version.revision = pkgVersion.getRevision();
    version.preRelease = pkgVersion.getPreRelease();
    version.hasSource = pkgService.getCorrespondingSourcePkgVersion(context, pkgVersion).isPresent();
    version.createTimestamp = pkgVersion.getCreateTimestamp().getTime();
    version.payloadLength = pkgVersion.getPayloadLength();
    version.repositorySourceCode = pkgVersion.getRepositorySource().getCode();
    version.repositoryCode = pkgVersion.getRepositorySource().getRepository().getCode();
    version.architectureCode = pkgVersion.getArchitecture().getCode();
    version.copyrights = pkgVersion.getPkgVersionCopyrights().stream().map(PkgVersionCopyright::getBody).collect(Collectors.toList());
    version.licenses = pkgVersion.getPkgVersionLicenses().stream().map(PkgVersionLicense::getBody).collect(Collectors.toList());
    version.viewCounter = pkgVersion.getViewCounter();
    version.hpkgDownloadURL = pkgService.createHpkgDownloadUrl(pkgVersion);
    ResolvedPkgVersionLocalization resolvedPkgVersionLocalization = pkgLocalizationService.resolvePkgVersionLocalization(context, pkgVersion, null, naturalLanguage);
    version.title = resolvedPkgVersionLocalization.getTitle();
    version.description = resolvedPkgVersionLocalization.getDescription();
    version.summary = resolvedPkgVersionLocalization.getSummary();
    version.urls = pkgVersion.getPkgVersionUrls().stream().map(u -> new PkgVersionUrl(u.getPkgUrlType().getCode(), u.getUrl())).collect(Collectors.toList());
    return version;
}
Also used : PkgVersionUrl(org.haiku.haikudepotserver.api1.model.pkg.PkgVersionUrl) org.haiku.haikudepotserver.dataobjects.auto._PkgVersion(org.haiku.haikudepotserver.dataobjects.auto._PkgVersion)

Aggregations

PkgVersionUrl (org.haiku.haikudepotserver.api1.model.pkg.PkgVersionUrl)1 org.haiku.haikudepotserver.dataobjects.auto._PkgVersion (org.haiku.haikudepotserver.dataobjects.auto._PkgVersion)1