Search in sources :

Example 1 with ProcessEPSGResultResponse

use of org.geosdi.geoplatform.gui.client.command.publish.basic.ProcessEPSGResultResponse in project geo-platform by geosdi.

the class CasProcessEPSGResultCommand method execute.

@Override
public ProcessEPSGResultResponse execute(CasProcessEPSGResultRequest request, HttpServletRequest httpServletRequest) {
    GPAccount account;
    try {
        account = sessionUtility.getLoggedAccount(httpServletRequest);
    } catch (GPSessionTimeout timeout) {
        throw new GeoPlatformException(timeout);
    }
    List<EPSGLayerData> previewLayerList = request.getPreviewLayerList();
    try {
        List<InfoPreview> resultList = casPublisherService.processEPSGResult(new ProcessEPSGResultRequest(account.getNaturalID(), this.trasformPreviewLayerList(previewLayerList), request.getWorkspace())).getInfoPreviews();
        return new ProcessEPSGResultResponse(generateJSONObjects(resultList));
    } catch (Exception ex) {
        ex.printStackTrace();
        throw new GeoPlatformException("Error on publish shape.");
    }
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) EPSGLayerData(org.geosdi.geoplatform.gui.client.model.EPSGLayerData) CasProcessEPSGResultRequest(org.geosdi.geoplatform.gui.client.command.publish.cas.CasProcessEPSGResultRequest) ProcessEPSGResultRequest(org.geosdi.geoplatform.request.ProcessEPSGResultRequest) InfoPreview(org.geosdi.geoplatform.responce.InfoPreview) GPSessionTimeout(org.geosdi.geoplatform.gui.utility.GPSessionTimeout) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) GeoPlatformException(org.geosdi.geoplatform.gui.global.GeoPlatformException) ProcessEPSGResultResponse(org.geosdi.geoplatform.gui.client.command.publish.basic.ProcessEPSGResultResponse)

Example 2 with ProcessEPSGResultResponse

use of org.geosdi.geoplatform.gui.client.command.publish.basic.ProcessEPSGResultResponse in project geo-platform by geosdi.

the class EPSGTablePanel method addComponent.

