// Path: src/main/java/org/graylog/plugins/aggregates/report/schedule/rest/models/requests/AddReportScheduleRequest.java
// @AutoValue
// @JsonAutoDetect
// public abstract class AddReportScheduleRequest {
// 	
//     @JsonProperty("reportSchedule")
//     @NotNull
//     public abstract ReportScheduleImpl getReportSchedule();
//     
//     @JsonCreator    
//     public static AddReportScheduleRequest create(//@JsonProperty("name") @Valid String name,
//     		@JsonProperty("reportSchedule") @Valid ReportScheduleImpl reportSchedule
// 
//     		) {
//         return new AutoValue_AddReportScheduleRequest(reportSchedule);
//     }
// }
// 
// Path: src/main/java/org/graylog/plugins/aggregates/report/schedule/rest/models/requests/UpdateReportScheduleRequest.java
// @AutoValue
// @JsonAutoDetect
// public abstract class UpdateReportScheduleRequest {
// 	
// 
//     @JsonProperty("reportSchedule")
//     @NotNull
//     public abstract ReportScheduleImpl getReportSchedule();
//     
//     @JsonCreator    
//     public static UpdateReportScheduleRequest create(
//     		@JsonProperty("reportSchedule") @Valid ReportScheduleImpl reportSchedule    		    		
//     		) {
//         return new AutoValue_UpdateReportScheduleRequest(reportSchedule);
//     }
// }
// 
// Path: src/main/java/org/graylog/plugins/aggregates/rule/RuleImpl.java
// @AutoValue
// @JsonAutoDetect
// @JsonIgnoreProperties(ignoreUnknown = true)
// @CollectionName("aggregate_rules")
// public abstract class RuleImpl implements Rule{
// 
// 
// 	@JsonProperty("query")
//     @Override
//     @NotNull
//     public abstract String getQuery();
// 
//     @JsonProperty("field")
//     @Override
//     @NotNull
//     public abstract String getField();
// 
//     @JsonProperty("numberOfMatches")
//     @Override
//     @Min(1)
//     public abstract long getNumberOfMatches();
//     
//     @JsonProperty("matchMoreOrEqual")
//     @Override
//     public abstract boolean isMatchMoreOrEqual();
// 	
//     @JsonProperty("interval")
//     @Override
//     @Min(1)
//     public abstract int getInterval();
// 		
//     @JsonProperty("name")    
//     @Override
//     @NotNull
//     public abstract String getName();
// 
//     @JsonProperty("enabled")
//     @Override
//     public abstract boolean isEnabled();
//     
//     @JsonProperty("streamId")
//     @Override
//     public abstract String getStreamId();
// 
//     @JsonProperty("inReport")
//     @Override
//     public abstract boolean isInReport();
//     
//     @JsonProperty("reportSchedules")
//     @Override
//     @Nullable
//     public abstract List<String> getReportSchedules();
// 
//     @JsonProperty("alertConditionId")
//     @Override
//     @Nullable
//     public abstract String getAlertConditionId();
// 
//     @JsonProperty("repeatNotifications")
//     @Override
//     @Nullable
//     public abstract boolean shouldRepeatNotifications();
// 
//     @JsonProperty("backlog")
//     @Override
//     @Nullable
//     @Min(0)
//     public abstract long getBacklog();
// 
// 	@JsonCreator
//     public static RuleImpl create(@JsonProperty("_id") String objectId,
//                                        @JsonProperty("query") String query,
//                                        @JsonProperty("field") String field,
//                                        @JsonProperty("numberOfMatches") long numberOfMatches,
//                                        @JsonProperty("matchMoreOrEqual") boolean matchMoreOrEqual,
//                                        @JsonProperty("interval") int interval,
//                                        @JsonProperty("name") String name,
//                                        @JsonProperty("enabled") boolean enabled,
//                                        @JsonProperty("streamId") String streamId,
//                                        @JsonProperty("inReport") boolean inReport,
//                                        @JsonProperty("reportSchedules") List<String> reportSchedules,
//                                        @JsonProperty("alertConditionId") String alertConditionId,
//                                        @JsonProperty("repeatNotifications") boolean repeatNotifications,
//                                        @JsonProperty("backlog") long backlog) {
//         return new AutoValue_RuleImpl(query, field, numberOfMatches, matchMoreOrEqual, interval, name, enabled, streamId, inReport, reportSchedules, alertConditionId, repeatNotifications, backlog);
//     }
// 	
// 	public static RuleImpl create(
//             String query,
//             String field,
//             long numberOfMatches,
//             boolean matchMoreOrEqual,
//             int interval,
//             String name,
//             boolean enabled,
//             String streamId,
//             boolean inReport,
//             List<String> reportSchedules,
//             String alertConditionId,
//             boolean repeatNotifications,
//             long backlog) {
// 		return new AutoValue_RuleImpl(query, field, numberOfMatches, matchMoreOrEqual, interval, name, enabled, streamId, inReport, reportSchedules, alertConditionId, repeatNotifications, backlog);
// 	
// 	}
// }


