first commit
This commit is contained in:
50
hrmsEjb/wenrgise/ejb/common/utility/PositionResolver.java
Normal file
50
hrmsEjb/wenrgise/ejb/common/utility/PositionResolver.java
Normal file
@@ -0,0 +1,50 @@
|
||||
package wenrgise.ejb.common.utility;
|
||||
|
||||
import wenrgise.common.vo.BaseQueryVO;
|
||||
import wenrgise.common.vo.DetailSizeValues;
|
||||
|
||||
public class PositionResolver {
|
||||
public static long getStartPosition(BaseQueryVO oBaseQueryVO, long lTotalCount) {
|
||||
int iMaxHeaderSize = oBaseQueryVO.getMaxHeaderSize();
|
||||
long lPositionRequested = oBaseQueryVO.getPositionRequested();
|
||||
if (lPositionRequested != 0L) {
|
||||
long l;
|
||||
return l = lPositionRequested;
|
||||
}
|
||||
int iStep = (int)(lTotalCount / iMaxHeaderSize);
|
||||
long lStartPosition;
|
||||
return lStartPosition = (iStep * iMaxHeaderSize + 1);
|
||||
}
|
||||
|
||||
public static long getLastPosition(BaseQueryVO oBaseQueryVO, long lTotalCount) {
|
||||
long lLastPosition;
|
||||
int iMaxHeaderSize = oBaseQueryVO.getMaxHeaderSize();
|
||||
long lPositionRequested = oBaseQueryVO.getPositionRequested();
|
||||
if (lPositionRequested != 0L) {
|
||||
if (lPositionRequested + iMaxHeaderSize - 1L < lTotalCount) {
|
||||
lLastPosition = lPositionRequested + iMaxHeaderSize - 1L;
|
||||
} else {
|
||||
lLastPosition = lTotalCount;
|
||||
}
|
||||
} else {
|
||||
lLastPosition = lTotalCount;
|
||||
}
|
||||
return lLastPosition;
|
||||
}
|
||||
|
||||
public static long getDetailFirstPosition(int iStartPage, long lTotalDetailRecord, DetailSizeValues oDetailSizeValues) {
|
||||
int iDetailRecordPerPage = oDetailSizeValues.getDetailRecordPerPage();
|
||||
int iMaxPage = oDetailSizeValues.getMaxPages();
|
||||
if (lTotalDetailRecord > ((iStartPage - 1) * iDetailRecordPerPage))
|
||||
return ((iStartPage - 1) * iDetailRecordPerPage + 1);
|
||||
return 1L;
|
||||
}
|
||||
|
||||
public static long getDetailLastPosition(int iStartPage, long lTotalDetailRecord, DetailSizeValues oDetailSizeValues) {
|
||||
int iDetailRecordPerPage = oDetailSizeValues.getDetailRecordPerPage();
|
||||
int iMaxPage = oDetailSizeValues.getMaxPages();
|
||||
if (lTotalDetailRecord > ((iStartPage + iMaxPage - 1) * iDetailRecordPerPage))
|
||||
return ((iStartPage + iMaxPage - 1) * iDetailRecordPerPage);
|
||||
return lTotalDetailRecord;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user