commit
b9cd5fe4c8
35 changed files with 1313 additions and 953 deletions
|
@ -28,6 +28,7 @@ import org.codelibs.fess.es.user.cbean.GroupCB;
|
|||
import org.codelibs.fess.es.user.exbhv.GroupBhv;
|
||||
import org.codelibs.fess.es.user.exentity.Group;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
public class GroupService implements Serializable {
|
||||
|
||||
|
@ -52,17 +53,8 @@ public class GroupService implements Serializable {
|
|||
return groupList;
|
||||
}
|
||||
|
||||
public Group getGroup(final Map<String, String> keys) {
|
||||
final Group group = groupBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
if (group == null) {
|
||||
// TODO exception?
|
||||
return null;
|
||||
}
|
||||
|
||||
return group;
|
||||
public OptionalEntity<Group> getGroup(final String id) {
|
||||
return groupBhv.selectByPK(id);
|
||||
}
|
||||
|
||||
public void store(final Group group) {
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.codelibs.fess.es.user.cbean.RoleCB;
|
|||
import org.codelibs.fess.es.user.exbhv.RoleBhv;
|
||||
import org.codelibs.fess.es.user.exentity.Role;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
public class RoleService implements Serializable {
|
||||
|
||||
|
@ -52,17 +53,8 @@ public class RoleService implements Serializable {
|
|||
return roleList;
|
||||
}
|
||||
|
||||
public Role getRole(final Map<String, String> keys) {
|
||||
final Role role = roleBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
if (role == null) {
|
||||
// TODO exception?
|
||||
return null;
|
||||
}
|
||||
|
||||
return role;
|
||||
public OptionalEntity<Role> getRole(final String id) {
|
||||
return roleBhv.selectByPK(id);
|
||||
}
|
||||
|
||||
public void store(final Role role) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.codelibs.fess.es.config.exbhv.ScheduledJobBhv;
|
|||
import org.codelibs.fess.es.config.exentity.ScheduledJob;
|
||||
import org.codelibs.fess.job.JobScheduler;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
public class ScheduledJobService implements Serializable {
|
||||
|
||||
|
@ -57,17 +58,8 @@ public class ScheduledJobService implements Serializable {
|
|||
return scheduledJobList;
|
||||
}
|
||||
|
||||
public ScheduledJob getScheduledJob(final Map<String, String> keys) {
|
||||
final ScheduledJob scheduledJob = scheduledJobBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
if (scheduledJob == null) {
|
||||
// TODO exception?
|
||||
return null;
|
||||
}
|
||||
|
||||
return scheduledJob;
|
||||
public OptionalEntity<ScheduledJob> getScheduledJob(final String id) {
|
||||
return scheduledJobBhv.selectByPK(id);
|
||||
}
|
||||
|
||||
public void delete(final ScheduledJob scheduledJob) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.codelibs.fess.es.config.exentity.SuggestBadWord;
|
|||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.dbflute.bhv.readable.EntityRowHandler;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
import com.orangesignal.csv.CsvConfig;
|
||||
import com.orangesignal.csv.CsvReader;
|
||||
|
@ -73,17 +74,8 @@ public class SuggestBadWordService implements Serializable {
|
|||
return suggestBadWordList;
|
||||
}
|
||||
|
||||
public SuggestBadWord getSuggestBadWord(final Map<String, String> keys) {
|
||||
final SuggestBadWord suggestBadWord = suggestBadWordBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
if (suggestBadWord == null) {
|
||||
// TODO exception?
|
||||
return null;
|
||||
}
|
||||
|
||||
return suggestBadWord;
|
||||
public OptionalEntity<SuggestBadWord> getSuggestBadWord(final String id) {
|
||||
return suggestBadWordBhv.selectByPK(id);
|
||||
}
|
||||
|
||||
public void store(final SuggestBadWord suggestBadWord) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.codelibs.fess.es.config.exentity.SuggestElevateWord;
|
|||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.dbflute.bhv.readable.EntityRowHandler;
|
||||
import org.dbflute.cbean.result.PagingResultBean;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
|
||||
import com.orangesignal.csv.CsvConfig;
|
||||
import com.orangesignal.csv.CsvReader;
|
||||
|
@ -71,17 +72,8 @@ public class SuggestElevateWordService implements Serializable {
|
|||
return suggestElevateWordList;
|
||||
}
|
||||
|
||||
public SuggestElevateWord getSuggestElevateWord(final Map<String, String> keys) {
|
||||
final SuggestElevateWord suggestElevateWord = suggestElevateWordBhv.selectEntity(cb -> {
|
||||
cb.query().docMeta().setId_Equal(keys.get("id"));
|
||||
setupEntityCondition(cb, keys);
|
||||
}).orElse(null);//TODO
|
||||
if (suggestElevateWord == null) {
|
||||
// TODO exception?
|
||||
return null;
|
||||
}
|
||||
|
||||
return suggestElevateWord;
|
||||
public OptionalEntity<SuggestElevateWord> getSuggestElevateWord(final String id) {
|
||||
return suggestElevateWordBhv.selectByPK(id);
|
||||
}
|
||||
|
||||
public void store(final SuggestElevateWord suggestElevateWord) {
|
||||
|
|
|
@ -56,10 +56,8 @@ public class CreateForm implements Serializable {
|
|||
public String handlerScript;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public Integer boost;
|
||||
// @FloatType
|
||||
public float boost;
|
||||
|
||||
@Required
|
||||
@Size(max = 5)
|
||||
|
@ -81,7 +79,7 @@ public class CreateForm implements Serializable {
|
|||
|
||||
public void initialize() {
|
||||
crudMode = CrudMode.CREATE;
|
||||
boost = 1;
|
||||
boost = 1.0f;
|
||||
sortOrder = 0;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
|
|
|
@ -90,10 +90,8 @@ public class CreateForm implements Serializable {
|
|||
public Integer intervalTime;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public Integer boost;
|
||||
// @FloatType
|
||||
public float boost;
|
||||
|
||||
@Required
|
||||
@Size(max = 5)
|
||||
|
@ -115,7 +113,7 @@ public class CreateForm implements Serializable {
|
|||
|
||||
public void initialize() {
|
||||
crudMode = CrudMode.CREATE;
|
||||
boost = 1;
|
||||
boost = 1.0f;
|
||||
numOfThread = Constants.DEFAULT_NUM_OF_THREAD_FOR_FS;
|
||||
intervalTime = Constants.DEFAULT_INTERVAL_TIME_FOR_FS;
|
||||
sortOrder = 0;
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
package org.codelibs.fess.app.web.admin.group;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
@ -28,6 +26,7 @@ import org.codelibs.fess.app.web.CrudMode;
|
|||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.user.exentity.Group;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -37,6 +36,7 @@ import org.lastaflute.web.validation.VaErrorHook;
|
|||
|
||||
/**
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminGroupAction extends FessAdminAction {
|
||||
|
||||
|
@ -63,14 +63,14 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final GroupSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminGroup_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final GroupSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
groupPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminGroup_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -78,15 +78,15 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final GroupSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, groupPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, groupPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminGroup_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final GroupSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
groupPager.clear();
|
||||
return asHtml(path_AdminGroup_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -94,17 +94,17 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final GroupSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminGroup_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final GroupSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("groupItems", groupService.getGroupList(groupPager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(groupPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(groupPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -114,46 +114,86 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse createpage(final GroupEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
public HtmlResponse createpage() {
|
||||
return asHtml(path_AdminGroup_EditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.EDIT);
|
||||
return asHtml(path_AdminGroup_EditJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
groupService.getGroup(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse createagain(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminGroup_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final GroupEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
loadGroup(form);
|
||||
public HtmlResponse editagain(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminGroup_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editagain(final GroupEditForm form) {
|
||||
return asHtml(path_AdminGroup_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editfromconfirm(final GroupEditForm form) {
|
||||
public HtmlResponse editfromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
loadGroup(form);
|
||||
final String id = form.id;
|
||||
groupService.getGroup(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminGroup_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final GroupEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadGroup(form);
|
||||
return asHtml(path_AdminGroup_ConfirmJsp);
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminGroup_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
groupService.getGroup(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletefromconfirm(final GroupEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadGroup(form);
|
||||
final String id = form.id;
|
||||
groupService.getGroup(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminGroup_ConfirmJsp);
|
||||
}
|
||||
|
||||
|
@ -161,23 +201,33 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final GroupEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadGroup(form);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminGroup_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
groupService.getGroup(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminGroup_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final GroupEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminGroup_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromupdate(final GroupEditForm form) {
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminGroup_ConfirmJsp);
|
||||
}
|
||||
|
||||
|
@ -185,69 +235,80 @@ public class AdminGroupAction extends FessAdminAction {
|
|||
// Actually Crud
|
||||
// -------------
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse create(final GroupEditForm form) {
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
groupService.store(createGroup(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
createGroup(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
entity.setId(Base64.getEncoder().encodeToString(entity.getName().getBytes(Constants.CHARSET_UTF_8)));
|
||||
groupService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse update(final GroupEditForm form) {
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
groupService.store(createGroup(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
createGroup(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
entity.setId(Base64.getEncoder().encodeToString(entity.getName().getBytes(Constants.CHARSET_UTF_8)));
|
||||
groupService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final GroupEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
groupService.delete(getGroup(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
final String id = form.id;
|
||||
groupService.getGroup(id).ifPresent(entity -> {
|
||||
groupService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadGroup(final GroupEditForm form) {
|
||||
copyBeanToBean(getGroup(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected Group getGroup(final GroupEditForm form) {
|
||||
final Group group = groupService.getGroup(createKeyMap(form));
|
||||
if (group == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
protected OptionalEntity<Group> createGroup(final CreateForm form) {
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
if (form instanceof CreateForm) {
|
||||
final Group entity = new Group();
|
||||
return OptionalEntity.of(entity);
|
||||
}
|
||||
break;
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
return groupService.getGroup(((EditForm) form).id).map(entity -> {
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return group;
|
||||
}
|
||||
|
||||
protected Group createGroup(final GroupEditForm form) {
|
||||
Group group;
|
||||
if (form.crudMode == CrudMode.EDIT) {
|
||||
group = getGroup(form);
|
||||
} else {
|
||||
group = new Group();
|
||||
}
|
||||
copyBeanToBean(form, group, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
group.setId(Base64.getEncoder().encodeToString(group.getName().getBytes(Constants.CHARSET_UTF_8)));
|
||||
return group;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final GroupEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final GroupEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.group;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class CreateForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public int crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 100)
|
||||
public String name;
|
||||
|
||||
public void initialize() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.group;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
@Size(max = 1000)
|
||||
public String updatedBy;
|
||||
|
||||
@Digits(integer = 19, fraction = 0)
|
||||
public Long updatedTime;
|
||||
|
||||
@Required
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -16,15 +16,13 @@
|
|||
package org.codelibs.fess.app.web.admin.group;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class GroupSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
public String id;
|
||||
}
|
|
@ -47,10 +47,12 @@ public class CreateForm implements Serializable {
|
|||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
public String maxSize;
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public Integer maxSize;
|
||||
|
||||
@Required
|
||||
public String boost;
|
||||
// @FloatType
|
||||
public float boost;
|
||||
|
||||
@Required
|
||||
@Size(max = 255)
|
||||
|
@ -62,8 +64,8 @@ public class CreateForm implements Serializable {
|
|||
|
||||
public void initialize() {
|
||||
crudMode = CrudMode.CREATE;
|
||||
maxSize = "10";
|
||||
boost = "100.0";
|
||||
maxSize = 10;
|
||||
boost = 100.0f;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
package org.codelibs.fess.app.web.admin.role;
|
||||
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
@ -28,6 +26,7 @@ import org.codelibs.fess.app.web.CrudMode;
|
|||
import org.codelibs.fess.app.web.base.FessAdminAction;
|
||||
import org.codelibs.fess.es.user.exentity.Role;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -37,6 +36,7 @@ import org.lastaflute.web.validation.VaErrorHook;
|
|||
|
||||
/**
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminRoleAction extends FessAdminAction {
|
||||
|
||||
|
@ -63,14 +63,14 @@ public class AdminRoleAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final RoleSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminRole_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final RoleSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
rolePager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminRole_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -78,15 +78,15 @@ public class AdminRoleAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final RoleSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, rolePager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, rolePager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminRole_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final RoleSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
rolePager.clear();
|
||||
return asHtml(path_AdminRole_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -94,17 +94,17 @@ public class AdminRoleAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final RoleSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminRole_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final RoleSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("roleItems", roleService.getRoleList(rolePager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(rolePager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(rolePager, form, op -> op.include("id"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -114,46 +114,86 @@ public class AdminRoleAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse createpage(final RoleEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
public HtmlResponse createpage() {
|
||||
return asHtml(path_AdminRole_EditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.EDIT);
|
||||
return asHtml(path_AdminRole_EditJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
roleService.getRole(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse createagain(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminRole_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final RoleEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
loadRole(form);
|
||||
public HtmlResponse editagain(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminRole_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editagain(final RoleEditForm form) {
|
||||
return asHtml(path_AdminRole_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editfromconfirm(final RoleEditForm form) {
|
||||
public HtmlResponse editfromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
loadRole(form);
|
||||
final String id = form.id;
|
||||
roleService.getRole(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminRole_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final RoleEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadRole(form);
|
||||
return asHtml(path_AdminRole_ConfirmJsp);
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminRole_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
roleService.getRole(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletefromconfirm(final RoleEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadRole(form);
|
||||
final String id = form.id;
|
||||
roleService.getRole(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminRole_ConfirmJsp);
|
||||
}
|
||||
|
||||
|
@ -161,23 +201,33 @@ public class AdminRoleAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final RoleEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadRole(form);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminRole_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
roleService.getRole(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminRole_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final RoleEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminRole_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromupdate(final RoleEditForm form) {
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminRole_ConfirmJsp);
|
||||
}
|
||||
|
||||
|
@ -185,69 +235,80 @@ public class AdminRoleAction extends FessAdminAction {
|
|||
// Actually Crud
|
||||
// -------------
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse create(final RoleEditForm form) {
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
roleService.store(createRole(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
createRole(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
entity.setId(Base64.getEncoder().encodeToString(entity.getName().getBytes(Constants.CHARSET_UTF_8)));
|
||||
roleService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse update(final RoleEditForm form) {
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
roleService.store(createRole(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
createRole(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
entity.setId(Base64.getEncoder().encodeToString(entity.getName().getBytes(Constants.CHARSET_UTF_8)));
|
||||
roleService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final RoleEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
roleService.delete(getRole(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
final String id = form.id;
|
||||
roleService.getRole(id).ifPresent(entity -> {
|
||||
roleService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadRole(final RoleEditForm form) {
|
||||
copyBeanToBean(getRole(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected Role getRole(final RoleEditForm form) {
|
||||
final Role role = roleService.getRole(createKeyMap(form));
|
||||
if (role == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
protected OptionalEntity<Role> createRole(final CreateForm form) {
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
if (form instanceof CreateForm) {
|
||||
final Role entity = new Role();
|
||||
return OptionalEntity.of(entity);
|
||||
}
|
||||
break;
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
return roleService.getRole(((EditForm) form).id).map(entity -> {
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return role;
|
||||
}
|
||||
|
||||
protected Role createRole(final RoleEditForm form) {
|
||||
Role role;
|
||||
if (form.crudMode == CrudMode.EDIT) {
|
||||
role = getRole(form);
|
||||
} else {
|
||||
role = new Role();
|
||||
}
|
||||
copyBeanToBean(form, role, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
role.setId(Base64.getEncoder().encodeToString(role.getName().getBytes(Constants.CHARSET_UTF_8)));
|
||||
return role;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final RoleEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final RoleEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.role;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class CreateForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public int crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 100)
|
||||
public String name;
|
||||
|
||||
public void initialize() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.role;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
@Size(max = 1000)
|
||||
public String updatedBy;
|
||||
|
||||
@Digits(integer = 19, fraction = 0)
|
||||
public Long updatedTime;
|
||||
|
||||
@Required
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.role;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class RoleEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public int crudMode;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 100)
|
||||
public String name;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
name = null;
|
||||
versionNo = null;
|
||||
}
|
||||
}
|
|
@ -16,15 +16,13 @@
|
|||
package org.codelibs.fess.app.web.admin.role;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class RoleSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
public String id;
|
||||
}
|
|
@ -15,9 +15,6 @@
|
|||
*/
|
||||
package org.codelibs.fess.app.web.admin.scheduledjob;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
|
@ -29,6 +26,7 @@ import org.codelibs.fess.es.config.exentity.ScheduledJob;
|
|||
import org.codelibs.fess.helper.JobHelper;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.codelibs.fess.job.JobExecutor;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -38,6 +36,7 @@ import org.lastaflute.web.validation.VaErrorHook;
|
|||
|
||||
/**
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminScheduledjobAction extends FessAdminAction {
|
||||
|
||||
|
@ -46,13 +45,10 @@ public class AdminScheduledjobAction extends FessAdminAction {
|
|||
// =========
|
||||
@Resource
|
||||
private ScheduledJobService scheduledJobService;
|
||||
|
||||
@Resource
|
||||
private ScheduledJobPager scheduledJobPager;
|
||||
|
||||
@Resource
|
||||
protected SystemHelper systemHelper;
|
||||
|
||||
private SystemHelper systemHelper;
|
||||
@Resource
|
||||
protected JobHelper jobHelper;
|
||||
|
||||
|
@ -71,14 +67,14 @@ public class AdminScheduledjobAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final ScheduledjobSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminScheduledjob_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final ScheduledjobSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
scheduledJobPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminScheduledjob_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -86,15 +82,15 @@ public class AdminScheduledjobAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final ScheduledjobSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, scheduledJobPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, scheduledJobPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminScheduledjob_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final ScheduledjobSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
scheduledJobPager.clear();
|
||||
return asHtml(path_AdminScheduledjob_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -102,17 +98,17 @@ public class AdminScheduledjobAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final ScheduledjobSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminScheduledjob_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final ScheduledjobSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("scheduledJobItems", scheduledJobService.getScheduledJobList(scheduledJobPager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(scheduledJobPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(scheduledJobPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -122,46 +118,82 @@ public class AdminScheduledjobAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse createpage(final ScheduledjobEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
public HtmlResponse createpage() {
|
||||
return asHtml(path_AdminScheduledjob_EditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.EDIT);
|
||||
return asHtml(path_AdminScheduledjob_EditJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
loadScheduledJob(form, entity);
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse createagain(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminScheduledjob_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final ScheduledjobEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
loadScheduledJob(form);
|
||||
public HtmlResponse editagain(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminScheduledjob_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editagain(final ScheduledjobEditForm form) {
|
||||
return asHtml(path_AdminScheduledjob_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editfromconfirm(final ScheduledjobEditForm form) {
|
||||
public HtmlResponse editfromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
loadScheduledJob(form);
|
||||
final String id = form.id;
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
loadScheduledJob(form, entity);
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminScheduledjob_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final ScheduledjobEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadScheduledJob(form);
|
||||
return asHtml(path_AdminScheduledjob_ConfirmJsp);
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminScheduledjob_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
loadScheduledJob(form, entity);
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletefromconfirm(final ScheduledjobEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadScheduledJob(form);
|
||||
final String id = form.id;
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
loadScheduledJob(form, entity);
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminScheduledjob_ConfirmJsp);
|
||||
}
|
||||
|
||||
|
@ -169,27 +201,35 @@ public class AdminScheduledjobAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final ScheduledjobEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadScheduledJob(form);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminScheduledjob_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
loadScheduledJob(form, entity);
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
});
|
||||
}).renderWith(data -> {
|
||||
data.register("running", running);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminScheduledjob_ConfirmJsp).renderWith(data -> {
|
||||
data.register("running", running);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final ScheduledjobEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminScheduledjob_ConfirmJsp).renderWith(data -> {
|
||||
data.register("running", running);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromupdate(final ScheduledjobEditForm form) {
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminScheduledjob_ConfirmJsp).renderWith(data -> {
|
||||
data.register("running", running);
|
||||
});
|
||||
|
@ -199,113 +239,139 @@ public class AdminScheduledjobAction extends FessAdminAction {
|
|||
// Actually Crud
|
||||
// -------------
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse create(final ScheduledjobEditForm form) {
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
scheduledJobService.store(createScheduledJob(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
createScheduledJob(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
scheduledJobService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse update(final ScheduledjobEditForm form) {
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
scheduledJobService.store(createScheduledJob(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
createScheduledJob(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
scheduledJobService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final ScheduledjobEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
scheduledJobService.delete(getScheduledJob(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
final String id = form.id;
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
scheduledJobService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse start(final ScheduledjobEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
final ScheduledJob scheduledJob = getScheduledJob(form);
|
||||
try {
|
||||
scheduledJob.start();
|
||||
saveInfo(messages -> messages.addSuccessJobStarted(GLOBAL, scheduledJob.getName()));
|
||||
} catch (final Exception e) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsFailedToStartJob(GLOBAL, scheduledJob.getName());
|
||||
}, toEditHtml());
|
||||
}
|
||||
public HtmlResponse start(final EditForm form) {
|
||||
final String id = form.id;
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
try {
|
||||
entity.start();
|
||||
saveInfo(messages -> messages.addSuccessJobStarted(GLOBAL, entity.getName()));
|
||||
} catch (final Exception e) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsFailedToStartJob(GLOBAL, entity.getName());
|
||||
}, toEditHtml());
|
||||
}
|
||||
}).orElse(() -> {
|
||||
// TODO
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse stop(final ScheduledjobEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
final ScheduledJob scheduledJob = getScheduledJob(form);
|
||||
try {
|
||||
final JobExecutor jobExecutoer = jobHelper.getJobExecutoer(scheduledJob.getId());
|
||||
jobExecutoer.shutdown();
|
||||
saveInfo(messages -> messages.addSuccessJobStopped(GLOBAL, scheduledJob.getName()));
|
||||
} catch (final Exception e) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsFailedToStopJob(GLOBAL, scheduledJob.getName());
|
||||
}, toEditHtml());
|
||||
}
|
||||
public HtmlResponse stop(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CONFIRM);
|
||||
final String id = form.id;
|
||||
scheduledJobService.getScheduledJob(id).ifPresent(entity -> {
|
||||
try {
|
||||
final JobExecutor jobExecutoer = jobHelper.getJobExecutoer(entity.getId());
|
||||
jobExecutoer.shutdown();
|
||||
saveInfo(messages -> messages.addSuccessJobStopped(GLOBAL, entity.getName()));
|
||||
} catch (final Exception e) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsFailedToStopJob(GLOBAL, entity.getName());
|
||||
}, toEditHtml());
|
||||
}
|
||||
}).orElse(() -> {
|
||||
// TODO
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadScheduledJob(final ScheduledjobEditForm form) {
|
||||
final ScheduledJob scheduledJob = getScheduledJob(form);
|
||||
copyBeanToBean(scheduledJob, form, op -> op.exclude("crudMode"));
|
||||
form.jobLogging = scheduledJob.isLoggingEnabled() ? Constants.ON : null;
|
||||
form.crawler = scheduledJob.isCrawlerJob() ? Constants.ON : null;
|
||||
form.available = scheduledJob.isEnabled() ? Constants.ON : null;
|
||||
running = scheduledJob.isRunning();
|
||||
protected void loadScheduledJob(final EditForm form, ScheduledJob entity) {
|
||||
copyBeanToBean(entity, form, op -> op.exclude("crudMode").excludeNull());
|
||||
form.jobLogging = entity.isLoggingEnabled() ? Constants.ON : null;
|
||||
form.crawler = entity.isCrawlerJob() ? Constants.ON : null;
|
||||
form.available = entity.isEnabled() ? Constants.ON : null;
|
||||
}
|
||||
|
||||
protected ScheduledJob getScheduledJob(final ScheduledjobEditForm form) {
|
||||
final ScheduledJob scheduledJob = scheduledJobService.getScheduledJob(createKeyMap(form));
|
||||
if (scheduledJob == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return scheduledJob;
|
||||
}
|
||||
|
||||
protected ScheduledJob createScheduledJob(final ScheduledjobEditForm form) {
|
||||
ScheduledJob scheduledJob;
|
||||
protected OptionalEntity<ScheduledJob> createScheduledJob(final CreateForm form) {
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CrudMode.EDIT) {
|
||||
scheduledJob = getScheduledJob(form);
|
||||
} else {
|
||||
scheduledJob = new ScheduledJob();
|
||||
scheduledJob.setCreatedBy(username);
|
||||
scheduledJob.setCreatedTime(currentTime);
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
if (form instanceof CreateForm) {
|
||||
final ScheduledJob entity = new ScheduledJob();
|
||||
entity.setCreatedBy(username);
|
||||
entity.setCreatedTime(currentTime);
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
entity.setJobLogging(Constants.ON.equals(form.jobLogging) ? Constants.T : Constants.F);
|
||||
entity.setCrawler(Constants.ON.equals(form.crawler) ? Constants.T : Constants.F);
|
||||
entity.setAvailable(Constants.ON.equals(form.available) ? Constants.T : Constants.F);
|
||||
return OptionalEntity.of(entity);
|
||||
}
|
||||
break;
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
return scheduledJobService.getScheduledJob(((EditForm) form).id).map(entity -> {
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
entity.setJobLogging(Constants.ON.equals(form.jobLogging) ? Constants.T : Constants.F);
|
||||
entity.setCrawler(Constants.ON.equals(form.crawler) ? Constants.T : Constants.F);
|
||||
entity.setAvailable(Constants.ON.equals(form.available) ? Constants.T : Constants.F);
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
scheduledJob.setUpdatedBy(username);
|
||||
scheduledJob.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, scheduledJob, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
scheduledJob.setJobLogging(Constants.ON.equals(form.jobLogging) ? Constants.T : Constants.F);
|
||||
scheduledJob.setCrawler(Constants.ON.equals(form.crawler) ? Constants.T : Constants.F);
|
||||
scheduledJob.setAvailable(Constants.ON.equals(form.available) ? Constants.T : Constants.F);
|
||||
return scheduledJob;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final ScheduledjobEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final ScheduledjobEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.scheduledjob;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.CronExpression;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class CreateForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public int crudMode;
|
||||
|
||||
@Required
|
||||
@Size(max = 100)
|
||||
public String name;
|
||||
|
||||
@Required
|
||||
@Size(max = 100)
|
||||
public String target;
|
||||
|
||||
@Required
|
||||
@Size(max = 100)
|
||||
@CronExpression
|
||||
public String cronExpression;
|
||||
|
||||
@Required
|
||||
@Size(max = 100)
|
||||
public String scriptType;
|
||||
|
||||
@Size(max = 4000)
|
||||
public String scriptData;
|
||||
|
||||
// ignore
|
||||
public String crawler;
|
||||
|
||||
// ignore
|
||||
public String jobLogging;
|
||||
|
||||
// ignore
|
||||
public String available;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public Integer sortOrder;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String createdBy;
|
||||
|
||||
@Required
|
||||
@Digits(integer = 19, fraction = 0)
|
||||
public Long createdTime;
|
||||
|
||||
public void initialize() {
|
||||
target = Constants.DEFAULT_JOB_TARGET;
|
||||
cronExpression = Constants.DEFAULT_CRON_EXPRESSION;
|
||||
scriptType = Constants.DEFAULT_JOB_SCRIPT_TYPE;
|
||||
sortOrder = 0;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.scheduledjob;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
@Required
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.scheduledjob;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.annotation.CronExpression;
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class ScheduledjobEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public int crudMode;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 100)
|
||||
public String name;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 100)
|
||||
public String target;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 100)
|
||||
@CronExpression
|
||||
public String cronExpression;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 100)
|
||||
public String scriptType;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 4000)
|
||||
public String scriptData;
|
||||
|
||||
// ignore
|
||||
public String crawler;
|
||||
|
||||
// ignore
|
||||
public String jobLogging;
|
||||
|
||||
// ignore
|
||||
public String available;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Digits(integer=10, fraction=0)
|
||||
//@IntRange(min = 0, max = 2147483647)
|
||||
public String sortOrder;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
public String createdBy;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Digits(integer=19, fraction=0)
|
||||
public String createdTime;
|
||||
|
||||
public String updatedBy;
|
||||
|
||||
//@Digits(integer=19, fraction=0)
|
||||
public String updatedTime;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
name = null;
|
||||
target = null;
|
||||
cronExpression = null;
|
||||
scriptType = null;
|
||||
scriptData = null;
|
||||
crawler = null;
|
||||
jobLogging = null;
|
||||
available = null;
|
||||
sortOrder = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
versionNo = null;
|
||||
target = Constants.DEFAULT_JOB_TARGET;
|
||||
cronExpression = Constants.DEFAULT_CRON_EXPRESSION;
|
||||
scriptType = Constants.DEFAULT_JOB_SCRIPT_TYPE;
|
||||
sortOrder = "0";
|
||||
}
|
||||
}
|
|
@ -16,15 +16,13 @@
|
|||
package org.codelibs.fess.app.web.admin.scheduledjob;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
*/
|
||||
public class ScheduledjobSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
public String id;
|
||||
}
|
|
@ -25,8 +25,6 @@ import java.io.InputStreamReader;
|
|||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -42,6 +40,7 @@ import org.codelibs.fess.app.web.base.FessAdminAction;
|
|||
import org.codelibs.fess.es.config.exentity.SuggestBadWord;
|
||||
import org.codelibs.fess.exception.FessSystemException;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -51,7 +50,7 @@ import org.lastaflute.web.util.LaResponseUtil;
|
|||
import org.lastaflute.web.validation.VaErrorHook;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class AdminSuggestbadwordAction extends FessAdminAction {
|
||||
|
||||
|
@ -80,14 +79,14 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SuggestBadWordSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminSuggestbadword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final SuggestBadWordSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
suggestBadWordPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminSuggestbadword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -95,15 +94,15 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final SuggestBadWordSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, suggestBadWordPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, suggestBadWordPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminSuggestbadword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final SuggestBadWordSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
suggestBadWordPager.clear();
|
||||
return asHtml(path_AdminSuggestbadword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -111,16 +110,17 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final SuggestBadWordSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminSuggestbadword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final SuggestBadWordSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("suggestBadWordItems", suggestBadWordService.getSuggestBadWordList(suggestBadWordPager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(suggestBadWordPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(suggestBadWordPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -130,46 +130,86 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse createpage(final SuggestBadWordEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
public HtmlResponse createpage() {
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.EDIT);
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
suggestBadWordService.getSuggestBadWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse createagain(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final SuggestBadWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
loadSuggestBadWord(form);
|
||||
public HtmlResponse editagain(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editagain(final SuggestBadWordEditForm form) {
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editfromconfirm(final SuggestBadWordEditForm form) {
|
||||
public HtmlResponse editfromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
loadSuggestBadWord(form);
|
||||
final String id = form.id;
|
||||
suggestBadWordService.getSuggestBadWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminSuggestbadword_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final SuggestBadWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadSuggestBadWord(form);
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp);
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
suggestBadWordService.getSuggestBadWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletefromconfirm(final SuggestBadWordEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadSuggestBadWord(form);
|
||||
final String id = form.id;
|
||||
suggestBadWordService.getSuggestBadWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp);
|
||||
}
|
||||
|
||||
|
@ -177,36 +217,46 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final SuggestBadWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadSuggestBadWord(form);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
suggestBadWordService.getSuggestBadWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final SuggestBadWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromupdate(final SuggestBadWordEditForm form) {
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminSuggestbadword_ConfirmJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Download
|
||||
// -------
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse downloadpage(final SuggestBadWordSearchForm form) {
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse downloadpage(final SearchForm form) {
|
||||
return asHtml(path_AdminSuggestbadword_DownloadJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse download(final SuggestBadWordSearchForm form) {
|
||||
public HtmlResponse download(final SearchForm form) {
|
||||
final HttpServletResponse response = LaResponseUtil.getResponse();
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + "badword.csv" + "\"");
|
||||
|
@ -223,8 +273,8 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
|
|||
// -----------------------------------------------------
|
||||
// Upload
|
||||
// -------
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse uploadpage(final SuggestBadWordUploadForm form) {
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse uploadpage(final UploadForm form) {
|
||||
return asHtml(path_AdminSuggestbadword_UploadJsp);
|
||||
}
|
||||
|
||||
|
@ -232,31 +282,49 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
|
|||
// Actually Crud
|
||||
// -------------
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse create(final SuggestBadWordEditForm form) {
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
suggestBadWordService.store(createSuggestBadWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
createSuggestBadWord(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
suggestBadWordService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse update(final SuggestBadWordEditForm form) {
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
suggestBadWordService.store(createSuggestBadWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
createSuggestBadWord(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
suggestBadWordService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final SuggestBadWordEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
suggestBadWordService.delete(getSuggestBadWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
final String id = form.id;
|
||||
suggestBadWordService.getSuggestBadWord(id).ifPresent(entity -> {
|
||||
suggestBadWordService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse upload(final SuggestBadWordUploadForm form) {
|
||||
public HtmlResponse upload(final UploadForm form) {
|
||||
BufferedInputStream is = null;
|
||||
File tempFile = null;
|
||||
FileOutputStream fos = null;
|
||||
|
@ -310,58 +378,45 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
|
|||
return redirect(getClass());
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadSuggestBadWord(final SuggestBadWordEditForm form) {
|
||||
copyBeanToBean(getSuggestBadWord(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected SuggestBadWord getSuggestBadWord(final SuggestBadWordEditForm form) {
|
||||
final SuggestBadWord suggestBadWord = suggestBadWordService.getSuggestBadWord(createKeyMap(form));
|
||||
if (suggestBadWord == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return suggestBadWord;
|
||||
}
|
||||
|
||||
protected SuggestBadWord createSuggestBadWord(final SuggestBadWordEditForm form) {
|
||||
SuggestBadWord suggestBadWord;
|
||||
protected OptionalEntity<SuggestBadWord> createSuggestBadWord(final CreateForm form) {
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CrudMode.EDIT) {
|
||||
suggestBadWord = getSuggestBadWord(form);
|
||||
} else {
|
||||
suggestBadWord = new SuggestBadWord();
|
||||
suggestBadWord.setCreatedBy(username);
|
||||
suggestBadWord.setCreatedTime(currentTime);
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
if (form instanceof CreateForm) {
|
||||
final SuggestBadWord entity = new SuggestBadWord();
|
||||
entity.setCreatedBy(username);
|
||||
entity.setCreatedTime(currentTime);
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return OptionalEntity.of(entity);
|
||||
}
|
||||
break;
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
return suggestBadWordService.getSuggestBadWord(((EditForm) form).id).map(entity -> {
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
suggestBadWord.setUpdatedBy(username);
|
||||
suggestBadWord.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, suggestBadWord, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
return suggestBadWord;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final SuggestBadWordEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
}
|
||||
|
||||
protected Map<String, String> createItem(final String label, final String value) {
|
||||
final Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put(Constants.ITEM_LABEL, label);
|
||||
map.put(Constants.ITEM_VALUE, value);
|
||||
return map;
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final SuggestBadWordEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,35 +13,40 @@
|
|||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.group;
|
||||
package org.codelibs.fess.app.web.admin.suggestbadword;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author shinsuke
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class GroupEditForm implements Serializable {
|
||||
public class CreateForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@Digits(integer=10, fraction=0)
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public int crudMode;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
@Required
|
||||
public String suggestWord;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 100)
|
||||
public String name;
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String createdBy;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public String versionNo;
|
||||
@Required
|
||||
@Digits(integer = 19, fraction = 0)
|
||||
public Long createdTime;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
name = null;
|
||||
versionNo = null;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.suggestbadword;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
@Size(max = 1000)
|
||||
public String updatedBy;
|
||||
|
||||
@Digits(integer = 19, fraction = 0)
|
||||
public Long updatedTime;
|
||||
|
||||
@Required
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -16,16 +16,14 @@
|
|||
package org.codelibs.fess.app.web.admin.suggestbadword;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestBadWordSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
public String id;
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.suggestbadword;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestBadWordEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public String pageNumber;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public int crudMode;
|
||||
|
||||
public String getCurrentPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
public String suggestWord;
|
||||
|
||||
public String reading;
|
||||
|
||||
public String targetRole;
|
||||
|
||||
public String targetLabel;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@FloatType
|
||||
public String boost;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String createdBy;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Digits(integer=19, fraction=0)
|
||||
public String createdTime;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String updatedBy;
|
||||
|
||||
//@Digits(integer=19, fraction=0)
|
||||
public String updatedTime;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
suggestWord = null;
|
||||
reading = null;
|
||||
targetRole = null;
|
||||
targetLabel = null;
|
||||
boost = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
versionNo = null;
|
||||
boost = "100";
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ import org.lastaflute.web.ruts.multipart.MultipartFormFile;
|
|||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestBadWordUploadForm implements Serializable {
|
||||
public class UploadForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -25,8 +25,6 @@ import java.io.InputStreamReader;
|
|||
import java.io.OutputStreamWriter;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
@ -42,6 +40,7 @@ import org.codelibs.fess.app.web.base.FessAdminAction;
|
|||
import org.codelibs.fess.es.config.exentity.SuggestElevateWord;
|
||||
import org.codelibs.fess.exception.FessSystemException;
|
||||
import org.codelibs.fess.helper.SystemHelper;
|
||||
import org.dbflute.optional.OptionalEntity;
|
||||
import org.lastaflute.web.Execute;
|
||||
import org.lastaflute.web.callback.ActionRuntime;
|
||||
import org.lastaflute.web.response.HtmlResponse;
|
||||
|
@ -80,14 +79,14 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
// Search Execute
|
||||
// ==============
|
||||
@Execute
|
||||
public HtmlResponse index(final SuggestElevateWordSearchForm form) {
|
||||
public HtmlResponse index(final SearchForm form) {
|
||||
return asHtml(path_AdminSuggestelevateword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse list(final Integer pageNumber, final SuggestElevateWordSearchForm form) {
|
||||
public HtmlResponse list(final Integer pageNumber, final SearchForm form) {
|
||||
suggestElevateWordPager.setCurrentPageNumber(pageNumber);
|
||||
return asHtml(path_AdminSuggestelevateword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -95,15 +94,15 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse search(final SuggestElevateWordSearchForm form) {
|
||||
copyBeanToBean(form.searchParams, suggestElevateWordPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
public HtmlResponse search(final SearchForm form) {
|
||||
copyBeanToBean(form, suggestElevateWordPager, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
return asHtml(path_AdminSuggestelevateword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse reset(final SuggestElevateWordSearchForm form) {
|
||||
public HtmlResponse reset(final SearchForm form) {
|
||||
suggestElevateWordPager.clear();
|
||||
return asHtml(path_AdminSuggestelevateword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
|
@ -111,16 +110,17 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse back(final SuggestElevateWordSearchForm form) {
|
||||
public HtmlResponse back(final SearchForm form) {
|
||||
return asHtml(path_AdminSuggestelevateword_IndexJsp).renderWith(data -> {
|
||||
searchPaging(data, form);
|
||||
});
|
||||
}
|
||||
|
||||
protected void searchPaging(final RenderData data, final SuggestElevateWordSearchForm form) {
|
||||
protected void searchPaging(final RenderData data, final SearchForm form) {
|
||||
data.register("suggestElevateWordItems", suggestElevateWordService.getSuggestElevateWordList(suggestElevateWordPager)); // page navi
|
||||
|
||||
// restore from pager
|
||||
copyBeanToBean(suggestElevateWordPager, form.searchParams, op -> op.exclude(Constants.PAGER_CONVERSION_RULE));
|
||||
copyBeanToBean(suggestElevateWordPager, form, op -> op.include("id"));
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
|
@ -130,46 +130,86 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
// Entry Page
|
||||
// ----------
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse createpage(final SuggestElevateWordEditForm form) {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
public HtmlResponse createpage() {
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp).useForm(CreateForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
form.initialize();
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.EDIT);
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
suggestElevateWordService.getSuggestElevateWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse createagain(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editpage(final int crudMode, final String id, final SuggestElevateWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.EDIT);
|
||||
loadSuggestElevateWord(form);
|
||||
public HtmlResponse editagain(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editagain(final SuggestElevateWordEditForm form) {
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse editfromconfirm(final SuggestElevateWordEditForm form) {
|
||||
public HtmlResponse editfromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
loadSuggestElevateWord(form);
|
||||
final String id = form.id;
|
||||
suggestElevateWordService.getSuggestElevateWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_EditJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletepage(final int crudMode, final String id, final SuggestElevateWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
loadSuggestElevateWord(form);
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp);
|
||||
public HtmlResponse deletepage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.DELETE);
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
suggestElevateWordService.getSuggestElevateWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse deletefromconfirm(final SuggestElevateWordEditForm form) {
|
||||
public HtmlResponse deletefromconfirm(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.DELETE;
|
||||
loadSuggestElevateWord(form);
|
||||
final String id = form.id;
|
||||
suggestElevateWordService.getSuggestElevateWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, op -> {});
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp);
|
||||
}
|
||||
|
||||
|
@ -177,36 +217,46 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
// Confirm
|
||||
// -------
|
||||
@Execute
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id, final SuggestElevateWordEditForm form) {
|
||||
form.crudMode = crudMode;
|
||||
form.id = id;
|
||||
verifyCrudMode(form, CrudMode.CONFIRM);
|
||||
loadSuggestElevateWord(form);
|
||||
public HtmlResponse confirmpage(final int crudMode, final String id) {
|
||||
verifyCrudMode(crudMode, CrudMode.CONFIRM);
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp).useForm(EditForm.class, op -> {
|
||||
op.setup(form -> {
|
||||
suggestElevateWordService.getSuggestElevateWord(id).ifPresent(entity -> {
|
||||
copyBeanToBean(entity, form, copyOp -> {
|
||||
copyOp.excludeNull();
|
||||
});
|
||||
form.crudMode = crudMode;
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final CreateForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.CREATE;
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromcreate(final SuggestElevateWordEditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE_KEEP)
|
||||
public HtmlResponse confirmfromupdate(final SuggestElevateWordEditForm form) {
|
||||
public HtmlResponse confirmfromupdate(final EditForm form) {
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
form.crudMode = CrudMode.EDIT;
|
||||
return asHtml(path_AdminSuggestelevateword_ConfirmJsp);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Download
|
||||
// -------
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse downloadpage(final SuggestElevateWordSearchForm form) {
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse downloadpage(final SearchForm form) {
|
||||
return asHtml(path_AdminSuggestelevateword_DownloadJsp);
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse download(final SuggestElevateWordSearchForm form) {
|
||||
public HtmlResponse download(final SearchForm form) {
|
||||
final HttpServletResponse response = LaResponseUtil.getResponse();
|
||||
response.setContentType("application/octet-stream");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + "elevateword.csv" + "\"");
|
||||
|
@ -223,8 +273,8 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
// -----------------------------------------------------
|
||||
// Upload
|
||||
// -------
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse uploadpage(final SuggestElevateWordUploadForm form) {
|
||||
@Execute(token = TxToken.SAVE)
|
||||
public HtmlResponse uploadpage(final UploadForm form) {
|
||||
return asHtml(path_AdminSuggestelevateword_UploadJsp);
|
||||
}
|
||||
|
||||
|
@ -232,31 +282,49 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
// Actually Crud
|
||||
// -------------
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse create(final SuggestElevateWordEditForm form) {
|
||||
public HtmlResponse create(final CreateForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.CREATE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
suggestElevateWordService.store(createSuggestElevateWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
createSuggestElevateWord(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
suggestElevateWordService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudFailedToCreateCrudTable(GLOBAL), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse update(final SuggestElevateWordEditForm form) {
|
||||
public HtmlResponse update(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.EDIT);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
suggestElevateWordService.store(createSuggestElevateWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
createSuggestElevateWord(form).ifPresent(entity -> {
|
||||
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
suggestElevateWordService.store(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute
|
||||
public HtmlResponse delete(final SuggestElevateWordEditForm form) {
|
||||
verifyCrudMode(form, CrudMode.DELETE);
|
||||
suggestElevateWordService.delete(getSuggestElevateWord(form));
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
public HtmlResponse delete(final EditForm form) {
|
||||
verifyCrudMode(form.crudMode, CrudMode.DELETE);
|
||||
validate(form, messages -> {}, toEditHtml());
|
||||
final String id = form.id;
|
||||
suggestElevateWordService.getSuggestElevateWord(id).ifPresent(entity -> {
|
||||
suggestElevateWordService.delete(entity);
|
||||
saveInfo(messages -> messages.addSuccessCrudDeleteCrudTable(GLOBAL));
|
||||
}).orElse(() -> {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, id), toEditHtml());
|
||||
});
|
||||
return redirect(getClass());
|
||||
}
|
||||
|
||||
@Execute(token = TxToken.VALIDATE)
|
||||
public HtmlResponse upload(final SuggestElevateWordUploadForm form) {
|
||||
public HtmlResponse upload(final UploadForm form) {
|
||||
BufferedInputStream is = null;
|
||||
File tempFile = null;
|
||||
FileOutputStream fos = null;
|
||||
|
@ -310,58 +378,45 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
|
|||
return redirect(getClass());
|
||||
}
|
||||
|
||||
//===================================================================================
|
||||
// ===================================================================================
|
||||
// Assist Logic
|
||||
// ============
|
||||
protected void loadSuggestElevateWord(final SuggestElevateWordEditForm form) {
|
||||
copyBeanToBean(getSuggestElevateWord(form), form, op -> op.exclude("crudMode"));
|
||||
}
|
||||
|
||||
protected SuggestElevateWord getSuggestElevateWord(final SuggestElevateWordEditForm form) {
|
||||
final SuggestElevateWord suggestElevateWord = suggestElevateWordService.getSuggestElevateWord(createKeyMap(form));
|
||||
if (suggestElevateWord == null) {
|
||||
throwValidationError(messages -> messages.addErrorsCrudCouldNotFindCrudTable(GLOBAL, form.id), toEditHtml());
|
||||
}
|
||||
return suggestElevateWord;
|
||||
}
|
||||
|
||||
protected SuggestElevateWord createSuggestElevateWord(final SuggestElevateWordEditForm form) {
|
||||
SuggestElevateWord suggestElevateWord;
|
||||
protected OptionalEntity<SuggestElevateWord> createSuggestElevateWord(final CreateForm form) {
|
||||
final String username = systemHelper.getUsername();
|
||||
final long currentTime = systemHelper.getCurrentTimeAsLong();
|
||||
if (form.crudMode == CrudMode.EDIT) {
|
||||
suggestElevateWord = getSuggestElevateWord(form);
|
||||
} else {
|
||||
suggestElevateWord = new SuggestElevateWord();
|
||||
suggestElevateWord.setCreatedBy(username);
|
||||
suggestElevateWord.setCreatedTime(currentTime);
|
||||
switch (form.crudMode) {
|
||||
case CrudMode.CREATE:
|
||||
if (form instanceof CreateForm) {
|
||||
final SuggestElevateWord entity = new SuggestElevateWord();
|
||||
entity.setCreatedBy(username);
|
||||
entity.setCreatedTime(currentTime);
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return OptionalEntity.of(entity);
|
||||
}
|
||||
break;
|
||||
case CrudMode.EDIT:
|
||||
if (form instanceof EditForm) {
|
||||
return suggestElevateWordService.getSuggestElevateWord(((EditForm) form).id).map(entity -> {
|
||||
entity.setUpdatedBy(username);
|
||||
entity.setUpdatedTime(currentTime);
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
suggestElevateWord.setUpdatedBy(username);
|
||||
suggestElevateWord.setUpdatedTime(currentTime);
|
||||
copyBeanToBean(form, suggestElevateWord, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
|
||||
return suggestElevateWord;
|
||||
}
|
||||
|
||||
protected Map<String, String> createKeyMap(final SuggestElevateWordEditForm form) {
|
||||
final Map<String, String> keys = new HashMap<String, String>();
|
||||
keys.put("id", form.id);
|
||||
return keys;
|
||||
}
|
||||
|
||||
protected Map<String, String> createItem(final String label, final String value) {
|
||||
final Map<String, String> map = new HashMap<String, String>(2);
|
||||
map.put(Constants.ITEM_LABEL, label);
|
||||
map.put(Constants.ITEM_VALUE, value);
|
||||
return map;
|
||||
return OptionalEntity.empty();
|
||||
}
|
||||
|
||||
// ===================================================================================
|
||||
// Small Helper
|
||||
// ============
|
||||
protected void verifyCrudMode(final SuggestElevateWordEditForm form, final int expectedMode) {
|
||||
if (form.crudMode != expectedMode) {
|
||||
protected void verifyCrudMode(final int crudMode, final int expectedMode) {
|
||||
if (crudMode != expectedMode) {
|
||||
throwValidationError(messages -> {
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(form.crudMode));
|
||||
messages.addErrorsCrudInvalidMode(GLOBAL, String.valueOf(expectedMode), String.valueOf(crudMode));
|
||||
}, toEditHtml());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.suggestelevateword;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class CreateForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public int crudMode;
|
||||
|
||||
@Required
|
||||
public String suggestWord;
|
||||
|
||||
public String reading;
|
||||
|
||||
public String targetRole;
|
||||
|
||||
public String targetLabel;
|
||||
|
||||
@Required
|
||||
// @FloatType
|
||||
public float boost;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String createdBy;
|
||||
|
||||
@Required
|
||||
@Digits(integer = 19, fraction = 0)
|
||||
public Long createdTime;
|
||||
|
||||
public void initialize() {
|
||||
boost = 100.0f;
|
||||
createdBy = ComponentUtil.getSystemHelper().getUsername();
|
||||
createdTime = ComponentUtil.getSystemHelper().getCurrentTimeAsLong();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.suggestelevateword;
|
||||
|
||||
import javax.validation.constraints.Digits;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
import org.lastaflute.web.validation.Required;
|
||||
|
||||
/**
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class EditForm extends CreateForm {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Required
|
||||
@Size(max = 1000)
|
||||
public String id;
|
||||
|
||||
@Size(max = 1000)
|
||||
public String updatedBy;
|
||||
|
||||
@Digits(integer = 19, fraction = 0)
|
||||
public Long updatedTime;
|
||||
|
||||
@Required
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public Integer versionNo;
|
||||
|
||||
}
|
|
@ -16,16 +16,14 @@
|
|||
package org.codelibs.fess.app.web.admin.suggestelevateword;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestElevateWordSearchForm implements Serializable {
|
||||
public class SearchForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
public String id;
|
||||
}
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012-2015 CodeLibs Project and the Others.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||
* either express or implied. See the License for the specific language
|
||||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
package org.codelibs.fess.app.web.admin.suggestelevateword;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codelibs.fess.util.ComponentUtil;
|
||||
|
||||
/**
|
||||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestElevateWordEditForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public String pageNumber;
|
||||
|
||||
public Map<String, String> searchParams = new HashMap<String, String>();
|
||||
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public int crudMode;
|
||||
|
||||
public String getCurrentPageNumber() {
|
||||
return pageNumber;
|
||||
}
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 1000)
|
||||
public String id;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
public String suggestWord;
|
||||
|
||||
public String reading;
|
||||
|
||||
public String targetRole;
|
||||
|
||||
public String targetLabel;
|
||||
|
||||
//@Required(target = "confirmfromcreate,create,confirmfromupdate,update,delete")
|
||||
//@FloatType
|
||||
public String boost;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String createdBy;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Digits(integer=19, fraction=0)
|
||||
public String createdTime;
|
||||
|
||||
//@Maxbytelength(maxbytelength = 255)
|
||||
public String updatedBy;
|
||||
|
||||
//@Digits(integer=19, fraction=0)
|
||||
public String updatedTime;
|
||||
|
||||
//@Required(target = "confirmfromupdate,update,delete")
|
||||
//@Digits(integer=10, fraction=0)
|
||||
public String versionNo;
|
||||
|
||||
public void initialize() {
|
||||
id = null;
|
||||
suggestWord = null;
|
||||
reading = null;
|
||||
targetRole = null;
|
||||
targetLabel = null;
|
||||
boost = null;
|
||||
createdBy = "system";
|
||||
createdTime = Long.toString(ComponentUtil.getSystemHelper().getCurrentTimeAsLong());
|
||||
updatedBy = null;
|
||||
updatedTime = null;
|
||||
versionNo = null;
|
||||
boost = "100";
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ import org.lastaflute.web.ruts.multipart.MultipartFormFile;
|
|||
* @author codelibs
|
||||
* @author Keiichi Watanabe
|
||||
*/
|
||||
public class SuggestElevateWordUploadForm implements Serializable {
|
||||
public class UploadForm implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -96,10 +96,8 @@ public class CreateForm implements Serializable {
|
|||
public Integer intervalTime;
|
||||
|
||||
@Required
|
||||
@Min(value = 0)
|
||||
@Max(value = 2147483647)
|
||||
@Digits(integer = 10, fraction = 0)
|
||||
public Integer boost;
|
||||
// @FloatType
|
||||
public float boost;
|
||||
|
||||
@Required
|
||||
@Size(max = 5)
|
||||
|
@ -121,7 +119,7 @@ public class CreateForm implements Serializable {
|
|||
|
||||
public void initialize() {
|
||||
crudMode = CrudMode.CREATE;
|
||||
boost = 1;
|
||||
boost = 1.0f;
|
||||
if (StringUtil.isBlank(userAgent)) {
|
||||
userAgent = "FessCrawler/" + Constants.FESS_VERSION;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue