This commit is contained in:
Shinsuke Sugaya 2013-12-27 23:51:13 +09:00
parent 22a706725d
commit e145a5e628
26 changed files with 1010 additions and 248 deletions

View file

@ -28,6 +28,9 @@ public class Constants extends CoreLibConstants {
public static final String FESS_VERSION = String.valueOf(MAJOR_VERSION)
+ "." + String.valueOf(MINOR_VERSION);
public static final String LINE_SEPARATOR = System
.getProperty("line.separator");
public static final int DEFAULT_ADMIN_PAGE_SIZE = 25;
public static final String WEB_API_VERSION = "4";
@ -36,6 +39,8 @@ public class Constants extends CoreLibConstants {
public static final String EMPTY_STRING = "";
public static final String[] EMPTY_STRINGS = new String[0];
public static final String TRUE = "true";
public static final String FALSE = "false";

View file

@ -16,18 +16,21 @@
package jp.sf.fess.action.admin;
import java.io.Serializable;
import javax.annotation.Resource;
import jp.sf.fess.dict.DictionaryFile;
import jp.sf.fess.dict.DictionaryManager;
import jp.sf.fess.form.admin.DictForm;
import jp.sf.fess.helper.SystemHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
public class DictAction {
public class DictAction implements Serializable {
private static final long serialVersionUID = 1L;
private static final Log log = LogFactory.getLog(DictAction.class);
@ -39,8 +42,15 @@ public class DictAction {
@Resource
protected DictionaryManager dictionaryManager;
@Resource
protected SystemHelper systemHelper;
public DictionaryFile[] dictFiles;
public String getHelpLink() {
return systemHelper.getHelpLink("dict");
}
@Execute(validator = false, input = "error.jsp")
public String index() {
dictFiles = dictionaryManager.getDictionaryFiles();

View file

@ -0,0 +1,361 @@
/*
* Copyright 2009-2013 the Fess 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 jp.sf.fess.action.admin.dict;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import jp.sf.fess.Constants;
import jp.sf.fess.crud.CommonConstants;
import jp.sf.fess.crud.CrudMessageException;
import jp.sf.fess.crud.util.SAStrutsUtil;
import jp.sf.fess.dict.synonym.SynonymItem;
import jp.sf.fess.form.admin.dict.SynonymForm;
import jp.sf.fess.helper.SystemHelper;
import jp.sf.fess.pager.SynonymPager;
import jp.sf.fess.service.SynonymService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.codelibs.sastruts.core.annotation.Token;
import org.seasar.framework.beans.util.Beans;
import org.seasar.framework.util.StringUtil;
import org.seasar.struts.annotation.ActionForm;
import org.seasar.struts.annotation.Execute;
import org.seasar.struts.exception.ActionMessagesException;
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 getHelpLink() {
return systemHelper.getHelpLink("dict");
}
protected String displayList(final boolean redirect) {
// page navi
synonymItemItems = synonymService.getSynonymList(synonymForm.dictId,
synonymPager);
// restore from pager
Beans.copy(synonymPager, synonymForm.searchParams)
.excludes(CommonConstants.PAGER_CONVERSION_RULE).execute();
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() {
Beans.copy(synonymForm.searchParams, synonymPager)
.excludes(CommonConstants.PAGER_CONVERSION_RULE).execute();
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 ActionMessagesException e) {
log.error(e.getMessage(), e);
throw e;
} catch (final CrudMessageException e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
} catch (final Exception e) {
log.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 SynonymItem synonymItem = createSynonym();
synonymService.store(synonymForm.dictId, synonymItem);
SAStrutsUtil.addSessionMessage("success.crud_update_crud_table");
return displayList(true);
} catch (final ActionMessagesException e) {
log.error(e.getMessage(), e);
throw e;
} catch (final CrudMessageException e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
} catch (final Exception e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(
"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 ActionMessagesException e) {
log.error(e.getMessage(), e);
throw e;
} catch (final CrudMessageException e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(e.getMessageId(), e.getArgs());
} catch (final Exception e) {
log.error(e.getMessage(), e);
throw new ActionMessagesException(
"errors.crud_failed_to_delete_crud_table");
}
}
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, Constants.EMPTY_STRINGS,
Constants.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 Constants.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;
}
}

View file

@ -1,38 +1,56 @@
package jp.sf.fess.dict;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
public abstract class DictionaryFile {
public abstract class DictionaryFile<T extends DictionaryItem> {
protected String id;
public abstract String getType();
public abstract String getName();
public abstract PagingList<DictionaryItem> selectList(int offset, int size);
public abstract PagingList<T> selectList(int offset, int size);
public abstract void insert(DictionaryItem item);
public abstract T get(long id);
public abstract void update(DictionaryItem item);
public abstract void insert(T item);
public abstract void delete(DictionaryItem item);
public abstract void update(T item);
public abstract void delete(T item);
public String getId() {
return id;
}
public void setId(final String id) {
this.id = id;
}
public static class PagingList<E> implements List<E> {
private final List<E> parent;
protected int allPageCount;
protected int allRecordCount;
protected int pageSize;
protected int currentPageNumber;
protected int pageRangeSize;
public PagingList(final List<E> list, final int offset, final int size,
final int allRecordCount) {
this.parent = list;
this.allRecordCount = allRecordCount;
pageSize = size;
currentPageNumber = offset / size + 1;
allPageCount = (allRecordCount - 1) / size + 1;
}
@Override
@ -162,5 +180,38 @@ public abstract class DictionaryFile {
return currentPageNumber;
}
public int getAllPageCount() {
return allPageCount;
}
public boolean isExistPrePage() {
return currentPageNumber != 1;
}
public boolean isExistNextPage() {
return currentPageNumber != allPageCount;
}
public void setPageRangeSize(final int pageRangeSize) {
this.pageRangeSize = pageRangeSize;
}
public List<Integer> createPageNumberList() {
int startPage = currentPageNumber - pageRangeSize;
if (startPage < 1) {
startPage = 1;
}
int endPage = currentPageNumber + pageRangeSize;
if (endPage > allPageCount) {
endPage = allPageCount;
}
final List<Integer> pageNumberList = new ArrayList<Integer>();
for (int i = startPage; i <= endPage; i++) {
pageNumberList.add(i);
}
return pageNumberList;
}
}
}

View file

@ -4,7 +4,6 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import jp.sf.fess.util.ResourceUtil;
@ -14,7 +13,7 @@ import org.apache.commons.io.filefilter.AbstractFileFilter;
public abstract class DictionaryLocator {
protected List<String> searchPathList = new ArrayList<String>();
public abstract Map<String, DictionaryFile> find();
public abstract List<DictionaryFile<? extends DictionaryItem>> find();
protected File[] findFiles(final String path, final String filenamePrefix,
final List<String> excludedSet) {

View file

@ -2,9 +2,10 @@ package jp.sf.fess.dict;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.UUID;
import jp.sf.fess.dict.synonym.SynonymFile;
@ -13,6 +14,7 @@ import org.seasar.extension.timer.TimeoutTarget;
import org.seasar.extension.timer.TimeoutTask;
import org.seasar.framework.container.annotation.tiger.DestroyMethod;
import org.seasar.framework.container.annotation.tiger.InitMethod;
import org.seasar.framework.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -20,7 +22,7 @@ public class DictionaryManager {
private static final Logger logger = LoggerFactory
.getLogger(DictionaryManager.class);
protected Map<String, DictionaryFile> dicFileMap;
protected Map<String, DictionaryFile<? extends DictionaryItem>> dicFileMap;
public long keepAlive = 5 * 60 * 1000; // 5min
@ -47,29 +49,39 @@ public class DictionaryManager {
}
}
public DictionaryFile[] getDictionaryFiles() {
final Map<String, DictionaryFile> fileMap = getDictionaryFileMap();
public DictionaryFile<? extends DictionaryItem>[] getDictionaryFiles() {
final Map<String, DictionaryFile<? extends DictionaryItem>> fileMap = getDictionaryFileMap();
final Collection<DictionaryFile> values = fileMap.values();
final Collection<DictionaryFile<? extends DictionaryItem>> values = fileMap
.values();
return values.toArray(new SynonymFile[values.size()]);
}
public DictionaryFile getDictionaryFile(final String uri) {
final Map<String, DictionaryFile> fileMap = getDictionaryFileMap();
public DictionaryFile<? extends DictionaryItem> getDictionaryFile(
final String id) {
if (StringUtil.isBlank(id)) {
return null;
}
return fileMap.get(uri);
final Map<String, DictionaryFile<? extends DictionaryItem>> fileMap = getDictionaryFileMap();
return fileMap.get(id);
}
protected Map<String, DictionaryFile> getDictionaryFileMap() {
protected Map<String, DictionaryFile<? extends DictionaryItem>> getDictionaryFileMap() {
synchronized (this) {
if (lifetime > System.currentTimeMillis() && dicFileMap != null) {
lifetime = System.currentTimeMillis() + keepAlive;
return dicFileMap;
}
final Map<String, DictionaryFile> newFileMap = new TreeMap<String, DictionaryFile>();
final Map<String, DictionaryFile<? extends DictionaryItem>> newFileMap = new HashMap<String, DictionaryFile<? extends DictionaryItem>>();
for (final DictionaryLocator locator : locatorList) {
newFileMap.putAll(locator.find());
for (final DictionaryFile<? extends DictionaryItem> dictFile : locator
.find()) {
final String id = UUID.randomUUID().toString();
dictFile.setId(id);
newFileMap.put(id, dictFile);
}
}
dicFileMap = newFileMap;
lifetime = System.currentTimeMillis() + keepAlive;

View file

@ -16,17 +16,16 @@ import java.util.List;
import jp.sf.fess.Constants;
import jp.sf.fess.dict.DictionaryException;
import jp.sf.fess.dict.DictionaryFile;
import jp.sf.fess.dict.DictionaryItem;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
public class SynonymFile extends DictionaryFile {
public class SynonymFile extends DictionaryFile<SynonymItem> {
private static final String SYNONYM = "synonym";
private final File file;
List<DictionaryItem> synonymItemList;
List<SynonymItem> synonymItemList;
public SynonymFile(final File file) {
this.file = file;
@ -43,15 +42,25 @@ public class SynonymFile extends DictionaryFile {
}
@Override
public synchronized PagingList<DictionaryItem> selectList(final int offset,
public SynonymItem get(final long id) {
for (final SynonymItem synonymItem : synonymItemList) {
if (id == synonymItem.getId()) {
return synonymItem;
}
}
return null;
}
@Override
public synchronized PagingList<SynonymItem> selectList(final int offset,
final int size) {
if (synonymItemList == null) {
reload(null);
}
if (offset >= synonymItemList.size() || offset < 0) {
return new PagingList<DictionaryItem>(
Collections.<DictionaryItem> emptyList(), offset, size,
return new PagingList<SynonymItem>(
Collections.<SynonymItem> emptyList(), offset, size,
synonymItemList.size());
}
@ -60,13 +69,13 @@ public class SynonymFile extends DictionaryFile {
toIndex = synonymItemList.size();
}
return new PagingList<DictionaryItem>(synonymItemList.subList(offset,
return new PagingList<SynonymItem>(synonymItemList.subList(offset,
toIndex), offset, size, synonymItemList.size());
}
@Override
public synchronized void insert(final DictionaryItem item) {
final SynonymItem synonymItem = (SynonymItem) item;
public synchronized void insert(final SynonymItem item) {
final SynonymItem synonymItem = item;
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new OutputStreamWriter(
@ -74,8 +83,15 @@ public class SynonymFile extends DictionaryFile {
bw.newLine();
bw.write(synonymItem.toLineString());
bw.flush();
synonymItemList.add(new SynonymItem(synonymItemList.size() + 1,
synonymItem.getInputs(), synonymItem.getOutputs()));
long nextId = 1;
if (!synonymItemList.isEmpty()) {
final SynonymItem lastItem = synonymItemList
.get(synonymItemList.size() - 1);
nextId = lastItem.getId() + 1;
}
synonymItemList.add(new SynonymItem(nextId, synonymItem
.getNewInputs(), synonymItem.getNewOutputs()));
} catch (final IOException e) {
throw new DictionaryException("Failed to write: " + item, e);
} finally {
@ -84,25 +100,25 @@ public class SynonymFile extends DictionaryFile {
}
@Override
public synchronized void update(final DictionaryItem item) {
reload(new SynonymUpdater(file, (SynonymItem) item));
public synchronized void update(final SynonymItem item) {
reload(new SynonymUpdater(file, item));
}
@Override
public synchronized void delete(final DictionaryItem item) {
final SynonymItem synonymItem = (SynonymItem) item;
public synchronized void delete(final SynonymItem item) {
final SynonymItem synonymItem = item;
synonymItem.setNewInputs(new String[0]);
synonymItem.setNewOutputs(new String[0]);
reload(new SynonymUpdater(file, synonymItem));
}
protected void reload(final SynonymUpdater updater) {
final List<DictionaryItem> itemList = new ArrayList<DictionaryItem>();
final List<SynonymItem> itemList = new ArrayList<SynonymItem>();
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(
new FileInputStream(file), Constants.UTF_8));
int id = 0;
long id = 0;
String line = null;
while ((line = reader.readLine()) != null) {
if (line.length() == 0 || line.charAt(0) == '#') {
@ -175,12 +191,12 @@ public class SynonymFile extends DictionaryFile {
if (updater != null) {
updater.commit();
}
synonymItemList = itemList;
} catch (final IOException e) {
throw new DictionaryException("Failed to parse "
+ file.getAbsolutePath(), e);
} finally {
IOUtils.closeQuietly(reader);
synonymItemList = itemList;
if (updater != null) {
updater.close();
}
@ -273,7 +289,7 @@ public class SynonymFile extends DictionaryFile {
if (!item.isDeleted()) {
// update
writer.write(item.toLineString());
writer.write(System.lineSeparator());
writer.write(Constants.LINE_SEPARATOR);
return new SynonymItem(item.getId(),
item.getNewInputs(),
item.getNewOutputs());
@ -291,7 +307,7 @@ public class SynonymFile extends DictionaryFile {
}
} else {
writer.write(oldItem.toLineString());
writer.write(System.lineSeparator());
writer.write(Constants.LINE_SEPARATOR);
return oldItem;
}
} catch (final IOException e) {
@ -303,7 +319,7 @@ public class SynonymFile extends DictionaryFile {
public void write(final String line) {
try {
writer.write(line);
writer.write(System.lineSeparator());
writer.write(Constants.LINE_SEPARATOR);
} catch (final IOException e) {
throw new DictionaryException("Failed to write: " + line, e);
}
@ -335,4 +351,5 @@ public class SynonymFile extends DictionaryFile {
}
}
}
}

View file

@ -15,9 +15,9 @@ public class SynonymItem extends DictionaryItem {
private String[] newOutputs;
private final int id;
private final long id;
public SynonymItem(final int id, final String[] inputs,
public SynonymItem(final long id, final String[] inputs,
final String[] outputs) {
this.id = id;
this.inputs = inputs;
@ -26,9 +26,15 @@ public class SynonymItem extends DictionaryItem {
if (inputs != outputs) {
Arrays.sort(outputs);
}
if (id == 0) {
// create
newInputs = inputs;
newOutputs = outputs;
}
}
public int getId() {
public long getId() {
return id;
}

View file

@ -1,11 +1,11 @@
package jp.sf.fess.dict.synonym;
import java.io.File;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import jp.sf.fess.dict.DictionaryFile;
import jp.sf.fess.dict.DictionaryItem;
import jp.sf.fess.dict.DictionaryLocator;
import org.slf4j.Logger;
@ -20,8 +20,8 @@ public class SynonymLocator extends DictionaryLocator {
public List<String> excludedSynonymList;
@Override
public Map<String, DictionaryFile> find() {
final Map<String, DictionaryFile> fileMap = new HashMap<String, DictionaryFile>();
public List<DictionaryFile<? extends DictionaryItem>> find() {
final List<DictionaryFile<? extends DictionaryItem>> fileList = new ArrayList<DictionaryFile<? extends DictionaryItem>>();
for (final String path : searchPathList) {
final File[] files = findFiles(path, synonymFilePrefix,
excludedSynonymList);
@ -29,10 +29,10 @@ public class SynonymLocator extends DictionaryLocator {
if (logger.isInfoEnabled()) {
logger.info("Synonym File: " + file.getAbsolutePath());
}
fileMap.put(file.getAbsolutePath(), new SynonymFile(file));
fileList.add(new SynonymFile(file));
}
}
return fileMap;
return fileList;
}
}

View file

@ -0,0 +1,43 @@
package jp.sf.fess.form.admin.dict;
import java.util.HashMap;
import java.util.Map;
import org.seasar.struts.annotation.IntegerType;
import org.seasar.struts.annotation.LongType;
import org.seasar.struts.annotation.Maxbytelength;
import org.seasar.struts.annotation.Required;
public class SynonymForm {
@IntegerType
public String pageNumber;
public Map<String, String> searchParams = new HashMap<String, String>();
@Required
public String dictId;
@IntegerType
public int crudMode;
public String getCurrentPageNumber() {
return pageNumber;
}
@Required(target = "confirmfromupdate,update,delete")
@LongType
public String id;
@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
@Maxbytelength(maxbytelength = 1000)
public String inputs;
@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
@Maxbytelength(maxbytelength = 1000)
public String outputs;
public void initialize() {
id = null;
}
}

View file

@ -0,0 +1,118 @@
/*
* Copyright 2009-2013 the Fess 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 jp.sf.fess.pager;
import java.io.Serializable;
import java.util.List;
public class SynonymPager implements Serializable {
private static final long serialVersionUID = 1L;
private int allRecordCount;
private int allPageCount;
private boolean existPrePage;
private boolean existNextPage;
private List<Integer> pageNumberList;
private int pageSize;
private int currentPageNumber;
public String id;
public void clear() {
pageSize = getDefaultPageSize();
currentPageNumber = getDefaultCurrentPageNumber();
id = null;
}
protected int getDefaultPageSize() {
return 20;
}
protected int getDefaultCurrentPageNumber() {
return 1;
}
public int getAllRecordCount() {
return allRecordCount;
}
public void setAllRecordCount(final int allRecordCount) {
this.allRecordCount = allRecordCount;
}
public int getAllPageCount() {
return allPageCount;
}
public void setAllPageCount(final int allPageCount) {
this.allPageCount = allPageCount;
}
public boolean isExistPrePage() {
return existPrePage;
}
public void setExistPrePage(final boolean existPrePage) {
this.existPrePage = existPrePage;
}
public boolean isExistNextPage() {
return existNextPage;
}
public void setExistNextPage(final boolean existNextPage) {
this.existNextPage = existNextPage;
}
public int getPageSize() {
if (pageSize <= 0) {
pageSize = getDefaultPageSize();
}
return pageSize;
}
public void setPageSize(final int pageSize) {
this.pageSize = pageSize;
}
public int getCurrentPageNumber() {
if (currentPageNumber <= 0) {
currentPageNumber = getDefaultCurrentPageNumber();
}
return currentPageNumber;
}
public void setCurrentPageNumber(final int currentPageNumber) {
this.currentPageNumber = currentPageNumber;
}
public List<Integer> getPageNumberList() {
return pageNumberList;
}
public void setPageNumberList(final List<Integer> pageNumberList) {
this.pageNumberList = pageNumberList;
}
}

View file

@ -0,0 +1,82 @@
package jp.sf.fess.service;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import jp.sf.fess.crud.CommonConstants;
import jp.sf.fess.dict.DictionaryFile;
import jp.sf.fess.dict.DictionaryFile.PagingList;
import jp.sf.fess.dict.DictionaryManager;
import jp.sf.fess.dict.synonym.SynonymFile;
import jp.sf.fess.dict.synonym.SynonymItem;
import jp.sf.fess.pager.SynonymPager;
import org.seasar.framework.beans.util.Beans;
import org.seasar.framework.util.StringUtil;
import org.seasar.struts.exception.ActionMessagesException;
public class SynonymService {
@Resource
protected DictionaryManager dictionaryManager;
public List<SynonymItem> getSynonymList(final String dictId,
final SynonymPager synonymPager) {
final SynonymFile synonymFile = getSynonymFile(dictId);
final int pageSize = synonymPager.getPageSize();
final PagingList<SynonymItem> synonymList = synonymFile.selectList(
(synonymPager.getCurrentPageNumber() - 1) * pageSize, pageSize);
// update pager
Beans.copy(synonymList, synonymPager)
.includes(CommonConstants.PAGER_CONVERSION_RULE).execute();
synonymList.setPageRangeSize(5);
synonymPager.setPageNumberList(synonymList.createPageNumberList());
return synonymList;
}
protected SynonymFile getSynonymFile(final String dictId) {
final DictionaryFile<?> dictionaryFile = dictionaryManager
.getDictionaryFile(dictId);
if (dictionaryFile instanceof SynonymFile) {
return (SynonymFile) dictionaryFile;
}
throw new ActionMessagesException("errors.expired_dict_id");
}
public SynonymItem getSynonym(final String dictId,
final Map<String, String> paramMap) {
final SynonymFile synonymFile = getSynonymFile(dictId);
final String idStr = paramMap.get("id");
if (StringUtil.isNotBlank(idStr)) {
try {
final long id = Long.parseLong(idStr);
return synonymFile.get(id);
} catch (final NumberFormatException e) {
// ignore
}
}
return null;
}
public void store(final String dictId, final SynonymItem synonymItem) {
final SynonymFile synonymFile = getSynonymFile(dictId);
if (synonymItem.getId() == 0) {
synonymFile.insert(synonymItem);
} else {
synonymFile.update(synonymItem);
}
}
public void delete(final String dictId, final SynonymItem synonymItem) {
final SynonymFile synonymFile = getSynonymFile(dictId);
synonymFile.delete(synonymItem);
}
}

View file

@ -71,6 +71,7 @@ errors.document_not_found=Not found URL of Doc ID:{0}
errors.not_load_from_server=Could not load from this server: {0}
errors.failed_to_start_job=Failed to start job {0}.
errors.failed_to_stop_job=Failed to stop job {0}.
errors.expired_dict_id=Expired dictionary information. Please reload it.
errors.invalid_query_unknown=The given query is invalid.
errors.invalid_query_quoted=An invalid quote character is used.
@ -1334,7 +1335,29 @@ labels.dict_list_title=Dictionary List
labels.dict_list_link=Dictionaries
labels.dictionary_name=Name
labels.dictionary_type=Type
labels.dict_link_details=Details
labels.dict_link_edit=Edit
labels.dict_link_delete=Delete
labels.dict_link_prev_page=Prev
labels.dict_link_next_page=Next
labels.dict_button_back=Back
# synonym
labels.dict_synonym_configuration=Synonym List
labels.dict_synonym_title=Synonym List
labels.dict_synonym_list_link=List
labels.dict_synonym_link_create=Create
labels.dict_synonym_link_update=Update
labels.dict_synonym_link_delete=Delete
labels.dict_synonym_link_confirm=Confirm
labels.dict_synonym_source=Source
labels.dict_synonym_target=Target
labels.dict_synonym_button_create=Create
labels.dict_synonym_button_back=Back
labels.dict_synonym_button_confirm=Confirm
labels.dict_synonym_button_edit=Edit
labels.dict_synonym_button_delete=Delete
labels.dict_synonym_button_update=Update
# CRUD PROPERTIES: BEGIN
errors.crud_invalid_mode=Invalid mode(expected value is {0}, but it's {1}).
@ -1361,7 +1384,7 @@ labels.crud_link_delete=Delete
labels.crud_link_back=Back
labels.crud_link_edit=Edit
labels.crud_link_next_page=Next
labels.crud_link_prev_page=Back
labels.crud_link_prev_page=Prev
labels.crud_title_details=Details
labels.crud_title_confirm=Confirmation

View file

@ -71,6 +71,7 @@ errors.document_not_found=ID:{0}\u306eURL\u304c\u898b\u3064\u304b\u308a\u307e\u3
errors.not_load_from_server=\u3053\u306e\u30b5\u30fc\u30d0\u304b\u3089\u30ed\u30fc\u30c9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f: {0}
errors.failed_to_start_job=\u30b8\u30e7\u30d6 {0} \u306e\u958b\u59cb\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002
errors.failed_to_stop_job=\u30b8\u30e7\u30d6 {0} \u306e\u958b\u59cb\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002
errors.expired_dict_id=\u8f9e\u66f8\u60c5\u5831\u304c\u671f\u9650\u5207\u308c\u3067\u3059\u3002\u518d\u5ea6\u8aad\u307f\u306a\u304a\u3057\u3066\u304f\u3060\u3055\u3044\u3002
errors.invalid_query_unknown=\u691c\u7d22\u30af\u30a8\u30ea\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002
errors.invalid_query_quoted=\u30af\u30aa\u30fc\u30c8\u6587\u5b57(")\u306e\u5229\u7528\u65b9\u6cd5\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002
@ -1326,6 +1327,36 @@ labels.joblog_target=\u5bfe\u8c61
labels.joblog_title_confirm=\u78ba\u8a8d
labels.joblog_title_details=\u8a73\u7d30
# dict
labels.dict_configuration=\u8f9e\u66f8\u4e00\u89a7
labels.dict_list_title=\u8f9e\u66f8\u4e00\u89a7
labels.dict_list_link=\u8f9e\u66f8\u4e00\u89a7
labels.dictionary_name=\u540d\u524d
labels.dictionary_type=\u7a2e\u985e
labels.dict_link_details=\u8a73\u7d30
labels.dict_link_edit=\u7de8\u96c6
labels.dict_link_delete=\u524a\u9664
labels.dict_link_prev_page=\u524d\u3078
labels.dict_link_next_page=\u6b21\u3078
labels.dict_button_back=\u623b\u308b
# synonym
labels.dict_synonym_configuration=\u540c\u7fa9\u8a9e\u4e00\u89a7
labels.dict_synonym_title=\u540c\u7fa9\u8a9e\u4e00\u89a7
labels.dict_synonym_list_link=\u4e00\u89a7
labels.dict_synonym_link_create=\u4f5c\u6210
labels.dict_synonym_link_update=\u66f4\u65b0
labels.dict_synonym_link_delete=\u524a\u9664
labels.dict_synonym_link_confirm=\u78ba\u8a8d
labels.dict_synonym_source=\u5909\u63db\u5143
labels.dict_synonym_target=\u5909\u63db\u5f8c
labels.dict_synonym_button_create=\u4f5c\u6210
labels.dict_synonym_button_back=\u623b\u308b
labels.dict_synonym_button_confirm=\u78ba\u8a8d
labels.dict_synonym_button_edit=\u7de8\u96c6
labels.dict_synonym_button_delete=\u524a\u9664
labels.dict_synonym_button_update=\u66f4\u65b0
# CRUD PROPERTIES: BEGIN
errors.crud_invalid_mode=\u30e2\u30fc\u30c9\u304c\u9055\u3044\u307e\u3059\u3002(\u6b63\u3057\u3044\u5024\u306f {0} \u3067\u3059\u304c\u3001\u5165\u529b\u3055\u308c\u305f\u5024\u306f {1} \u306b\u306a\u3063\u3066\u3044\u307e\u3059)
errors.crud_failed_to_create_crud_table=\u30c7\u30fc\u30bf\u306e\u4f5c\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002

View file

@ -1,5 +1,5 @@
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp" flush="true">
<tiles:put name="title"><bean:message key="labels.supported_browser_configuration" /></tiles:put>
<tiles:put name="title"><bean:message key="labels.dict_configuration" /></tiles:put>
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
<tiles:put name="menu" value="/WEB-INF/view/common/admin/menu.jsp" />

View file

@ -51,7 +51,7 @@
<c:forEach var="data" varStatus="s" items="${dictFiles}">
<tr class="${s.index % 2 == 0 ? 'row1' : 'row2'}">
<td>${f:h(data.type)}</td>
<td>${f:h(data.name)}</td>
<td><s:link href="${f:h(data.type)}/index?dictId=${f:h(data.id)}">${f:h(data.name)}</s:link></td>
</tr>
</c:forEach>
</tbody>

View file

@ -1,7 +1,7 @@
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp"
flush="true">
<tiles:put name="title">
<bean:message key="labels.supported_browser_configuration" />
<bean:message key="labels.dict_synonym_configuration" />
</tiles:put>
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
@ -11,7 +11,7 @@
<tiles:put name="body" type="string">
<h3>
<bean:message key="labels.dict_title_confirm" />
<bean:message key="labels.dict_synonym_title" />
</h3>
<%-- Message: BEGIN --%>
@ -25,24 +25,27 @@
<div>
<ul class="pills">
<li><s:link href="index">
<bean:message key="labels.dict_link_list" />
<li><s:link href="../index">
<bean:message key="labels.dict_list_link" />
</s:link></li>
<li><s:link href="index?dictId=${f:u(dictId)}">
<bean:message key="labels.dict_synonym_list_link" />
</s:link></li>
<c:if test="${crudMode == 1}">
<li class="active"><a href="#"><bean:message
key="labels.dict_link_create" /></a></li>
key="labels.dict_synonym_link_create" /></a></li>
</c:if>
<c:if test="${crudMode == 2}">
<li class="active"><a href="#"><bean:message
key="labels.dict_link_update" /></a></li>
key="labels.dict_synonym_link_update" /></a></li>
</c:if>
<c:if test="${crudMode == 3}">
<li class="active"><a href="#"><bean:message
key="labels.dict_link_delete" /></a></li>
key="labels.dict_synonym_link_delete" /></a></li>
</c:if>
<c:if test="${crudMode == 4}">
<li class="active"><a href="#"><bean:message
key="labels.dict_link_confirm" /></a></li>
key="labels.dict_synonym_link_confirm" /></a></li>
</c:if>
</ul>
</div>
@ -51,51 +54,46 @@
<s:form>
<html:hidden property="crudMode" />
<div>
<html:hidden property="dictId" />
<c:if test="${crudMode==2 || crudMode==3 || crudMode==4}">
<html:hidden property="id" />
<html:hidden property="versionNo" />
</c:if>
<html:hidden property="createdBy" />
<html:hidden property="createdTime" />
<html:hidden property="sortOrder" />
<table class="bordered-table zebra-striped" style="width: 500px;">
<tbody>
<tr>
<th style="width: 150px;"><bean:message
key="labels.dict_name" /></th>
<td>${f:h(name)}<html:hidden property="name" /></td>
key="labels.dict_synonym_source" /></th>
<td>${f:br(f:h(inputs))}<html:hidden property="inputs" /></td>
</tr>
<tr>
<th><bean:message key="labels.dict_value" /></th>
<td>${f:h(value)}<html:hidden property="value" /></td>
<th><bean:message key="labels.dict_synonym_target" /></th>
<td>${f:br(f:h(outputs))}<html:hidden property="outputs" /></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2"><c:if test="${crudMode == 1}">
<input type="submit" class="btn mini" name="create"
value="<bean:message key="labels.dict_button_create"/>" />
value="<bean:message key="labels.dict_synonym_button_create"/>" />
<input type="submit" class="btn mini" name="editagain"
value="<bean:message key="labels.dict_button_back"/>" />
value="<bean:message key="labels.dict_synonym_button_back"/>" />
</c:if> <c:if test="${crudMode == 2}">
<input type="submit" class="btn mini" name="update"
value="<bean:message key="labels.dict_button_update"/>" />
value="<bean:message key="labels.dict_synonym_button_update"/>" />
<input type="submit" class="btn mini" name="editagain"
value="<bean:message key="labels.dict_button_back"/>" />
value="<bean:message key="labels.dict_synonym_button_back"/>" />
</c:if> <c:if test="${crudMode == 3}">
<input type="submit" class="btn mini" name="delete"
value="<bean:message key="labels.dict_button_delete"/>" />
value="<bean:message key="labels.dict_synonym_button_delete"/>" />
<input type="submit" class="btn mini" name="back"
value="<bean:message key="labels.dict_button_back"/>" />
value="<bean:message key="labels.dict_synonym_button_back"/>" />
</c:if> <c:if test="${crudMode == 4}">
<input type="submit" class="btn mini" name="back"
value="<bean:message key="labels.dict_button_back"/>" />
value="<bean:message key="labels.dict_synonym_button_back"/>" />
<input type="submit" class="btn mini" name="editfromconfirm"
value="<bean:message key="labels.dict_button_edit"/>" />
value="<bean:message key="labels.dict_synonym_button_edit"/>" />
<input type="submit" class="btn mini" name="deletefromconfirm"
value="<bean:message key="labels.dict_button_delete"/>" />
value="<bean:message key="labels.dict_synonym_button_delete"/>" />
</c:if></td>
</tr>
</tfoot>

View file

@ -1,7 +1,7 @@
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp"
flush="true">
<tiles:put name="title">
<bean:message key="labels.supported_browser_configuration" />
<bean:message key="labels.dict_synonym_configuration" />
</tiles:put>
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
@ -11,7 +11,7 @@
<tiles:put name="body" type="string">
<h3>
<bean:message key="labels.dict_title_details" />
<bean:message key="labels.dict_synonym_title" />
</h3>
<%-- Message: BEGIN --%>
@ -25,24 +25,27 @@
<div>
<ul class="pills">
<li><s:link href="index">
<bean:message key="labels.dict_link_list" />
<li><s:link href="../index">
<bean:message key="labels.dict_list_link" />
</s:link></li>
<li><s:link href="index?dictId=${f:u(dictId)}">
<bean:message key="labels.dict_synonym_list_link" />
</s:link></li>
<c:if test="${crudMode == 1}">
<li class="active"><a href="#"><bean:message
key="labels.dict_link_create" /></a></li>
key="labels.dict_synonym_link_create" /></a></li>
</c:if>
<c:if test="${crudMode == 2}">
<li class="active"><a href="#"><bean:message
key="labels.dict_link_update" /></a></li>
key="labels.dict_synonym_link_update" /></a></li>
</c:if>
<c:if test="${crudMode == 3}">
<li class="active"><a href="#"><bean:message
key="labels.dict_link_delete" /></a></li>
key="labels.dict_synonym_link_delete" /></a></li>
</c:if>
<c:if test="${crudMode == 4}">
<li class="active"><a href="#"><bean:message
key="labels.dict_link_confirm" /></a></li>
key="labels.dict_synonym_link_confirm" /></a></li>
</c:if>
</ul>
</div>
@ -51,39 +54,35 @@
<s:form>
<html:hidden property="crudMode" />
<div>
<html:hidden property="dictId" />
<c:if test="${crudMode==2}">
<html:hidden property="id" />
<html:hidden property="versionNo" />
</c:if>
<html:hidden property="createdBy" />
<html:hidden property="createdTime" />
<html:hidden property="sortOrder" />
<table class="bordered-table zebra-striped" style="width: 500px;">
<tbody>
<tr>
<th style="width: 150px;"><bean:message
key="labels.dict_name" /></th>
<td><html:text property="name" style="width:98%;" /></td>
key="labels.dict_synonym_source" /></th>
<td><html:textarea property="inputs" rows="5" style="width:98%;" /></td>
</tr>
<tr>
<th><bean:message key="labels.dict_value" /></th>
<td><html:text property="value" style="width:98%;" /></td>
<th><bean:message
key="labels.dict_synonym_target" /></th>
<td><html:textarea property="outputs" rows="5" style="width:98%;" /></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2"><c:if test="${crudMode == 1}">
<input type="submit" class="btn mini" name="confirmfromcreate"
value="<bean:message key="labels.dict_button_create"/>" />
value="<bean:message key="labels.dict_synonym_button_create"/>" />
<input type="submit" class="btn mini" name="back"
value="<bean:message key="labels.dict_button_back"/>" />
value="<bean:message key="labels.dict_synonym_button_back"/>" />
</c:if> <c:if test="${crudMode == 2}">
<input type="submit" class="btn mini" name="confirmfromupdate"
value="<bean:message key="labels.dict_button_confirm"/>" />
value="<bean:message key="labels.dict_synonym_button_confirm"/>" />
<input type="submit" class="btn mini" name="back"
value="<bean:message key="labels.dict_button_back"/>" />
value="<bean:message key="labels.dict_synonym_button_back"/>" />
</c:if></td>
</tr>
</tfoot>

View file

@ -0,0 +1,19 @@
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp" flush="true">
<tiles:put name="title"><bean:message key="labels.dict_synonym_configuration" /></tiles:put>
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
<tiles:put name="menu" value="/WEB-INF/view/common/admin/menu.jsp" />
<tiles:put name="menuType" value="dict" />
<tiles:put name="headerScript" type="string"></tiles:put>
<tiles:put name="body" type="string">
<div id="main">
<html:errors/>
<br/>
<s:link href="../index"><bean:message key="labels.dict_button_back"/></s:link>
</div>
</tiles:put>
</tiles:insert>

View file

@ -1,7 +1,7 @@
<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><tiles:insert template="/WEB-INF/view/common/admin/layout.jsp"
flush="true">
<tiles:put name="title">
<bean:message key="labels.supported_browser_configuration" />
<bean:message key="labels.dict_synonym_configuration" />
</tiles:put>
<tiles:put name="header" value="/WEB-INF/view/common/admin/header.jsp" />
<tiles:put name="footer" value="/WEB-INF/view/common/admin/footer.jsp" />
@ -11,7 +11,7 @@
<tiles:put name="body" type="string">
<h3>
<bean:message key="labels.dict_title_details" />
<bean:message key="labels.dict_synonym_title" />
</h3>
<%-- Message: BEGIN --%>
@ -27,41 +27,44 @@
<div class="list-table">
<div>
<ul class="pills">
<li><s:link href="../index">
<bean:message key="labels.dict_list_link" />
</s:link></li>
<li class="active"><a href="#"><bean:message
key="labels.dict_link_list" /></a></li>
<li><s:link href="createpage">
<bean:message key="labels.dict_link_create_new" />
key="labels.dict_synonym_list_link" /></a></li>
<li><s:link href="createpage?dictId=${f:u(dictId)}">
<bean:message key="labels.dict_synonym_link_create" />
</s:link></li>
</ul>
</div>
<c:if test="${dictPager.allRecordCount == 0}">
<c:if test="${synonymPager.allRecordCount == 0}">
<p class="alert-message warning">
<bean:message key="labels.list_could_not_find_crud_table" />
</p>
</c:if>
<c:if test="${dictPager.allRecordCount > 0}">
<c:if test="${synonymPager.allRecordCount > 0}">
<table class="bordered-table zebra-striped">
<thead>
<tr>
<th style="text-align: center;"><bean:message
key="labels.dict_name" /></th>
key="labels.dict_synonym_source" /></th>
<th style="text-align: center;"><bean:message
key="labels.dict_synonym_target" /></th>
<th style="text-align: center; width: 200px;">&nbsp;</th>
</tr>
</thead>
<tbody>
<c:forEach var="data" varStatus="s" items="${dictItems}">
<c:forEach var="data" varStatus="s" items="${synonymItemItems}">
<tr class="${s.index % 2 == 0 ? 'row1' : 'row2'}">
<td>${f:h(data.name)}</td>
<td>${f:h(data.inputs)}</td>
<td>${f:h(data.outputs)}</td>
<td style="text-align: center;"><s:link
href="confirmpage/4/${f:u(data.id)}">
href="confirmpage/${f:u(dictId)}/4/${f:u(data.id)}">
<bean:message key="labels.dict_link_details" />
</s:link> <s:link href="editpage/2/${f:u(data.id)}">
</s:link> <s:link href="editpage/${f:u(dictId)}/2/${f:u(data.id)}">
<bean:message key="labels.dict_link_edit" />
</s:link> <s:link href="deletepage/3/${f:u(data.id)}">
</s:link> <s:link href="deletepage/${f:u(dictId)}/3/${f:u(data.id)}">
<bean:message key="labels.dict_link_delete" />
</s:link></td>
</tr>
@ -72,30 +75,30 @@
<div class="row center">
<div class="pagination">
<ul>
<c:if test="${dictPager.existPrePage}">
<c:if test="${synonymPager.existPrePage}">
<li class="prev"><s:link
href="list/${dictPager.currentPageNumber - 1}">
href="list/${f:u(dictId)}/${synonymPager.currentPageNumber - 1}">
<bean:message key="labels.dict_link_prev_page" />
</s:link></li>
</c:if>
<c:if test="${!dictPager.existPrePage}">
<c:if test="${!synonymPager.existPrePage}">
<li class="prev disabled"><a href="#"><bean:message
key="labels.dict_link_prev_page" /></a></li>
</c:if>
<c:forEach var="p" varStatus="s"
items="${dictPager.pageNumberList}">
items="${synonymPager.pageNumberList}">
<li
<c:if test="${p == dictPager.currentPageNumber}">class="active"</c:if>>
<s:link href="list/${p}">${p}</s:link>
<c:if test="${p == synonymPager.currentPageNumber}">class="active"</c:if>>
<s:link href="list/${f:u(dictId)}/${p}">${p}</s:link>
</li>
</c:forEach>
<c:if test="${dictPager.existNextPage}">
<c:if test="${synonymPager.existNextPage}">
<li class="next disabled"><s:link
href="list/${dictPager.currentPageNumber + 1}">
href="list/${f:u(dictId)}/${synonymPager.currentPageNumber + 1}">
<bean:message key="labels.dict_link_next_page" />
</s:link></li>
</c:if>
<c:if test="${!dictPager.existNextPage}">
<c:if test="${!synonymPager.existNextPage}">
<li class="next disabled"><a href="#"><bean:message
key="labels.dict_link_next_page" /></a></li>
</c:if>
@ -104,9 +107,9 @@
<div>
<span><bean:message key="labels.pagination_page_guide_msg"
arg0="${f:h(dictPager.currentPageNumber)}"
arg1="${f:h(dictPager.allPageCount)}"
arg2="${f:h(dictPager.allRecordCount)}" /></span>
arg0="${f:h(synonymPager.currentPageNumber)}"
arg1="${f:h(synonymPager.allPageCount)}"
arg2="${f:h(synonymPager.allRecordCount)}" /></span>
</div>
</div>
<%-- Page Navigation: END --%>

View file

@ -16,7 +16,7 @@
<bean:message key="labels.header.help" />
</s:link></li>
</c:if>
<li><s:link href="../logout">
<li><s:link href="${contextPath}/admin/logout">
<bean:message key="labels.menu.logout" />
</s:link></li>
</ul>

View file

@ -8,7 +8,7 @@
<c:if test="${menuType=='wizard'}">
<span class="selected">
</c:if>
<s:link href="../wizard/index">
<s:link href="${contextPath}/admin/wizard/index">
<bean:message key="labels.menu.wizard" />
</s:link>
<c:if test="${menuType=='wizard'}">
@ -18,7 +18,7 @@
<c:if test="${menuType=='crawl'}">
<span class="selected">
</c:if>
<s:link href="../crawl/index">
<s:link href="${contextPath}/admin/crawl/index">
<bean:message key="labels.menu.crawl_config" />
</s:link>
<c:if test="${menuType=='crawl'}">
@ -28,7 +28,7 @@
<c:if test="${menuType=='system'}">
<span class="selected">
</c:if>
<s:link href="../system/index">
<s:link href="${contextPath}/admin/system/index">
<bean:message key="labels.menu.system_config" />
</s:link>
<c:if test="${menuType=='system'}">
@ -38,7 +38,7 @@
<c:if test="${menuType=='document'}">
<span class="selected">
</c:if>
<s:link href="../document/index">
<s:link href="${contextPath}/admin/document/index">
<bean:message key="labels.menu.document_config" />
</s:link>
<c:if test="${menuType=='document'}">
@ -48,7 +48,7 @@
<c:if test="${menuType=='scheduledJob'}">
<span class="selected">
</c:if>
<s:link href="../scheduledJob/index">
<s:link href="${contextPath}/admin/scheduledJob/index">
<bean:message key="labels.menu.scheduled_job_config" />
</s:link>
<c:if test="${menuType=='scheduledJob'}">
@ -58,7 +58,7 @@
<c:if test="${menuType=='design'}">
<span class="selected">
</c:if>
<s:link href="../design/index">
<s:link href="${contextPath}/admin/design/index">
<bean:message key="labels.menu.design" />
</s:link>
<c:if test="${menuType=='design'}">
@ -68,7 +68,7 @@
<c:if test="${menuType=='dict'}">
<span class="selected">
</c:if>
<s:link href="../dict/index">
<s:link href="${contextPath}/admin/dict/index">
<bean:message key="labels.menu.dict" />
</s:link>
<c:if test="${menuType=='dict'}">
@ -78,7 +78,7 @@
<c:if test="${menuType=='data'}">
<span class="selected">
</c:if>
<s:link href="../data/index">
<s:link href="${contextPath}/admin/data/index">
<bean:message key="labels.menu.data" />
</s:link>
<c:if test="${menuType=='data'}">
@ -93,7 +93,7 @@
<c:if test="${menuType=='webCrawlingConfig'}">
<span class="selected">
</c:if>
<s:link href="../webCrawlingConfig/index">
<s:link href="${contextPath}/admin/webCrawlingConfig/index">
<bean:message key="labels.menu.web" />
</s:link>
<c:if test="${menuType=='webCrawlingConfig'}">
@ -103,7 +103,7 @@
<c:if test="${menuType=='fileCrawlingConfig'}">
<span class="selected">
</c:if>
<s:link href="../fileCrawlingConfig/index">
<s:link href="${contextPath}/admin/fileCrawlingConfig/index">
<bean:message key="labels.menu.file_system" />
</s:link>
<c:if test="${menuType=='fileCrawlingConfig'}">
@ -113,7 +113,7 @@
<c:if test="${menuType=='dataCrawlingConfig'}">
<span class="selected">
</c:if>
<s:link href="../dataCrawlingConfig/index">
<s:link href="${contextPath}/admin/dataCrawlingConfig/index">
<bean:message key="labels.menu.data_store" />
</s:link>
<c:if test="${menuType=='dataCrawlingConfig'}">
@ -123,7 +123,7 @@
<c:if test="${menuType=='labelType'}">
<span class="selected">
</c:if>
<s:link href="../labelType/index">
<s:link href="${contextPath}/admin/labelType/index">
<bean:message key="labels.menu.label_type" />
</s:link>
<c:if test="${menuType=='labelType'}">
@ -133,7 +133,7 @@
<c:if test="${menuType=='pathMapping'}">
<span class="selected">
</c:if>
<s:link href="../pathMapping/index">
<s:link href="${contextPath}/admin/pathMapping/index">
<bean:message key="labels.menu.path_mapping" />
</s:link>
<c:if test="${menuType=='pathMapping'}">
@ -143,7 +143,7 @@
<c:if test="${menuType=='webAuthentication'}">
<span class="selected">
</c:if>
<s:link href="../webAuthentication/index">
<s:link href="${contextPath}/admin/webAuthentication/index">
<bean:message key="labels.menu.web_authentication" />
</s:link>
<c:if test="${menuType=='webAuthentication'}">
@ -153,7 +153,7 @@
<c:if test="${menuType=='fileAuthentication'}">
<span class="selected">
</c:if>
<s:link href="../fileAuthentication/index">
<s:link href="${contextPath}/admin/fileAuthentication/index">
<bean:message key="labels.menu.file_authentication" />
</s:link>
<c:if test="${menuType=='fileAuthentication'}">
@ -163,7 +163,7 @@
<c:if test="${menuType=='requestHeader'}">
<span class="selected">
</c:if>
<s:link href="../requestHeader/index">
<s:link href="${contextPath}/admin/requestHeader/index">
<bean:message key="labels.menu.request_header" />
</s:link>
<c:if test="${menuType=='requestHeader'}">
@ -173,7 +173,7 @@
<c:if test="${menuType=='overlappingHost'}">
<span class="selected">
</c:if>
<s:link href="../overlappingHost/index">
<s:link href="${contextPath}/admin/overlappingHost/index">
<bean:message key="labels.menu.overlapping_host" />
</s:link>
<c:if test="${menuType=='overlappingHost'}">
@ -183,7 +183,7 @@
<c:if test="${menuType=='roleType'}">
<span class="selected">
</c:if>
<s:link href="../roleType/index">
<s:link href="${contextPath}/admin/roleType/index">
<bean:message key="labels.menu.role_type" />
</s:link>
<c:if test="${menuType=='roleType'}">
@ -193,7 +193,7 @@
<c:if test="${menuType=='browserType'}">
<span class="selected">
</c:if>
<s:link href="../browserType/index">
<s:link href="${contextPath}/admin/browserType/index">
<bean:message key="labels.menu.supported_browser" />
</s:link>
<c:if test="${menuType=='browserType'}">
@ -208,7 +208,7 @@
<c:if test="${menuType=='systemInfo'}">
<span class="selected">
</c:if>
<s:link href="../systemInfo/index">
<s:link href="${contextPath}/admin/systemInfo/index">
<bean:message key="labels.menu.system_info" />
</s:link>
<c:if test="${menuType=='systemInfo'}">
@ -218,7 +218,7 @@
<c:if test="${menuType=='jobLog'}">
<span class="selected">
</c:if>
<s:link href="../jobLog/index">
<s:link href="${contextPath}/admin/jobLog/index">
<bean:message key="labels.menu.jobLog" />
</s:link>
<c:if test="${menuType=='jobLog'}">
@ -228,7 +228,7 @@
<c:if test="${menuType=='crawlingSession'}">
<span class="selected">
</c:if>
<s:link href="../crawlingSession/index">
<s:link href="${contextPath}/admin/crawlingSession/index">
<bean:message key="labels.menu.session_info" />
</s:link>
<c:if test="${menuType=='crawlingSession'}">
@ -238,7 +238,7 @@
<c:if test="${menuType=='log'}">
<span class="selected">
</c:if>
<s:link href="../log/index">
<s:link href="${contextPath}/admin/log/index">
<bean:message key="labels.menu.log" />
</s:link>
<c:if test="${menuType=='log'}">
@ -248,7 +248,7 @@
<c:if test="${menuType=='failureUrl'}">
<span class="selected">
</c:if>
<s:link href="../failureUrl/index">
<s:link href="${contextPath}/admin/failureUrl/index">
<bean:message key="labels.menu.failure_url" />
</s:link>
<c:if test="${menuType=='failureUrl'}">
@ -258,7 +258,7 @@
<c:if test="${menuType=='searchList'}">
<span class="selected">
</c:if>
<s:link href="../searchList/index">
<s:link href="${contextPath}/admin/searchList/index">
<bean:message key="labels.menu.search_list" />
</s:link>
<c:if test="${menuType=='searchList'}">
@ -273,7 +273,7 @@
<c:if test="${menuType=='searchLog'}">
<span class="selected">
</c:if>
<s:link href="../searchLog/index">
<s:link href="${contextPath}/admin/searchLog/index">
<bean:message key="labels.menu.search_log" />
</s:link>
<c:if test="${menuType=='searchLog'}">
@ -283,7 +283,7 @@
<c:if test="${menuType=='stats'}">
<span class="selected">
</c:if>
<s:link href="../stats/index">
<s:link href="${contextPath}/admin/stats/index">
<bean:message key="labels.menu.stats" />
</s:link>
<c:if test="${menuType=='stats'}">
@ -293,7 +293,7 @@
<c:if test="${menuType=='userInfo'}">
<span class="selected">
</c:if>
<s:link href="../userInfo/index">
<s:link href="${contextPath}/admin/userInfo/index">
<bean:message key="labels.menu.user" />
</s:link>
<c:if test="${menuType=='userInfo'}">
@ -303,7 +303,7 @@
<c:if test="${menuType=='favoriteLog'}">
<span class="selected">
</c:if>
<s:link href="../favoriteLog/index">
<s:link href="${contextPath}/admin/favoriteLog/index">
<bean:message key="labels.menu.favoriteLog" />
</s:link>
<c:if test="${menuType=='favoriteLog'}">

View file

@ -8,4 +8,5 @@
--%><%@taglib prefix="s" uri="http://sastruts.seasar.org" %><%--
--%><%@taglib prefix="f" uri="http://sastruts.seasar.org/functions" %><%--
--%><%@taglib prefix="m" uri="http://taglibs.mobylet.org/" %><%--
--%><%@taglib prefix="fe" uri="http://fess.codelibs.org/functions" %>
--%><%@taglib prefix="fe" uri="http://fess.codelibs.org/functions" %><%--
--%><c:set var="contextPath" value="${request.contextPath}"/>

View file

@ -20,8 +20,6 @@ import java.io.File;
import java.util.ArrayList;
import jp.sf.fess.Constants;
import jp.sf.fess.dict.DictionaryFile;
import jp.sf.fess.dict.DictionaryManager;
import jp.sf.fess.dict.synonym.SynonymLocator;
import org.apache.commons.io.FileUtils;
@ -59,7 +57,7 @@ public class DictionaryManagerTest extends S2TestCase {
synonymLocator.addSearchPath(testDir.getAbsolutePath());
dictionaryManager.addLocator(synonymLocator);
dictionaryManager.init();
final DictionaryFile[] synonymFiles = dictionaryManager
final DictionaryFile<? extends DictionaryItem>[] synonymFiles = dictionaryManager
.getDictionaryFiles();
assertEquals(1, synonymFiles.length);
@ -67,7 +65,7 @@ public class DictionaryManagerTest extends S2TestCase {
Thread.sleep(2000);
assertNull(dictionaryManager.dicFileMap);
final DictionaryFile[] synonymFiles2 = dictionaryManager
final DictionaryFile<? extends DictionaryItem>[] synonymFiles2 = dictionaryManager
.getDictionaryFiles();
assertEquals(1, synonymFiles2.length);

View file

@ -19,10 +19,7 @@ package jp.sf.fess.dict.synonym;
import java.io.File;
import jp.sf.fess.Constants;
import jp.sf.fess.dict.DictionaryItem;
import jp.sf.fess.dict.DictionaryFile.PagingList;
import jp.sf.fess.dict.synonym.SynonymFile;
import jp.sf.fess.dict.synonym.SynonymItem;
import org.seasar.extension.unit.S2TestCase;
import org.seasar.framework.util.FileUtil;
@ -46,15 +43,13 @@ public class SynonymFileTest extends S2TestCase {
public void test_selectList() {
final SynonymFile synonymFile = new SynonymFile(file1);
final PagingList<DictionaryItem> itemList1 = synonymFile.selectList(0,
20);
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
assertEquals(5, itemList1.size());
assertEquals(5, itemList1.getAllRecordCount());
assertEquals(1, itemList1.getCurrentPageNumber());
assertEquals(20, itemList1.getPageSize());
final PagingList<DictionaryItem> itemList2 = synonymFile.selectList(4,
2);
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(4, 2);
assertEquals(1, itemList2.size());
assertEquals(5, itemList2.getAllRecordCount());
assertEquals(3, itemList2.getCurrentPageNumber());
@ -66,90 +61,84 @@ public class SynonymFileTest extends S2TestCase {
public void test_selectList2() {
final SynonymFile synonymFile = new SynonymFile(file1);
final PagingList<DictionaryItem> itemList = synonymFile
.selectList(0, 5);
assertEquals(1, ((SynonymItem) itemList.get(0)).getInputs().length);
assertEquals(1, ((SynonymItem) itemList.get(0)).getOutputs().length);
assertEquals("a1", ((SynonymItem) itemList.get(0)).getInputs()[0]);
assertEquals("A1", ((SynonymItem) itemList.get(0)).getOutputs()[0]);
assertFalse(((SynonymItem) itemList.get(0)).isUpdated());
final PagingList<SynonymItem> itemList = synonymFile.selectList(0, 5);
assertEquals(1, itemList.get(0).getInputs().length);
assertEquals(1, itemList.get(0).getOutputs().length);
assertEquals("a1", itemList.get(0).getInputs()[0]);
assertEquals("A1", itemList.get(0).getOutputs()[0]);
assertFalse(itemList.get(0).isUpdated());
assertEquals(2, ((SynonymItem) itemList.get(1)).getInputs().length);
assertEquals(1, ((SynonymItem) itemList.get(1)).getOutputs().length);
assertEquals("b1", ((SynonymItem) itemList.get(1)).getInputs()[0]);
assertEquals("b2", ((SynonymItem) itemList.get(1)).getInputs()[1]);
assertEquals("B1", ((SynonymItem) itemList.get(1)).getOutputs()[0]);
assertFalse(((SynonymItem) itemList.get(1)).isUpdated());
assertEquals(2, itemList.get(1).getInputs().length);
assertEquals(1, itemList.get(1).getOutputs().length);
assertEquals("b1", itemList.get(1).getInputs()[0]);
assertEquals("b2", itemList.get(1).getInputs()[1]);
assertEquals("B1", itemList.get(1).getOutputs()[0]);
assertFalse(itemList.get(1).isUpdated());
assertEquals(1, ((SynonymItem) itemList.get(2)).getInputs().length);
assertEquals(2, ((SynonymItem) itemList.get(2)).getOutputs().length);
assertEquals("c1", ((SynonymItem) itemList.get(2)).getInputs()[0]);
assertEquals("C1", ((SynonymItem) itemList.get(2)).getOutputs()[0]);
assertEquals("C2", ((SynonymItem) itemList.get(2)).getOutputs()[1]);
assertFalse(((SynonymItem) itemList.get(2)).isUpdated());
assertEquals(1, itemList.get(2).getInputs().length);
assertEquals(2, itemList.get(2).getOutputs().length);
assertEquals("c1", itemList.get(2).getInputs()[0]);
assertEquals("C1", itemList.get(2).getOutputs()[0]);
assertEquals("C2", itemList.get(2).getOutputs()[1]);
assertFalse(itemList.get(2).isUpdated());
assertEquals(2, ((SynonymItem) itemList.get(3)).getInputs().length);
assertEquals(2, ((SynonymItem) itemList.get(3)).getOutputs().length);
assertEquals("X1", ((SynonymItem) itemList.get(3)).getInputs()[0]);
assertEquals("x1", ((SynonymItem) itemList.get(3)).getInputs()[1]);
assertEquals("X1", ((SynonymItem) itemList.get(3)).getOutputs()[0]);
assertEquals("x1", ((SynonymItem) itemList.get(3)).getOutputs()[1]);
assertFalse(((SynonymItem) itemList.get(3)).isUpdated());
assertEquals(2, itemList.get(3).getInputs().length);
assertEquals(2, itemList.get(3).getOutputs().length);
assertEquals("X1", itemList.get(3).getInputs()[0]);
assertEquals("x1", itemList.get(3).getInputs()[1]);
assertEquals("X1", itemList.get(3).getOutputs()[0]);
assertEquals("x1", itemList.get(3).getOutputs()[1]);
assertFalse(itemList.get(3).isUpdated());
assertEquals(3, ((SynonymItem) itemList.get(4)).getInputs().length);
assertEquals(3, ((SynonymItem) itemList.get(4)).getOutputs().length);
assertEquals("Y1", ((SynonymItem) itemList.get(4)).getInputs()[0]);
assertEquals("y1", ((SynonymItem) itemList.get(4)).getInputs()[1]);
assertEquals("y2", ((SynonymItem) itemList.get(4)).getInputs()[2]);
assertEquals("Y1", ((SynonymItem) itemList.get(4)).getOutputs()[0]);
assertEquals("y1", ((SynonymItem) itemList.get(4)).getOutputs()[1]);
assertEquals("y2", ((SynonymItem) itemList.get(4)).getOutputs()[2]);
assertFalse(((SynonymItem) itemList.get(4)).isUpdated());
assertEquals(3, itemList.get(4).getInputs().length);
assertEquals(3, itemList.get(4).getOutputs().length);
assertEquals("Y1", itemList.get(4).getInputs()[0]);
assertEquals("y1", itemList.get(4).getInputs()[1]);
assertEquals("y2", itemList.get(4).getInputs()[2]);
assertEquals("Y1", itemList.get(4).getOutputs()[0]);
assertEquals("y1", itemList.get(4).getOutputs()[1]);
assertEquals("y2", itemList.get(4).getOutputs()[2]);
assertFalse(itemList.get(4).isUpdated());
}
public void test_insert() {
final SynonymFile synonymFile = new SynonymFile(file1);
final PagingList<DictionaryItem> itemList1 = synonymFile.selectList(0,
20);
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
assertEquals(5, itemList1.size());
final SynonymItem synonymItem1 = new SynonymItem(0, new String[] {
"z1", "z2" }, new String[] { "Z1", "Z2" });
synonymFile.insert(synonymItem1);
final PagingList<DictionaryItem> itemList2 = synonymFile.selectList(0,
20);
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
assertEquals(6, itemList2.size());
assertEquals("z1", ((SynonymItem) itemList2.get(5)).getInputs()[0]);
assertEquals("z2", ((SynonymItem) itemList2.get(5)).getInputs()[1]);
assertEquals("Z1", ((SynonymItem) itemList2.get(5)).getOutputs()[0]);
assertEquals("Z2", ((SynonymItem) itemList2.get(5)).getOutputs()[1]);
assertEquals("z1", itemList2.get(5).getInputs()[0]);
assertEquals("z2", itemList2.get(5).getInputs()[1]);
assertEquals("Z1", itemList2.get(5).getOutputs()[0]);
assertEquals("Z2", itemList2.get(5).getOutputs()[1]);
final SynonymItem synonymItem2 = new SynonymItem(0, new String[] {
"z1", "z2" }, new String[] { "z1", "z2" });
synonymFile.insert(synonymItem2);
final PagingList<DictionaryItem> itemList3 = synonymFile.selectList(0,
20);
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
assertEquals(7, itemList3.size());
assertEquals("z1", ((SynonymItem) itemList3.get(6)).getInputs()[0]);
assertEquals("z2", ((SynonymItem) itemList3.get(6)).getInputs()[1]);
assertEquals("z1", ((SynonymItem) itemList3.get(6)).getOutputs()[0]);
assertEquals("z2", ((SynonymItem) itemList3.get(6)).getOutputs()[1]);
assertEquals("z1", itemList3.get(6).getInputs()[0]);
assertEquals("z2", itemList3.get(6).getInputs()[1]);
assertEquals("z1", itemList3.get(6).getOutputs()[0]);
assertEquals("z2", itemList3.get(6).getOutputs()[1]);
}
public void test_update() {
final SynonymFile synonymFile = new SynonymFile(file1);
final PagingList<DictionaryItem> itemList1 = synonymFile.selectList(0,
20);
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
assertEquals(5, itemList1.size());
final SynonymItem synonymItem1 = (SynonymItem) itemList1.get(0);
final SynonymItem synonymItem1 = itemList1.get(0);
synonymItem1.setNewInputs(new String[] { "a1", "a2" });
synonymItem1.setNewOutputs(new String[] { "A1", "A2" });
synonymFile.update(synonymItem1);
final PagingList<DictionaryItem> itemList2 = synonymFile.selectList(0,
20);
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
assertEquals(5, itemList2.size());
final SynonymItem synonymItem2 = (SynonymItem) itemList2.get(0);
final SynonymItem synonymItem2 = itemList2.get(0);
assertEquals(2, synonymItem2.getInputs().length);
assertEquals(2, synonymItem2.getOutputs().length);
assertEquals("a1", synonymItem2.getInputs()[0]);
@ -158,14 +147,13 @@ public class SynonymFileTest extends S2TestCase {
assertEquals("A2", synonymItem2.getOutputs()[1]);
assertFalse(synonymItem2.isUpdated());
final SynonymItem synonymItem3 = (SynonymItem) itemList2.get(2);
final SynonymItem synonymItem3 = itemList2.get(2);
synonymItem3.setNewInputs(new String[] { "c1", "c2" });
synonymItem3.setNewOutputs(new String[] { "c1", "c2" });
synonymFile.update(synonymItem3);
final PagingList<DictionaryItem> itemList3 = synonymFile.selectList(0,
20);
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
assertEquals(5, itemList3.size());
final SynonymItem synonymItem4 = (SynonymItem) itemList3.get(2);
final SynonymItem synonymItem4 = itemList3.get(2);
assertEquals(2, synonymItem4.getInputs().length);
assertEquals(2, synonymItem4.getOutputs().length);
assertEquals("c1", synonymItem4.getInputs()[0]);
@ -177,24 +165,23 @@ public class SynonymFileTest extends S2TestCase {
public void test_delete() throws Exception {
final SynonymFile synonymFile = new SynonymFile(file1);
final PagingList<DictionaryItem> itemList1 = synonymFile.selectList(0,
20);
final PagingList<SynonymItem> itemList1 = synonymFile.selectList(0, 20);
assertEquals(5, itemList1.size());
final SynonymItem synonymItem1 = (SynonymItem) itemList1.get(0);
final SynonymItem synonymItem1 = itemList1.get(0);
synonymFile.delete(synonymItem1);
final PagingList<DictionaryItem> itemList2 = synonymFile.selectList(0,
20);
final PagingList<SynonymItem> itemList2 = synonymFile.selectList(0, 20);
assertEquals(4, itemList2.size());
final SynonymItem synonymItem2 = (SynonymItem) itemList2.get(3);
final SynonymItem synonymItem2 = itemList2.get(3);
synonymFile.delete(synonymItem2);
final PagingList<DictionaryItem> itemList3 = synonymFile.selectList(0,
20);
final PagingList<SynonymItem> itemList3 = synonymFile.selectList(0, 20);
assertEquals(3, itemList3.size());
assertEquals("b1,b2=>B1" + System.lineSeparator() + "c1=>C1,C2"
+ System.lineSeparator() + "X1,x1" + System.lineSeparator(),
assertEquals(
"b1,b2=>B1" + Constants.LINE_SEPARATOR + "c1=>C1,C2"
+ Constants.LINE_SEPARATOR + "X1,x1"
+ Constants.LINE_SEPARATOR,
new String(FileUtil.getBytes(file1), Constants.UTF_8));
}

View file

@ -18,11 +18,11 @@ package jp.sf.fess.dict.synonym;
import java.io.File;
import java.util.ArrayList;
import java.util.Map;
import java.util.List;
import jp.sf.fess.Constants;
import jp.sf.fess.dict.DictionaryFile;
import jp.sf.fess.dict.synonym.SynonymLocator;
import jp.sf.fess.dict.DictionaryItem;
import org.apache.commons.io.FileUtils;
import org.seasar.extension.unit.S2TestCase;
@ -83,12 +83,11 @@ public class SynonymLocatorTest extends S2TestCase {
synonymLocator.excludedSynonymList = new ArrayList<String>();
synonymLocator.excludedSynonymList.add("data");
synonymLocator.addSearchPath(testDir.getAbsolutePath());
final Map<String, DictionaryFile> fileMap = synonymLocator.find();
assertEquals(2, fileMap.size());
final DictionaryFile dicFile1 = fileMap.get(synonymFile1
.getAbsolutePath());
final DictionaryFile dicFile2 = fileMap.get(synonymFile3
.getAbsolutePath());
final List<DictionaryFile<? extends DictionaryItem>> list = synonymLocator
.find();
assertEquals(2, list.size());
final DictionaryFile<? extends DictionaryItem> dicFile1 = list.get(0);
final DictionaryFile<? extends DictionaryItem> dicFile2 = list.get(1);
assertEquals(synonymFile1.getAbsolutePath(), dicFile1.getName());
assertEquals(synonymFile3.getAbsolutePath(), dicFile2.getName());
}