Package org.rhq.core.domain.resource

Examples of org.rhq.core.domain.resource.Resource


    }

    @SuppressWarnings("unchecked")
    private void addImportAndCreateButtons(boolean override) {

        final Resource parentResource = parentResourceComposite.getResource();

        // Create Child Menu and Manual Import Menu
        if (canCreate && (hasCreatableTypes || hasImportableTypes)) {
            if (hasCreatableTypes) {
                Map<String, ResourceType> displayNameMap = getDisplayNames(creatableChildTypes);
View Full Code Here


            registerPlugin("update2-v1_0.xml");

            Subject overlord = LookupUtil.getSubjectManager().getOverlord();

            ResourceType platform1 = getResourceType("myPlatform");
            Resource platformResource = createResource("foo-myPlatform", "foo-myPlatform", platform1);
            resourceManager.createResource(overlord, platformResource, -1);

            ResourceType service1 = getResourceType("service1");
            Resource service1Resource = createResource("foo-service1", "foo-service1", service1);
            platformResource.addChildResource(service1Resource);
            resourceManager.createResource(overlord, service1Resource, -1);

            ResourceType nestedOne = getResourceType("nestedOne");
            Resource nestedOneResource = createResource("foo-nestedOne", "foo-nestedOne", nestedOne);
            service1Resource.addChildResource(nestedOneResource);
            resourceManager.createResource(overlord, nestedOneResource, -1);

            getTransactionManager().begin();
            platform1 = em.find(ResourceType.class, platform1.getId());

            assert platform1 != null : "I did not find myPlatform";
            Set<MeasurementDefinition> defs = platform1.getMetricDefinitions();
            // no built-in AvailabilityType metric for platforms
            assert defs.size() == 1 : "I was expecting 1 metric definition at platform level in v1";
            assert DisplayType.DETAIL == defs.iterator().next().getDisplayType() : "Display type should be DETAIL in v1";

            // one child service in v1
            Set<ResourceType> platformChildren = platform1.getChildResourceTypes();
            assert platformChildren.size() == 1 : "Expected 1 direct child service of platform in v1";
            service1 = platformChildren.iterator().next();
            assert service1.getName().equals("service1") : "Expected 'service1' as name of direct platform child in v1";
            // include the built-in AvailabilityType metric           
            assert service1.getMetricDefinitions().size() == 2 : "Expected 2 metric for 'service1' in v1";
            Set<ResourceType> nestedServices = service1.getChildResourceTypes();
            assert nestedServices.size() == 1 : "Expected 1 nested service of 'service1' in v1";
            Set<MeasurementDefinition> nestedDefs = nestedServices.iterator().next().getMetricDefinitions();
            // include the built-in AvailabilityType metric
            assert nestedDefs.size() == 2 : "Expected 2 definition within 'nestedService' in v1";
            MeasurementDefinition defThree = nestedDefs.iterator().next();
            int definitionId = defThree.getId(); // get the id of the definition "Three" and save it for later use
            getTransactionManager().rollback();

            System.out.println("testMoveResourceType -- done with the first plugin version");

            /*
             * The nested service got pulled out and put under platform
             */
            registerPlugin("update2-v2_0.xml");
            ResourceType platform2 = getResourceType("myPlatform");
            getTransactionManager().begin();

            platform2 = em.find(ResourceType.class, platform2.getId());

            assert platform2 != null : "I did not find myPlatform";
            Set<MeasurementDefinition> defs2 = platform2.getMetricDefinitions();
            // no built-in AvailabilityType metric for platforms           
            assert defs2.size() == 1 : "I was expecting 1 definition at platform level in v2";
            assert DisplayType.SUMMARY == defs2.iterator().next().getDisplayType() : "Display type should be SUMMARY in v2";

            ResourceCriteria resourceCriteria = new ResourceCriteria();
            resourceCriteria.setStrict(true);
            resourceCriteria.addFilterResourceKey("foo-myPlatform");
            resourceCriteria.fetchChildResources(true);
            Resource platform2Resource = getResource(resourceCriteria);
            assert platform2Resource != null : "Expected to find platform Resource in db.";

            // two children in v2
            Set<ResourceType> platformChildren2 = platform2.getChildResourceTypes();
            assert platformChildren2.size() == 2 : "Expected 2 direct child service types of platform in v2";

            Set<Resource> platform2ChildResources = platform2Resource.getChildResources();
            assert platform2ChildResources.size() == 2 : "Expected 2 direct child services of platform in v2";
            boolean foundMovedResource = false;
            for (Resource childResource : platform2ChildResources) {
                assert childResource.getChildResources().isEmpty() : "Expected child Resource " + childResource
                    + " to have no children";
View Full Code Here

        }
        ret.setAlertTime(al.getCtime());
        ret.setDescription(alertManager.prettyPrintAlertConditions(al,false));
        ret.setRecoveryTime(al.getRecoveryTime());

        Resource r = fetchResource(alertDefinition.getResource().getId());
        ResourceWithType rwt;
        if (slim) {
            rwt = new ResourceWithType(r.getName(),r.getId());
        } else {
            rwt = fillRWT(r,uriInfo);
        }
        ret.setResource(rwt);
View Full Code Here

                        uncommittedCount--;
                    } else {
                        avail = AvailabilityType.UP;
                    }

                    Resource res = SessionTestHelper.createNewResourceForGroup(em, lge.compatibleGroup,
                        "LargeGroupTestServer", lge.serverType, avail, (i % 100) == 0);
                    res.setAgent(lge.agent);
                    res.setInventoryStatus(inventoryStatus);
                    lge.platformResource.addChildResource(res);

                    // give it an initial plugin configuration
                    Configuration pc = new Configuration();
                    pc.put(new PropertySimple(PC_PROP1_NAME, PC_PROP1_VALUE));
                    pc.put(new PropertySimple(PC_PROP2_NAME, res.getId()));
                    em.persist(pc);
                    res.setPluginConfiguration(pc);

                    if ((i % 100) == 0) {
                        System.out.print(i);
                    } else if ((i % 10) == 0) {
                        System.out.print('.');
View Full Code Here

                record.setAttribute(DriftDefinitionDataSource.ATTR_ATTACHED, from.isAttached() ? MSG.common_val_yes()
                    : MSG.common_val_no());

                // for ancestry handling
                Resource resource = from.getResource();
                record.setAttribute(AncestryUtil.RESOURCE_ID, resource.getId());
                record.setAttribute(AncestryUtil.RESOURCE_NAME, resource.getName());
                record.setAttribute(AncestryUtil.RESOURCE_ANCESTRY, resource.getAncestry());
                record.setAttribute(AncestryUtil.RESOURCE_TYPE_ID, resource.getResourceType().getId());

                return record;
            }
View Full Code Here

                                @Context HttpHeaders headers, @Context UriInfo uriInfo) {

        MediaType mediaType = headers.getAcceptableMediaTypes().get(0);

        ResourceGroup resourceGroup = fetchGroup(id, false);
        Resource res = resourceManager.getResource(caller,resourceId);
        if (res==null)
            throw new StuffNotFoundException("Resource with id " + resourceId);

        // A resource type is set for the group, so only allow to add resources with the same type.
        if (resourceGroup.getResourceType()!=null) {
            if (!res.getResourceType().equals(resourceGroup.getResourceType())) {
                Response.ResponseBuilder status = Response.status(Response.Status.CONFLICT);
                status.type(mediaType);
                return status.build();
            }
        }
View Full Code Here

                                   @ApiParam("Id of the resource to remove") @PathParam("resourceId") int resourceId,
                                   @ApiParam("Validate if the resource exists in the group") @QueryParam(
                                       "validate") @DefaultValue("false") boolean validate) {

        ResourceGroup resourceGroup = fetchGroup(id, false);
        Resource res = resourceManager.getResource(caller, resourceId);
        if (res==null)
            throw new StuffNotFoundException("Resource with id " + resourceId);

        boolean removed = resourceGroup.removeExplicitResource(res);
        if (!removed && validate) {
View Full Code Here

                + pluginName + ".");
        }
    }

    protected Resource createResource(String resourceKey, String name, ResourceType type) {
        Resource resource = new Resource(resourceKey, name, type);
        resource.setUuid(UUID.randomUUID().toString());
        resource.setInventoryStatus(InventoryStatus.COMMITTED);
        return resource;
    }
View Full Code Here

    protected Resource persistNewResource(final String resourceTypeName) throws Exception {
        return executeInTransaction(false, new TransactionCallbackReturnable<Resource>() {

            public Resource execute() throws Exception {
                ResourceType resourceType = getResourceType(resourceTypeName);
                Resource resource = new Resource("reskey" + System.currentTimeMillis(), "resname", resourceType);
                resource.setUuid(UUID.randomUUID().toString());
                resource.setInventoryStatus(InventoryStatus.COMMITTED);
                setUpAgent(resource);
                em.persist(resource);
                return resource;
            }
        });
View Full Code Here

        leftPane.setWidth("50%");
        leftPane.setPadding(5);
        leftPane.setMembersMargin(5);
        leftPane.setAutoHeight();

        Resource resource = null;
        ResourceGroup group = null;
        GroupCategory groupCategory = null;
        Set<ResourceTypeFacet> facets = null;
        Set<ResourceTypeFacet> resourceFacets = null;
        if ((groupComposite != null) && (groupComposite.getResourceGroup() != null)) {
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.resource.Resource

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.