All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lontime.extjooq.batch.Batch Maven / Gradle / Ivy

The newest version!
package com.github.lontime.extjooq.batch;

import java.util.Collection;
import java.util.List;
import java.util.concurrent.CompletableFuture;

import com.github.lontime.base.pagination.Page;
import com.github.lontime.base.pagination.Pageable;
import org.jooq.Condition;
import org.jooq.DSLContext;
import org.jooq.Field;
import org.jooq.Record;
import org.jooq.Table;
import org.jooq.TableField;

/**
 * Batch.
 * @author lontime
 * @since 1.0
 */
public interface Batch {

    /**
     * page.
     * @param context context
     * @param table table
     * @param condition condition
     * @return Page
     */
    default Page page(DSLContext context, Table table, Condition condition) {
        return page(context, table, null, condition, Pageable.ofSize(20), true);
    }

    /**
     * page.
     * @param context context
     * @param table table
     * @param condition condition
     * @param pageable pageable
     * @return Page
     */
    default Page page(DSLContext context, Table table, Condition condition,
                              Pageable pageable) {
        return page(context, table, null, condition, pageable, pageable.hasPrevious());
    }

    /**
     * page.
     * @param context context
     * @param table table
     * @param fields fields
     * @param condition condition
     * @param pageable pageable
     * @param searchCount searchCount
     * @return Page
     */
    Page page(DSLContext context, Table table, List fields, Condition condition,
                      Pageable pageable, boolean searchCount);

    /**
     * updateAsync.
     * @param context context
     * @param table table
     * @param keyField keyField
     * @param records records
     * @param  T
     * @param  R
     * @return int
     */
    default  int update(DSLContext context, Table table,
                                             Field keyField, Collection records) {
        return updateAsync(context, table, keyField, records).join();
    }

    /**
     * updateAsync.
     * @param context context
     * @param table table
     * @param keyField keyField
     * @param records records
     * @param  R
     * @return int
     */
    default  int update(DSLContext context, Table table,
                                             List> keyField, Collection records) {
        return updateAsync(context, table, keyField, records).join();
    }


    /**
     * updateAsync.
     * @param context context
     * @param table table
     * @param keyField keyField
     * @param records records
     * @param  T
     * @param  R
     * @return int
     */
     CompletableFuture updateAsync(DSLContext context, Table table,
                                                                 Field keyField, Collection records);

    /**
     * updateAsync.
     * @param context context
     * @param table table
     * @param keyField keyField
     * @param records records
     * @param  R
     * @return int
     */
     CompletableFuture updateAsync(DSLContext context, Table table,
                                                              List> keyField, Collection records);

    /**
     * insertAsync.
     * @param context context
     * @param table table
     * @param records records
     * @param  R
     * @return int
     */
    default  int insert(DSLContext context, Table table, Collection records) {
        return insertAsync(context, table, records).join();
    }

    /**
     * insertAsync.
     * @param context context
     * @param table table
     * @param records records
     * @param  R
     * @return int
     */
     CompletableFuture insertAsync(DSLContext context, Table table,
                                                                   Collection records);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy