package com.github.aureliano.verbum_domini.web.bc;

import com.github.aureliano.verbum_domini.core.bean.BibleBean;
import com.github.aureliano.verbum_domini.core.impl.dao.DaoFactory;
import com.github.aureliano.verbum_domini.core.web.Pagination;
import com.github.aureliano.verbum_domini.web.DataPage;

public final class BiblesBC {

	private BiblesBC() {
		super();
	}
	
	public static DataPage createDataPage(BibleBean filter, Integer pageIndex) {
		if (pageIndex == null) {
			pageIndex = 1;
		}
		
		final int pageSize = 10;
		final int firstElement = (pageIndex * pageSize - (pageSize - 1));
		
		Pagination<BibleBean> pagination = DaoFactory.createDao(BibleBean.class)
				.list(filter, firstElement, pageSize);
		
		return new DataPage()
			.withData(pagination.getElements())
			.withTotal(pagination.getSize())
			.withPageSize(pageSize)
			.withPageIndex(pageIndex);
	}
	
	public static BibleBean fetchBible(Integer id) {
		return DaoFactory.createDao(BibleBean.class).load(id);
	}
}
@@ -320,17 +320,16 @@
 ss Bible
-s
 BC %7B%0A%0A%09p
@@ -340,17 +340,16 @@
 te Bible
-s
 BC() %7B%0A%09

Rename from BiblesBC to BibleBC.