Package org.rhq.enterprise.server.resource

Examples of org.rhq.enterprise.server.resource.ResourceTypeManagerLocal


        MessageResources res = getResources(request);

        Subject subject = RequestUtils.getSubject(request);

        ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
        HttpSession session = request.getSession();

        Integer[] resourceIds = (Integer[]) session.getAttribute(Constants.RESOURCE_IDS_ATTR);
        if (resourceIds != null) {
            newForm.setResourceIds(resourceIds);

            boolean commonResourceType = false;
            Integer resourceTypeId = (Integer) session.getAttribute(Constants.RESOURCE_TYPE_ATTR);

            if (resourceTypeId != null) {
                if (resourceTypeManager.ensureResourceType(subject, resourceTypeId, resourceIds) == false) {
                    ResourceType compatibleResourceType = resourceTypeManager.getResourceTypeById(subject,
                        resourceTypeId);

                    newForm.setResourceTypeName(compatibleResourceType.getName());
                    newForm.setResourceTypeId(resourceTypeId);
                    newForm.setGroupCategory(GroupCategory.COMPATIBLE);

                    return null;
                }
            } else {
                // TODO: do we need to set the name for mixed groups anymore?
                newForm.setResourceTypeName(res.getMessage("dash.home.DisplayCategory.group.plat.server.service"));
                newForm.setGroupCategory(GroupCategory.MIXED);

                return null;
            }
        }

        /*
         * We effectively want PageControl.PAGE_ALL here, so don't even bother having a method that takes one
         */
        // TODO: Why not turn this into a single select, and simplify the display by ordering the results?
        List<ResourceType> platformTypes = resourceTypeManager.getUtilizedResourceTypesByCategory(subject,
            ResourceCategory.PLATFORM, null);
        List<ResourceType> serverTypes = resourceTypeManager.getUtilizedResourceTypesByCategory(subject,
            ResourceCategory.SERVER, null);
        List<ResourceType> serviceTypes = resourceTypeManager.getUtilizedResourceTypesByCategory(subject,
            ResourceCategory.SERVICE, null);
        List groupTypes = BizappUtils.buildGroupTypes(request);

        newForm.setPlatformTypes(platformTypes);
        newForm.setServerTypes(serverTypes);
View Full Code Here


        for (ResourceCategory nextCategory : ResourceCategory.values()) {
            addForm.addFunction(new LabelValueBean(nextCategory.toString(), nextCategory.name()));
        }

        // type drop-down
        ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
        List<ResourceType> resourceTypes = resourceTypeManager.getUtilizedResourceTypesByCategory(subject, category,
            null);
        for (ResourceType nextType : resourceTypes) {
            addForm.addType(new LabelValueBean(nextType.getName(), String.valueOf(nextType.getId())));
        }
    }
