|
@@ -25,6 +25,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -38,8 +39,10 @@ import org.apache.commons.logging.LogFactory;
|
|
|
import org.codelibs.core.CoreLibConstants;
|
|
|
import org.codelibs.core.util.StringUtil;
|
|
|
import org.codelibs.fess.FessSystemException;
|
|
|
-import org.codelibs.fess.crud.service.BsCrawlingSessionService;
|
|
|
+import org.codelibs.fess.crud.CommonConstants;
|
|
|
+import org.codelibs.fess.crud.CrudMessageException;
|
|
|
import org.codelibs.fess.db.cbean.CrawlingSessionCB;
|
|
|
+import org.codelibs.fess.db.exbhv.CrawlingSessionBhv;
|
|
|
import org.codelibs.fess.db.exbhv.CrawlingSessionInfoBhv;
|
|
|
import org.codelibs.fess.db.exentity.CrawlingSession;
|
|
|
import org.codelibs.fess.db.exentity.CrawlingSessionInfo;
|
|
@@ -47,8 +50,10 @@ import org.codelibs.fess.pager.CrawlingSessionPager;
|
|
|
import org.codelibs.fess.util.ComponentUtil;
|
|
|
import org.dbflute.bhv.readable.EntityRowHandler;
|
|
|
import org.dbflute.cbean.result.ListResultBean;
|
|
|
+import org.dbflute.cbean.result.PagingResultBean;
|
|
|
+import org.seasar.framework.beans.util.Beans;
|
|
|
|
|
|
-public class CrawlingSessionService extends BsCrawlingSessionService implements Serializable {
|
|
|
+public class CrawlingSessionService implements Serializable {
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
@@ -57,9 +62,64 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements
|
|
|
@Resource
|
|
|
protected CrawlingSessionInfoBhv crawlingSessionInfoBhv;
|
|
|
|
|
|
- @Override
|
|
|
+ @Resource
|
|
|
+ protected CrawlingSessionBhv crawlingSessionBhv;
|
|
|
+
|
|
|
+ public CrawlingSessionService() {
|
|
|
+ super();
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<CrawlingSession> getCrawlingSessionList(final CrawlingSessionPager crawlingSessionPager) {
|
|
|
+
|
|
|
+ final PagingResultBean<CrawlingSession> crawlingSessionList = crawlingSessionBhv.selectPage(cb -> {
|
|
|
+ cb.paging(crawlingSessionPager.getPageSize(), crawlingSessionPager.getCurrentPageNumber());
|
|
|
+ setupListCondition(cb, crawlingSessionPager);
|
|
|
+ });
|
|
|
+
|
|
|
+ // update pager
|
|
|
+ Beans.copy(crawlingSessionList, crawlingSessionPager).includes(CommonConstants.PAGER_CONVERSION_RULE).execute();
|
|
|
+ crawlingSessionPager.setPageNumberList(crawlingSessionList.pageRange(op -> {
|
|
|
+ op.rangeSize(5);
|
|
|
+ }).createPageNumberList());
|
|
|
+
|
|
|
+ return crawlingSessionList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public CrawlingSession getCrawlingSession(final Map<String, String> keys) {
|
|
|
+ final CrawlingSession crawlingSession = crawlingSessionBhv.selectEntity(cb -> {
|
|
|
+ cb.query().setId_Equal(Long.parseLong(keys.get("id")));
|
|
|
+ setupEntityCondition(cb, keys);
|
|
|
+ }).orElse(null);//TODO
|
|
|
+ if (crawlingSession == null) {
|
|
|
+ // TODO exception?
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ return crawlingSession;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void store(final CrawlingSession crawlingSession) throws CrudMessageException {
|
|
|
+ setupStoreCondition(crawlingSession);
|
|
|
+
|
|
|
+ crawlingSessionBhv.insertOrUpdate(crawlingSession);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public void delete(final CrawlingSession crawlingSession) throws CrudMessageException {
|
|
|
+ setupDeleteCondition(crawlingSession);
|
|
|
+
|
|
|
+ crawlingSessionBhv.delete(crawlingSession);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ protected void setupEntityCondition(final CrawlingSessionCB cb, final Map<String, String> keys) {
|
|
|
+ }
|
|
|
+
|
|
|
protected void setupListCondition(final CrawlingSessionCB cb, final CrawlingSessionPager crawlingSessionPager) {
|
|
|
- super.setupListCondition(cb, crawlingSessionPager);
|
|
|
+ if (crawlingSessionPager.id != null) {
|
|
|
+ cb.query().setId_Equal(Long.parseLong(crawlingSessionPager.id));
|
|
|
+ }
|
|
|
+ // TODO Long, Integer, String supported only.
|
|
|
if (StringUtil.isNotBlank(crawlingSessionPager.sessionId)) {
|
|
|
cb.query().setSessionId_LikeSearch(crawlingSessionPager.sessionId, op -> {
|
|
|
op.likeContain();
|
|
@@ -68,7 +128,6 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements
|
|
|
cb.query().addOrderBy_CreatedTime_Desc();
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
protected void setupStoreCondition(final CrawlingSession crawlingSession) {
|
|
|
if (crawlingSession == null) {
|
|
|
throw new FessSystemException("Crawling Session is null.");
|
|
@@ -79,7 +138,6 @@ public class CrawlingSessionService extends BsCrawlingSessionService implements
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
protected void setupDeleteCondition(final CrawlingSession crawlingSession) {
|
|
|
crawlingSessionInfoBhv.varyingQueryDelete(cb -> {
|
|
|
cb.query().setCrawlingSessionId_Equal(crawlingSession.getId());
|