import com.google.common.collect.Lists;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import org.bson.types.ObjectId;
import org.drools.core.time.impl.CronExpression;
import org.graylog.plugins.aggregates.report.schedule.rest.models.requests.AddReportScheduleRequest;
import org.graylog.plugins.aggregates.report.schedule.rest.models.requests.UpdateReportScheduleRequest;
import org.graylog.plugins.aggregates.rule.RuleImpl;
import org.graylog2.bindings.providers.MongoJackObjectMapperProvider;
import org.graylog2.database.CollectionName;
import org.graylog2.database.MongoConnection;
import org.mongojack.DBCursor;
import org.mongojack.DBQuery;
import org.mongojack.DBUpdate;
import org.mongojack.JacksonDBCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Set;
package org.graylog.plugins.aggregates.report.schedule;


public class ReportScheduleServiceImpl implements ReportScheduleService {

	private final JacksonDBCollection<ReportScheduleImpl, String> coll;
// Path: src/main/java/org/graylog/plugins/aggregates/report/schedule/rest/models/requests/AddReportScheduleRequest.java
// @AutoValue
// @JsonAutoDetect
// public abstract class AddReportScheduleRequest {
// 	
//     @JsonProperty("reportSchedule")
//     @NotNull
//     public abstract ReportScheduleImpl getReportSchedule();
//     
//     @JsonCreator    
//     public static AddReportScheduleRequest create(//@JsonProperty("name") @Valid String name,
//     		@JsonProperty("reportSchedule") @Valid ReportScheduleImpl reportSchedule
// 
//     		) {
//         return new AutoValue_AddReportScheduleRequest(reportSchedule);
//     }
// }
// 
// Path: src/main/java/org/graylog/plugins/aggregates/report/schedule/rest/models/requests/UpdateReportScheduleRequest.java
// @AutoValue
// @JsonAutoDetect
// public abstract class UpdateReportScheduleRequest {
// 	
// 
//     @JsonProperty("reportSchedule")
//     @NotNull
//     public abstract ReportScheduleImpl getReportSchedule();
//     
//     @JsonCreator    
//     public static UpdateReportScheduleRequest create(
//     		@JsonProperty("reportSchedule") @Valid ReportScheduleImpl reportSchedule    		    		
//     		) {
//         return new AutoValue_UpdateReportScheduleRequest(reportSchedule);
//     }
// }
// 
// Path: src/main/java/org/graylog/plugins/aggregates/rule/RuleImpl.java
// @AutoValue
// @JsonAutoDetect
// @JsonIgnoreProperties(ignoreUnknown = true)
// @CollectionName("aggregate_rules")
// public abstract class RuleImpl implements Rule{
// 
// 
// 	@JsonProperty("query")
//     @Override
//     @NotNull
//     public abstract String getQuery();
// 
//     @JsonProperty("field")
//     @Override
//     @NotNull
//     public abstract String getField();
// 
//     @JsonProperty("numberOfMatches")
//     @Override
//     @Min(1)
//     public abstract long getNumberOfMatches();
//     
//     @JsonProperty("matchMoreOrEqual")
//     @Override
//     public abstract boolean isMatchMoreOrEqual();
// 	
//     @JsonProperty("interval")
//     @Override
//     @Min(1)
//     public abstract int getInterval();
// 		
//     @JsonProperty("name")    
//     @Override
//     @NotNull
//     public abstract String getName();
// 
//     @JsonProperty("enabled")
//     @Override
//     public abstract boolean isEnabled();
//     
//     @JsonProperty("streamId")
//     @Override
//     public abstract String getStreamId();
// 
//     @JsonProperty("inReport")
//     @Override
//     public abstract boolean isInReport();
//     
//     @JsonProperty("reportSchedules")
//     @Override
//     @Nullable
//     public abstract List<String> getReportSchedules();
// 
//     @JsonProperty("alertConditionId")
//     @Override
//     @Nullable
//     public abstract String getAlertConditionId();
// 
//     @JsonProperty("repeatNotifications")
//     @Override
//     @Nullable
//     public abstract boolean shouldRepeatNotifications();
// 
//     @JsonProperty("backlog")
//     @Override
//     @Nullable
//     @Min(0)
//     public abstract long getBacklog();
// 
// 	@JsonCreator
//     public static RuleImpl create(@JsonProperty("_id") String objectId,
//                                        @JsonProperty("query") String query,
//                                        @JsonProperty("field") String field,
//                                        @JsonProperty("numberOfMatches") long numberOfMatches,
//                                        @JsonProperty("matchMoreOrEqual") boolean matchMoreOrEqual,
//                                        @JsonProperty("interval") int interval,
//                                        @JsonProperty("name") String name,
//                                        @JsonProperty("enabled") boolean enabled,
//                                        @JsonProperty("streamId") String streamId,
//                                        @JsonProperty("inReport") boolean inReport,
//                                        @JsonProperty("reportSchedules") List<String> reportSchedules,
//                                        @JsonProperty("alertConditionId") String alertConditionId,
//                                        @JsonProperty("repeatNotifications") boolean repeatNotifications,
//                                        @JsonProperty("backlog") long backlog) {
//         return new AutoValue_RuleImpl(query, field, numberOfMatches, matchMoreOrEqual, interval, name, enabled, streamId, inReport, reportSchedules, alertConditionId, repeatNotifications, backlog);
//     }
// 	
// 	public static RuleImpl create(
//             String query,
//             String field,
//             long numberOfMatches,
//             boolean matchMoreOrEqual,
//             int interval,
//             String name,
//             boolean enabled,
//             String streamId,
//             boolean inReport,
//             List<String> reportSchedules,
//             String alertConditionId,
//             boolean repeatNotifications,
//             long backlog) {
// 		return new AutoValue_RuleImpl(query, field, numberOfMatches, matchMoreOrEqual, interval, name, enabled, streamId, inReport, reportSchedules, alertConditionId, repeatNotifications, backlog);
// 	
// 	}
// }


// Path: src/main/java/org/graylog/plugins/aggregates/report/schedule/ReportScheduleServiceImpl.java
import com.google.common.collect.Lists;
import com.mongodb.BasicDBObject;
import com.mongodb.DBCollection;
import org.bson.types.ObjectId;
import org.drools.core.time.impl.CronExpression;
import org.graylog.plugins.aggregates.report.schedule.rest.models.requests.AddReportScheduleRequest;
import org.graylog.plugins.aggregates.report.schedule.rest.models.requests.UpdateReportScheduleRequest;
import org.graylog.plugins.aggregates.rule.RuleImpl;
import org.graylog2.bindings.providers.MongoJackObjectMapperProvider;
import org.graylog2.database.CollectionName;
import org.graylog2.database.MongoConnection;
import org.mongojack.DBCursor;
import org.mongojack.DBQuery;
import org.mongojack.DBUpdate;
import org.mongojack.JacksonDBCollection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
import java.util.Set;

package org.graylog.plugins.aggregates.report.schedule;


public class ReportScheduleServiceImpl implements ReportScheduleService {

	private final JacksonDBCollection<ReportScheduleImpl, String> coll;
	private final JacksonDBCollection<RuleImpl, String> ruleColl;