View Full Code Here

        } catch (Exception e) {
            RequestUtils.setError(request, "resource.group.inventory.error.GroupTypeIsRequired");
            return returnFailure(request, mapping);
        }

        ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
        ResourceGroupManagerLocal resourceGroupManager = LookupUtil.getResourceGroupManager();

        ResourceGroup newGroup = new ResourceGroup(newGroupName);
        try {
            if (category == GroupCategory.COMPATIBLE) {
                ResourceType groupResourceType = resourceTypeManager.getResourceTypeById(subject, resourceTypeId);
                newGroup.setResourceType(groupResourceType);
            }
        } catch (ResourceTypeNotFoundException ex) {
            log.debug("group created failed: ", ex);
            RequestUtils.setError(request, "resource.group.inventory.error.ResourceTypeIdNotFound");
View Full Code Here

    public static ResourceType getResourceType(HttpServletRequest request) {
        try {
            Integer resourceTypeId = getResourceTypeId(request);
            Subject subject = RequestUtils.getSubject(request);
            ResourceTypeManagerLocal typeManager = LookupUtil.getResourceTypeManager();

            ResourceType resourceType = typeManager.getResourceTypeById(subject, resourceTypeId);

            setResourceType(request, resourceType);

            return resourceType;
        } catch (Exception e) {
View Full Code Here

     * Get a list of the individual 'child resources' of that autogroup.
     */
    private List<AutoGroupComposite> getAutoGroupChildren(Subject subject, int parentId, int resourceTypeId) {
        List<AutoGroupComposite> children = new ArrayList<AutoGroupComposite>();
        ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
        ResourceTypeManagerLocal resourceTypeMananger = LookupUtil.getResourceTypeManager();
        Resource parentResource = resourceManager.getResourceById(subject, parentId);
        ResourceType resourceType = null;
        try {
            resourceType = resourceTypeMananger.getResourceTypeById(subject, resourceTypeId);
        } catch (ResourceTypeNotFoundException e) {
            return children; // empty list if we don't know the child type
        }

        if ((resourceType != null) && (parentResource != null)) {
View Full Code Here

        log.trace("Executing ConfigMetricsFormPrepareAction...");

        Subject subject = WebUtility.getSubject(request);
        MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
        MeasurementDefinitionManagerLocal definitionManager = LookupUtil.getMeasurementDefinitionManager();
        ResourceTypeManagerLocal rtManager = LookupUtil.getResourceTypeManager();

        // NOTE: This action will be passed either a resourceTypeId OR a resourceId or a groupID or type+parent
        boolean configuringDefaultSchedules = false;
        int type = WebUtility.getOptionalIntRequestParameter(request, "type", -1);
        int parent = WebUtility.getOptionalIntRequestParameter(request, "parent", -1);

        // If only a type is present, we want the defaults
        if ((type > 0) && (parent == -1)) {
            configuringDefaultSchedules = true;
        }

        PageList<MeasurementScheduleComposite> measurementSchedules = null;
        PageControl pageControl = WebUtility.getPageControl(request);
        int groupId = WebUtility.getOptionalIntRequestParameter(request, "groupId", -1);
        if (configuringDefaultSchedules || (groupId > 0) || ((type > 0) && (parent > 0))) {
            pageControl.initDefaultOrderingField("md.name"); // underlying query runs over the MeasurementDefinition
        } else {
            pageControl.initDefaultOrderingField("ms.definition.name");
        }

        // We never want pagination for the schedules table, so don't allow user to change ps to anything other than -1.
        pageControl.setPageSize(PageControl.SIZE_UNLIMITED);

        if (configuringDefaultSchedules) {
            int resourceTypeId = type;
            log.debug("Obtaining default metric schedules for resource type " + resourceTypeId + "...");
            List<MeasurementDefinition> definitions = definitionManager.findMeasurementDefinitionsByResourceType(
                subject, resourceTypeId, null, null);
            List<MeasurementScheduleComposite> composites = new ArrayList<MeasurementScheduleComposite>();
            for (MeasurementDefinition definition : definitions) {
                composites.add(new MeasurementScheduleComposite(definition, definition.isDefaultOn(), definition
                    .getDefaultInterval()));
            }
            measurementSchedules = new PageList<MeasurementScheduleComposite>(composites, definitions.size(),
                pageControl);
            //request.setAttribute(AttrConstants.MONITOR_ENABLED_ATTR, Boolean.FALSE);
            ResourceType rType = rtManager.getResourceTypeById(subject, resourceTypeId);

            request.setAttribute(AttrConstants.RESOURCE_TYPE_ATTR, rType);
            //request.setAttribute("section", resourceCategoryName);
        } else {
            int resourceId = WebUtility.getOptionalIntRequestParameter(request, "id", -1);
View Full Code Here

            String[] resourceIds = request.getParameterValues("resourceIds");

            // TODO rewrite the selection using WebUtility.getMetricsDisplayMode()
            if ((resourceTypeId > 0) && (parent > 0)) // autogroup
            {
                ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
                ResourceType resourceType = resourceTypeManager.getResourceTypeById(subject, resourceTypeId);
                request.setAttribute(AttrConstants.RESOURCE_TYPE_ATTR, resourceType);
                request.setAttribute(AttrConstants.TITLE_PARAM_ATTR, resourceType.getName());
                request.setAttribute("parent", parent);
                request.setAttribute(ParamConstants.RESOURCE_TYPE_ID_PARAM, resourceTypeId);
                if (log.isDebugEnabled()) {
                    log.debug("Autogroup p=" + parent + ", ct=" + resourceTypeId);
                }
            } else if (groupId > 0) // compat (or mixed) group
            {
                ResourceGroupManagerLocal resourceGroupManager = LookupUtil.getResourceGroupManager();
                ResourceGroup group = resourceGroupManager.getResourceGroupById(subject, groupId, null);
                request.setAttribute(AttrConstants.GROUP_ID, groupId);
                request.setAttribute(AttrConstants.TITLE_PARAM_ATTR, group.getName());
                // TODO more ?
            } else if ((resourceTypeId > 0) && (parent == -1)) // MeasurementDefinition
            {
                ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();
                ResourceType resourceType = resourceTypeManager.getResourceTypeById(subject, resourceTypeId);
                request.setAttribute(AttrConstants.RESOURCE_TYPE_ATTR, resourceType);
                request.setAttribute(ParamConstants.RESOURCE_TYPE_ID_PARAM, resourceTypeId);
            } else if ((r != null) && (r.length > 0)) // multiple scathered resources
            {
                log.trace("Multiple resources not handled yet"); // TODO what do we do here?
View Full Code Here

    }

    private AlertDefinition injectAlertDef(InjectedTemplate injectedAlertDef, boolean replaceIfExists) {

        AlertDefinition result = null;
        ResourceTypeManagerLocal typeManager = LookupUtil.getResourceTypeManager();
        AlertDefinitionManagerLocal alertDefManager = LookupUtil.getAlertDefinitionManager();
        SubjectManagerLocal subjectManager = LookupUtil.getSubjectManager();

        ResourceTypeCriteria rtc = new ResourceTypeCriteria();
        rtc.addFilterPluginName(injectedAlertDef.getPluginName());
        rtc.addFilterName(injectedAlertDef.getResourceTypeName());
        rtc.fetchMetricDefinitions(true);
        List<ResourceType> resourceTypes = typeManager.findResourceTypesByCriteria(subjectManager.getOverlord(), rtc);

        if (resourceTypes.isEmpty()) {
            return result;
        }
View Full Code Here

                // not a problem, this can be null
            }

            Subject subject = RequestUtils.getSubject(request);
            ResourceGroupManagerLocal groupManager = LookupUtil.getResourceGroupManager();
            ResourceTypeManagerLocal resourceTypeManager = LookupUtil.getResourceTypeManager();

            // auto-group support (of plats?)
            // request.setAttribute(Constants.CONTROL_ENABLED_ATTR, Boolean.FALSE);
            // request.setAttribute(Constants.PERFORMANCE_SUPPORTED_ATTR, Boolean.FALSE);
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.resource.ResourceTypeManagerLocal

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.