modify crawling session page
This commit is contained in:
parent
b060c6723a
commit
bf00dda81c
6 changed files with 90 additions and 102 deletions
|
@ -50,6 +50,7 @@ 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.dbflute.optional.OptionalEntity;
|
||||
|
||||
import com.orangesignal.csv.CsvConfig;
|
||||
import com.orangesignal.csv.CsvReader;
|
||||
|
@ -87,17 +88,8 @@ public class CrawlingSessionService implements Serializable {
|
|||
return crawlingSessionList;
|
||||
}
|
||||
|
||||
public CrawlingSession getCrawlingSession(final Map<String, String> keys) {
|
||||
final CrawlingSession crawlingSession = crawlingSessionBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
if (crawlingSession == null) {
|
||||
// TODO exception?
|
||||
return null;
|
||||
}
|
||||
|
||||
return crawlingSession;
|
||||
public OptionalEntity<CrawlingSession> getCrawlingSession(final String id) {
|
||||
return crawlingSessionBhv.selectByPK(id);
|
||||
}
|
||||
|
||||
public void store(final CrawlingSession crawlingSession) {
|
||||
|
@ -354,4 +346,4 @@ public class CrawlingSessionService implements Serializable {
|
|||
return list.get(0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -16,9 +16,6 @@
|
|||
|
||||
package org.codelibs.fess.app.web.admin.crawlingsession;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
|
@ -26,7 +23,6 @@ import org.codelibs.fess.app.pager.CrawlingSessionPager;
|
|||
import org.codelibs.fess.app.service.CrawlingSessionService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.exentity.CrawlingSession;
|
||||
import org.codelibs.fess.helper.JobHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.lastaflute.web.Execute;
|
||||
|
@ -67,21 +63,22 @@ public class AdminCrawlingsessionAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse deleteall(final CrawlingSessionEditForm form) {
|
||||
public HtmlResponse deleteall(final EditForm form) {
|
||||
validate(form, messages -> {}, toIndexHtml());
|
||||
crawlingSessionService.deleteOldSessions(jobHelper.getRunningSessionIdSet());
|
||||
saveInfo(messages -> messages.addSuccessCrawlingSessionDeleteAll(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse index(final CrawlingSessionSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminCrawlingsession_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final CrawlingSessionSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
crawlingSessionPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminCrawlingsession_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -89,15 +86,15 @@ public class AdminCrawlingsessionAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final CrawlingSessionSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, crawlingSessionPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, crawlingSessionPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminCrawlingsession_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final CrawlingSessionSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
crawlingSessionPager.clear();
|
||||
return asHtml(path_AdminCrawlingsession_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -105,17 +102,17 @@ public class AdminCrawlingsessionAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final CrawlingSessionSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminCrawlingsession_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final CrawlingSessionSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("crawlingSessionItems", crawlingSessionService.getCrawlingSessionList(crawlingSessionPager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(crawlingSessionPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(crawlingSessionPager, form, op -> op.include("sessionId"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -125,18 +122,32 @@ public class AdminCrawlingsessionAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final CrawlingSessionEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadCrawlingSession(form);
|
||||
return asHtml(path_AdminCrawlingsession_ConfirmJsp);
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminCrawlingsession_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
crawlingSessionService.getCrawlingSession(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toIndexHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletefromconfirm(final CrawlingSessionEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadCrawlingSession(form);
|
||||
validate(form, messages -> {}, toIndexHtml());
|
||||
String id = form.id;
|
||||
crawlingSessionService.getCrawlingSession(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toIndexHtml());
|
||||
});
|
||||
return asHtml(path_AdminCrawlingsession_ConfirmJsp);
|
||||
}
|
||||
|
||||
|
@ -144,50 +155,48 @@ public class AdminCrawlingsessionAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final CrawlingSessionEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadCrawlingSession(form);
|
||||
return asHtml(path_AdminCrawlingsession_ConfirmJsp);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminCrawlingsession_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
crawlingSessionService.getCrawlingSession(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toIndexHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Actually Crud
|
||||
// -------------
|
||||
@Execute
|
||||
public HtmlResponse delete(final CrawlingSessionEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
crawlingSessionService.delete(getCrawlingSession(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toIndexHtml());
|
||||
String id = form.id;
|
||||
crawlingSessionService.getCrawlingSession(id).alwaysPresent(entity -> {
|
||||
crawlingSessionService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadCrawlingSession(final CrawlingSessionEditForm form) {
|
||||
copyBeanToBean(getCrawlingSession(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected CrawlingSession getCrawlingSession(final CrawlingSessionEditForm form) {
|
||||
final CrawlingSession crawlingSession = crawlingSessionService.getCrawlingSession(createKeyMap(form));
|
||||
return crawlingSession;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final CrawlingSessionEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final CrawlingSessionEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toIndexHtml());
|
||||
}
|
||||
}
|
||||
|
@ -197,4 +206,4 @@ public class AdminCrawlingsessionAction extends FessAdminAction {
|
|||
return asHtml(path_AdminCrawlingsession_IndexJsp);
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,34 +18,36 @@ package org.codelibs.fess.app.web.admin.crawlingsession;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author shinsuke
|
||||
* @author Shunji Makino
|
||||
*/
|
||||
public class CrawlingSessionEditForm implements Serializable {
|
||||
public class EditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@Digits(integer=10, fraction=0)
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public int crudMode;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 20)
|
||||
@Required
|
||||
@Size(max = 20)
|
||||
public String sessionId;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 20)
|
||||
@Size(max = 20)
|
||||
public String name;
|
||||
|
||||
//@DateType
|
||||
public String expiredTime;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@DateType
|
||||
public String createdTime;
|
||||
public Long createdTime;
|
||||
|
||||
public void initialize() {
|
||||
|
||||
|
@ -56,4 +58,4 @@ public class CrawlingSessionEditForm implements Serializable {
|
|||
createdTime = null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,16 +17,14 @@
|
|||
package org.codelibs.fess.app.web.admin.crawlingsession;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author shinsuke
|
||||
* @author Shunji Makino
|
||||
*/
|
||||
public class CrawlingSessionSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
}
|
||||
public String sessionId;
|
||||
}
|
|
@ -94,8 +94,7 @@
|
|||
<tr>
|
||||
<th><la:message
|
||||
key="labels.crawling_session_session_id" /></th>
|
||||
<td><la:link
|
||||
href="${f:url('/admin/searchList/search')}?query=segment:${f:u(sessionId)}">${f:h(sessionId)}</la:link>
|
||||
<td><a href="${f:url('/admin/searchlist/search')}?query=segment:${f:u(sessionId)}">${f:h(sessionId)}</a>
|
||||
<la:hidden property="sessionId" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -127,21 +126,21 @@
|
|||
</button>
|
||||
</c:if>
|
||||
<c:if test="${crudMode == 3}">
|
||||
<button type="submit" class="btn" name="delete"
|
||||
value="<la:message key="labels.crawling_session_button_delete" />">
|
||||
<la:message key="labels.crawling_session_button_delete" />
|
||||
</button>
|
||||
<button type="submit" class="btn" name="back"
|
||||
value="<la:message key="labels.crawling_session_button_back" />">
|
||||
<la:message key="labels.crawling_session_button_back" />
|
||||
</button>
|
||||
<button type="submit" class="btn btn-danger" name="delete"
|
||||
value="<la:message key="labels.crawling_session_button_delete" />">
|
||||
<la:message key="labels.crawling_session_button_delete" />
|
||||
</button>
|
||||
</c:if>
|
||||
<c:if test="${crudMode == 4}">
|
||||
<button type="submit" class="btn" name="back"
|
||||
value="<la:message key="labels.crawling_session_button_back" />">
|
||||
<la:message key="labels.crawling_session_button_back" />
|
||||
</button>
|
||||
<button type="submit" class="btn" name="deletefromconfirm"
|
||||
<button type="submit" class="btn btn-danger" name="deletefromconfirm"
|
||||
value="<la:message key="labels.crawling_session_button_delete" />">
|
||||
<la:message key="labels.crawling_session_button_delete" />
|
||||
</button>
|
||||
|
|
|
@ -46,14 +46,14 @@
|
|||
<label for="sessionIdSearchBtn"><la:message
|
||||
key="labels.crawling_session_session_id_search" /></label>
|
||||
<la:text styleId="sessionIdSearchBtn"
|
||||
property="searchParams.sessionId" styleClass="form-control"></la:text>
|
||||
property="sessionId" styleClass="form-control"></la:text>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary" name="search"
|
||||
value="<la:message key="labels.crawling_session_search" />">
|
||||
<la:message key="labels.crawling_session_search" />
|
||||
</button>
|
||||
<button type="reset" class="btn btn-secondary" name="reset"
|
||||
<button type="submit" class="btn btn-secondary" name="reset"
|
||||
value="<la:message key="labels.crawling_session_reset" />">
|
||||
<la:message key="labels.crawling_session_reset" />
|
||||
</button>
|
||||
|
@ -81,8 +81,6 @@
|
|||
key="labels.crawling_session_session_id" /></th>
|
||||
<th><la:message
|
||||
key="labels.crawling_session_created_time" /></th>
|
||||
<th><la:message
|
||||
key="labels.crawling_session_expired_time" /></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -91,17 +89,7 @@
|
|||
<tr class="${s.index % 2 == 0 ? 'row1' : 'row2'}"
|
||||
data-href="${contextPath}/admin/crawlingsession/confirmpage/4/${f:u(data.id)}">
|
||||
<td>${f:h(data.sessionId)}</td>
|
||||
<td>${f:h(data.createdTime)}</td>
|
||||
<td><c:if test="${data.expiredTime==null}">
|
||||
<la:message key="labels.none" />
|
||||
</c:if> <c:if test="${data.expiredTime!=null}">${f:h(data.expiredTime)}</c:if>
|
||||
</td>
|
||||
<td style="overflow-x: auto;"><la:link
|
||||
href="confirmpage/4/${f:u(data.id)}">
|
||||
<la:message key="labels.crawling_session_link_details" />
|
||||
</la:link> <la:link href="deletepage/3/${f:u(data.id)}">
|
||||
<la:message key="labels.crawling_session_link_delete" />
|
||||
</la:link></td>
|
||||
<td><fmt:formatDate value="${fe:date(data.createdTime)}" pattern="yyyy-MM-dd'T'HH:mm:ss" /></td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
|
|
Loading…
Add table
Reference in a new issue