Package org.rhq.core.domain.content

Examples of org.rhq.core.domain.content.Package


            resourceType1.addPackageType(packageType1);
            resourceType1.addPackageType(packageType2);
            resourceType1.addPackageType(packageType3);

            // Package 1 - Contains 2 versions
            package1 = new Package("Package1", packageType1);

            package1.addVersion(new PackageVersion(package1, "1.0.0", architecture1));
            package1.addVersion(new PackageVersion(package1, "2.0.0", architecture1));

            em.persist(package1);

            // Package 2 - Contains 2 versions
            package2 = new Package("Package2", packageType2);

            package2.addVersion(new PackageVersion(package2, "1.0.0", architecture1));
            package2.addVersion(new PackageVersion(package2, "2.0.0", architecture1));

            em.persist(package2);

            // Package 3 - Contains 1 version
            package3 = new Package("Package3", packageType3);

            package3.addVersion(new PackageVersion(package3, "1.0.0", architecture1));

            em.persist(package3);

            // Package 4 - Contains 2 versions, the first is installed
            package4 = new Package("Package4", packageType4);

            PackageVersion package4Installed = new PackageVersion(package4, "1.0.0", architecture1);
            package4.addVersion(package4Installed);
            package4.addVersion(new PackageVersion(package4, "2.0.0", architecture1));

            em.persist(package4);

            // Package 5 - Contains 1 version, it is installed
            package5 = new Package("Package5", packageType4);

            PackageVersion package5Installed = new PackageVersion(package5, "1.0.0", architecture1);
            package5.addVersion(package5Installed);

            em.persist(package5);
