Package org.rhq.core.domain.resource

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


                removeDefinitions.setParameter("resourceTypeId", type.getId());
                removeDefinitions.executeUpdate();
            }

            for (int resourceId : resourceIds) {
                Resource r = em.find(Resource.class, resourceId);
                ResourceTreeHelper.deleteResource(em, r);
            }

            if (type != null) {
                type = em.find(ResourceType.class, type.getId());
View Full Code Here


                            MSG.view_drift_wizard_pinTemplate_failure("Invalid Snapshot"));
                    }

                    // get the relevant ResourceType, including the type's potential drift templates to pin
                    final DriftDefinition driftDef = result.get(0);
                    final Resource resource = driftDef.getResource();

                    ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
                        EnumSet.of(ResourceTypeRepository.MetadataType.driftDefinitionTemplates),
                        new ResourceTypeRepository.TypeLoadedCallback() {

                            public void onTypesLoaded(ResourceType type) {
                                DriftPinTemplateWizard wizard = new DriftPinTemplateWizard(type, driftDef,
View Full Code Here

            public void execute() throws Exception {
                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);
View Full Code Here

        executeInTransaction(new TransactionCallback() {

            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);
View Full Code Here

    public void testDeleteEventStuff() throws Exception {
        System.out.println("= testDeleteEvent");
        EventManagerLocal eventManager = LookupUtil.getEventManager();

        ResourceType platform = null;
        Resource testResource = null;

        // prepare basic stuff
        try {
            registerPlugin("event1-2.xml");
            getTransactionManager().begin();
            platform = getResourceType("events");

            testResource = new Resource("-test-", "-test resource", platform);
            testResource.setUuid("" + new Random().nextInt());
            em.persist(testResource);
            setUpAgent(testResource);
            getTransactionManager().commit();

            getTransactionManager().begin();
            platform = em.find(ResourceType.class, platform.getId());
            testResource = em.find(Resource.class, testResource.getId());
            Set<EventDefinition> eDefs = platform.getEventDefinitions();
            assert eDefs.size() == 2 : "Did not find the expected 2 eventDefinitions, but " + eDefs.size();
            Iterator<EventDefinition> eIter = eDefs.iterator();
            boolean found = false;
            Map<EventSource, Set<Event>> events = new HashMap<EventSource, Set<Event>>(1);
View Full Code Here

    @Path("/{id}/sources")
    @ApiOperation(value = "List the defined event sources for the resource", responseClass = "EventSourceRest", multiValueResponse = true)
    public Response listEventSourcesForResource(@ApiParam("id of the resource") @PathParam("id") int resourceId,
                                                @Context HttpHeaders headers) {

        Resource res = fetchResource(resourceId);
        Set<EventSource> eventSources = res.getEventSources();

        List<EventSourceRest> restSources = new ArrayList<EventSourceRest>(eventSources.size());
        for (EventSource source : eventSources) {
            EventSourceRest esr = convertEventSource(source);
            restSources.add(esr);
View Full Code Here

    @Path("/{id}/definitions")
    @ApiOperation(value = "List the defined event source definitions for the resource", responseClass = "EventDefintionRest", multiValueResponse = true)
    public Response listEventDefinitionsForResource(@ApiParam("id of the resource") @PathParam("id") int resourceId,
                                                    @Context HttpHeaders headers) {

        Resource res = fetchResource(resourceId);
        ResourceType resourceType = res.getResourceType();
        em.refresh(resourceType);
        Set<EventDefinition> eventDefinitions = resourceType.getEventDefinitions();

        List<EventDefinitionRest> definitionsRest = new ArrayList<EventDefinitionRest>(eventDefinitions.size());
        for (EventDefinition source : eventDefinitions) {
View Full Code Here

        @ApiError(code = 406, reason = "Tried to create an event source on the same definition with the same location")
    })
    public EventSourceRest addEventSource(@ApiParam("id of the resource") @PathParam("id") int resourceId,
                                          EventSourceRest esr) {

        Resource resource = fetchResource(resourceId);
        ResourceType rt = resource.getResourceType();
        Set<EventDefinition> eventDefinitions = rt.getEventDefinitions();
        EventDefinition eventDefinition=null;
        for (EventDefinition ed : eventDefinitions) {
            if (ed.getName().equals(esr.getName())) {
                eventDefinition = ed;
View Full Code Here

        // To properly filter Create Child and Import menus we need existing singleton child resources. If the
        // user has create permission and the parent type has singleton child types and creatable or importable child
        // types, perform an async call to fetch the singleton children. If we make the async call don't declare this
        // instance initialized until after it completes as we must have the children before the menu buttons can be drawn.

        final Resource parentResource = parentResourceComposite.getResource();
        ResourceType parentType = parentResource.getResourceType();
        creatableChildTypes = getCreatableChildTypes(parentType);
        importableChildTypes = getImportableChildTypes(parentType);
        hasCreatableTypes = !creatableChildTypes.isEmpty();
        hasImportableTypes = !importableChildTypes.isEmpty();
        refreshSingletons(parentResource, new AsyncCallback<PageList<Resource>>() {
View Full Code Here

                    if (isEnabled) {
                        for (ListGridRecord record : selection) {
                            ResourceComposite resComposite = (ResourceComposite) record
                                .getAttributeAsObject("resourceComposite");
                            Resource res = resComposite.getResource();
                            if (!(isEnabled = res.getResourceType().isDeletable())) {
                                break;
                            }
                            ResourcePermission resPermission = resComposite.getResourcePermission();
                            if (!(isEnabled = resPermission.isDeleteResource())) {
                                break;
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.