package io.digdag.core.schedule;

import java.util.List;
import com.google.common.base.Optional;
import io.digdag.core.repository.ResourceConflictException;
import io.digdag.core.repository.ResourceLimitExceededException;
import io.digdag.core.repository.ResourceNotFoundException;

public interface ScheduleStore
{
    List<StoredSchedule> getSchedules(int pageSize, Optional<Integer> lastId);

    StoredSchedule getScheduleById(int schedId)
        throws ResourceNotFoundException;

    List<StoredSchedule> getSchedulesByProjectId(int projectId, int pageSize, Optional<Integer> lastId);

    StoredSchedule getScheduleByProjectIdAndWorkflowName(int projectId, String workflowName)
            throws ResourceNotFoundException;

    interface ScheduleUpdateAction <T>
    {
        T call(ScheduleControlStore store, StoredSchedule storedSched)
            throws ResourceNotFoundException, ResourceConflictException;
    }

    <T> T updateScheduleById(int schedId, ScheduleUpdateAction<T> func)
        throws ResourceNotFoundException, ResourceConflictException;

    interface ScheduleLockAction <T>
    {
        T call(ScheduleControlStore store, StoredSchedule storedSched)
            throws ResourceNotFoundException, ResourceConflictException, ResourceLimitExceededException;
    }

    <T> T lockScheduleById(int schedId, ScheduleLockAction<T> func)
        throws ResourceNotFoundException, ResourceConflictException, ResourceLimitExceededException;
}

@@ -274,16 +274,58 @@
 ception;
+%0Aimport io.digdag.spi.ac.AccessController;
 %0A%0Apublic
@@ -419,32 +419,70 @@
 %3CInteger%3E lastId
+, AccessController.ListFilter acFilter
 );%0A%0A    StoredSc
@@ -662,16 +662,54 @@
 %3E lastId
+, AccessController.ListFilter acFilter
 );%0A%0A    

Update digdag-core's ScheduleStore