package edu.kit.ipd.crowdcontrol.objectservice.database.operations;

import edu.kit.ipd.crowdcontrol.objectservice.database.model.tables.records.TaskRecord;
import org.jooq.DSLContext;
import org.jooq.impl.DSL;

/**
 * responsible for the operations involving the creation of tasks.
 * @author LeanderK
 * @version 1.0
 */
public class TasksOperations extends AbstractOperations {
    protected TasksOperations(DSLContext create) {
        super(create);
    }

    /**
     * creates a Task
     * @param taskRecord the task to create
     * @return the id of the task
     */
    public int createTask(TaskRecord taskRecord) {
        return doIfNotRunning(taskRecord.getExperiment(), trans -> DSL.using(trans).executeInsert(taskRecord));
    }

    /**
     * updates a Task
     * @param taskRecord the update
     * @return whether the update was successful
     */
    public boolean updateTask(TaskRecord taskRecord) {
        return create.executeUpdate(taskRecord) == 1;
    }
}

@@ -978,11 +978,295 @@
 1;%0A    %7D
+%0A%0A    /**%0A     * searches for a task specified by platform and experimentid%0A     * @param platform The string of the platform%0A     * @param experimentId the experimentId%0A     * @return the found task%0A     */%0A    public TaskRecord searchTask(String platform, int experimentId) %7B%0A%0A    %7D
 %0A%7D%0A

add search for tasks