Search in sources :

Example 1 with PkgUrlType

use of org.haiku.haikudepotserver.dataobjects.PkgUrlType in project haikudepotserver by haiku.

the class PkgImportServiceImpl method importUrls.

private void importUrls(ObjectContext objectContext, org.haiku.pkg.model.Pkg pkg, PkgVersion persistedPkgVersion) {
    PkgUrlType pkgUrlType = PkgUrlType.getByCode(objectContext, org.haiku.pkg.model.PkgUrlType.HOMEPAGE.name().toLowerCase()).orElseThrow(IllegalStateException::new);
    Optional<PkgVersionUrl> homeUrlOptional = persistedPkgVersion.getPkgVersionUrlForType(pkgUrlType);
    if (null != pkg.getHomePageUrl()) {
        if (homeUrlOptional.isPresent()) {
            homeUrlOptional.get().setUrl(pkg.getHomePageUrl().getUrl());
            homeUrlOptional.get().setName(pkg.getHomePageUrl().getName());
        } else {
            PkgVersionUrl persistedPkgVersionUrl = objectContext.newObject(PkgVersionUrl.class);
            persistedPkgVersionUrl.setUrl(pkg.getHomePageUrl().getUrl());
            persistedPkgVersionUrl.setName(pkg.getHomePageUrl().getName());
            persistedPkgVersionUrl.setPkgUrlType(pkgUrlType);
            persistedPkgVersionUrl.setPkgVersion(persistedPkgVersion);
        }
    }
}
Also used : PkgVersionUrl(org.haiku.haikudepotserver.dataobjects.PkgVersionUrl) PkgUrlType(org.haiku.haikudepotserver.dataobjects.PkgUrlType)

Aggregations

PkgUrlType (org.haiku.haikudepotserver.dataobjects.PkgUrlType)1 PkgVersionUrl (org.haiku.haikudepotserver.dataobjects.PkgVersionUrl)1