From 75c47d246ee01d148c42e9431f197948f342a1e0 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Mar 16 2016 15:38:37 +0000 Subject: Refactor packages and baselines Packages and baselines are replaced with one common entity -- modules. --- diff --git a/doc/import.sql b/doc/import.sql index 5f3ffc4..9e3064c 100644 --- a/doc/import.sql +++ b/doc/import.sql @@ -1,45 +1,28 @@ BEGIN; -INSERT INTO BASELINE(NAME) VALUES - ('buildsys-build'), - ('java'), - ('java-devel'), - ('eclipse'), - ('empty'); - -INSERT INTO BASELINE_PKGS(BASELINE_NAME, PKGS) VALUES - ('buildsys-build', 'bash'), ('buildsys-build', 'bzip2'), ('buildsys-build', 'coreutils'), ('buildsys-build', 'cpio'), - ('buildsys-build', 'diffutils'), ('buildsys-build', 'fedora-release'), ('buildsys-build', 'findutils'), ('buildsys-build', 'gawk'), - ('buildsys-build', 'gcc'), ('buildsys-build', 'gcc-c++'), ('buildsys-build', 'grep'), ('buildsys-build', 'gzip'), - ('buildsys-build', 'info'), ('buildsys-build', 'make'), ('buildsys-build', 'patch'), ('buildsys-build', 'redhat-rpm-config'), - ('buildsys-build', 'rpm-build'), ('buildsys-build', 'sed'), ('buildsys-build', 'shadow-utils'), ('buildsys-build', 'tar'), - ('buildsys-build', 'unzip'), ('buildsys-build', 'util-linux'), ('buildsys-build', 'which'), ('buildsys-build', 'xz'), - ('java', 'java-1.8.0-openjdk'), - ('java-devel', 'java-1.8.0-openjdk-devel'), - ('eclipse', 'eclipse-platform'); - -INSERT INTO BASELINE_BASELINE(BASELINE_NAME, PARENTS_NAME) VALUES - ('eclipse', 'java-devel'); - INSERT INTO COLLECTION(NAME, LOCATION) VALUES ('f22', 'https://kojipkgs.fedoraproject.org/repos/f22-build/latest/{arch}/'), ('f23', 'https://kojipkgs.fedoraproject.org/repos/f23-build/latest/{arch}/'), ('f24', 'https://kojipkgs.fedoraproject.org/repos/f24-build/latest/{arch}/'), ('f25', 'https://kojipkgs.fedoraproject.org/repos/f21-build/latest/{arch}/'); -INSERT INTO PACKAGE(NAME, UPSTREAM, UPSTREAMDOWNLOADSIZE, UPSTREAMINSTALLSIZE, UPSTREAMVERSION, BASELINE_NAME) VALUES - ('maven', 'http://maven.apache.org/', 8042383, 9533094, '3.3.3', 'java-devel'), - ('ant', 'http://ant.apache.org/', 4351965, 37939729, '1.9.4', 'java-devel'), - ('eclipse-jdt', 'https://www.eclipse.org/', 160990943, 182863820, '4.4.2', 'java-devel'), - ('jenkins', 'https://jenkins-ci.org/', 63121651, 73292627, '1.615', 'java-devel'), - ('gradle', 'http://gradle.org/', 45383133, 51291589, '2.4', 'java-devel'), - ('groovy', 'http://www.groovy-lang.org/', 31968599, 35756588, '2.4.3', 'java-devel'), - ('freemind', 'http://sourceforge.net/projects/freemind/', 37583505, 41406322, '1.0.1', 'java'), - ('maven-local', '', 0, 0, '0', 'buildsys-build'), - ('gradle-local', '', 0, 0, '0', 'buildsys-build'), - ('core', '', 0, 0, '0', 'empty'); +INSERT INTO MODULE(NAME, UPSTREAM, UPSTREAMDOWNLOADSIZE, UPSTREAMINSTALLSIZE, UPSTREAMVERSION) VALUES + ('java-headless', '', 0, 0, '0'), + ('java', '', 0, 0, '0'), + ('java-devel', '', 0, 0, '0'), + ('maven', 'http://maven.apache.org/', 8042383, 9533094, '3.3.3'), + ('ant', 'http://ant.apache.org/', 4351965, 37939729, '1.9.4'), + ('eclipse-jdt', 'https://www.eclipse.org/', 160990943, 182863820, '4.4.2'), + ('jenkins', 'https://jenkins-ci.org/', 63121651, 73292627, '1.615'), + ('gradle', 'http://gradle.org/', 45383133, 51291589, '2.4'), + ('groovy', 'http://www.groovy-lang.org/', 31968599, 35756588, '2.4.3'), + ('freemind', 'http://sourceforge.net/projects/freemind/', 37583505, 41406322, '1.0.1'), + ('maven-local', '', 0, 0, '0'), + ('gradle-local', '', 0, 0, '0'), + ('core', '', 0, 0, '0'), + ('buildsys-build', '', 0, 0, '0'); -INSERT INTO PACKAGE_RPMS(PACKAGE_NAME, RPMS) VALUES +INSERT INTO MODULE_RPMS(MODULE_NAME, RPMS) VALUES ('core', 'audit'), ('core', 'basesystem'), ('core', 'bash'), @@ -77,9 +60,34 @@ INSERT INTO PACKAGE_RPMS(PACKAGE_NAME, RPMS) VALUES ('core', 'systemd'), ('core', 'systemd-udev'), ('core', 'util-linux'), - ('core', 'vim-minimal'); + ('core', 'vim-minimal'), + + ('buildsys-build', 'bash'), ('buildsys-build', 'bzip2'), ('buildsys-build', 'coreutils'), ('buildsys-build', 'cpio'), + ('buildsys-build', 'diffutils'), ('buildsys-build', 'fedora-release'), ('buildsys-build', 'findutils'), ('buildsys-build', 'gawk'), + ('buildsys-build', 'gcc'), ('buildsys-build', 'gcc-c++'), ('buildsys-build', 'grep'), ('buildsys-build', 'gzip'), + ('buildsys-build', 'info'), ('buildsys-build', 'make'), ('buildsys-build', 'patch'), ('buildsys-build', 'redhat-rpm-config'), + ('buildsys-build', 'rpm-build'), ('buildsys-build', 'sed'), ('buildsys-build', 'shadow-utils'), ('buildsys-build', 'tar'), + ('buildsys-build', 'unzip'), ('buildsys-build', 'util-linux'), ('buildsys-build', 'which'), ('buildsys-build', 'xz'), + + ('java-headless', 'java-1.8.0-openjdk-headless'), + ('java', 'java-1.8.0-openjdk'), + ('java-devel', 'java-1.8.0-openjdk-devel'); + +INSERT INTO MODULE_MODULE(MODULE_NAME, PARENTS_NAME) VALUES + ('java-headless', 'core'), + ('java', 'core'), + ('java-devel', 'core'), + ('maven', 'java-devel'), + ('ant', 'java-devel'), + ('eclipse-jdt', 'java'), + ('jenkins', 'java-headless'), + ('gradle', 'java-devel'), + ('groovy', 'java-devel'), + ('freemind', 'java'), + ('maven-local', 'buildsys-build'), + ('gradle-local', 'buildsys-build'); -INSERT INTO COLLECTION_PACKAGE(PACKAGES_NAME, COLLECTIONS_NAME) - SELECT PACKAGE.NAME, COLLECTION.NAME FROM PACKAGE, COLLECTION; +INSERT INTO COLLECTION_MODULE(MODULES_NAME, COLLECTIONS_NAME) + SELECT MODULE.NAME, COLLECTION.NAME FROM MODULE, COLLECTION; COMMIT; diff --git a/src/main/java/org/fedoraproject/insim/backend/Indexer.java b/src/main/java/org/fedoraproject/insim/backend/Indexer.java index 638ebe6..4d7097e 100644 --- a/src/main/java/org/fedoraproject/insim/backend/Indexer.java +++ b/src/main/java/org/fedoraproject/insim/backend/Indexer.java @@ -32,12 +32,12 @@ import javax.ws.rs.core.Response.Status; import org.fedoraproject.insim.data.CollectionDAO; import org.fedoraproject.insim.data.DependencyGraphDAO; import org.fedoraproject.insim.data.InstallationDAO; -import org.fedoraproject.insim.data.PackageDAO; +import org.fedoraproject.insim.data.ModuleDAO; import org.fedoraproject.insim.data.RepositoryDAO; import org.fedoraproject.insim.model.Collection; import org.fedoraproject.insim.model.DependencyGraph; import org.fedoraproject.insim.model.Installation; -import org.fedoraproject.insim.model.Package; +import org.fedoraproject.insim.model.Module; import org.fedoraproject.insim.model.Repository; import org.fedoraproject.insim.model.Rpm; import org.fedoraproject.javadeptools.hawkey.HawkeyException; @@ -59,7 +59,7 @@ public class Indexer { private RepositoryDAO repoDao; @Inject - private PackageDAO pkgDao; + private ModuleDAO moduleDao; @Inject private InstallationDAO instDao; @@ -76,14 +76,14 @@ public class Indexer { + "}"; } - private void newInstallation(Sack sack, Repository repo, Package pkg) throws HawkeyException { + private void newInstallation(Sack sack, Repository repo, Module module) throws HawkeyException { Installation inst = new Installation(); inst.setRepository(repo); - inst.setPackage(pkg); + inst.setModule(module); Simulation sim = new Simulation(sack); - sim.addBaseDeps(pkg.getBaseline().getAllPackages()); - sim.addInstDeps(pkg.getInstallRpms()); + sim.addBaseDeps(module.getBaselineRpms()); + sim.addInstDeps(module.getInstallRpms()); if (!sim.run()) { inst.setComplete(false); instDao.persist(inst); @@ -97,7 +97,7 @@ public class Indexer { fileCount += dep.getFileCount(); downloadSize += dep.getDownloadSize(); installSize += dep.getInstallSize(); - if (dep.getName().equals(pkg.getName())) { + if (dep.getName().equals(module.getName())) { inst.setVersion(dep.getVersion()); inst.setRelease(dep.getRelease()); } @@ -157,8 +157,8 @@ public class Indexer { repo.setCreationTime(new Timestamp(timestamp)); repoDao.persist(repo); - for (Package pkg : pkgDao.getAll()) { - newInstallation(sack, repo, pkg); + for (Module module : moduleDao.getAll()) { + newInstallation(sack, repo, module); } } catch (HawkeyException | IOException e) { throw new RuntimeException(e); diff --git a/src/main/java/org/fedoraproject/insim/data/BaselineDAO.java b/src/main/java/org/fedoraproject/insim/data/BaselineDAO.java deleted file mode 100644 index 55d85ce..0000000 --- a/src/main/java/org/fedoraproject/insim/data/BaselineDAO.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Copyright (c) 2016 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.insim.data; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; - -import org.fedoraproject.insim.model.Baseline; - -/** - * @author Mikolaj Izdebski - */ -@ApplicationScoped -public class BaselineDAO { - - @Inject - private EntityManager em; - - public Baseline getByName(String name) { - return em.find(Baseline.class, name); - } - -} diff --git a/src/main/java/org/fedoraproject/insim/data/InstallationDAO.java b/src/main/java/org/fedoraproject/insim/data/InstallationDAO.java index 8da2027..13cc6f1 100644 --- a/src/main/java/org/fedoraproject/insim/data/InstallationDAO.java +++ b/src/main/java/org/fedoraproject/insim/data/InstallationDAO.java @@ -33,7 +33,7 @@ import javax.transaction.Transactional; import org.fedoraproject.insim.model.Collection; import org.fedoraproject.insim.model.Installation; import org.fedoraproject.insim.model.Installation_; -import org.fedoraproject.insim.model.Package; +import org.fedoraproject.insim.model.Module; import org.fedoraproject.insim.model.Repository_; /** @@ -49,24 +49,24 @@ public class InstallationDAO { return em.find(Installation.class, id); } - private TypedQuery createPackageCollectionQuery(Package pkg, Collection col, boolean orderDescTime) { + private TypedQuery createModuleCollectionQuery(Module module, Collection col, boolean orderDescTime) { CriteriaBuilder cb = em.getCriteriaBuilder(); CriteriaQuery criteria = cb.createQuery(Installation.class); Root inst = criteria.from(Installation.class); - Predicate pkgMatch = cb.equal(inst.get(Installation_.pkg), pkg); + Predicate modMatch = cb.equal(inst.get(Installation_.module), module); Predicate colMatch = cb.equal(inst.join(Installation_.repository).get(Repository_.collection), col); Function, Order> orderFunc = orderDescTime ? cb::desc : cb::asc; Order order = orderFunc.apply(inst.join(Installation_.repository).get(Repository_.creationTime)); - criteria.select(inst).where(cb.and(pkgMatch, colMatch)).orderBy(order); + criteria.select(inst).where(cb.and(modMatch, colMatch)).orderBy(order); return em.createQuery(criteria); } - public List getByPackageCollection(Package pkg, Collection col) { - return createPackageCollectionQuery(pkg, col, false).getResultList(); + public List getByModuleCollection(Module module, Collection col) { + return createModuleCollectionQuery(module, col, false).getResultList(); } - public Installation getLatestByPackageCollection(Package pkg, Collection col) { - return createPackageCollectionQuery(pkg, col, true) // + public Installation getLatestByModuleCollection(Module module, Collection col) { + return createModuleCollectionQuery(module, col, true) // .setMaxResults(1).getResultList().stream().findFirst().orElse(null); } diff --git a/src/main/java/org/fedoraproject/insim/data/ModuleDAO.java b/src/main/java/org/fedoraproject/insim/data/ModuleDAO.java new file mode 100644 index 0000000..59e4794 --- /dev/null +++ b/src/main/java/org/fedoraproject/insim/data/ModuleDAO.java @@ -0,0 +1,57 @@ +/*- + * Copyright (c) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.fedoraproject.insim.data; + +import java.util.List; + +import javax.enterprise.context.ApplicationScoped; +import javax.inject.Inject; +import javax.persistence.EntityManager; +import javax.persistence.criteria.CriteriaBuilder; +import javax.persistence.criteria.CriteriaQuery; +import javax.persistence.criteria.Root; +import javax.transaction.Transactional; + +import org.fedoraproject.insim.model.Module; +import org.fedoraproject.insim.model.Module_; + +/** + * @author Mikolaj Izdebski + */ +@ApplicationScoped +public class ModuleDAO { + + @Inject + private EntityManager em; + + public Module getByName(String name) { + return em.find(Module.class, name); + } + + public List getAll() { + CriteriaBuilder cb = em.getCriteriaBuilder(); + CriteriaQuery criteria = cb.createQuery(Module.class); + Root module = criteria.from(Module.class); + criteria.select(module).orderBy(cb.asc(module.get(Module_.name))); + return em.createQuery(criteria).getResultList(); + } + + @Transactional + public void persist(Module module) { + em.persist(module); + } + +} diff --git a/src/main/java/org/fedoraproject/insim/data/PackageDAO.java b/src/main/java/org/fedoraproject/insim/data/PackageDAO.java deleted file mode 100644 index b9ed10b..0000000 --- a/src/main/java/org/fedoraproject/insim/data/PackageDAO.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.insim.data; - -import java.util.List; - -import javax.enterprise.context.ApplicationScoped; -import javax.inject.Inject; -import javax.persistence.EntityManager; -import javax.persistence.criteria.CriteriaBuilder; -import javax.persistence.criteria.CriteriaQuery; -import javax.persistence.criteria.Root; -import javax.transaction.Transactional; - -import org.fedoraproject.insim.model.Package; -import org.fedoraproject.insim.model.Package_; - -/** - * @author Mikolaj Izdebski - */ -@ApplicationScoped -public class PackageDAO { - - @Inject - private EntityManager em; - - public Package getByName(String name) { - return em.find(Package.class, name); - } - - public List getAll() { - CriteriaBuilder cb = em.getCriteriaBuilder(); - CriteriaQuery criteria = cb.createQuery(Package.class); - Root pkg = criteria.from(Package.class); - criteria.select(pkg).orderBy(cb.asc(pkg.get(Package_.name))); - return em.createQuery(criteria).getResultList(); - } - - @Transactional - public void persist(Package pkg) { - em.persist(pkg); - } - -} diff --git a/src/main/java/org/fedoraproject/insim/frontend/controller/ModuleListProducer.java b/src/main/java/org/fedoraproject/insim/frontend/controller/ModuleListProducer.java new file mode 100644 index 0000000..752fd44 --- /dev/null +++ b/src/main/java/org/fedoraproject/insim/frontend/controller/ModuleListProducer.java @@ -0,0 +1,51 @@ +/*- + * Copyright (c) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.fedoraproject.insim.frontend.controller; + +import java.util.List; + +import javax.annotation.PostConstruct; +import javax.enterprise.context.RequestScoped; +import javax.enterprise.inject.Produces; +import javax.inject.Inject; +import javax.inject.Named; + +import org.fedoraproject.insim.data.ModuleDAO; +import org.fedoraproject.insim.model.Module; + +/** + * @author Mikolaj Izdebski + */ +@RequestScoped +public class ModuleListProducer { + + @Inject + private ModuleDAO dao; + + private List modules; + + @Produces + @Named + public List getModules() { + return modules; + } + + @PostConstruct + public void initialize() { + modules = dao.getAll(); + } + +} diff --git a/src/main/java/org/fedoraproject/insim/frontend/controller/PackageListProducer.java b/src/main/java/org/fedoraproject/insim/frontend/controller/PackageListProducer.java deleted file mode 100644 index a929f6e..0000000 --- a/src/main/java/org/fedoraproject/insim/frontend/controller/PackageListProducer.java +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.insim.frontend.controller; - -import java.util.List; - -import javax.annotation.PostConstruct; -import javax.enterprise.context.RequestScoped; -import javax.enterprise.inject.Produces; -import javax.inject.Inject; -import javax.inject.Named; - -import org.fedoraproject.insim.data.PackageDAO; -import org.fedoraproject.insim.model.Package; - -/** - * @author Mikolaj Izdebski - */ -@RequestScoped -public class PackageListProducer { - - @Inject - private PackageDAO dao; - - private List packages; - - @Produces - @Named - public List getPackages() { - return packages; - } - - @PostConstruct - public void initialize() { - packages = dao.getAll(); - } - -} diff --git a/src/main/java/org/fedoraproject/insim/frontend/view/BaselineView.java b/src/main/java/org/fedoraproject/insim/frontend/view/BaselineView.java deleted file mode 100644 index 6e16d8c..0000000 --- a/src/main/java/org/fedoraproject/insim/frontend/view/BaselineView.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 2016 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.insim.frontend.view; - -import javax.faces.bean.ManagedBean; -import javax.faces.bean.ViewScoped; -import javax.inject.Inject; - -import org.fedoraproject.insim.data.BaselineDAO; -import org.fedoraproject.insim.model.Baseline; - -/** - * @author Mikolaj Izdebski - */ -@ManagedBean -@ViewScoped -public class BaselineView { - - @Inject - private BaselineDAO dao; - - private Baseline baseline; - - private String name; - - public Baseline getBaseline() { - return baseline; - } - - public void load() { - baseline = dao.getByName(name); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/src/main/java/org/fedoraproject/insim/frontend/view/ModuleView.java b/src/main/java/org/fedoraproject/insim/frontend/view/ModuleView.java new file mode 100644 index 0000000..58741d7 --- /dev/null +++ b/src/main/java/org/fedoraproject/insim/frontend/view/ModuleView.java @@ -0,0 +1,96 @@ +/*- + * Copyright (c) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.fedoraproject.insim.frontend.view; + +import java.util.ArrayList; +import java.util.List; + +import javax.faces.bean.ManagedBean; +import javax.faces.bean.ViewScoped; +import javax.inject.Inject; + +import org.fedoraproject.insim.data.InstallationDAO; +import org.fedoraproject.insim.data.ModuleDAO; +import org.fedoraproject.insim.model.Collection; +import org.fedoraproject.insim.model.Installation; +import org.fedoraproject.insim.model.Module; + +/** + * @author Mikolaj Izdebski + */ +@ManagedBean +@ViewScoped +public class ModuleView { + + @Inject + private ModuleDAO dao; + @Inject + private InstallationDAO instDAO; + + private Module module; + + private String name; + + private final List collectionInfos = new ArrayList<>(); + + public static class CollectionInfo { + private final Collection collection; + private final Installation latestInstallation; + + public CollectionInfo(Collection collection, Installation latestInstallation) { + this.collection = collection; + this.latestInstallation = latestInstallation; + } + + public Collection getCollection() { + return collection; + } + + public Installation getLatestInstallation() { + return latestInstallation; + } + + } + + public Module getModule() { + return module; + } + + public void load() { + module = dao.getByName(name); + if (module == null) + return; + + for (Collection coll : module.getCollections()) { + Installation latestInstallation = instDAO.getLatestByModuleCollection(module, coll); + if (latestInstallation != null) { + collectionInfos.add(new CollectionInfo(coll, latestInstallation)); + } + } + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public List getCollectionInfos() { + return collectionInfos; + } +} diff --git a/src/main/java/org/fedoraproject/insim/frontend/view/PackageView.java b/src/main/java/org/fedoraproject/insim/frontend/view/PackageView.java deleted file mode 100644 index 58ea4f3..0000000 --- a/src/main/java/org/fedoraproject/insim/frontend/view/PackageView.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * Copyright (c) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.insim.frontend.view; - -import java.util.ArrayList; -import java.util.List; - -import javax.faces.bean.ManagedBean; -import javax.faces.bean.ViewScoped; -import javax.inject.Inject; - -import org.fedoraproject.insim.data.InstallationDAO; -import org.fedoraproject.insim.data.PackageDAO; -import org.fedoraproject.insim.model.Collection; -import org.fedoraproject.insim.model.Installation; -import org.fedoraproject.insim.model.Package; - -/** - * @author Mikolaj Izdebski - */ -@ManagedBean -@ViewScoped -public class PackageView { - - @Inject - private PackageDAO dao; - @Inject - private InstallationDAO instDAO; - - private Package pkg; - - private String name; - - private final List collectionInfos = new ArrayList<>(); - - public static class CollectionInfo { - private final Collection collection; - private final Installation latestInstallation; - - public CollectionInfo(Collection collection, Installation latestInstallation) { - this.collection = collection; - this.latestInstallation = latestInstallation; - } - - public Collection getCollection() { - return collection; - } - - public Installation getLatestInstallation() { - return latestInstallation; - } - - } - - public Package getPackage() { - return pkg; - } - - public void load() { - pkg = dao.getByName(name); - if (pkg == null) - return; - - for (Collection coll : pkg.getCollections()) { - Installation latestInstallation = instDAO.getLatestByPackageCollection(pkg, coll); - if (latestInstallation != null) { - collectionInfos.add(new CollectionInfo(coll, latestInstallation)); - } - } - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public List getCollectionInfos() { - return collectionInfos; - } -} diff --git a/src/main/java/org/fedoraproject/insim/model/Baseline.java b/src/main/java/org/fedoraproject/insim/model/Baseline.java deleted file mode 100644 index f2b0f28..0000000 --- a/src/main/java/org/fedoraproject/insim/model/Baseline.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * Copyright (c) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.insim.model; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.ManyToMany; - -/** - * @author Mikolaj Izdebski - */ -@Entity -public class Baseline implements Serializable { - - private static final long serialVersionUID = 1; - - @Id - private String name; - - @ElementCollection - private List pkgs; - - @ManyToMany - private List parents; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public List getPackages() { - return this.pkgs; - } - - public void setPackages(List pkgs) { - this.pkgs = pkgs; - } - - public List getParents() { - return parents; - } - - public void setParents(List parents) { - this.parents = parents; - } - - public List getAllPackages() { - return getAllPackages(new TreeSet<>(), new LinkedHashSet<>()); - } - - private List getAllPackages(Set pset, Set visited) { - if (!visited.contains(this)) { - pset.addAll(getPackages()); - visited.add(this); - for (Baseline b : parents) { - b.getAllPackages(pset, visited); - } - visited.remove(this); - } - return new ArrayList<>(pset); - } - -} diff --git a/src/main/java/org/fedoraproject/insim/model/Collection.java b/src/main/java/org/fedoraproject/insim/model/Collection.java index b5080e0..a9ed740 100644 --- a/src/main/java/org/fedoraproject/insim/model/Collection.java +++ b/src/main/java/org/fedoraproject/insim/model/Collection.java @@ -36,7 +36,7 @@ public class Collection implements Serializable { private String location; @ManyToMany - private List packages; + private List modules; public String getName() { return this.name; @@ -54,12 +54,12 @@ public class Collection implements Serializable { this.location = location; } - public List getPackages() { - return packages; + public List getModules() { + return modules; } - public void setPackages(List packages) { - this.packages = packages; + public void setModules(List modules) { + this.modules = modules; } } diff --git a/src/main/java/org/fedoraproject/insim/model/Installation.java b/src/main/java/org/fedoraproject/insim/model/Installation.java index 59ccd6e..72eb832 100644 --- a/src/main/java/org/fedoraproject/insim/model/Installation.java +++ b/src/main/java/org/fedoraproject/insim/model/Installation.java @@ -39,7 +39,7 @@ public class Installation implements Serializable { @GeneratedValue private Integer id; @ManyToOne - private Package pkg; + private Module module; @ManyToOne private Repository repository; private String version; @@ -60,12 +60,12 @@ public class Installation implements Serializable { this.id = id; } - public Package getPackage() { - return this.pkg; + public Module getModule() { + return this.module; } - public void setPackage(Package packagee) { - this.pkg = packagee; + public void setModule(Module module) { + this.module = module; } public Repository getRepository() { diff --git a/src/main/java/org/fedoraproject/insim/model/Module.java b/src/main/java/org/fedoraproject/insim/model/Module.java new file mode 100644 index 0000000..99a93f0 --- /dev/null +++ b/src/main/java/org/fedoraproject/insim/model/Module.java @@ -0,0 +1,142 @@ +/*- + * Copyright (c) 2015 Red Hat, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.fedoraproject.insim.model; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToMany; + +/** + * @author Mikolaj Izdebski + */ +@Entity +public class Module implements Serializable { + + private static final long serialVersionUID = 1; + + @Id + private String name; + private String upstream; + private String upstreamVersion; + private Long upstreamInstallSize; + private Long upstreamDownloadSize; + @ManyToMany(mappedBy = "modules") + private List collections; + @ElementCollection + private List rpms; + @ManyToMany + private List parents; + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUpstream() { + return this.upstream; + } + + public void setUpstream(String upstream) { + this.upstream = upstream; + } + + public String getUpstreamVersion() { + return upstreamVersion; + } + + public void setUpstreamVersion(String upstreamVersion) { + this.upstreamVersion = upstreamVersion; + } + + public Long getUpstreamInstallSize() { + return this.upstreamInstallSize; + } + + public void setUpstreamInstallSize(Long upstreamInstallSize) { + this.upstreamInstallSize = upstreamInstallSize; + } + + public Long getUpstreamDownloadSize() { + return this.upstreamDownloadSize; + } + + public void setUpstreamDownloadSize(Long upstreamDownloadSize) { + this.upstreamDownloadSize = upstreamDownloadSize; + } + + public List getCollections() { + return collections; + } + + public void setCollections(List collections) { + this.collections = collections; + } + + public List getRpms() { + return rpms; + } + + public void setRpms(List rpms) { + this.rpms = rpms; + } + + public boolean isMetamodule() { + return !getRpms().isEmpty(); + } + + public List getParents() { + return parents; + } + + public void setParents(List parents) { + this.parents = parents; + } + + public List getInstallRpms() { + return isMetamodule() ? getRpms() : Collections.singletonList(getName()); + } + + public List getBaselineRpms() { + return getParentRpms(new TreeSet<>(), new LinkedHashSet<>()); + } + + public List getAllRpms() { + return getParentRpms(new TreeSet<>(getInstallRpms()), new LinkedHashSet<>()); + } + + private List getParentRpms(Set rpmSet, Set visited) { + if (visited.add(this)) { + for (Module mod : parents) { + rpmSet.addAll(mod.getInstallRpms()); + mod.getParentRpms(rpmSet, visited); + } + } + return new ArrayList<>(rpmSet); + } + +} diff --git a/src/main/java/org/fedoraproject/insim/model/Package.java b/src/main/java/org/fedoraproject/insim/model/Package.java deleted file mode 100644 index a8c8e56..0000000 --- a/src/main/java/org/fedoraproject/insim/model/Package.java +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * Copyright (c) 2015 Red Hat, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.fedoraproject.insim.model; - -import java.io.Serializable; -import java.util.Collections; -import java.util.List; - -import javax.persistence.ElementCollection; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.ManyToMany; -import javax.persistence.ManyToOne; - -/** - * @author Mikolaj Izdebski - */ -@Entity -public class Package implements Serializable { - - private static final long serialVersionUID = 1; - - @Id - private String name; - @ManyToOne - private Baseline baseline; - private String upstream; - private String upstreamVersion; - private Long upstreamInstallSize; - private Long upstreamDownloadSize; - @ManyToMany(mappedBy = "packages") - private List collections; - @ElementCollection - private List rpms; - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - public Baseline getBaseline() { - return this.baseline; - } - - public void setBaseline(Baseline baseline) { - this.baseline = baseline; - } - - public String getUpstream() { - return this.upstream; - } - - public void setUpstream(String upstream) { - this.upstream = upstream; - } - - public String getUpstreamVersion() { - return upstreamVersion; - } - - public void setUpstreamVersion(String upstreamVersion) { - this.upstreamVersion = upstreamVersion; - } - - public Long getUpstreamInstallSize() { - return this.upstreamInstallSize; - } - - public void setUpstreamInstallSize(Long upstreamInstallSize) { - this.upstreamInstallSize = upstreamInstallSize; - } - - public Long getUpstreamDownloadSize() { - return this.upstreamDownloadSize; - } - - public void setUpstreamDownloadSize(Long upstreamDownloadSize) { - this.upstreamDownloadSize = upstreamDownloadSize; - } - - public List getCollections() { - return collections; - } - - public void setCollections(List collections) { - this.collections = collections; - } - - public List getRpms() { - return rpms; - } - - public void setRpms(List rpms) { - this.rpms = rpms; - } - - public boolean isMetapackage() { - return !getRpms().isEmpty(); - } - - public List getInstallRpms() { - return isMetapackage() ? getRpms() : Collections.singletonList(getName()); - } - -} diff --git a/src/main/java/org/fedoraproject/insim/rest/DataRest.java b/src/main/java/org/fedoraproject/insim/rest/DataRest.java index dc4be01..0e1f975 100644 --- a/src/main/java/org/fedoraproject/insim/rest/DataRest.java +++ b/src/main/java/org/fedoraproject/insim/rest/DataRest.java @@ -30,10 +30,10 @@ import javax.ws.rs.core.Response.Status; import org.fedoraproject.insim.data.DependencyGraphDAO; import org.fedoraproject.insim.data.InstallationDAO; -import org.fedoraproject.insim.data.PackageDAO; +import org.fedoraproject.insim.data.ModuleDAO; import org.fedoraproject.insim.model.Collection; import org.fedoraproject.insim.model.DependencyGraph; -import org.fedoraproject.insim.model.Package; +import org.fedoraproject.insim.model.Module; /** * @author Mikolaj Izdebski @@ -43,7 +43,7 @@ import org.fedoraproject.insim.model.Package; public class DataRest { @Inject - private PackageDAO pkgDao; + private ModuleDAO moduleDao; @Inject private InstallationDAO instDao; @@ -52,17 +52,17 @@ public class DataRest { private DependencyGraphDAO graphDao; @GET - @Path("installations/{package}") + @Path("installations/{module}") @Produces(MediaType.APPLICATION_JSON) - public Object getPackageInstallations( // - @PathParam("package") String pkgName // + public Object getModuleInstallations( // + @PathParam("module") String moduleName // ) { - Package pkg = pkgDao.getByName(pkgName); - if (pkg == null) + Module module = moduleDao.getByName(moduleName); + if (module == null) return Response.status(Status.NOT_FOUND).build(); - return pkg.getCollections().stream().collect(Collectors.toMap(Collection::getName, coll -> instDao - .getByPackageCollection(pkg, coll).stream() + return module.getCollections().stream().collect(Collectors.toMap(Collection::getName, coll -> instDao + .getByModuleCollection(module, coll).stream() .map(inst -> Arrays.asList(inst.getId(), inst.getRepository().getCreationTime(), inst.getComplete(), inst.getInstallSize(), inst.getDownloadSize(), inst.getDependencyCount(), inst.getFileCount())) .collect(Collectors.toList()))); diff --git a/src/main/webapp/WEB-INF/pretty-config.xml b/src/main/webapp/WEB-INF/pretty-config.xml index b9d2031..0256ff1 100644 --- a/src/main/webapp/WEB-INF/pretty-config.xml +++ b/src/main/webapp/WEB-INF/pretty-config.xml @@ -19,18 +19,18 @@ xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd"> - + - + - - - - #{packageView.load} + + + + #{moduleView.load} @@ -47,10 +47,5 @@ #{installationDiffView.load} - - - - #{baselineView.load} - diff --git a/src/main/webapp/WEB-INF/templates/default.xhtml b/src/main/webapp/WEB-INF/templates/default.xhtml index 8d82777..68269e7 100644 --- a/src/main/webapp/WEB-INF/templates/default.xhtml +++ b/src/main/webapp/WEB-INF/templates/default.xhtml @@ -34,7 +34,7 @@
diff --git a/src/main/webapp/baseline-details.xhtml b/src/main/webapp/baseline-details.xhtml deleted file mode 100644 index 590f421..0000000 --- a/src/main/webapp/baseline-details.xhtml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - Baseline details - - - - - - - Baseline not found. - - - -
-
-

Baseline information

-
- - - - - -
    - -
  • - -
  • -
    -
-
- - -
    - -
  • - - - -
  • -
    -
-
- - -
    - -
  • - -
  • -
    -
-
-
-
-
-
- -
diff --git a/src/main/webapp/collection-details.xhtml b/src/main/webapp/collection-details.xhtml index 834747d..1d9b5a3 100644 --- a/src/main/webapp/collection-details.xhtml +++ b/src/main/webapp/collection-details.xhtml @@ -26,8 +26,8 @@ - + Collection #{collectionView.name} is not known to Insim. You can contact Insim administrators in order to request adding this diff --git a/src/main/webapp/installation-details.xhtml b/src/main/webapp/installation-details.xhtml index 76bd57a..f36094d 100644 --- a/src/main/webapp/installation-details.xhtml +++ b/src/main/webapp/installation-details.xhtml @@ -55,19 +55,15 @@ - - - + + + - + - - - - - - + + @@ -120,7 +116,7 @@

The following is a dependency graph. Nodes represent packages and edges – requires between - them. Packages in baseline (assumed to be installed before attempting to install the package) + them. Packages in parent modules (assumed to be installed before attempting to install the package) are not included in the graph. Big graphs may fail to render due to memory constrains. You can hover nodes and edges to tooltip with some information – useful especially when graph is not readable due to its complexity. Soft-dependencies are not shown in the graph (yet).

diff --git a/src/main/webapp/installation-diff.xhtml b/src/main/webapp/installation-diff.xhtml index 316b33c..e1472d4 100644 --- a/src/main/webapp/installation-diff.xhtml +++ b/src/main/webapp/installation-diff.xhtml @@ -53,29 +53,22 @@ - - - + + + - - + + - + - - - - - - - - - + + - - + + diff --git a/src/main/webapp/list.xhtml b/src/main/webapp/list.xhtml index b0ec88c..df7f973 100644 --- a/src/main/webapp/list.xhtml +++ b/src/main/webapp/list.xhtml @@ -19,14 +19,14 @@ xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"> - - No packages. + + No modules. - +
- - #{package.name} + + #{module.name}
diff --git a/src/main/webapp/module-details.xhtml b/src/main/webapp/module-details.xhtml new file mode 100644 index 0000000..0901106 --- /dev/null +++ b/src/main/webapp/module-details.xhtml @@ -0,0 +1,215 @@ + + + + + + moduleName: '#{moduleView.module.name}' + + + + + + + + + + + Module #{moduleView.name} + + + + + + + Module #{moduleView.name} is not known to Insim. You + can contact Insim administrators in order to request adding this + module. + + + +
+
+

Module information

+
+ + + + + + + + + + + +
    + +
  • + +
  • +
    +
+
+ + +
    + +
  • + + + +
  • +
    +
+
+ + +
    + +
  • + +
  • +
    +
+
+
+
+ +
+
+

Latest statistics

+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CollectionVersionInstall sizeDownload sizeDependency countFile count
Upstream +
+
+ +
    +
  • install size
  • +
  • download size
  • +
  • dependency count
  • +
  • file count
  • +
+ +
+
+

Module information

+
+
+
+

Install size

+ +
+
+

Download size

+ +
+
+

Dependency count

+ +
+
+

File count

+ +
+
+
+ +

The following charts can be zoomed-in by clicking and dragging. To zoom-out, simply double-click + on the chart.

+

To see details of module installation, control-click on point representing it. + To see differences between two particular installations (from the same or different collections), + click on the first installation to compare and then shift-click on the second one.

+ + +
+

Collection #{collectionInfo.collection.name}

+

+ Latest version-release: + #{collectionInfo.latestInstallation.version}-#{collectionInfo.latestInstallation.release} +

+
+
+

Installation size

+
+
+
+
+
+
+
+

Download size

+
+
+
+
+
+
+
+

Dependency count

+
+
+
+
+
+
+
+

File count

+
+
+
+
+
+
+ + + + + diff --git a/src/main/webapp/module-list.xhtml b/src/main/webapp/module-list.xhtml new file mode 100644 index 0000000..1118ae6 --- /dev/null +++ b/src/main/webapp/module-list.xhtml @@ -0,0 +1,31 @@ + + + + + + Modules + + + + + + + diff --git a/src/main/webapp/package-details.xhtml b/src/main/webapp/package-details.xhtml deleted file mode 100644 index fec531a..0000000 --- a/src/main/webapp/package-details.xhtml +++ /dev/null @@ -1,197 +0,0 @@ - - - - - - packageName: '#{packageView.package.name}' - - - - - - - - - - - Package #{packageView.name} - - - - - - - Package #{packageView.name} is not known to Insim. You - can contact Insim administrators in order to request adding this - package. - - - -
-
-

Package information

-
- - - - - - - - - - - -
    - -
  • - -
  • -
    -
-
- - - - -
-
- -
-
-

Latest statistics

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CollectionVersionInstall sizeDownload sizeDependency countFile count
Upstream -
-
- -
    -
  • install size
  • -
  • download size
  • -
  • dependency count
  • -
  • file count
  • -
- -
-
-

Package information

-
-
-
-

Install size

- -
-
-

Download size

- -
-
-

Dependency count

- -
-
-

File count

- -
-
-
- -

The following charts can be zoomed-in by clicking and dragging. To zoom-out, simply double-click - on the chart.

-

To see details of package installation, control-click on point representing it. - To see differences between two particular installations (from the same or different collections), - click on the first installation to compare and then shift-click on the second one.

- - -
-

Collection #{collectionInfo.collection.name}

-

- Latest version-release: - #{collectionInfo.latestInstallation.version}-#{collectionInfo.latestInstallation.release} -

-
-
-

Installation size

-
-
-
-
-
-
-
-

Download size

-
-
-
-
-
-
-
-

Dependency count

-
-
-
-
-
-
-
-

File count

-
-
-
-
-
-
- - - - - diff --git a/src/main/webapp/package-list.xhtml b/src/main/webapp/package-list.xhtml deleted file mode 100644 index c8e5917..0000000 --- a/src/main/webapp/package-list.xhtml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - Packages - - - - - - - diff --git a/src/main/webapp/resources/js/graph.js b/src/main/webapp/resources/js/graph.js index e2aad7b..16e6a0f 100644 --- a/src/main/webapp/resources/js/graph.js +++ b/src/main/webapp/resources/js/graph.js @@ -129,5 +129,5 @@ function loadGraphs(data) { } $(document).ready(function() { - $.getJSON('/insim/api/data/installations/' + jsf.packageName, loadGraphs) + $.getJSON('/insim/api/data/installations/' + jsf.moduleName, loadGraphs) });