modify dict.synonym action
This commit is contained in:
parent
05edce0a13
commit
0d5747da92
7 changed files with 346 additions and 418 deletions
9
pom.xml
9
pom.xml
|
@ -115,15 +115,6 @@
|
|||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
<!-- TODO remove -->
|
||||
<excludes>
|
||||
<exclude>org/codelibs/fess/app/web/admin/dict/UserDictForm.java</exclude>
|
||||
<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/DictForm.java</exclude>
|
||||
<exclude>org/codelibs/fess/app/web/admin/DictAction.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
|
@ -1,406 +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.dict;
|
||||
|
||||
import java.beans.Beans;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codelibs.core.beans.util.BeanUtil;
|
||||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.dict.DictionaryExpiredException;
|
||||
import org.codelibs.fess.dict.synonym.SynonymFile;
|
||||
import org.codelibs.fess.dict.synonym.SynonymItem;
|
||||
import org.codelibs.fess.exception.SSCActionMessagesException;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.app.pager.SynonymPager;
|
||||
import org.codelibs.fess.app.service.SynonymService;
|
||||
import org.lastaflute.web.util.LaResponseUtil;
|
||||
|
||||
public class SynonymAction {
|
||||
|
||||
private static final Log log = LogFactory.getLog(SynonymAction.class);
|
||||
|
||||
@Resource
|
||||
//@ActionForm
|
||||
protected SynonymForm synonymForm;
|
||||
|
||||
@Resource
|
||||
protected SynonymService synonymService;
|
||||
|
||||
@Resource
|
||||
protected SynonymPager synonymPager;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
public List<SynonymItem> synonymItemItems;
|
||||
|
||||
public String filename;
|
||||
|
||||
public String getHelpLink() {
|
||||
return systemHelper.getHelpLink("dict");
|
||||
}
|
||||
|
||||
protected String displayList(final boolean redirect) {
|
||||
// page navi
|
||||
synonymItemItems = synonymService.getSynonymList(synonymForm.dictId, synonymPager);
|
||||
|
||||
// restore from pager
|
||||
BeanUtil.copyBeanToBean(synonymPager, synonymForm.searchParams, option -> option.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
|
||||
if (redirect) {
|
||||
return "index?dictId=" + synonymForm.dictId + "&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/{dictId}/{pageNumber}")
|
||||
public String list() {
|
||||
// page navi
|
||||
if (StringUtil.isNotBlank(synonymForm.pageNumber)) {
|
||||
try {
|
||||
synonymPager.setCurrentPageNumber(Integer.parseInt(synonymForm.pageNumber));
|
||||
} catch (final NumberFormatException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Invalid value: " + synonymForm.pageNumber, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String search() {
|
||||
BeanUtil.copyBeanToBean(synonymForm.searchParams, synonymPager, option -> option.exclude(CommonConstants.PAGER_CONVERSION_RULE));
|
||||
|
||||
return displayList(false);
|
||||
}
|
||||
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String reset() {
|
||||
synonymPager.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/{dictId}/{crudMode}/{id}")
|
||||
public String confirmpage() {
|
||||
if (synonymForm.crudMode != CommonConstants.CONFIRM_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.CONFIRM_MODE, synonymForm.crudMode });
|
||||
}
|
||||
|
||||
loadSynonym();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String createpage() {
|
||||
// page navi
|
||||
synonymForm.initialize();
|
||||
synonymForm.crudMode = CommonConstants.CREATE_MODE;
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp", urlPattern = "editpage/{dictId}/{crudMode}/{id}")
|
||||
public String editpage() {
|
||||
if (synonymForm.crudMode != CommonConstants.EDIT_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode", new Object[] { CommonConstants.EDIT_MODE, synonymForm.crudMode });
|
||||
}
|
||||
|
||||
loadSynonym();
|
||||
|
||||
return "edit.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String editfromconfirm() {
|
||||
synonymForm.crudMode = CommonConstants.EDIT_MODE;
|
||||
|
||||
loadSynonym();
|
||||
|
||||
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/{dictId}/{crudMode}/{id}")
|
||||
public String deletepage() {
|
||||
if (synonymForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE, synonymForm.crudMode });
|
||||
}
|
||||
|
||||
loadSynonym();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String deletefromconfirm() {
|
||||
synonymForm.crudMode = CommonConstants.DELETE_MODE;
|
||||
|
||||
loadSynonym();
|
||||
|
||||
return "confirm.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String create() {
|
||||
try {
|
||||
final SynonymItem synonymItem = createSynonym();
|
||||
synonymService.store(synonymForm.dictId, synonymItem);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_create_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final DictionaryExpiredException e) {
|
||||
throw e;
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, "errors.crud_failed_to_create_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "edit.jsp")
|
||||
public String update() {
|
||||
try {
|
||||
final SynonymItem synonymItem = createSynonym();
|
||||
synonymService.store(synonymForm.dictId, synonymItem);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final DictionaryExpiredException e) {
|
||||
throw e;
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, "errors.crud_failed_to_update_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = false, input = "error.jsp")
|
||||
public String delete() {
|
||||
if (synonymForm.crudMode != CommonConstants.DELETE_MODE) {
|
||||
throw new ActionMessagesException("errors.crud_invalid_mode",
|
||||
new Object[] { CommonConstants.DELETE_MODE, synonymForm.crudMode });
|
||||
}
|
||||
|
||||
try {
|
||||
final SynonymItem synonymItem = synonymService.getSynonym(synonymForm.dictId, createKeyMap());
|
||||
if (synonymItem == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { synonymForm.id });
|
||||
|
||||
}
|
||||
|
||||
synonymService.delete(synonymForm.dictId, synonymItem);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
return displayList(true);
|
||||
} catch (final DictionaryExpiredException e) {
|
||||
throw e;
|
||||
} catch (final ActionMessagesException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw e;
|
||||
} catch (final CrudMessageException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, e.getMessageId(), e.getArgs());
|
||||
} catch (final Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
throw new SSCActionMessagesException(e, "errors.crud_failed_to_delete_crud_table");
|
||||
}
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "downloadpage")
|
||||
public String downloadpage() {
|
||||
final SynonymFile synonymFile = synonymService.getSynonymFile(synonymForm.dictId);
|
||||
if (synonymFile == null) {
|
||||
throw new SSCActionMessagesException("errors.synonym_file_is_not_found");
|
||||
}
|
||||
filename = synonymFile.getSimpleName();
|
||||
return "download.jsp";
|
||||
}
|
||||
|
||||
@Token(save = true, validate = true)
|
||||
//@Execute(validator = false, input = "downloadpage")
|
||||
public String download() {
|
||||
final SynonymFile synonymFile = synonymService.getSynonymFile(synonymForm.dictId);
|
||||
if (synonymFile == null) {
|
||||
throw new SSCActionMessagesException("errors.synonym_file_is_not_found");
|
||||
}
|
||||
try (InputStream in = synonymFile.getInputStream()) {
|
||||
LaResponseUtil.download(synonymFile.getSimpleName(), in);
|
||||
} catch (final IOException e) {
|
||||
throw new SSCActionMessagesException("errors.failed_to_download_synonym_file");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
//@Execute(validator = false, input = "uploadpage")
|
||||
public String uploadpage() {
|
||||
final SynonymFile synonymFile = synonymService.getSynonymFile(synonymForm.dictId);
|
||||
if (synonymFile == null) {
|
||||
throw new SSCActionMessagesException("errors.synonym_file_is_not_found");
|
||||
}
|
||||
filename = synonymFile.getName();
|
||||
return "upload.jsp";
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
//@Execute(validator = true, input = "uploadpage")
|
||||
public String upload() {
|
||||
final SynonymFile synonymFile = synonymService.getSynonymFile(synonymForm.dictId);
|
||||
if (synonymFile == null) {
|
||||
throw new SSCActionMessagesException("errors.synonym_file_is_not_found");
|
||||
}
|
||||
try (InputStream in = synonymForm.synonymFile.getInputStream()) {
|
||||
synonymFile.update(in);
|
||||
} catch (final IOException e) {
|
||||
throw new SSCActionMessagesException("errors.failed_to_upload_synonym_file");
|
||||
}
|
||||
|
||||
SAStrutsUtil.addSessionMessage("success.upload_synonym_file");
|
||||
|
||||
return "uploadpage?dictId=" + synonymForm.dictId + "&redirect=true";
|
||||
}
|
||||
|
||||
protected void loadSynonym() {
|
||||
|
||||
final SynonymItem synonymItem = synonymService.getSynonym(synonymForm.dictId, createKeyMap());
|
||||
if (synonymItem == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { synonymForm.id });
|
||||
|
||||
}
|
||||
|
||||
synonymForm.id = Long.toString(synonymItem.getId());
|
||||
synonymForm.inputs = StringUtils.join(synonymItem.getInputs(), "\n");
|
||||
synonymForm.outputs = StringUtils.join(synonymItem.getOutputs(), "\n");
|
||||
}
|
||||
|
||||
protected SynonymItem createSynonym() {
|
||||
SynonymItem synonymItem;
|
||||
if (synonymForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
synonymItem = synonymService.getSynonym(synonymForm.dictId, createKeyMap());
|
||||
if (synonymItem == null) {
|
||||
// throw an exception
|
||||
throw new ActionMessagesException("errors.crud_could_not_find_crud_table",
|
||||
|
||||
new Object[] { synonymForm.id });
|
||||
|
||||
}
|
||||
} else {
|
||||
synonymItem = new SynonymItem(0, StringUtil.EMPTY_STRINGS, StringUtil.EMPTY_STRINGS);
|
||||
}
|
||||
|
||||
final String[] newInputs = splitLine(synonymForm.inputs);
|
||||
synonymItem.setNewInputs(newInputs);
|
||||
final String[] newOutputs = splitLine(synonymForm.outputs);
|
||||
synonymItem.setNewOutputs(newOutputs);
|
||||
|
||||
return synonymItem;
|
||||
}
|
||||
|
||||
private String[] splitLine(final String value) {
|
||||
if (StringUtil.isBlank(value)) {
|
||||
return StringUtil.EMPTY_STRINGS;
|
||||
}
|
||||
final String[] values = value.split("[\r\n]");
|
||||
final List<String> list = new ArrayList<String>(values.length);
|
||||
for (final String line : values) {
|
||||
if (StringUtil.isNotBlank(line)) {
|
||||
list.add(line.trim());
|
||||
}
|
||||
}
|
||||
return list.toArray(new String[list.size()]);
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap() {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", synonymForm.id);
|
||||
return keys;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,270 @@
|
|||
/*
|
||||
* 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.dict.synonym;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.core.misc.DynamicProperties;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.Token;
|
||||
import org.codelibs.fess.app.pager.SynonymPager;
|
||||
import org.codelibs.fess.app.service.SynonymService;
|
||||
import org.codelibs.fess.app.web.CrudMode;
|
||||
import org.codelibs.fess.app.web.admin.suggestelevateword.SuggestElevateWordEditForm;
|
||||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
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 Keiichi Watanabe
|
||||
*/
|
||||
public class AdminDictSynonymAction extends FessAdminAction {
|
||||
|
||||
// ===================================================================================
|
||||
// Attribute
|
||||
// =========
|
||||
@Resource
|
||||
private SynonymService synonymService;
|
||||
@Resource
|
||||
private SynonymPager synonymPager;
|
||||
@Resource
|
||||
private SystemHelper systemHelper;
|
||||
@Resource
|
||||
protected DynamicProperties crawlerProperties;
|
||||
|
||||
// ===================================================================================
|
||||
// Hook
|
||||
// ======
|
||||
@Override
|
||||
protected void setupHtmlData(final ActionRuntime runtime) {
|
||||
super.setupHtmlData(runtime);
|
||||
runtime.registerData("helpLink", systemHelper.getHelpLink("synonym"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SynonymSearchForm form) {
|
||||
return asHtml(path_AdminDictSynonym_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final SynonymSearchForm form) {
|
||||
synonymPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminDictSynonym_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final SynonymSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, synonymPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminDictSynonym_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final SynonymSearchForm form) {
|
||||
synonymPager.clear();
|
||||
return asHtml(path_AdminDictSynonym_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final SynonymSearchForm form) {
|
||||
return asHtml(path_AdminDictSynonym_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final SynonymSearchForm form) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Edit Execute
|
||||
// ============
|
||||
// -----------------------------------------------------
|
||||
// Entry Page
|
||||
// ----------
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse createpage(final SynonymEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminDictSynonym_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final SynonymEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
// TODO loadSynonym(form);
|
||||
return asHtml(path_AdminDictSynonym_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editagain(final SynonymEditForm form) {
|
||||
return asHtml(path_AdminDictSynonym_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse editfromconfirm(final SynonymEditForm form) {
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
// TODO loadSynonym(form);
|
||||
return asHtml(path_AdminDictSynonym_EditJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final SynonymEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
// TODO loadSynonym(form);
|
||||
return asHtml(path_AdminDictSynonym_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = true, validate = false)
|
||||
@Execute
|
||||
public HtmlResponse deletefromconfirm(final SynonymEditForm form) {
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
// TODO loadSynonym(form);
|
||||
return asHtml(path_AdminDictSynonym_ConfirmJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final SynonymEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
// TODO loadSynonym(form);
|
||||
return asHtml(path_AdminDictSynonym_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromcreate(final SynonymEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminDictSynonym_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true, keep = true)
|
||||
@Execute
|
||||
public HtmlResponse confirmfromupdate(final SynonymEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminDictSynonym_ConfirmJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Download
|
||||
// -------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse downloadpage(final SynonymSearchForm form) {
|
||||
return asHtml(path_AdminDictSynonym_DownloadJsp);
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse download(final SynonymSearchForm form) {
|
||||
// TODO Download
|
||||
|
||||
return asHtml(path_AdminDictSynonym_DownloadJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Upload
|
||||
// -------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse uploadpage(final SynonymUploadForm form) {
|
||||
// TODO Upload
|
||||
|
||||
return asHtml(path_AdminDictSynonym_UploadJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Actually Crud
|
||||
// -------------
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse create(final SynonymEditForm form) {
|
||||
// TODO
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse update(final SynonymEditForm form) {
|
||||
// TODO
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final SynonymEditForm form) {
|
||||
// TODO
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Token(save = false, validate = true)
|
||||
@Execute
|
||||
public HtmlResponse upload(final SynonymUploadForm form) {
|
||||
// TODO
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadSynonym(final SuggestElevateWordEditForm form) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final SynonymEditForm form, final 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_AdminDictSynonym_EditJsp);
|
||||
};
|
||||
}
|
||||
}
|
|
@ -14,12 +14,20 @@
|
|||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.codelibs.fess.app.web.admin.dict;
|
||||
package org.codelibs.fess.app.web.admin.dict.synonym;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SynonymForm {
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SynonymEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@IntegerType
|
||||
public String pageNumber;
|
||||
|
|
@ -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.dict.synonym;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SynonymSearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* 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.dict.synonym;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.lastaflute.web.ruts.multipart.MultipartFormFile;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SynonymUploadForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MultipartFormFile synonymFile;
|
||||
|
||||
}
|
|
@ -39,7 +39,7 @@
|
|||
</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<span class="label label-default">
|
||||
<la:link href="../index">
|
||||
<la:link href="../">
|
||||
<la:message key="labels.dict_list_link" />
|
||||
</la:link>
|
||||
</span>
|
||||
|
|
Loading…
Add table
Reference in a new issue