Search in sources :

Example 1 with org.haiku.haikudepotserver.dataobjects.auto._RepositorySource

use of org.haiku.haikudepotserver.dataobjects.auto._RepositorySource in project haikudepotserver by haiku.

the class RepositoryDumpExportJobRunner method createDumpRepository.

private DumpExportRepository createDumpRepository(Repository repository) {
    DumpExportRepository dumpRepository = new DumpExportRepository();
    dumpRepository.setCode(repository.getCode());
    dumpRepository.setName(repository.getName());
    dumpRepository.setDescription(repository.getDescription());
    dumpRepository.setInformationUrl(repository.getInformationUrl());
    dumpRepository.setRepositorySources(repository.getRepositorySources().stream().filter(_RepositorySource::getActive).filter(rs -> rs.tryGetPrimaryMirror().isPresent()).sorted(Comparator.comparing(_RepositorySource::getCode)).map((rs) -> {
        DumpExportRepositorySource dumpRepositorySource = new DumpExportRepositorySource();
        dumpRepositorySource.setCode(rs.getCode());
        dumpRepositorySource.setArchitectureCode(Optional.ofNullable(rs.getArchitecture()).map(Architecture::getCode).orElse(null));
        dumpRepositorySource.setIdentifier(rs.getIdentifier());
        dumpRepositorySource.setRepoInfoUrl(rs.getIdentifier());
        // ^^ deprecated; repoInfoUrl is replaced with identifier
        dumpRepositorySource.setExtraIdentifiers(rs.getExtraIdentifiers());
        dumpRepositorySource.setRepositorySourceMirrors(rs.getRepositorySourceMirrors().stream().filter(_RepositorySourceMirror::getActive).sorted(Comparator.comparing(_RepositorySourceMirror::getCode)).map(rsm -> {
            DumpExportRepositorySourceMirror dumpMirror = new DumpExportRepositorySourceMirror();
            dumpMirror.setBaseUrl(rsm.getBaseUrl());
            dumpMirror.setCountryCode(rsm.getCountry().getCode());
            dumpMirror.setDescription(rsm.getDescription());
            dumpMirror.setIsPrimary(rsm.getIsPrimary());
            return dumpMirror;
        }).collect(Collectors.toList()));
        return dumpRepositorySource;
    }).collect(Collectors.toList()));
    return dumpRepository;
}
Also used : DumpExportRepository(org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepository) DumpExportRepositorySourceMirror(org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepositorySourceMirror) org.haiku.haikudepotserver.dataobjects.auto._RepositorySource(org.haiku.haikudepotserver.dataobjects.auto._RepositorySource) Architecture(org.haiku.haikudepotserver.dataobjects.Architecture) org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror(org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror) DumpExportRepositorySource(org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepositorySource)

Aggregations

Architecture (org.haiku.haikudepotserver.dataobjects.Architecture)1 org.haiku.haikudepotserver.dataobjects.auto._RepositorySource (org.haiku.haikudepotserver.dataobjects.auto._RepositorySource)1 org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror (org.haiku.haikudepotserver.dataobjects.auto._RepositorySourceMirror)1 DumpExportRepository (org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepository)1 DumpExportRepositorySource (org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepositorySource)1 DumpExportRepositorySourceMirror (org.haiku.haikudepotserver.repository.model.dumpexport.DumpExportRepositorySourceMirror)1