diff --git a/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/AdminDictSeunjeonAction.java b/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/AdminDictSeunjeonAction.java index 6323f8e19..d59b535dc 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/AdminDictSeunjeonAction.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/AdminDictSeunjeonAction.java @@ -18,8 +18,6 @@ package org.codelibs.fess.app.web.admin.dict.seunjeon; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; import javax.annotation.Resource; @@ -34,6 +32,7 @@ import org.codelibs.fess.app.web.admin.dict.AdminDictAction; import org.codelibs.fess.app.web.base.FessAdminAction; import org.codelibs.fess.dict.seunjeon.SeunjeonItem; import org.codelibs.fess.util.RenderDataUtil; +import org.codelibs.fess.util.StreamUtil; import org.dbflute.optional.OptionalEntity; import org.dbflute.optional.OptionalThing; import org.lastaflute.web.Execute; @@ -45,6 +44,7 @@ import org.lastaflute.web.validation.VaErrorHook; /** * @author nocode + * @author shinsuke */ public class AdminDictSeunjeonAction extends FessAdminAction { @@ -144,7 +144,6 @@ public class AdminDictSeunjeonAction extends FessAdminAction { .getSeunjeonItem(form.dictId, form.id) .ifPresent(entity -> { form.inputs = entity.getInputsValue(); - form.outputs = entity.getOutputsValue(); }) .orElse(() -> { throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.getDisplayId()), @@ -176,7 +175,6 @@ public class AdminDictSeunjeonAction extends FessAdminAction { .getSeunjeonItem(dictId, id) .ifPresent(entity -> { form.inputs = entity.getInputsValue(); - form.outputs = entity.getOutputsValue(); }) .orElse(() -> { throwValidationError( @@ -321,7 +319,7 @@ public class AdminDictSeunjeonAction extends FessAdminAction { private OptionalEntity getEntity(final CreateForm form) { switch (form.crudMode) { case CrudMode.CREATE: - final SeunjeonItem entity = new SeunjeonItem(0, StringUtil.EMPTY_STRINGS, StringUtil.EMPTY_STRINGS); + final SeunjeonItem entity = new SeunjeonItem(0, StringUtil.EMPTY_STRINGS); return OptionalEntity.of(entity); case CrudMode.EDIT: if (form instanceof EditForm) { @@ -339,9 +337,6 @@ public class AdminDictSeunjeonAction extends FessAdminAction { final String[] newInputs = splitLine(form.inputs); validateSeunjeonString(newInputs, "inputs", hook); entity.setNewInputs(newInputs); - final String[] newOutputs = splitLine(form.outputs); - validateSeunjeonString(newOutputs, "outputs", hook); - entity.setNewOutputs(newOutputs); return entity; }); } @@ -361,32 +356,14 @@ public class AdminDictSeunjeonAction extends FessAdminAction { if (values.length == 0) { return; } - for (final String value : values) { - if (value.indexOf(',') >= 0) { - throwValidationError(messages -> { - messages.addErrorsInvalidStrIsIncluded(propertyName, value, ","); - }, hook); - } - if (value.indexOf("=>") >= 0) { - throwValidationError(messages -> { - messages.addErrorsInvalidStrIsIncluded(propertyName, value, "=>"); - }, hook); - } - } + // TODO validation } private String[] splitLine(final String value) { if (StringUtil.isBlank(value)) { return StringUtil.EMPTY_STRINGS; } - final String[] values = value.split("[\r\n]"); - final List list = new ArrayList<>(values.length); - for (final String line : values) { - if (StringUtil.isNotBlank(line)) { - list.add(line.trim()); - } - } - return list.toArray(new String[list.size()]); + return StreamUtil.of(value.split(",")).filter(s -> StringUtil.isNotBlank(s)).map(s -> s.trim()).toArray(n -> new String[n]); } // =================================================================================== diff --git a/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/CreateForm.java b/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/CreateForm.java index cdc70c36b..37094a38b 100644 --- a/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/CreateForm.java +++ b/src/main/java/org/codelibs/fess/app/web/admin/dict/seunjeon/CreateForm.java @@ -40,10 +40,6 @@ public class CreateForm implements Serializable { @Size(max = 1000) public String inputs; - @Required - @Size(max = 1000) - public String outputs; - public void initialize() { crudMode = CrudMode.CREATE; } diff --git a/src/main/java/org/codelibs/fess/dict/seunjeon/SeunjeonFile.java b/src/main/java/org/codelibs/fess/dict/seunjeon/SeunjeonFile.java index dc75c4437..c762a4af9 100644 --- a/src/main/java/org/codelibs/fess/dict/seunjeon/SeunjeonFile.java +++ b/src/main/java/org/codelibs/fess/dict/seunjeon/SeunjeonFile.java @@ -107,7 +107,6 @@ public class SeunjeonFile extends DictionaryFile { public synchronized void delete(final SeunjeonItem item) { final SeunjeonItem SeunjeonItem = item; SeunjeonItem.setNewInputs(StringUtil.EMPTY_STRINGS); - SeunjeonItem.setNewOutputs(StringUtil.EMPTY_STRINGS); try (SynonymUpdater updater = new SynonymUpdater(item)) { reload(updater, null); } @@ -127,60 +126,24 @@ public class SeunjeonFile extends DictionaryFile { continue; // ignore empty lines and comments } - String inputs[]; - String outputs[]; + final List inputStrings = split(line, ","); + String[] inputs = new String[inputStrings.size()]; + for (int i = 0; i < inputs.length; i++) { + inputs[i] = unescape(inputStrings.get(i)).trim(); + } - final List sides = split(line, "=>"); - if (sides.size() > 1) { // explicit mapping - if (sides.size() != 2) { - throw new DictionaryException("more than one explicit mapping specified on the same line"); - } - final List inputStrings = split(sides.get(0), ","); - inputs = new String[inputStrings.size()]; - for (int i = 0; i < inputs.length; i++) { - inputs[i] = unescape(inputStrings.get(i)).trim(); - } - - final List outputStrings = split(sides.get(1), ","); - outputs = new String[outputStrings.size()]; - for (int i = 0; i < outputs.length; i++) { - outputs[i] = unescape(outputStrings.get(i)).trim(); - } - - if (inputs.length > 0 && outputs.length > 0) { - id++; - final SeunjeonItem item = new SeunjeonItem(id, inputs, outputs); - if (updater != null) { - final SeunjeonItem newItem = updater.write(item); - if (newItem != null) { - itemList.add(newItem); - } else { - id--; - } + if (inputs.length > 0) { + id++; + final SeunjeonItem item = new SeunjeonItem(id, inputs); + if (updater != null) { + final SeunjeonItem newItem = updater.write(item); + if (newItem != null) { + itemList.add(newItem); } else { - itemList.add(item); - } - } - } else { - final List inputStrings = split(line, ","); - inputs = new String[inputStrings.size()]; - for (int i = 0; i < inputs.length; i++) { - inputs[i] = unescape(inputStrings.get(i)).trim(); - } - - if (inputs.length > 0) { - id++; - final SeunjeonItem item = new SeunjeonItem(id, inputs, inputs); - if (updater != null) { - final SeunjeonItem newItem = updater.write(item); - if (newItem != null) { - itemList.add(newItem); - } else { - id--; - } - } else { - itemList.add(item); + id--; } + } else { + itemList.add(item); } } } @@ -297,13 +260,12 @@ public class SeunjeonFile extends DictionaryFile { // update writer.write(item.toLineString()); writer.write(Constants.LINE_SEPARATOR); - return new SeunjeonItem(item.getId(), item.getNewInputs(), item.getNewOutputs()); + return new SeunjeonItem(item.getId(), item.getNewInputs()); } else { return null; } } finally { item.setNewInputs(null); - item.setNewOutputs(null); } } else { throw new DictionaryException("Seunjeon file was updated: old=" + oldItem + " : new=" + item); diff --git a/src/main/java/org/codelibs/fess/dict/seunjeon/SeunjeonItem.java b/src/main/java/org/codelibs/fess/dict/seunjeon/SeunjeonItem.java index 44e177f07..8bac737a8 100644 --- a/src/main/java/org/codelibs/fess/dict/seunjeon/SeunjeonItem.java +++ b/src/main/java/org/codelibs/fess/dict/seunjeon/SeunjeonItem.java @@ -24,25 +24,15 @@ import org.codelibs.fess.dict.DictionaryItem; public class SeunjeonItem extends DictionaryItem { private final String[] inputs; - private final String[] outputs; - private String[] newInputs; - private String[] newOutputs; - - public SeunjeonItem(final long id, final String[] inputs, final String[] outputs) { + public SeunjeonItem(final long id, final String[] inputs) { this.id = id; this.inputs = inputs; - this.outputs = outputs; - Arrays.sort(inputs); - if (inputs != outputs) { - Arrays.sort(outputs); - } if (id == 0) { // create newInputs = inputs; - newOutputs = outputs; } } @@ -54,14 +44,6 @@ public class SeunjeonItem extends DictionaryItem { this.newInputs = newInputs; } - public String[] getNewOutputs() { - return newOutputs; - } - - public void setNewOutputs(final String[] newOutputs) { - this.newOutputs = newOutputs; - } - public String[] getInputs() { return inputs; } @@ -70,49 +52,22 @@ public class SeunjeonItem extends DictionaryItem { if (inputs == null) { return StringUtil.EMPTY; } - return String.join("\n", inputs); - } - - public String[] getOutputs() { - return outputs; - } - - public String getOutputsValue() { - if (outputs == null) { - return StringUtil.EMPTY; - } - return String.join("\n", outputs); + return String.join(",", inputs); } public boolean isUpdated() { - return newInputs != null && newOutputs != null; + return newInputs != null; } public boolean isDeleted() { return isUpdated() && newInputs.length == 0; } - public void sort() { - if (inputs != null) { - Arrays.sort(inputs); - } - if (outputs != null) { - Arrays.sort(outputs); - } - if (newInputs != null) { - Arrays.sort(newInputs); - } - if (newOutputs != null) { - Arrays.sort(newOutputs); - } - } - @Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + Arrays.hashCode(inputs); - result = prime * result + Arrays.hashCode(outputs); return result; } @@ -128,36 +83,22 @@ public class SeunjeonItem extends DictionaryItem { return false; } final SeunjeonItem other = (SeunjeonItem) obj; - sort(); - other.sort(); if (!Arrays.equals(inputs, other.inputs)) { return false; } - if (!Arrays.equals(outputs, other.outputs)) { - return false; - } return true; } @Override public String toString() { - return "SynonymItem [id=" + id + ", inputs=" + Arrays.toString(inputs) + ", outputs=" + Arrays.toString(outputs) + ", newInputs=" - + Arrays.toString(newInputs) + ", newOutputs=" + Arrays.toString(newOutputs) + "]"; + return "SynonymItem [id=" + id + ", inputs=" + Arrays.toString(inputs) + ", newInputs=" + Arrays.toString(newInputs) + "]"; } public String toLineString() { if (isUpdated()) { - if (Arrays.equals(newInputs, newOutputs)) { - return StringUtils.join(newInputs, ","); - } else { - return StringUtils.join(newInputs, ",") + "=>" + StringUtils.join(newOutputs, ","); - } + return StringUtils.join(newInputs, ","); } else { - if (Arrays.equals(inputs, outputs)) { - return StringUtils.join(inputs, ","); - } else { - return StringUtils.join(inputs, ",") + "=>" + StringUtils.join(outputs, ","); - } + return StringUtils.join(inputs, ","); } } diff --git a/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java b/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java index c3197f29d..359e77253 100644 --- a/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java +++ b/src/main/java/org/codelibs/fess/mylasta/action/FessLabels.java @@ -1755,6 +1755,45 @@ public class FessLabels extends ActionMessages { /** The key of the message: Synonym File */ public static final String LABELS_dict_synonym_file = "{labels.dict_synonym_file}"; + /** The key of the message: Seunjeon List */ + public static final String LABELS_dict_seunjeon_configuration = "{labels.dict_seunjeon_configuration}"; + + /** The key of the message: Seunjeon List */ + public static final String LABELS_dict_seunjeon_title = "{labels.dict_seunjeon_title}"; + + /** The key of the message: List */ + public static final String LABELS_dict_seunjeon_list_link = "{labels.dict_seunjeon_list_link}"; + + /** The key of the message: Create New */ + public static final String LABELS_dict_seunjeon_link_create = "{labels.dict_seunjeon_link_create}"; + + /** The key of the message: Edit */ + public static final String LABELS_dict_seunjeon_link_edit = "{labels.dict_seunjeon_link_edit}"; + + /** The key of the message: Delete */ + public static final String LABELS_dict_seunjeon_link_delete = "{labels.dict_seunjeon_link_delete}"; + + /** The key of the message: Details */ + public static final String LABELS_dict_seunjeon_link_details = "{labels.dict_seunjeon_link_details}"; + + /** The key of the message: Download */ + public static final String LABELS_dict_seunjeon_link_download = "{labels.dict_seunjeon_link_download}"; + + /** The key of the message: Upload */ + public static final String LABELS_dict_seunjeon_link_upload = "{labels.dict_seunjeon_link_upload}"; + + /** The key of the message: Source */ + public static final String LABELS_dict_seunjeon_source = "{labels.dict_seunjeon_source}"; + + /** The key of the message: Download */ + public static final String LABELS_dict_seunjeon_button_download = "{labels.dict_seunjeon_button_download}"; + + /** The key of the message: Upload */ + public static final String LABELS_dict_seunjeon_button_upload = "{labels.dict_seunjeon_button_upload}"; + + /** The key of the message: Seunjeon File */ + public static final String LABELS_dict_seunjeon_file = "{labels.dict_seunjeon_file}"; + /** The key of the message: Kuromoji List */ public static final String LABELS_dict_kuromoji_configuration = "{labels.dict_kuromoji_configuration}"; diff --git a/src/main/resources/fess_label.properties b/src/main/resources/fess_label.properties index 941fc8d0c..287d992e5 100644 --- a/src/main/resources/fess_label.properties +++ b/src/main/resources/fess_label.properties @@ -575,6 +575,19 @@ labels.dict_synonym_target=Target labels.dict_synonym_button_download=Download labels.dict_synonym_button_upload=Upload labels.dict_synonym_file=Synonym File +labels.dict_seunjeon_configuration = Seunjeon List +labels.dict_seunjeon_title = Seunjeon List +labels.dict_seunjeon_list_link = List +labels.dict_seunjeon_link_create = Create New +labels.dict_seunjeon_link_edit = Edit +labels.dict_seunjeon_link_delete = Delete +labels.dict_seunjeon_link_details = Details +labels.dict_seunjeon_link_download = Download +labels.dict_seunjeon_link_upload = Upload +labels.dict_seunjeon_source = Source +labels.dict_seunjeon_button_download = Download +labels.dict_seunjeon_button_upload = Upload +labels.dict_seunjeon_file = Seunjeon File labels.dict_kuromoji_configuration=Kuromoji List labels.dict_kuromoji_title=Kuromoji List labels.dict_kuromoji_list_link=List diff --git a/src/main/resources/fess_label_en.properties b/src/main/resources/fess_label_en.properties index 84ca61d82..f3100a9ad 100644 --- a/src/main/resources/fess_label_en.properties +++ b/src/main/resources/fess_label_en.properties @@ -585,7 +585,6 @@ labels.dict_seunjeon_link_details = Details labels.dict_seunjeon_link_download = Download labels.dict_seunjeon_link_upload = Upload labels.dict_seunjeon_source = Source -labels.dict_seunjeon_target = Target labels.dict_seunjeon_button_download = Download labels.dict_seunjeon_button_upload = Upload labels.dict_seunjeon_file = Seunjeon File diff --git a/src/main/resources/fess_label_ja.properties b/src/main/resources/fess_label_ja.properties index 1eecf90e7..2b64199c5 100644 --- a/src/main/resources/fess_label_ja.properties +++ b/src/main/resources/fess_label_ja.properties @@ -571,8 +571,8 @@ labels.dict_synonym_target=\u5909\u63db\u5f8c labels.dict_synonym_button_download=\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9 labels.dict_synonym_button_upload=\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9 labels.dict_synonym_file=\u540c\u7fa9\u8a9e\u30d5\u30a1\u30a4\u30eb -labels.dict_seunjeon_configuration = Seunjeon\u4e00\u89a7 -labels.dict_seunjeon_title = Seunjeon\u4e00\u89a7 +labels.dict_seunjeon_configuration = Seunjeon\u5358\u8a9e\u4e00\u89a7 +labels.dict_seunjeon_title = Seunjeon\u5358\u8a9e\u4e00\u89a7 labels.dict_seunjeon_list_link = \u4e00\u89a7 labels.dict_seunjeon_link_create = \u65b0\u898f\u4f5c\u6210 labels.dict_seunjeon_link_edit = \u7de8\u96c6 @@ -580,13 +580,12 @@ labels.dict_seunjeon_link_delete = \u524a\u9664 labels.dict_seunjeon_link_details = \u8a73\u7d30 labels.dict_seunjeon_link_download = \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9 labels.dict_seunjeon_link_upload = \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9 -labels.dict_seunjeon_source = \u5909\u63db\u5143 -labels.dict_seunjeon_target = \u5909\u63db\u5f8c +labels.dict_seunjeon_source = \u5358\u8a9e\u60c5\u5831 labels.dict_seunjeon_button_download = \u30c0\u30a6\u30f3\u30ed\u30fc\u30c9 labels.dict_seunjeon_button_upload = \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9 labels.dict_seunjeon_file = Seunjeon\u30d5\u30a1\u30a4\u30eb -labels.dict_kuromoji_configuration=Kuromoji\u4e00\u89a7 -labels.dict_kuromoji_title=Kuromoji\u4e00\u89a7 +labels.dict_kuromoji_configuration=Kuromoji\u5358\u8a9e\u4e00\u89a7 +labels.dict_kuromoji_title=Kuromoji\u5358\u8a9e\u4e00\u89a7 labels.dict_kuromoji_list_link=\u4e00\u89a7 labels.dict_kuromoji_link_create=\u65b0\u898f\u4f5c\u6210 labels.dict_kuromoji_link_edit=\u7de8\u96c6 diff --git a/src/main/resources/fess_label_ko.properties b/src/main/resources/fess_label_ko.properties index a97ee45e0..1156b2ec4 100644 --- a/src/main/resources/fess_label_ko.properties +++ b/src/main/resources/fess_label_ko.properties @@ -580,7 +580,6 @@ labels.dict_seunjeon_link_details = \uc0c1\uc138 labels.dict_seunjeon_link_download = \ub2e4\uc6b4\ub85c\ub4dc labels.dict_seunjeon_link_upload = \uc5c5\ub85c\ub4dc labels.dict_seunjeon_source = \uc6d0\ubcf8 -labels.dict_seunjeon_target = \ubcc0\ud658 \ud6c4 labels.dict_seunjeon_button_download = \ub2e4\uc6b4\ub85c\ub4dc labels.dict_seunjeon_button_upload = \uc5c5\ub85c\ub4dc labels.dict_seunjeon_file = Seunjeon \ud30c\uc77c diff --git a/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon.jsp b/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon.jsp index 8e87b7d94..a10a85ad0 100644 --- a/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon.jsp +++ b/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon.jsp @@ -85,7 +85,6 @@ - @@ -93,8 +92,7 @@ items="${seunjeonItemItems}"> - ${f:h(data.inputs)} - ${f:h(data.outputs)} + ${f:h(data.inputsValue)} diff --git a/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon_details.jsp b/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon_details.jsp index b03adc58a..796c303dc 100644 --- a/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon_details.jsp +++ b/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon_details.jsp @@ -99,11 +99,7 @@ - ${f:br(f:h(inputs))} - - - - ${f:br(f:h(outputs))} + ${f:h(inputs)} diff --git a/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon_edit.jsp b/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon_edit.jsp index 035da5385..de465bba5 100644 --- a/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon_edit.jsp +++ b/src/main/webapp/WEB-INF/view/admin/dict/seunjeon/admin_dict_seunjeon_edit.jsp @@ -96,16 +96,7 @@ key="labels.dict_seunjeon_source" />
- -
- -
- -
- -