public static void addNewReceiver(ResourceList<ReceiverConfiguration> receiverConfigs, String name, String email, String sms, String xmpp, String rest, String restUser, String restPw) { ReceiverConfiguration newReceiver = receiverConfigs.add(); newReceiver.userName().<StringResource>create().setValue(name); if(!email.isEmpty()) newReceiver.email().<StringResource>create().setValue(email); if(!sms.isEmpty()) newReceiver.sms().<StringResource>create().setValue(sms); if(!xmpp.isEmpty()) newReceiver.xmpp().<StringResource>create().setValue(xmpp); if(!rest.isEmpty()) newReceiver.remoteMessageRestUrl().<StringResource>create().setValue( rest.endsWith("/") ? rest : rest+"/"); if(!restUser.isEmpty()) newReceiver.remoteMessageUser().<StringResource>create().setValue(restUser); if(!restPw.isEmpty()) newReceiver.remoteMessagePassword().<StringResource>create().setValue(restPw); newReceiver.activate(true); }
private void createTestReceiverResource(ResourceList<ReceiverConfiguration> receiverConfigs, ApplicationManager appMan) { ReceiverConfiguration testConfig = receiverConfigs.add(); StringResource name = testConfig.userName().create(); name.setValue("XAll"); StringResource email = testConfig.email().create(); email.setValue("testtransmitter@web.de"); StringResource sms = testConfig.sms().create(); sms.setValue("49157123456789.testtransmitter@tmsg.de"); StringResource xmpp = testConfig.xmpp().create(); xmpp.setValue("testtransmitter2@jabber.de"); StringResource rest = testConfig.remoteMessageRestUrl().create(); rest.setValue("https://localhost:8444/rest/resources"); StringResource restUser = testConfig.remoteMessageRestUrl().create(); restUser.setValue("rest"); StringResource restPw = testConfig.remoteMessagePassword().create(); restPw.setValue("rest"); testConfig.activate(true); }
private void createEmailUser(String name, String email, String password, String host, int port, boolean createActive) { EmailConfiguration newEmailUser = emailConfigs.add(); newEmailUser.userName().<StringResource>create().setValue(name); newEmailUser.email().<StringResource>create().setValue(email); newEmailUser.password().<StringResource>create().setValue(password); newEmailUser.serverURL().<StringResource>create().setValue(host); newEmailUser.port().<IntegerResource>create().setValue(port); newEmailUser.active().<BooleanResource>create().setValue(createActive); newEmailUser.activate(true); }
private void createSmsUser(String name, String sms, String password, String host, int port, boolean createActive) { SmsConfiguration newSmsUser = smsConfigs.add(); newSmsUser.userName().<StringResource>create().setValue(name); newSmsUser.smsEmail().<StringResource>create().setValue(sms); newSmsUser.smsEmailPassword().<StringResource>create().setValue(password); newSmsUser.smsEmailServer().<StringResource>create().setValue(host); newSmsUser.smsEmailPort().<IntegerResource>create().setValue(port); newSmsUser.active().<BooleanResource>create().setValue(createActive); newSmsUser.activate(true); }
private void createXmppUser(String name, String xmpp, String password, int port, boolean createActive) { XmppConfiguration newXmppUser = xmppConfigs.add(); newXmppUser.userName().<StringResource>create().setValue(name); newXmppUser.xmpp().<StringResource>create().setValue(xmpp); newXmppUser.password().<StringResource>create().setValue(password); newXmppUser.port().<IntegerResource>create().setValue(port); newXmppUser.active().<BooleanResource>create().setValue(createActive); newXmppUser.activate(true); }
private void storeCommonData(HmDevice dev, DeviceDescription desc) { dev.type().<StringResource>create().setValue(desc.getType()); dev.address().<StringResource>create().setValue(desc.getAddress()); dev.version().<IntegerResource>create().setValue(desc.getVersion()); dev.paramsets().<StringArrayResource>create().setValues(desc.getParamsets()); }
config.email().create(); config.email().setValue(email); config.email().activate(true); config.sms().create(); config.sms().setValue(sms); config.sms().activate(true); config.xmpp().create(); config.xmpp().setValue(xmpp); config.xmpp().activate(true); config.remoteMessageRestUrl().create(); config.remoteMessageRestUrl().setValue(rest.endsWith("/") ? rest : rest + "/"); config.remoteMessageRestUrl().activate(true); config.remoteMessageUser().create(); config.remoteMessageUser().setValue(restUser); config.remoteMessageUser().activate(true); config.remoteMessagePassword().create(); config.remoteMessagePassword().setValue(restPw); config.remoteMessagePassword().activate(true);
@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); }
final ScheduledSimulationConfig config = configs.add(); config.target().setAsReference(resource); config.typePrimary().<StringResource> create().setValue(type.primaryType); if (type.secondaryType != null) config.typeSecondary().<StringResource> create().setValue(type.secondaryType); if (forecast != null) { config.forecastSchedule().<StringResource> create().setValue(forecast); config.forecastHorizon().<TimeResource> create().setValue(horizon);
@Override public boolean commit() { if (m_targetResource == null) { return false; } // delete the old configuration if it exsited. if (m_config != null) { m_config.delete(); } m_config = m_base.createResource(ProgramEnforcerModel.class); m_config.targetResource().setAsReference(m_targetResource); m_config.updateInterval().create(); m_config.updateInterval().setValue(m_updateInterval); m_config.exclusiveAccessRequired().create(); m_config.exclusiveAccessRequired().setValue(m_exclusiveAccessRequired); m_config.priority().create(); m_config.priority().setValue(m_priority.toString()); m_config.deactivateIfValueMissing().create(); m_config.deactivateIfValueMissing().setValue(m_deactivate); if (m_scheduleName != null) { m_config.scheduleResourceName().<StringResource> create().setValue(m_scheduleName); } m_config.activate(true); return true; }
throw new UnsupportedOperationException("Cannot create a resource instance for unknown or un-implemented configuration type " + type.getName()); result.application().create(); result.application().requestAccessMode(AccessMode.EXCLUSIVE, AccessPriority.PRIO_HIGHEST); result.application().setValue(appId);
private void addMandatoryChannels() { HM_hlConfig attributeConfig = new HM_hlConfig(); attributeConfig.driverId = hm_hlConfig.driverId; attributeConfig.interfaceId = hm_hlConfig.interfaceId; attributeConfig.deviceAddress = hm_hlConfig.deviceAddress; attributeConfig.channelAddress = "ATTRIBUTE:0001"; attributeConfig.timeout = -1; attributeConfig.resourceName = hm_hlConfig.resourceName + "_HighWater"; attributeConfig.chLocator = addChannel(attributeConfig); attributeConfig = new HM_hlConfig(); attributeConfig.driverId = hm_hlConfig.driverId; attributeConfig.interfaceId = hm_hlConfig.interfaceId; attributeConfig.deviceAddress = hm_hlConfig.deviceAddress; attributeConfig.channelAddress = "ATTRIBUTE:0002"; attributeConfig.timeout = -1; attributeConfig.resourceName = hm_hlConfig.resourceName + "_BatteryStatus"; attributeConfig.chLocator = addChannel(attributeConfig); WaterDetector threeStateDevice = resourceManager.createResource(hm_hlConfig.resourceName, WaterDetector.class); highWater = threeStateDevice.reading().create(); // highWater.activate(true); // highWater.setValue("dry"); highWater.requestAccessMode(AccessMode.EXCLUSIVE, AccessPriority.PRIO_HIGHEST); StateOfChargeSensor eSens = threeStateDevice.battery().chargeSensor().create(); batteryStatus = eSens.reading().create(); // batteryStatus.activate(true); // batteryStatus.setValue(95); batteryStatus.requestAccessMode(AccessMode.EXCLUSIVE, AccessPriority.PRIO_HIGHEST); // do not activate value resources, since they do not contain sensible values yet ResourceUtils.activateComplexResources(threeStateDevice, true, appManager.getResourceAccess()); }