@Override public void onPOSTComplete(String data, OgemaHttpRequest req) { String name = nameInput.getValue(req).trim(); String email = emailInput.getValue(req).trim(); String sms = smsInput.getValue(req).trim(); String xmpp = xmppInput.getValue(req).trim(); String rest = restInput.getValue(req).trim(); String restUser = restUserInput.getValue(req).trim(); String restPw = restPwInput.getValue(req); try { Logger.getGlobal().info(rest + ", " + restUser + ", " + restPw); filter(name, email, sms, xmpp, rest, restUser, restPw, req); addNewReceiver(receiverConfigs, name, email, sms, xmpp, rest, restUser, restPw); alert.showAlert("Receiver '" + name + "' successfully created", true, req); } catch (Exception e) { alert.showAlert("Could not create new user: " + e.getMessage(), false, req); } }
private static Object getValue(OgemaWidgetBase<?> widget, ResourceAccess ra, OgemaHttpRequest req) { if (widget instanceof TextField) return ((TextField) widget).getValue(req).trim(); if (widget instanceof ReferenceDropdown<?>) { String selected = ((ReferenceDropdown<?>) widget).getSelectedValue(req); if (selected == null || selected.equals(DropdownData.EMPTY_OPT_ID)) return null; return ra.getResource(selected); // will need to create the associated pattern later on } else throw new UnsupportedOperationException("Context creation for widget type " + widget.getWidgetClass().getSimpleName() + " not implemented yet"); }
@Override public void onPOSTComplete(String data, OgemaHttpRequest req) { String xmppRegex = "[A-Za-z0-9.-]+[@][A-Za-z0-9.-]+[.][a-zA-Z_0-9]+$"; String portRegex = "[0-9]{1,5}$"; int port = 70000; if (editXmppPortTextField.getValue(req).matches(portRegex)) { port = Integer.parseInt(editXmppPortTextField.getValue(req)); } if (editXmppTextField.getValue(req).matches(xmppRegex) && !editXmppPasswordTextField.getValue(req).isEmpty() && (port <= 65535)) { config.xmpp().setValue(editXmppTextField.getValue(req)); config.password().setValue(editXmppPasswordTextField.getValue(req)); config.port().setValue(port); alert.showAlert("Changes on User '" + id + "' confirmed", true, req); } else { if (!editXmppTextField.getValue(req).matches(xmppRegex)) alert.showAlert("Invalid Xmpp-Address", false, req); if (editXmppPasswordTextField.getValue(req).isEmpty()) alert.showAlert("No Password entered", false, req); if (port > 65535) alert.showAlert("Invalid Port", false, req); } }
@Override public void onPOSTComplete(String data, OgemaHttpRequest req) { String name = newEmailNameTextField.getValue(req).trim(); String email = newEmailTextField.getValue(req).trim(); String pw = newEmailPasswordTextField.getValue(req).trim(); String host = newEmailUrlTextField.getValue(req).trim(); String serverPort = newEmailPortTextField.getValue(req).trim();
@Override public void onPOSTComplete(String data, OgemaHttpRequest req) { String name = newSmsNameTextField.getValue(req).trim(); String sms = newSmsEmailTextField.getValue(req).trim(); String host = newSmsEmailServerTextField.getValue(req).trim(); String pw = newSmsEmailPasswordTextField.getValue(req); String serverPort = newSmsEmailPortTextField.getValue(req).trim(); int port = INVALID_PORT;
public static <P extends ResourcePattern<? extends Resource>> void setValues(Class<P> patternType, P newPattern, Method[] methods, Map<String,OgemaWidgetBase<?>> valueWidgets, OgemaHttpRequest req, ApplicationManager am) { FieldUtils.setAccessiblePrivileged(methods); for (Method method: methods) { SetValue sv = method.getAnnotation(SetValue.class); if (sv == null) continue; String targetMethod = sv.target(); if (targetMethod == null || targetMethod.isEmpty()) targetMethod = method.getName(); OgemaWidgetBase<?> widget = valueWidgets.get(targetMethod); if (!(widget instanceof TextField)) continue; // should not be necessary String value = ((TextField) widget).getValue(req); try { method.invoke(newPattern, value); } catch (Exception e) { am.getLogger().warn("Could not invoke pattern method " + method.getName(),e); } } }
if (!reference) { if (!res.isActive() && res instanceof StringResource && widget instanceof TextField && ((TextField) widget).getValue(req).trim().isEmpty()) continue;
continue; TextField tf = (TextField) widget; String value = tf.getValue(req); FilterRange filterRange = externalRangeFilters.get(id); if (type.equals(Float.class)) {
@SuppressWarnings({ "rawtypes", "unchecked" }) private static void setValue(final Resource res,OgemaWidgetBase<?> widget, OgemaHttpRequest req, final ResourceAccess ra) { if (widget instanceof TextField && (res instanceof SingleValueResource || res instanceof ByteArrayResource)) { String text= ((TextField) widget).getValue(req); setValue((ValueResource) res,text);
@Override public void onPOSTComplete(String data, OgemaHttpRequest req) { IntegerResource source = getResource(sva, req, IntegerResource.class); String val = myField.getValue(req); Integer value = checker.checkNewValueInt(val, req); if(value == null) return; if(!source.exists()) { source.create(); source.setValue(value); source.activate(true); } else { source.setValue(value); } }
@Override public void onPOSTComplete(String data, OgemaHttpRequest req) { String email = editEMailTextField.getValue(req).trim(); String sms = editSmsTextField.getValue(req).trim(); String xmpp = editXmppTextField.getValue(req).trim(); String rest = editRESTTextField.getValue(req).trim(); String restUser = editRESTUserTextField.getValue(req).trim(); String restPw = editRESTPwTextField.getValue(req);
@Override public void onPOSTComplete(String data, OgemaHttpRequest req) { FloatResource source = getResource(sva, req, FloatResource.class); String val = myField.getValue(req); float value; try { value = Float.parseFloat(val); } catch (NumberFormatException | NullPointerException e) { if(alert != null) alert.showAlert(notAllowedMessageUsed, false, req); return; } if (value < minimumAllowed) { if(alert != null) alert.showAlert(notAllowedMessageUsed, false, req); return; } if (value > maximumAllowed) { if(alert != null) alert.showAlert(notAllowedMessageUsed, false, req); return; } if(!source.exists()) { source.create(); setValue(source, value); source.activate(true); } else { setValue(source, value); } if(alert != null) alert.showAlert("New value: " + value, true, req); }
@Override public void onPOSTComplete(String data, OgemaHttpRequest req) { IntegerResource source = getResource(sva, req, IntegerResource.class); String val = myField.getValue(req); int value; try { value = Integer.parseInt(val); } catch (NumberFormatException | NullPointerException e) { if(alert != null) alert.showAlert(notAllowedMessageUsed, false, req); return; } if (value < minimumAllowed) { if(alert != null) alert.showAlert(notAllowedMessageUsed, false, req); return; } if (value > maximumAllowed) { if(alert != null) alert.showAlert(notAllowedMessageUsed, false, req); return; } if(!source.exists()) { source.create(); source.setValue(value); source.activate(true); } else { source.setValue(value); } if(alert != null) alert.showAlert("New value: " + value, true, req); }
@Override public void onPOSTComplete(String data, OgemaHttpRequest req) { StringResource source = getResource(sva, req, StringResource.class); String val = myField.getValue(req); /*String value; try { value = Float.parseFloat(val); } catch (NumberFormatException | NullPointerException e) { if(alert != null) alert.showAlert(notAllowedMessageUsed, false, req); return; } if (value < minimumAllowed) { if(alert != null) alert.showAlert(notAllowedMessageUsed, false, req); return; } if (value > maximumAllowed) { if(alert != null) alert.showAlert(notAllowedMessageUsed, false, req); return; }*/ if(!source.exists()) { source.create(); source.setValue(val); source.activate(true); } else { source.setValue(val); } if(alert != null) alert.showAlert("New value: " + val, true, req); }
@Override public void onPOSTComplete(String data, OgemaHttpRequest req) { TimeResource source = getResource(sva, req, TimeResource.class); String val = myField.getValue(req); int value; int flexMode = -99; //init here should never be relevant
resource = targetSelector.getSelectedItem(req); } else { final String path = newPathField.getValue(req).trim(); if (path.isEmpty()) { alert.showAlert("Resource path must not be empty", false, req); return; final boolean createForecast = resSelectorCheckbox.getCheckboxList(req).get(1).isChecked(); final String forecast = createForecast ? schedulePathField.getValue(req) : null; final Long horizon = scheduleHorizonMinutes.getNumericalValue(req); if (forecast != null && !ResourceUtils.isValidResourcePath(forecast)) {