@Override
public void addComponent() {
    List<ColumnConfig> configs = Lists.<ColumnConfig>newArrayList();
    ColumnConfig featureNameColumnConfig = new ColumnConfig(EPSGLayerData.NAME, PublisherWidgetConstants.INSTANCE.EPSGTablePanel_columnFeatureNameText(), 80);
    configs.add(featureNameColumnConfig);
    ColumnConfig epsgColumnConfig = new ColumnConfig(EPSGLayerData.CRS, PublisherWidgetConstants.INSTANCE.EPSGTablePanel_columnEPSGCodeText(), 80);
    GPSecureStringTextField epsgTextField = new GPSecureStringTextField();
    epsgTextField.setEmptyText(PublisherWidgetConstants.INSTANCE.EPSGTablePanel_epsgTextFieldEmptyText());
    epsgTextField.setAllowBlank(Boolean.FALSE);
    epsgColumnConfig.setEditor(new CellEditor(epsgTextField));
    configs.add(epsgColumnConfig);
    ColumnConfig newNameColumnConfig = new ColumnConfig(EPSGLayerData.NEW_NAME, PublisherWidgetConstants.INSTANCE.EPSGTablePanel_columnNewNameText(), 120);
    GPSecureStringTextField newNameTextField = new GPSecureStringTextField();
    newNameTextField.setEmptyText(PublisherWidgetConstants.INSTANCE.EPSGTablePanel_epsgTextFieldEmptyText());
    newNameTextField.setAllowBlank(Boolean.TRUE);
    final CellEditor newNameCellEditor = new CellEditor(newNameTextField);
    newNameColumnConfig.setEditor(newNameCellEditor);
    ColumnConfig publishColumnConfig = new ColumnConfig(EPSGLayerData.PUBLISH_ACTION, PublisherWidgetConstants.INSTANCE.EPSGTablePanel_columnPublishActionText(), 100);
    GridCellRenderer<EPSGLayerData> renderer = new GridCellRenderer<EPSGLayerData>() {

        @Override
        public Object render(final EPSGLayerData model, String property, ColumnData config, int rowIndex, final int colIndex, final ListStore<EPSGLayerData> store, final Grid<EPSGLayerData> grid) {
            SimpleComboBox<String> publishActionComboBox;
            Object publishActionCBObj = comboBoxMap.get("" + model.hashCode());
            if (publishActionCBObj == null) {
                publishActionComboBox = new SimpleComboBox<String>();
                publishActionComboBox.setEditable(Boolean.FALSE);
                publishActionComboBox.setWidth(grid.getColumnModel().getColumnWidth(colIndex) - 5);
                List<LayerPublishAction> l = model.getPublishActions();
                if (l != null) {
                    for (LayerPublishAction publishAction : GPSharedUtils.safeList(l)) {
                        publishActionComboBox.add(publishAction.toString());
                    }
                    publishActionComboBox.setAllowBlank(Boolean.FALSE);
                    publishActionComboBox.addSelectionChangedListener(new SelectionChangedListener<SimpleComboValue<String>>() {

                        @Override
                        public void selectionChanged(SelectionChangedEvent<SimpleComboValue<String>> se) {
                            SimpleComboValue<String> selectedItem = se.getSelectedItem();
                            if (selectedItem != null) {
                                String publishAction = selectedItem.getValue();
                                model.setPublishAction(publishAction);
                                if (!LayerPublishAction.valueOf(publishAction).equals(LayerPublishAction.RENAME)) {
                                    model.setNewName("");
                                    store.update(model);
                                }
                            } else {
                                model.setPublishAction(null);
                            }
                            manageProcessEPSGButton();
                        }
                    });
                } else {
                    publishActionComboBox.setEnabled(Boolean.FALSE);
                }
                comboBoxMap.put("" + model.hashCode(), publishActionComboBox);
            } else {
                publishActionComboBox = (SimpleComboBox<String>) publishActionCBObj;
            }
            return publishActionComboBox;
        }
    };
    publishColumnConfig.setRenderer(renderer);
    configs.add(publishColumnConfig);
    configs.add(newNameColumnConfig);
    this.grid = new EditorGrid<EPSGLayerData>(store, new ColumnModel(configs));
    grid.setBorders(Boolean.TRUE);
    grid.setStripeRows(Boolean.TRUE);
    grid.setBorders(Boolean.TRUE);
    this.grid.setClicksToEdit(EditorGrid.ClicksToEdit.ONE);
    grid.setStyleAttribute("borderTop", "none");
    grid.setAutoExpandColumn(EPSGLayerData.NAME);
    grid.setAutoExpandMin(120);
    grid.setSize(GPPublisherWidget.PUBLISHER_WIDGET_WIDTH - 29, GPPublisherWidget.PUBLISHER_WIDGET_HEIGHT - 223);
    super.add(this.grid);
    this.processEPSGButton.addSelectionListener(new SelectionListener<ButtonEvent>() {

        @Override
        public void componentSelected(ButtonEvent ce) {
            PublisherProgressBar.getInstance().show(PublisherWidgetConstants.INSTANCE.EPSGTablePanel_processingDataProgressBarText());
            store.commitChanges();
            processEPSGRequest.setPreviewLayerList(store.getModels());
            processEPSGRequest.setWorkspace(workspace);
            ClientCommandDispatcher.getInstance().execute(new GPClientCommand<ProcessEPSGResultResponse>() {

                private static final long serialVersionUID = -8303308816796000537L;

                {
                    super.setCommandRequest(processEPSGRequest);
                }

                private FeaturePreviewEvent event = new FeaturePreviewEvent();

                @Override
                public void onCommandSuccess(ProcessEPSGResultResponse response) {
                    PublisherProgressBar.getInstance().hide();
                    event.setResult(response.getResult());
                    GPHandlerManager.fireEvent(event);
                    comboBoxMap.clear();
                }

                @Override
                public void onCommandFailure(Throwable exception) {
                    PublisherProgressBar.getInstance().hide();
                    GeoPlatformMessage.errorMessage(PublisherWidgetConstants.INSTANCE.errorPublishingText(), exception.getMessage());
                    logger.log(Level.WARNING, "EPSGTablePanel Exception: " + exception.toString());
                    logger.log(Level.WARNING, "Stack Trace Exception: " + exception.getStackTrace());
                    logger.log(Level.WARNING, "Message Exception: " + exception.getMessage());
                    exception.printStackTrace();
                }
            });
        }
    });
    this.processEPSGButton.setToolTip(PublisherWidgetConstants.INSTANCE.EPSGTablePanel_processEPSGButtonTooltipText());
    super.addButton(this.processEPSGButton);
}
Also used : GPSecureStringTextField(org.geosdi.geoplatform.gui.configuration.GPSecureStringTextField) LayerPublishAction(org.geosdi.geoplatform.gui.shared.publisher.LayerPublishAction) SimpleComboValue(com.extjs.gxt.ui.client.widget.form.SimpleComboValue) ListStore(com.extjs.gxt.ui.client.store.ListStore) EPSGLayerData(org.geosdi.geoplatform.gui.client.model.EPSGLayerData) FeaturePreviewEvent(org.geosdi.geoplatform.gui.client.event.shapepreview.FeaturePreviewEvent) GPClientCommand(org.geosdi.geoplatform.gui.command.api.GPClientCommand) ProcessEPSGResultResponse(org.geosdi.geoplatform.gui.client.command.publish.basic.ProcessEPSGResultResponse) ButtonEvent(com.extjs.gxt.ui.client.event.ButtonEvent)

Aggregations

ProcessEPSGResultResponse (org.geosdi.geoplatform.gui.client.command.publish.basic.ProcessEPSGResultResponse)2 EPSGLayerData (org.geosdi.geoplatform.gui.client.model.EPSGLayerData)2 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)1 ListStore (com.extjs.gxt.ui.client.store.ListStore)1 SimpleComboValue (com.extjs.gxt.ui.client.widget.form.SimpleComboValue)1 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)1 CasProcessEPSGResultRequest (org.geosdi.geoplatform.gui.client.command.publish.cas.CasProcessEPSGResultRequest)1 FeaturePreviewEvent (org.geosdi.geoplatform.gui.client.event.shapepreview.FeaturePreviewEvent)1 GPClientCommand (org.geosdi.geoplatform.gui.command.api.GPClientCommand)1 GPSecureStringTextField (org.geosdi.geoplatform.gui.configuration.GPSecureStringTextField)1 GeoPlatformException (org.geosdi.geoplatform.gui.global.GeoPlatformException)1 LayerPublishAction (org.geosdi.geoplatform.gui.shared.publisher.LayerPublishAction)1 GPSessionTimeout (org.geosdi.geoplatform.gui.utility.GPSessionTimeout)1 ProcessEPSGResultRequest (org.geosdi.geoplatform.request.ProcessEPSGResultRequest)1 InfoPreview (org.geosdi.geoplatform.responce.InfoPreview)1