public void lock() { ScriptLock lock = new ScriptLock(); lock.setTitle(title); lock.setStartlock(startlock); lock.setEndlock(endlock); lock.save(); } }
public static void log(String uuid, String sensor, String value) { SensorData log = new SensorData(); log.uuid = uuid; log.sensor = sensor; log.value = value; log.save(); }
public void addIntoDB(String name, String description) { ModuleStatus status = new ModuleStatus(); status.setName(name); status.setInternalName(internalName); status.setDescription(description); status.setLastseen(new Timestamp(new Date().getTime())); status.setStatus("RUNNING"); status.save(); } }
Speaks speak = new Speaks(); speak.setText(advertisement.getText()); speak.setConfidence(advertisement.getConfidence()); speak.setDevice(advertisement.getDevice());
private void update(String state) { ModuleStatus status = Ebean.find(ModuleStatus.class).where().eq("internalName", internalName).findUnique(); if (status != null) { status.setLastseen(new Timestamp(new Date().getTime())); status.setStatus(state); status.save(); } else { LOGGER.error("Error update module status! Module not found in DB!"); } }
/** * Loads properties from database. * * @return true if load successfully. */ private boolean loadPropertiesFromDatabase() { List<ru.iris.common.database.model.Config> dbcfg = Ebean.find(ru.iris.common.database.model.Config.class).findList(); for (ru.iris.common.database.model.Config line : dbcfg) { propertyMap.put(line.getParam(), line.getValue()); } return true; }
private void readSources() throws RuntimeException { sources = Ebean.find(DataSource.class).where().eq("enabled", true).findList(); for (DataSource source : sources) { switch (source.getType()) { // google calendar case "gcal": GoogleCalendarSource.getInstance().populateCalendar(source.getObj()); break; // VK.com case "vk": VKSource.getInstance().populateBirthDayCalendar(source.getObj()); break; default: LOGGER.info("Unknown data source: " + source.getType() + "!"); break; } } }
@Override public synchronized void delete() { if (this.getId() == null) { Ebean.delete(this); } }
private void reloadService() throws RuntimeException { LOGGER.info("Reload event service"); // unsubscribe current events for (Event event : events) { jsonMessaging.unsubscribe(event.getSubject()); LOGGER.debug("Unsubscribe from subject: " + event.getSubject()); } events = Ebean.find(Event.class).findList(); // subscribe to events from db for (Event event : events) { jsonMessaging.subscribe(event.getSubject()); LOGGER.debug("Subscribe from subject: " + event.getSubject()); } // take pause to save/remove new entity try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } // load all scripts, compile and put into map compiledScriptMap = loadAndCompile(events); LOGGER.info("Reload event service done"); }
private Map<String, CompiledScript> loadAndCompile(List<Event> events) throws RuntimeException { Map<String, CompiledScript> compiledScriptMap = new HashMap<>(); for (Event event : events) { File jsFile = new File("./scripts/" + event.getScript()); CompiledScript compile = null; try { compile = engine.compile(FileUtils.readFileToString(jsFile)); } catch (ScriptException | IOException e) { LOGGER.error("Compile error: " + e.getMessage()); } compiledScriptMap.put(event.getScript(), compile); } return compiledScriptMap; }
@Override public synchronized void save() { if (this.getId() == null) { Ebean.save(this); } else { Ebean.update(this); } }
jsonMessaging.subscribe(event.getSubject()); LOGGER.debug("Subscribe to subject: " + event.getSubject());