View Full Code Here


        final String pvName = "testPersistSafelyPackageVersion version";
        final PackageType pkgType = packageType1;
        final Architecture arch = architecture1;

        // these will not have any JPA stubs inside them (i.e. no lazy exceptions will occur with these)
        Package pkgPojo = new Package(pkgName, pkgType);
        PackageVersion pvPojo = new PackageVersion(pkgPojo, pvName, arch);
        Configuration configPojo = new Configuration();
        configPojo.put(new PropertySimple("one", "two"));
        pvPojo.setExtraProperties(configPojo);

        Package persistedPkg = null;
        PackageVersion persistedPV = null;

        try {
            // create the entities that we will pass to the persist methods - these will get altered
            Package pkg = new Package(pkgName, pkgType);
            PackageVersion pv = new PackageVersion(pkg, pvName, arch);
            pv.setExtraProperties(configPojo);

            persistedPkg = this.contentManager.persistOrMergePackageSafely(pkg);
            assert persistedPkg != null;
            assert persistedPkg.getId() > 0;
            assert persistedPkg.equals(pkgPojo) : "not equal: " + persistedPkg + "<>" + pkgPojo;

            persistedPV = this.contentManager.persistOrMergePackageVersionSafely(pv);
            assert persistedPV != null;
            assert persistedPV.getId() > 0;
            assert persistedPV.equals(pvPojo) : "not equal: " + persistedPV + "<>" + pvPojo;
            assert persistedPV.getExtraProperties() != null;
            assert persistedPV.getExtraProperties().getId() > 0;
            assert persistedPV.getExtraProperties().getSimple("one").getStringValue().equals("two");

            // remember their new IDs - we want to make sure the same IDs are reused later
            int pkgId = persistedPkg.getId();
            int pvId = persistedPV.getId();
            int configId = persistedPV.getExtraProperties().getId();
            int propId = persistedPV.getExtraProperties().getSimple("one").getId();

            // we've persisted them, let's make sure our "safely" methods still work
            // create new entities that we will pass to the persist methods - these will get altered
            pkg = new Package(pkgName, pkgType);
            pv = new PackageVersion(pkg, pvName, arch);
            pv.setExtraProperties(configPojo);

            persistedPkg = this.contentManager.persistOrMergePackageSafely(pkg);
            assert persistedPkg != null;
            assert persistedPkg.getId() > 0;
            assert persistedPkg.equals(pkgPojo) : "not equal: " + persistedPkg + "<>" + pkgPojo;

            persistedPV = this.contentManager.persistOrMergePackageVersionSafely(pv);
            assert persistedPV != null;
            assert persistedPV.getId() > 0;
            assert persistedPV.equals(pvPojo) : "not equal: " + persistedPV + "<>" + pvPojo;
            assert persistedPV.getExtraProperties() != null;
            assert persistedPV.getExtraProperties().getId() > 0;
            assert persistedPV.getExtraProperties().getSimple("one").getStringValue().equals("two");

            // make sure we merged the existing entities - we should not have created new ones
            assert pkgId == persistedPkg.getId();
            assert pvId == persistedPV.getId();
            assert configId == persistedPV.getExtraProperties().getId();
            assert propId == persistedPV.getExtraProperties().getSimple("one").getId();

            // now pass in existing entities with non-zero IDs
            pkg = new Package(pkgName, pkgType);
            pv = new PackageVersion(pkg, pvName, arch);
            pv.setExtraProperties(configPojo);
            pkg.setId(persistedPkg.getId());
            pv.setId(persistedPV.getId());

            persistedPkg = this.contentManager.persistOrMergePackageSafely(pkg);
            assert persistedPkg != null;
            assert persistedPkg.getId() > 0;
View Full Code Here

                // PackageX didn't already exist in the system, so ensure it was created and populated correctly from our
                // discovered package
                Query packageXQuery = em.createNamedQuery(Package.QUERY_FIND_BY_NAME_PKG_TYPE_ID);
                packageXQuery.setParameter("name", "PackageX");
                packageXQuery.setParameter("packageTypeId", packageType4.getId());
                Package packageX = (Package) packageXQuery.getSingleResult();

                assert packageX.getName().equals("PackageX") : "Package name not specified on created package";
                assert packageX.getPackageType().equals(packageType4) : "Package type incorrect on created package. Expected: "
                    + packageType4 + ", Found: " + packageX.getPackageType();

                Query packageVersionQuery = em.createNamedQuery(PackageVersion.QUERY_FIND_BY_PACKAGE_ID);
                packageVersionQuery.setParameter("packageId", packageX.getId());
                List<PackageVersion> packageVersions = packageVersionQuery.getResultList();

                assert packageVersions.size() == 1 : "Incorrect number of versions for package. Expected: 1, Found: "
                    + packageVersions.size();
View Full Code Here

            resourceType1.addPackageType(packageType1);
            resourceType1.addPackageType(packageType2);
            resourceType1.addPackageType(packageType3);

            // Package 1 - Contains 2 versions
            package1 = new Package("Package1", packageType1);

            package1.addVersion(new PackageVersion(package1, "1.0.0", architecture1));
            package1.addVersion(new PackageVersion(package1, "2.0.0", architecture1));

            em.persist(package1);

            // Package 2 - Contains 2 versions
            package2 = new Package("Package2", packageType2);

            package2.addVersion(new PackageVersion(package2, "1.0.0", architecture1));
            package2.addVersion(new PackageVersion(package2, "2.0.0", architecture1));

            em.persist(package2);

            // Package 3 - Contains 1 version
            package3 = new Package("Package3", packageType3);

            package3.addVersion(new PackageVersion(package3, "1.0.0", architecture1));

            em.persist(package3);

            // Package 4 - Contains 2 versions, the first is installed
            package4 = new Package("Package4", packageType4);

            PackageVersion package4Installed = new PackageVersion(package4, "1.0.0", architecture1);
            package4.addVersion(package4Installed);
            package4.addVersion(new PackageVersion(package4, "2.0.0", architecture1));

            em.persist(package4);

            // Package 5 - Contains 1 version, it is installed
            package5 = new Package("Package5", packageType3);

            PackageVersion package5Installed = new PackageVersion(package5, "1.0.0", architecture1);
            package5.addVersion(package5Installed);

            em.persist(package5);
View Full Code Here

            em.persist(packageType1);

            resourceType.addPackageType(packageType1);

            // Package 1 - No product versions specified
            package1 = new Package("Package1", packageType1);
            PackageVersion packageVersion1 = new PackageVersion(package1, "1.0.0", architecture);
            package1.addVersion(packageVersion1);

            em.persist(package1);

            // Package 2 - Has list of product versions that contains the resource's version
            package2 = new Package("Package2", packageType1);
            PackageVersion packageVersion2 = new PackageVersion(package2, "1.0.0", architecture);
            ProductVersionPackageVersion pvpv1 = packageVersion2.addProductVersion(productVersion1);
            ProductVersionPackageVersion pvpv2 = packageVersion2.addProductVersion(productVersion2);
            package2.addVersion(packageVersion2);

            em.persist(package2);
            em.persist(pvpv1);
            em.persist(pvpv2);

            // Package 3 - Has list of product versions where the resource version is not included
            package3 = new Package("Package3", packageType1);
            PackageVersion packageVersion3 = new PackageVersion(package3, "1.0.0", architecture);
            ProductVersionPackageVersion pvpv3 = packageVersion3.addProductVersion(productVersion2);
            package3.addVersion(packageVersion3);

            em.persist(package3);
            em.persist(pvpv3);

            // Package 4 - No product version restriction, but already installed on the resource
            package4 = new Package("Package4", packageType1);
            PackageVersion packageVersion4 = new PackageVersion(package4, "1.0.0", architecture);
            package4.addVersion(packageVersion4);

            em.persist(package4);
View Full Code Here

        packageType1.setDisplayName("TestResourcePackage");
        packageType1.setCreationData(true);
        packageType1.setResourceType(resourceType1);
        em.persist(packageType1);
        em.flush();
        Package package1 = new Package("Package1", packageType1);

        package1.addVersion(new PackageVersion(package1, "1.0.0", architecture1));
        package1.addVersion(new PackageVersion(package1, "2.0.0", architecture1));

        em.persist(package1);
        em.flush();
        //AdvisoryPackage ap = new AdvisoryPackage(advobject, package1);
        //em.persist(ap);

        AdvisoryPackage ap = advManager.createAdvisoryPackage(overlord, advobject, package1.getVersions().get(0));

        PageList<AdvisoryPackage> pkglist = advManager.findPackageByAdvisory(overlord, id1, PageControl
            .getUnlimitedInstance());
        assert pkglist != null;
        assert pkglist.size() != 0;
View Full Code Here

                LoadedPackageBitsComposite composite;

                try {
                    Resource resource = SessionTestHelper.createNewResource(em, "testPkgBitsResource");
                    PackageType pkgType = new PackageType("testPkgBitsPT", resource.getResourceType());
                    org.rhq.core.domain.content.Package pkg = new Package("testPkgBitsP", pkgType);
                    Architecture arch = new Architecture("testPkgArch");
                    PackageVersion pkgVer = new PackageVersion(pkg, "1", arch);

                    em.persist(pkgType);
                    em.persist(pkg);
View Full Code Here

            public void execute() throws Exception {
                LoadedPackageBitsComposite composite;
                try {
                    Resource resource = SessionTestHelper.createNewResource(em, "testPkgBitsLargeResource");
                    PackageType pkgType = new PackageType("testPkgBitsLargePT", resource.getResourceType());
                    org.rhq.core.domain.content.Package pkg = new Package("testPkgBitsLargeP", pkgType);
                    Architecture arch = new Architecture("testPkgLargeArch");
                    PackageVersion pkgVer = new PackageVersion(pkg, "1", arch);

                    em.persist(pkgType);
                    em.persist(pkg);
View Full Code Here

        SubjectManagerLocal subjectMgr = LookupUtil.getSubjectManager();
        ContentManagerLocal contentMgr = LookupUtil.getContentManager();

        List<PackageType> packageTypes = contentMgr.findPackageTypes(subjectMgr.getOverlord(), resourceTypeName,
            pluginName);
        Package pkg = new Package(packageName, packageTypes.get(0));

        contentMgr.persistPackage(pkg);
    }
View Full Code Here

            // we don't bother caching these - we won't have large amounts of the same packages
            q = entityManager.createNamedQuery(Package.QUERY_FIND_BY_NAME_PKG_TYPE_RESOURCE_TYPE);
            q.setParameter("name", newDetails.getName());
            q.setParameter("packageTypeName", newDetails.getPackageTypeName());
            q.setParameter("resourceTypeId", rt != null ? rt.getId() : null);
            Package pkg;
            try {
                pkg = (Package) q.getSingleResult();
            } catch (NoResultException nre) {
                pkg = new Package(newDetails.getName(), pt);
                pkg.setClassification(newDetails.getClassification());
                // we would have liked to rely on merge cascading when we merge the PV
                // but we need to watch out for the fact that we could be running at the
                // same time an agent sent us a content report that wants to create the same package.
                // if this is too hard a hit on performance, we can comment out the below line
                // and just accept the fact we might fail if the package is created underneath us,
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.content.Package

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.