private void unloadLoadSunRiseSetJobs() { List<Timer> timers = DaoUtils.getTimerDao().getAllEnabled(); // reload all jobs for (Timer timer : timers) { switch (TYPE.get(timer.getType())) { case BEFORE_SUNRISE: case AFTER_SUNRISE: case BEFORE_SUNSET: case AFTER_SUNSET: SchedulerUtils.reloadTimerJob(timer); break; default: break; } } }
@GET @Path("/") public Response getAll( @QueryParam(Timer.KEY_NAME) List<String> name, @QueryParam(Timer.KEY_RESOURCE_TYPE) String resourceType, @QueryParam(Timer.KEY_RESOURCE_ID) Integer resourceId, @QueryParam(Timer.KEY_TIMER_TYPE) String timerType, @QueryParam(Timer.KEY_FREQUENCY) String frequency, @QueryParam(Timer.KEY_ENABLED) Boolean enabled, @QueryParam(Query.PAGE_LIMIT) Long pageLimit, @QueryParam(Query.PAGE) Long page, @QueryParam(Query.ORDER_BY) String orderBy, @QueryParam(Query.ORDER) String order) { HashMap<String, Object> filters = new HashMap<String, Object>(); filters.put(Timer.KEY_NAME, name); filters.put(Timer.KEY_RESOURCE_TYPE, RESOURCE_TYPE.fromString(resourceType)); filters.put(Timer.KEY_RESOURCE_ID, resourceId); filters.put(Timer.KEY_TIMER_TYPE, TIMER_TYPE.fromString(timerType)); filters.put(Timer.KEY_FREQUENCY, FREQUENCY_TYPE.fromString(frequency)); filters.put(Timer.KEY_ENABLED, enabled); // Add allowed resources filter if he is non-admin if (!AuthUtils.isSuperAdmin(securityContext)) { filters.put( AllowedResources.KEY_ALLOWED_RESOURCES, AuthUtils.getUser(securityContext).getAllowedResources()); } QueryResponse queryResponse = DaoUtils.getTimerDao() .getAll( Query.builder() .order(order != null ? order : Query.ORDER_ASC) .orderBy(orderBy != null ? orderBy : Timer.KEY_ID) .filters(filters) .pageLimit(pageLimit != null ? pageLimit : Query.MAX_ITEMS_PER_PAGE) .page(page != null ? page : 1l) .build()); return RestUtils.getResponse(Status.OK, queryResponse); }
@GET @Path("/{id}") public Response get(@PathParam("id") int id) { hasAccessTimer(id); return RestUtils.getResponse(Status.OK, DaoUtils.getTimerDao().getById(id)); }