#279 modify KeyMatch
This commit is contained in:
parent
7fce51f081
commit
c180c80fa5
5 changed files with 43 additions and 35 deletions
|
@ -8,4 +8,20 @@ import org.codelibs.fess.es.bsentity.BsKeyMatch;
|
|||
public class KeyMatch extends BsKeyMatch {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public String getId() {
|
||||
return asDocMeta().id();
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
asDocMeta().id(id);
|
||||
}
|
||||
|
||||
public Long getVersionNo() {
|
||||
return asDocMeta().version();
|
||||
}
|
||||
|
||||
public void setVersionNo(Long version) {
|
||||
asDocMeta().version(version);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Map;
|
|||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.fess.client.FessEsClient;
|
||||
import org.codelibs.fess.client.FessEsClient.SearchConditionBuilder;
|
||||
import org.codelibs.fess.db.exentity.KeyMatch;
|
||||
import org.codelibs.fess.es.exentity.KeyMatch;
|
||||
import org.codelibs.fess.service.KeyMatchService;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.seasar.framework.container.SingletonS2Container;
|
||||
|
@ -80,10 +80,11 @@ public class KeyMatchHelper {
|
|||
final FessEsClient fessEsClient = ComponentUtil.getElasticsearchClient();
|
||||
final FieldHelper fieldHelper = ComponentUtil.getFieldHelper();
|
||||
final List<Map<String, Object>> documentList =
|
||||
fessEsClient.getDocumentList(fieldHelper.docIndex, fieldHelper.docType, searchRequestBuilder -> {
|
||||
return SearchConditionBuilder.builder(searchRequestBuilder).administrativeAccess().size(keyMatch.getMaxSize())
|
||||
.responseFields(new String[] { fieldHelper.docIdField }).build();
|
||||
});
|
||||
fessEsClient.getDocumentList(fieldHelper.docIndex, fieldHelper.docType,
|
||||
searchRequestBuilder -> {
|
||||
return SearchConditionBuilder.builder(searchRequestBuilder).administrativeAccess().size(keyMatch.getMaxSize())
|
||||
.query(keyMatch.getQuery()).responseFields(new String[] { fieldHelper.docIdField }).build();
|
||||
});
|
||||
return documentList;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ import javax.annotation.Resource;
|
|||
|
||||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.db.cbean.KeyMatchCB;
|
||||
import org.codelibs.fess.db.exbhv.KeyMatchBhv;
|
||||
import org.codelibs.fess.db.exentity.KeyMatch;
|
||||
import org.codelibs.fess.es.cbean.KeyMatchCB;
|
||||
import org.codelibs.fess.es.exbhv.KeyMatchBhv;
|
||||
import org.codelibs.fess.es.exentity.KeyMatch;
|
||||
import org.codelibs.fess.pager.KeyMatchPager;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.seasar.framework.beans.util.Beans;
|
||||
|
@ -60,7 +60,7 @@ public class KeyMatchService implements Serializable {
|
|||
|
||||
public KeyMatch getKeyMatch(final Map<String, String> keys) {
|
||||
final KeyMatch keyMatch = keyMatchBhv.selectEntity(cb -> {
|
||||
cb.query().setId_Equal(Long.parseLong(keys.get("id")));
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
if (keyMatch == null) {
|
||||
|
@ -74,25 +74,28 @@ public class KeyMatchService implements Serializable {
|
|||
public void store(final KeyMatch keyMatch) throws CrudMessageException {
|
||||
setupStoreCondition(keyMatch);
|
||||
|
||||
keyMatchBhv.insertOrUpdate(keyMatch);
|
||||
keyMatchBhv.insertOrUpdate(keyMatch, op -> {
|
||||
op.setRefresh(true);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void delete(final KeyMatch keyMatch) throws CrudMessageException {
|
||||
setupDeleteCondition(keyMatch);
|
||||
|
||||
keyMatchBhv.delete(keyMatch);
|
||||
keyMatchBhv.delete(keyMatch, op -> {
|
||||
op.setRefresh(true);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void setupListCondition(final KeyMatchCB cb, final KeyMatchPager keyMatchPager) {
|
||||
if (keyMatchPager.id != null) {
|
||||
cb.query().setId_Equal(Long.parseLong(keyMatchPager.id));
|
||||
cb.query().docMeta().setId_Equal(keyMatchPager.id);
|
||||
}
|
||||
// TODO Long, Integer, String supported only.
|
||||
|
||||
// setup condition
|
||||
cb.query().setDeletedBy_IsNull();
|
||||
cb.query().addOrderBy_Term_Asc();
|
||||
|
||||
// search
|
||||
|
@ -119,7 +122,7 @@ public class KeyMatchService implements Serializable {
|
|||
|
||||
public List<KeyMatch> getAvailableKeyMatchList() {
|
||||
return keyMatchBhv.selectList(cb -> {
|
||||
cb.query().setDeletedBy_IsNull();
|
||||
cb.query().matchAll();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.codelibs.fess.beans.FessBeans;
|
|||
import org.codelibs.fess.crud.CommonConstants;
|
||||
import org.codelibs.fess.crud.CrudMessageException;
|
||||
import org.codelibs.fess.crud.util.SAStrutsUtil;
|
||||
import org.codelibs.fess.db.exentity.KeyMatch;
|
||||
import org.codelibs.fess.es.exentity.KeyMatch;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.pager.KeyMatchPager;
|
||||
import org.codelibs.fess.service.KeyMatchService;
|
||||
|
@ -235,7 +235,7 @@ public class KeyMatchAction extends FessAdminAction {
|
|||
protected KeyMatch createKeyMatch() {
|
||||
KeyMatch keyMatch;
|
||||
final String username = systemHelper.getUsername();
|
||||
final LocalDateTime currentTime = systemHelper.getCurrentTime();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (keyMatchForm.crudMode == CommonConstants.EDIT_MODE) {
|
||||
keyMatch = keyMatchService.getKeyMatch(createKeyMap());
|
||||
if (keyMatch == null) {
|
||||
|
@ -313,12 +313,7 @@ public class KeyMatchAction extends FessAdminAction {
|
|||
throw new SSCActionMessagesException("errors.crud_could_not_find_crud_table", new Object[] { keyMatchForm.id });
|
||||
}
|
||||
|
||||
// keyMatchService.delete(keyMatch);
|
||||
final String username = systemHelper.getUsername();
|
||||
final LocalDateTime currentTime = systemHelper.getCurrentTime();
|
||||
keyMatch.setDeletedBy(username);
|
||||
keyMatch.setDeletedTime(currentTime);
|
||||
keyMatchService.store(keyMatch);
|
||||
keyMatchService.delete(keyMatch);
|
||||
SAStrutsUtil.addSessionMessage("success.crud_delete_crud_table");
|
||||
|
||||
ComponentUtil.getKeyMatchHelper().update();
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.seasar.struts.annotation.DateType;
|
||||
import org.seasar.struts.annotation.IntRange;
|
||||
import org.seasar.struts.annotation.IntegerType;
|
||||
|
@ -45,7 +46,7 @@ public class KeyMatchForm implements Serializable {
|
|||
}
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@LongType
|
||||
@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
|
@ -69,21 +70,15 @@ public class KeyMatchForm implements Serializable {
|
|||
public String createdBy;
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@DateType(datePattern = Constants.DEFAULT_DATETIME_FORMAT)
|
||||
@LongType
|
||||
public String createdTime;
|
||||
|
||||
@Maxbytelength(maxbytelength = 255)
|
||||
public String updatedBy;
|
||||
|
||||
@DateType(datePattern = Constants.DEFAULT_DATETIME_FORMAT)
|
||||
@LongType
|
||||
public String updatedTime;
|
||||
|
||||
@Maxbytelength(maxbytelength = 255)
|
||||
public String deletedBy;
|
||||
|
||||
@DateType(datePattern = Constants.DEFAULT_DATETIME_FORMAT)
|
||||
public String deletedTime;
|
||||
|
||||
@Required(target = "confirmfromupdate,update,delete")
|
||||
@IntegerType
|
||||
public String versionNo;
|
||||
|
@ -94,12 +89,10 @@ public class KeyMatchForm implements Serializable {
|
|||
query = null;
|
||||
maxSize = null;
|
||||
boost = null;
|
||||
createdBy = null;
|
||||
createdTime = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
deletedBy = null;
|
||||
deletedTime = null;
|
||||
versionNo = null;
|
||||
maxSize = "10";
|
||||
boost = "100.0";
|
||||
|
|
Loading…
Add table
Reference in a new issue