/** * updates the gui, which depends on the selected process * * @param event * @throws AbortProcessingException */ public void selectProcess(AjaxBehaviorEvent event) throws AbortProcessingException { FacesContext fc = FacesContext.getCurrentInstance(); if (wpsClient == null) { FacesMessage msg = getFacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.NO_URL"); fc.addMessage("ClientBean.selectProcess.NO_WPS", msg); return; } if (process == null) { FacesMessage msg = getFacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.NO_PROCESS"); fc.addMessage("ClientBean.selectProcess.NO_Process", msg); return; } selectedProcess = wpsClient.getProcess(process.getCode(), process.getCodeSpace()); if (selectedProcess == null) { FacesMessage msg = getFacesMessage(FacesMessage.SEVERITY_WARN, "WARN.NO_PROCESS_WITH_ID", url, process); fc.addMessage("ClientBean.selectProcess.NO_PROCESS_FOR_ID", msg); return; } information = selectedProcess.getAbstract() != null ? selectedProcess.getAbstract().getString() : ""; FacesMessage msg = getFacesMessage(FacesMessage.SEVERITY_INFO, "INFO.SELECT_PROCESS", selectedProcess.getId()); fc.addMessage("ClientBean.selectProcess.SELECT_PROCESS", msg); }
/** * action methode to update the information text dependent on the given parameter * * @return null, to stay on the same page */ public Object updateInfoText() { FacesContext fc = FacesContext.getCurrentInstance(); Map<String, String> params = fc.getExternalContext().getRequestParameterMap(); if (params.containsKey("type")) { String type = params.get("type"); if (WPS_INFOKEY.equals(type) && wpsClient != null) { ServiceIdentification si = wpsClient.getMetadata().getServiceIdentification(); information = getAsLocaleString(si.getAbstracts()); } else if (PROCESS_INFOKEY.equals(type) && selectedProcess != null) { information = selectedProcess.getAbstract() != null ? selectedProcess.getAbstract().getString() : ""; } else if (IN_INFOKEY.equals(type) && params.containsKey("dataId") && selectedProcess != null) { try { String id = params.get("dataId"); InputType[] inputTypes = selectedProcess.getInputTypes(); for (int i = 0; i < inputTypes.length; i++) { if (equalsCodeType(inputTypes[i].getId(), id)) { information = inputTypes[i].getAbstract() != null ? inputTypes[i].getAbstract().getString() : ""; } } } catch (Exception e) { information = null; FacesMessage msg = getFacesMessage(FacesMessage.SEVERITY_INFO, "INFO.UPDATE_INFO_FAILED"); fc.addMessage("ClientBean.updateInfoText.FAILED", msg); } } else if (OUT_INFOKEY.equals(type) && params.containsKey("dataId") && selectedProcess != null) { try { String id = params.get("dataId"); OutputType[] outputTypes = selectedProcess.getOutputTypes(); for (int i = 0; i < outputTypes.length; i++) { if (equalsCodeType(outputTypes[i].getId(), id)) { information = outputTypes[i].getAbstract() != null ? outputTypes[i].getAbstract().getString() : ""; } } } catch (Exception e) { information = null; FacesMessage msg = getFacesMessage(FacesMessage.SEVERITY_INFO, "INFO.UPDATE_INFO_FAILED"); fc.addMessage("ClientBean.updateInfoText.FAILED", msg); } } } return null; }
/** * change the URL of the WPS and update the list of processes * * @param event * @throws AbortProcessingException */ public void selectWPS(AjaxBehaviorEvent event) throws AbortProcessingException { FacesContext fc = FacesContext.getCurrentInstance(); processes.clear(); try { URL capUrl = new URL(url + "?service=WPS&version=1.0.0&request=GetCapabilities"); wpsClient = new WPSClient(capUrl); FacesMessage msg = getFacesMessage(FacesMessage.SEVERITY_INFO, "INFO.SELECT_WPS", url); fc.addMessage("ClientBean.selectWPS.SELECT_WPS", msg); Process[] p = wpsClient.getProcesses(); processes.addAll((List<Process>) Arrays.asList(p)); if (!urls.contains(url)) urls.add(url); } catch (MalformedURLException e) { FacesMessage msg = getFacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.INVALID_URL", url); fc.addMessage("ClientBean.selectWPS.INVALID_URL", msg); } catch (Exception e) { FacesMessage msg = getFacesMessage(FacesMessage.SEVERITY_ERROR, "ERROR.INVALID_WPS", url, e.getMessage()); fc.addMessage("ClientBean.selectWPS.INVALID_WPS", msg); } }