@Override public void scheduleEvent(final OScheduledEvent event) { if (event.getDocument().getIdentity().isNew()) // FIST TIME: SAVE IT event.save(); if (events.putIfAbsent(event.getName(), event) == null) event.schedule(); }
@Override public void load() { final ODatabaseDocument db = ODatabaseRecordThreadLocal.INSTANCE.get(); if (db.getMetadata().getSchema().existsClass(OScheduledEvent.CLASS_NAME)) { final Iterable<ODocument> result = db.browseClass(OScheduledEvent.CLASS_NAME); for (ODocument d : result) { final OScheduledEvent event = new OScheduledEvent(d); if (events.putIfAbsent(event.getName(), event) == null) this.scheduleEvent(event); } } }