use of com.orientechnologies.orient.core.schedule.OScheduledEvent in project serverless by bluenimble.
the class OrientDatabase method schedule.
@Override
public void schedule(String event, Query query, String cron) throws DatabaseException {
if (query == null || Lang.isNullOrEmpty(query.entity()) || query.construct() == null) {
throw new DatabaseException("query to schedule should provide the entity name and the construct [insert, update or delete]");
}
try {
OScheduler sch = db.getMetadata().getScheduler();
OScheduledEvent oEvent = sch.getEvent(event);
if (oEvent != null) {
sch.removeEvent(event);
}
sch.scheduleEvent(new OScheduledEventBuilder().setName(event).setRule(cron).setFunction(newFunction(event, query)).build());
} catch (Exception ex) {
throw new DatabaseException(ex.getMessage(), ex);
}
}
Aggregations