Example usage for javax.xml.registry BusinessLifeCycleManager deleteObjects

List of usage examples for javax.xml.registry BusinessLifeCycleManager deleteObjects

Introduction

In this page you can find the example usage for javax.xml.registry BusinessLifeCycleManager deleteObjects.

Prototype

BulkResponse deleteObjects(Collection keys) throws JAXRException;

Source Link

Document

Deletes one or more previously submitted objects from the registry using the object keys.

Usage

From source file:it.cnr.icar.eric.client.ui.swing.RegistryObjectsTable.java

/**
 * DOCUMENT ME!//  ww w .j  a  v a2 s .c  om
 */
@SuppressWarnings("unchecked")
protected void removeAction() {
    RegistryBrowser.setWaitCursor();

    int[] selectedIndices = getSelectedRows();

    if (selectedIndices.length >= 1) {
        try {
            ArrayList<?> selectedObjects = getSelectedRegistryObjects();
            ArrayList<Key> removeKeys = new ArrayList<Key>();

            int size = selectedObjects.size();

            for (int i = size - 1; i >= 0; i--) {
                RegistryObject obj = (RegistryObject) selectedObjects.get(i);
                Key key = obj.getKey();
                removeKeys.add(key);
            }

            // Confirm the remove
            boolean confirmRemoves = true;
            // I18N: Do not localize next statement.
            String confirmRemovesStr = ProviderProperties.getInstance()
                    .getProperty("jaxr-ebxml.registryBrowser.confirmRemoves", "true");

            if (confirmRemovesStr.equalsIgnoreCase("false") || confirmRemovesStr.toLowerCase().equals("off")) {
                confirmRemoves = false;
            }

            if (confirmRemoves) {
                int option = JOptionPane.showConfirmDialog(null,
                        resourceBundle.getString("dialog.confirmRemove.text"),
                        resourceBundle.getString("dialog.confirmRemove.title"), JOptionPane.YES_NO_OPTION);

                if (option == JOptionPane.NO_OPTION) {
                    RegistryBrowser.setDefaultCursor();

                    return;
                }
            }

            // cancels the cell editor, if any
            removeEditor();

            JAXRClient client = RegistryBrowser.getInstance().getClient();
            BusinessLifeCycleManager lcm = client.getBusinessLifeCycleManager();
            BulkResponse resp = lcm.deleteObjects(removeKeys);
            client.checkBulkResponse(resp);

            if (resp.getStatus() == JAXRResponse.STATUS_SUCCESS) {
                //Remove from UI model
                @SuppressWarnings("rawtypes")
                ArrayList objects = (ArrayList) ((tableModel.getRegistryObjects()).clone());
                size = selectedIndices.length;

                for (int i = size - 1; i >= 0; i--) {
                    RegistryObject ro = (RegistryObject) dataModel.getValueAt(selectedIndices[i], -1);
                    objects.remove(ro);
                }

                tableModel.setRegistryObjects(objects);
            }
        } catch (JAXRException e) {
            RegistryBrowser.displayError(e);
        }
    } else {
        RegistryBrowser.displayError(resourceBundle.getString("error.removeAction"));
    }

    RegistryBrowser.setDefaultCursor();
}