use of org.haiku.haikudepotserver.pkg.model.dumpexport.DumpExportPkgCategory in project haikudepotserver by haiku.
the class PkgDumpExportJobRunner method createDumpPkg.
private DumpExportPkg createDumpPkg(ObjectContext context, List<PkgVersion> pkgVersionsUnderCommonPkg, RepositorySource repositorySource, NaturalLanguage naturalLanguage, PkgLocalizationLookupService pkgLocalizationLookupService) {
Preconditions.checkArgument(null != pkgVersionsUnderCommonPkg && !pkgVersionsUnderCommonPkg.isEmpty());
// any will do to get the pkg.
Pkg pkg = pkgVersionsUnderCommonPkg.get(0).getPkg();
DumpExportPkg dumpExportPkg = new DumpExportPkg();
dumpExportPkg.setCreateTimestamp(pkg.getCreateTimestamp().getTime());
dumpExportPkg.setModifyTimestamp(pkg.getModifyTimestamp().getTime());
dumpExportPkg.setName(pkg.getName());
dumpExportPkg.setHasChangelog(pkg.getPkgSupplement().getPkgChangelog().isPresent());
dumpExportPkg.setProminenceOrdering(pkg.getPkgProminence(repositorySource.getRepository()).map((p) -> p.getProminence().getOrdering()).map(Long::new).orElse(null));
dumpExportPkg.setDerivedRating(pkg.getPkgUserRatingAggregate(repositorySource.getRepository()).map((v) -> v.getDerivedRating().doubleValue()).orElse(null));
dumpExportPkg.setPkgCategories(pkg.getPkgSupplement().getPkgPkgCategories().stream().map((ppc) -> {
DumpExportPkgCategory dumpExportPkgCategory = new DumpExportPkgCategory();
dumpExportPkgCategory.setCode(ppc.getPkgCategory().getCode());
return dumpExportPkgCategory;
}).collect(Collectors.toList()));
dumpExportPkg.setPkgScreenshots(pkg.getPkgSupplement().getPkgScreenshots().stream().sorted().map((ps) -> {
DumpExportPkgScreenshot dumpExportPkgScreenshot = new DumpExportPkgScreenshot();
dumpExportPkgScreenshot.setCode(ps.getCode());
dumpExportPkgScreenshot.setHeight(ps.getHeight().longValue());
dumpExportPkgScreenshot.setWidth(ps.getWidth().longValue());
dumpExportPkgScreenshot.setLength(ps.getLength().longValue());
dumpExportPkgScreenshot.setOrdering(ps.getOrdering().longValue());
return dumpExportPkgScreenshot;
}).collect(Collectors.toList()));
dumpExportPkg.setPkgVersions(pkgVersionsUnderCommonPkg.stream().sorted().map((pv) -> createDumpPkgVersion(context, pv, naturalLanguage, pkgLocalizationLookupService)).collect(Collectors.toList()));
return dumpExportPkg;
}
Aggregations