modify overlappingHost action
This commit is contained in:
parent
207fa13afd
commit
80aedac391
6 changed files with 316 additions and 341 deletions
2
pom.xml
2
pom.xml
|
@ -98,7 +98,6 @@
|
|||
<exclude>org/codelibs/fess/app/web/admin/dict/SynonymForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/dict/UserDictAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/dict/SynonymAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/OverlappingHostForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/DocumentAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/SystemInfoForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/JobLogForm.java</exclude>
|
||||
|
@ -120,7 +119,6 @@
|
|||
<exclude>org/codelibs/fess/app/web/admin/DictAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/SuggestElevateWordAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/LogForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/OverlappingHostAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/SystemInfoAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/WebAuthenticationAction.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/DataAction.java</exclude>
|
||||
|
|
|
@ -1,323 +0,0 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin;
|
||||
|
||||
import java.beans.Beans;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.beans.util.BeanUtil;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.beans.FessBeans;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.es.exentity.OverlappingHost;
|
||||
import org.codelibs.fess.exception.SSCActionMessagesException;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.app.pager.OverlappingHostPager;
|
||||
import org.codelibs.fess.app.service.OverlappingHostService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class OverlappingHostAction extends FessAdminAction {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(OverlappingHostAction.class);
|
||||
|
||||
// for list
|
||||
|
||||
public List<OverlappingHost> overlappingHostItems;
|
||||
|
||||
// for edit/confirm/delete
|
||||
|
||||
//@ActionForm
|
||||
@Resource
|
||||
protected OverlappingHostForm overlappingHostForm;
|
||||
|
||||
@Resource
|
||||
protected OverlappingHostService overlappingHostService;
|
||||
|
||||
@Resource
|
||||
protected OverlappingHostPager overlappingHostPager;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("overlappingHost");
|
||||
}
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
overlappingHostItems = overlappingHostService.getOverlappingHostList(overlappingHostPager);
|
||||
|
||||
// restore from pager
|
||||
BeanUtil.copyBeanToBean(overlappingHostPager, overlappingHostForm.searchParams,
|
||||
option -> option.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
|
||||
if (redirect) {
|
||||
return "index?redirect=true";
|
||||
} else {
|
||||
return "index.jsp";
|
||||
}
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String index() {
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp", urlPattern = "list/{pageNumber}")
|
||||
public String list() {
|
||||
// page navi
|
||||
if (StringUtil.isNotBlank(overlappingHostForm.pageNumber)) {
|
||||
try {
|
||||
overlappingHostPager.setCurrentPageNumber(Integer.parseInt(overlappingHostForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Invalid value: " + overlappingHostForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
BeanUtil.copyBeanToBean(overlappingHostForm.searchParams, overlappingHostPager,
|
||||
option -> option.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
overlappingHostPager.clear();
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String back() {
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String editagain() {
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp", urlPattern = "confirmpage/{crudMode}/{id}")
|
||||
public String confirmpage() {
|
||||
if (overlappingHostForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.CONFIRM_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
overlappingHostForm.initialize();
|
||||
overlappingHostForm.crudMode = CommonConstants.CREATE_MODE;
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{crudMode}/{id}")
|
||||
public String editpage() {
|
||||
if (overlappingHostForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
overlappingHostForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromcreate() {
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String confirmfromupdate() {
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp", urlPattern = "deletepage/{crudMode}/{id}")
|
||||
public String deletepage() {
|
||||
if (overlappingHostForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
overlappingHostForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadOverlappingHost();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final OverlappingHost overlappingHost = createOverlappingHost();
|
||||
overlappingHostService.store(overlappingHost);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_create_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String update() {
|
||||
try {
|
||||
final OverlappingHost overlappingHost = createOverlappingHost();
|
||||
overlappingHostService.store(overlappingHost);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new ActionMessagesException("errors.crud_failed_to_update_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
|
||||
keys.put("id", overlappingHostForm.id);
|
||||
|
||||
return keys;
|
||||
}
|
||||
|
||||
protected void loadOverlappingHost() {
|
||||
|
||||
final OverlappingHost overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap());
|
||||
if (overlappingHost == null) {
|
||||
// throw an exception
|
||||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { overlappingHostForm.id });
|
||||
}
|
||||
|
||||
BeanUtil.copyBeanToBean(overlappingHost, overlappingHostForm, option -> option.exclude("searchParams", "mode"));
|
||||
}
|
||||
|
||||
protected OverlappingHost createOverlappingHost() {
|
||||
OverlappingHost overlappingHost;
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (overlappingHostForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap());
|
||||
if (overlappingHost == null) {
|
||||
// throw an exception
|
||||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { overlappingHostForm.id });
|
||||
}
|
||||
} else {
|
||||
overlappingHost = new OverlappingHost();
|
||||
overlappingHost.setCreatedBy(username);
|
||||
overlappingHost.setCreatedTime(currentTime);
|
||||
}
|
||||
overlappingHost.setUpdatedBy(username);
|
||||
overlappingHost.setUpdatedTime(currentTime);
|
||||
BeanUtil.copyBeanToBean(overlappingHostForm, overlappingHost, option -> option.exclude(CommonConstants.COMMON_CONVERSION_RULE));
|
||||
|
||||
return overlappingHost;
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (overlappingHostForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new SSCActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.DELETE_MODE,
|
||||
overlappingHostForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final OverlappingHost overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap());
|
||||
if (overlappingHost == null) {
|
||||
// throw an exception
|
||||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { overlappingHostForm.id });
|
||||
}
|
||||
|
||||
overlappingHostService.delete(overlappingHost);
|
||||
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final ActionMessagesException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,275 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.overlappinghost;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.pager.OverlappingHostPager;
|
||||
import org.codelibs.fess.app.service.OverlappingHostService;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.es.exentity.OverlappingHost;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
import org.lastaflute.web.response.render.RenderData;
|
||||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
*/
|
||||
public class AdminOverlappinghostAction extends FessAdminAction {
|
||||
|
||||
// ===================================================================================
|
||||
// Attribute
|
||||
// =========
|
||||
@Resource
|
||||
private OverlappingHostService overlappingHostService;
|
||||
@Resource
|
||||
private OverlappingHostPager overlappingHostPager;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
// ======
|
||||
@Override
|
||||
protected void setupHtmlData(ActionRuntime runtime) {
|
||||
super.setupHtmlData(runtime);
|
||||
runtime.registerData("helpLink", systemHelper.getHelpLink("overlappingHost"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(OverlappingHostSearchForm form) {
|
||||
return asHtml(path_AdminOverlappinghost_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(Integer pageNumber, OverlappingHostSearchForm form) {
|
||||
overlappingHostPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminOverlappinghost_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(OverlappingHostSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, overlappingHostPager, op -> op.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminOverlappinghost_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(OverlappingHostSearchForm form) {
|
||||
overlappingHostPager.clear();
|
||||
return asHtml(path_AdminOverlappinghost_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(OverlappingHostSearchForm form) {
|
||||
return asHtml(path_AdminOverlappinghost_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(RenderData data, OverlappingHostSearchForm form) {
|
||||
data.register("overlappingHostItems", overlappingHostService.getOverlappingHostList(overlappingHostPager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(overlappingHostPager, form.searchParams, op -> op.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Edit Execute
|
||||
// ============
|
||||
// -----------------------------------------------------
|
||||
// Entry Page
|
||||
// ----------
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createpage(OverlappingHostEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CommonConstants.CREATE_MODE;
|
||||
return asHtml(path_AdminOverlappinghost_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(int crudMode, String id, OverlappingHostEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.EDIT_MODE);
|
||||
loadOverlappingHost(form);
|
||||
return asHtml(path_AdminOverlappinghost_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(OverlappingHostEditForm form) {
|
||||
return asHtml(path_AdminOverlappinghost_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editfromconfirm(OverlappingHostEditForm form) {
|
||||
form.crudMode = CommonConstants.EDIT_MODE;
|
||||
loadOverlappingHost(form);
|
||||
return asHtml(path_AdminOverlappinghost_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletepage(int crudMode, String id, OverlappingHostEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
loadOverlappingHost(form);
|
||||
return asHtml(path_AdminOverlappinghost_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletefromconfirm(OverlappingHostEditForm form) {
|
||||
form.crudMode = CommonConstants.DELETE_MODE;
|
||||
loadOverlappingHost(form);
|
||||
return asHtml(path_AdminOverlappinghost_ConfirmJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(int crudMode, String id, OverlappingHostEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CommonConstants.CONFIRM_MODE);
|
||||
loadOverlappingHost(form);
|
||||
return asHtml(path_AdminOverlappinghost_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(OverlappingHostEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminOverlappinghost_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(OverlappingHostEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminOverlappinghost_ConfirmJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Actually Crud
|
||||
// -------------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse create(OverlappingHostEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
overlappingHostService.store(createOverlappingHost(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse update(OverlappingHostEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
overlappingHostService.store(createOverlappingHost(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(OverlappingHostEditForm form) {
|
||||
verifyCrudMode(form, CommonConstants.DELETE_MODE);
|
||||
overlappingHostService.delete(getOverlappingHost(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadOverlappingHost(OverlappingHostEditForm form) {
|
||||
copyBeanToBean(getOverlappingHost(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected OverlappingHost getOverlappingHost(OverlappingHostEditForm form) {
|
||||
final OverlappingHost overlappingHost = overlappingHostService.getOverlappingHost(createKeyMap(form));
|
||||
if (overlappingHost == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return overlappingHost;
|
||||
}
|
||||
|
||||
protected OverlappingHost createOverlappingHost(OverlappingHostEditForm form) {
|
||||
OverlappingHost overlappingHost;
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CommonConstants.EDIT_MODE) {
|
||||
overlappingHost = getOverlappingHost(form);
|
||||
} else {
|
||||
overlappingHost = new OverlappingHost();
|
||||
overlappingHost.setCreatedBy(username);
|
||||
overlappingHost.setCreatedTime(currentTime);
|
||||
}
|
||||
overlappingHost.setUpdatedBy(username);
|
||||
overlappingHost.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, overlappingHost, op -> op.exclude(CommonConstants.COMMON_CONVERSION_RULE));
|
||||
return overlappingHost;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(OverlappingHostEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(OverlappingHostEditForm form, int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
||||
protected VaErrorHook toEditHtml() {
|
||||
return () -> {
|
||||
return asHtml(path_AdminOverlappinghost_EditJsp);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -14,30 +14,23 @@
|
|||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin;
|
||||
package org.codelibs.fess.app.web.admin.overlappinghost;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
public class OverlappingHostForm implements Serializable {
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
*/
|
||||
public class OverlappingHostEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@IntegerType
|
||||
public String pageNumber;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
|
||||
//@IntegerType
|
||||
public int crudMode;
|
||||
|
||||
public String getCurrentPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright 2009-2015 the CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.overlappinghost;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author jflute
|
||||
*/
|
||||
public class OverlappingHostSearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
}
|
|
@ -125,12 +125,12 @@
|
|||
<span><la:message key="labels.menu.request_header" /></span>
|
||||
</la:link></li>
|
||||
|
||||
<li <c:if test="${param.menuType=='overlappingHost'}">class="active"</c:if>><todo:link
|
||||
href="/admin/overlappingHost/index"
|
||||
<li <c:if test="${param.menuType=='overlappingHost'}">class="active"</c:if>><la:link
|
||||
href="/admin/overlappinghost/index"
|
||||
>
|
||||
<i class='fa fa-angle-right'></i>
|
||||
<span><la:message key="labels.menu.overlapping_host" /></span>
|
||||
</todo:link></li>
|
||||
</la:link></li>
|
||||
|
||||
<li <c:if test="${param.menuType=='roleType'}">class="active"</c:if>><la:link href="/admin/roletype/index">
|
||||
<i class='fa fa-angle-right'></i>
|
||||
|
|
Loading…
Add table
Reference in a new issue