use of com.nabalive.application.core.Application in project NabAlive by jcheype.
the class ApplicationScheduler method clock.
@Scheduled(cron = "0 0 * * * *")
public void clock() {
logger.debug("clock trigger");
// clock
Application application = checkNotNull(applicationManager.getApplication(CLOCK_APIKEY));
Query<Nabaztag> query = nabaztagDAO.createQuery().filter("applicationConfigList.applicationStoreApikey", CLOCK_APIKEY);
Iterator<Nabaztag> iterator = nabaztagDAO.find(query).iterator();
while (iterator.hasNext()) {
Nabaztag nabaztag = iterator.next();
Status status = connectionManager.get(nabaztag.getMacAddress());
if (status != null && !status.isAsleep()) {
try {
application.onStartup(nabaztag, findConfig(CLOCK_APIKEY, nabaztag.getApplicationConfigList()));
} catch (Exception e) {
logger.debug("cannot send message", e);
}
}
}
}
use of com.nabalive.application.core.Application in project NabAlive by jcheype.
the class ApplicationScheduler method taichi.
@Scheduled(fixedDelay = 400000)
public void taichi() {
logger.debug("taichi trigger");
// taichi
Application application = checkNotNull(applicationManager.getApplication(TAICHI_APIKEY));
Query<Nabaztag> query = nabaztagDAO.createQuery().filter("applicationConfigList.applicationStoreApikey", TAICHI_APIKEY);
Iterator<Nabaztag> iterator = nabaztagDAO.find(query).iterator();
while (iterator.hasNext()) {
Nabaztag nabaztag = iterator.next();
Status status = connectionManager.get(nabaztag.getMacAddress());
if (status != null && status.isIdle()) {
if (rand.nextInt(4) == 0) {
try {
application.onStartup(nabaztag, findConfig(TAICHI_APIKEY, nabaztag.getApplicationConfigList()));
} catch (Exception e) {
logger.debug("cannot send message", e);
}
}
}
}
}
use of com.nabalive.application.core.Application in project NabAlive by jcheype.
the class ApplicationScheduler method mood.
@Scheduled(fixedDelay = 300000)
public void mood() {
logger.debug("mood trigger");
// mood
Application application = checkNotNull(applicationManager.getApplication(MOOD_APIKEY));
Query<Nabaztag> query = nabaztagDAO.createQuery().filter("applicationConfigList.applicationStoreApikey", MOOD_APIKEY);
Iterator<Nabaztag> iterator = nabaztagDAO.find(query).iterator();
while (iterator.hasNext()) {
Nabaztag nabaztag = iterator.next();
Status status = connectionManager.get(nabaztag.getMacAddress());
if (status != null && status.isIdle()) {
if (rand.nextInt(4) == 0) {
try {
application.onStartup(nabaztag, findConfig(MOOD_APIKEY, nabaztag.getApplicationConfigList()));
} catch (Exception e) {
logger.debug("cannot send message", e);
}
}
}
}
}
Aggregations