Package org.rhq.coregui.client.gwt

Examples of org.rhq.coregui.client.gwt.ResourceGroupGWTServiceAsync


                    int[] groupIds = new int[selections.length];
                    int index = 0;
                    for (ListGridRecord selection : selections) {
                        groupIds[index++] = selection.getAttributeAsInt("id");
                    }
                    ResourceGroupGWTServiceAsync resourceGroupManager = GWTServiceLookup.getResourceGroupService();

                    resourceGroupManager.deleteResourceGroups(groupIds, new AsyncCallback<Void>() {
                        public void onFailure(Throwable caught) {
                            CoreGUI.getErrorHandler().handleError(MSG.view_inventory_groups_deleteFailed(), caught);
                            refreshTableInfo();
                        }
View Full Code Here


        setPadding(10);
        startRefreshCycle();
    }

    public void populateData() {
        ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();

        ResourceGroupCriteria criteria = new ResourceGroupCriteria();
        criteria.addFilterId(context.getGroupId());
        criteria.fetchResourceType(true);
        criteria.fetchExplicitResources(true);
        if (context.isAutoCluster()) {
            criteria.addFilterVisible(false);
        } else if (context.isAutoGroup()) {
            criteria.addFilterVisible(false);
            criteria.addFilterPrivate(true);
        }

        childResources = new TreeSet<Resource>();
        measurementForEachResource.clear();
        groupService.findResourceGroupCompositesByCriteria(criteria,
                new AsyncCallback<PageList<ResourceGroupComposite>>() {
                    @Override
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(), caught);
                    }
View Full Code Here

        addTableAction(MSG.common_button_delete(), MSG.common_msg_areYouSure(), ButtonColor.RED, new AbstractTableAction(
            TableActionEnablement.ANY) {
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                final int[] groupDefinitionIds = TableUtility.getIds(selection);
                ResourceGroupGWTServiceAsync groupManager = GWTServiceLookup.getResourceGroupService(60000);
                groupManager.deleteGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
                    @Override
                    public void onSuccess(Void result) {
                        CoreGUI.getMessageCenter().notify(
                            new Message(MSG.view_dynagroup_deleteSuccessfulSelection(String
                                .valueOf(groupDefinitionIds.length)), Severity.Info));
                        GroupDefinitionListView.this.refresh();
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError(MSG.view_dynagroup_deleteFailureSelection(), caught);
                    }
                });
            }
        });

        addTableAction(MSG.common_button_new(), null, ButtonColor.BLUE, new AbstractTableAction() {
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                newDetails();
            }
        });

        addTableAction(MSG.view_dynagroup_recalculate(), null, ButtonColor.GRAY, new AbstractTableAction(TableActionEnablement.ANY) {
            public void executeAction(ListGridRecord[] selection, Object actionValue) {
                final int[] groupDefinitionIds = TableUtility.getIds(selection);
                ResourceGroupGWTServiceAsync resourceGroupManager = GWTServiceLookup.getResourceGroupService();

                resourceGroupManager.recalculateGroupDefinitions(groupDefinitionIds, new AsyncCallback<Void>() {
                    public void onFailure(Throwable caught) {
                        if (caught instanceof DuplicateExpressionTypeException) {
                            CoreGUI.getMessageCenter().notify(
                                new Message(caught.getMessage(), Message.Severity.Warning));
                        } else {
View Full Code Here

            }
        });
    }

    private void getAutoGroupBackingGroup(final AutoGroupTreeNode agNode, final AsyncCallback<ResourceGroup> callback) {
        final ResourceGroupGWTServiceAsync resourceGroupService = GWTServiceLookup.getResourceGroupService();

        // get the children tree nodes and build a child resourceId array
        TreeNode[] children = treeGrid.getTree().getChildren(agNode);
        final int[] childIds = new int[children.length];
        for (int i = 0, size = children.length; (i < size); ++i) {
            childIds[i] = ((ResourceTreeNode) children[i]).getResource().getId();
        }

        // get the backing group if it exists, otherwise create the group
        ResourceGroupCriteria criteria = new ResourceGroupCriteria();
        criteria.addFilterPrivate(true);
        criteria.addFilterResourceTypeId(agNode.getResourceType().getId());
        criteria.addFilterAutoGroupParentResourceId(agNode.getParentResource().getId());
        criteria.addFilterVisible(false);
        CoreGUI.showBusy(true);;
        resourceGroupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() {

            public void onFailure(Throwable caught) {
                CoreGUI.showBusy(false);;
                callback.onFailure(new RuntimeException(MSG.view_tree_common_loadFailed_node(), caught));
            }

            public void onSuccess(PageList<ResourceGroup> result) {
                if (result.isEmpty()) {
                    // Not found, create new backing group
                    // the backing group name is a display name using a unique parentResource-resourceType combo
                    final String backingGroupName = agNode.getBackingGroupName();
                    ResourceGroup backingGroup = new ResourceGroup(backingGroupName);
                    backingGroup.setAutoGroupParentResource(agNode.getParentResource());
                    backingGroup.setResourceType(agNode.getResourceType());
                    backingGroup.setVisible(false);
                    resourceGroupService.createPrivateResourceGroup(backingGroup, childIds,
                        new AsyncCallback<ResourceGroup>() {
                            public void onFailure(Throwable caught) {
                                CoreGUI.showBusy(false);;
                                callback.onFailure(new RuntimeException(MSG.view_tree_common_loadFailed_create(),
                                    caught));
                            }

                            public void onSuccess(ResourceGroup result) {
                                CoreGUI.showBusy(false);;
                                // store a map entry from backingGroupId to AGTreeNode so we can easily
                                // get back to this node given the id of the backing group (from the viewpath)
                                autoGroupNodeMap.put(result.getId(), agNode);

                                // now that we know that backing group id, hold onto it in the node in case we need it
                                agNode.setResourceGroupId(result.getId());

                                callback.onSuccess(result);
                            }
                        });
                } else {
                    // backing group found
                    final ResourceGroup backingGroup = result.get(0);

                    // store a map entry from backingGroupId to AGTreeNode so we can easily
                    // get back to this node given the id of the backing group (from the viewpath)
                    autoGroupNodeMap.put(backingGroup.getId(), agNode);

                    // now that we know that backing group id, hold onto it in the node in case we need it
                    agNode.setResourceGroupId(backingGroup.getId());

                    // make sure the members are correct before rendering
                    resourceGroupService.setAssignedResources(backingGroup.getId(), childIds, false,
                        new AsyncCallback<Void>() {
                            public void onFailure(Throwable caught) {
                                CoreGUI.showBusy(false);;
                                callback.onFailure(new RuntimeException(MSG.view_tree_common_loadFailed_update(),
                                    caught));
View Full Code Here

            updateSelection();

        } else {
            // This is for cases where we have to load the tree fresh including down to the currently visible node

            final ResourceGroupGWTServiceAsync resourceGroupService = GWTServiceLookup.getResourceGroupService();
            ResourceGroupCriteria criteria = new ResourceGroupCriteria();
            criteria.addFilterId(selectedAutoGroupId);
            criteria.addFilterVisible(false);
            criteria.fetchResourceType(true);
            CoreGUI.showBusy(true);;
            resourceGroupService.findResourceGroupsByCriteria(criteria, new AsyncCallback<PageList<ResourceGroup>>() {

                public void onFailure(Throwable caught) {
                    CoreGUI.showBusy(false);;
                    CoreGUI.getErrorHandler().handleError(MSG.view_tree_common_loadFailed_node(), caught);
                }
View Full Code Here

        return createGroup(createStep.getGroup(), memberStep.getSelectedResourceIds());
    }

    public boolean createGroup(final ResourceGroup newGroupToCreate, final int[] selectedGroupMembersResourceIds) {

        ResourceGroupGWTServiceAsync groupService = GWTServiceLookup.getResourceGroupService();

        groupService.createResourceGroup(newGroupToCreate, selectedGroupMembersResourceIds,
            new AsyncCallback<ResourceGroup>() {
                public void onFailure(Throwable caught) {
                    String msg = caught.getMessage();
                    CoreGUI.getErrorHandler().handleError(
                        MSG.view_groupCreateWizard_createFailure(newGroupToCreate.getName(), msg), caught);
View Full Code Here

        }
    }

    private void queryResourceGroup(Integer entityId, final Integer measurementDefId) {
        ResourceGroupGWTServiceAsync resourceService = GWTServiceLookup.getResourceGroupService();

        ResourceGroupCriteria resourceCriteria = new ResourceGroupCriteria();
        resourceCriteria.addFilterId(entityId);
        resourceService.findResourceGroupsByCriteria(resourceCriteria, new AsyncCallback<PageList<ResourceGroup>>() {
            @Override
            public void onFailure(Throwable caught) {
                CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(), caught);
            }
View Full Code Here

TOP

Related Classes of org.rhq.coregui.client.gwt.ResourceGroupGWTServiceAsync

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.