modify createEntity method

This commit is contained in:
Keiichi Watanabe 2015-11-09 16:34:29 +09:00
parent b6909eb7bd
commit 14cfdd6680
20 changed files with 335 additions and 303 deletions

View file

@ -171,7 +171,6 @@ public class AdminBoostdocumentruleAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createBoostDocumentRule(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
boostDocumentRuleService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -185,7 +184,6 @@ public class AdminBoostdocumentruleAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createBoostDocumentRule(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
boostDocumentRuleService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -212,27 +210,20 @@ public class AdminBoostdocumentruleAction extends FessAdminAction {
// Assist Logic
// ============
protected OptionalEntity<BoostDocumentRule> createBoostDocumentRule(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<BoostDocumentRule> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final BoostDocumentRule entity = new BoostDocumentRule();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new BoostDocumentRule()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return boostDocumentRuleService.getBoostDocumentRule(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return boostDocumentRuleService.getBoostDocumentRule(((EditForm) form).id);
}
break;
default:
@ -241,6 +232,17 @@ public class AdminBoostdocumentruleAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<BoostDocumentRule> createBoostDocumentRule(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -196,7 +196,6 @@ public class AdminDataconfigAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createDataConfig(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
dataConfigService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -210,7 +209,6 @@ public class AdminDataconfigAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createDataConfig(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
dataConfigService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -236,27 +234,20 @@ public class AdminDataconfigAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<DataConfig> createDataConfig(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<DataConfig> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final DataConfig entity = new DataConfig();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new DataConfig()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return dataConfigService.getDataConfig(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return dataConfigService.getDataConfig(((EditForm) form).id);
}
break;
default:
@ -265,6 +256,17 @@ public class AdminDataconfigAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<DataConfig> createDataConfig(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
protected void registerRolesAndLabels(final RenderData data) {
data.register("roleTypeItems", roleTypeService.getRoleTypeList());
data.register("labelTypeItems", labelTypeService.getLabelTypeList());

View file

@ -266,10 +266,6 @@ public class AdminDictKuromojiAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createKuromojiItem(form).ifPresent(entity -> {
entity.setNewToken(form.token);
entity.setNewSegmentation(form.segmentation);
entity.setNewReading(form.reading);
entity.setNewPos(form.pos);
kuromojiService.store(form.dictId, entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -283,10 +279,6 @@ public class AdminDictKuromojiAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createKuromojiItem(form).ifPresent(entity -> {
entity.setNewToken(form.token);
entity.setNewSegmentation(form.segmentation);
entity.setNewReading(form.reading);
entity.setNewPos(form.pos);
kuromojiService.store(form.dictId, entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -312,7 +304,7 @@ public class AdminDictKuromojiAction extends FessAdminAction {
// Assist Logic
// ============
protected OptionalEntity<KuromojiItem> createKuromojiItem(final CreateForm form) {
private OptionalEntity<KuromojiItem> getEntity(final CreateForm form) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
@ -331,6 +323,16 @@ public class AdminDictKuromojiAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<KuromojiItem> createKuromojiItem(final CreateForm form) {
return getEntity(form).map(entity -> {
entity.setNewToken(form.token);
entity.setNewSegmentation(form.segmentation);
entity.setNewReading(form.reading);
entity.setNewPos(form.pos);
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -297,12 +297,6 @@ public class AdminDictSynonymAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createSynonymItem(form).ifPresent(entity -> {
final String[] newInputs = splitLine(form.inputs);
validateSynonymString(newInputs, () -> confirmfromcreate(form));
entity.setNewInputs(newInputs);
final String[] newOutputs = splitLine(form.outputs);
validateSynonymString(newOutputs, () -> confirmfromcreate(form));
entity.setNewOutputs(newOutputs);
synonymService.store(form.dictId, entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -316,12 +310,6 @@ public class AdminDictSynonymAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createSynonymItem(form).ifPresent(entity -> {
final String[] newInputs = splitLine(form.inputs);
validateSynonymString(newInputs, () -> confirmfromupdate(form));
entity.setNewInputs(newInputs);
final String[] newOutputs = splitLine(form.outputs);
validateSynonymString(newOutputs, () -> confirmfromupdate(form));
entity.setNewOutputs(newOutputs);
synonymService.store(form.dictId, entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -347,7 +335,7 @@ public class AdminDictSynonymAction extends FessAdminAction {
// Assist Logic
// ============
protected OptionalEntity<SynonymItem> createSynonymItem(final CreateForm form) {
private OptionalEntity<SynonymItem> getEntity(final CreateForm form) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
@ -366,6 +354,18 @@ public class AdminDictSynonymAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<SynonymItem> createSynonymItem(final CreateForm form) {
return getEntity(form).map(entity -> {
final String[] newInputs = splitLine(form.inputs);
validateSynonymString(newInputs, () -> confirmfromcreate(form));
entity.setNewInputs(newInputs);
final String[] newOutputs = splitLine(form.outputs);
validateSynonymString(newOutputs, () -> confirmfromcreate(form));
entity.setNewOutputs(newOutputs);
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -193,7 +193,6 @@ public class AdminFileauthenticationAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createFileAuthentication(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
fileAuthenticationService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -207,7 +206,6 @@ public class AdminFileauthenticationAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createFileAuthentication(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
fileAuthenticationService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -233,27 +231,20 @@ public class AdminFileauthenticationAction extends FessAdminAction {
//===================================================================================
// Assist Logic
// ============
protected OptionalEntity<FileAuthentication> createFileAuthentication(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<FileAuthentication> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final FileAuthentication entity = new FileAuthentication();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new FileAuthentication()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return fileAuthenticationService.getFileAuthentication(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return fileAuthenticationService.getFileAuthentication(((EditForm) form).id);
}
break;
default:
@ -262,6 +253,17 @@ public class AdminFileauthenticationAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<FileAuthentication> createFileAuthentication(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
protected void registerProtocolSchemeItems(final RenderData data) {
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
final Locale locale = LaRequestUtil.getRequest().getLocale();

View file

@ -184,7 +184,6 @@ public class AdminFileconfigAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createFileConfig(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
fileConfigService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -198,7 +197,6 @@ public class AdminFileconfigAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createFileConfig(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
fileConfigService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -224,27 +222,20 @@ public class AdminFileconfigAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<FileConfig> createFileConfig(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<FileConfig> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final FileConfig entity = new FileConfig();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new FileConfig()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return fileConfigService.getFileConfig(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return fileConfigService.getFileConfig(((EditForm) form).id);
}
break;
default:
@ -253,6 +244,17 @@ public class AdminFileconfigAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<FileConfig> createFileConfig(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
protected void registerRolesAndLabels(final RenderData data) {
data.register("roleTypeItems", roleTypeService.getRoleTypeList());
data.register("labelTypeItems", labelTypeService.getLabelTypeList());

View file

@ -174,8 +174,6 @@ public class AdminGroupAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
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(() -> {
@ -189,8 +187,6 @@ public class AdminGroupAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
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(() -> {
@ -216,19 +212,16 @@ public class AdminGroupAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<Group> createGroup(final CreateForm form) {
private OptionalEntity<Group> getEntity(final CreateForm form) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final Group entity = new Group();
return OptionalEntity.of(entity);
return OptionalEntity.of(new Group());
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return groupService.getGroup(((EditForm) form).id).map(entity -> {
return entity;
});
return groupService.getGroup(((EditForm) form).id);
}
break;
default:
@ -237,6 +230,14 @@ public class AdminGroupAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<Group> createGroup(final CreateForm form) {
return getEntity(form).map(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
entity.setId(Base64.getEncoder().encodeToString(entity.getName().getBytes(Constants.CHARSET_UTF_8)));
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -173,7 +173,6 @@ public class AdminKeymatchAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createKeyMatch(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
keyMatchService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
ComponentUtil.getKeyMatchHelper().update();
@ -188,7 +187,6 @@ public class AdminKeymatchAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createKeyMatch(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
keyMatchService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
ComponentUtil.getKeyMatchHelper().update();
@ -216,28 +214,21 @@ public class AdminKeymatchAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<KeyMatch> createKeyMatch(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<KeyMatch> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final KeyMatch entity = new KeyMatch();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new KeyMatch()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return keyMatchService.getKeyMatch(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return keyMatchService.getKeyMatch(((EditForm) form).id);
}
break;
default:
@ -246,6 +237,17 @@ public class AdminKeymatchAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<KeyMatch> createKeyMatch(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -182,7 +182,6 @@ public class AdminLabeltypeAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createLabelType(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
labelTypeService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -196,7 +195,6 @@ public class AdminLabeltypeAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createLabelType(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
labelTypeService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -222,27 +220,21 @@ public class AdminLabeltypeAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<LabelType> createLabelType(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<LabelType> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final LabelType entity = new LabelType();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new LabelType()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return labelTypeService.getLabelType(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return labelTypeService.getLabelType(((EditForm) form).id);
}
break;
default:
@ -251,6 +243,17 @@ public class AdminLabeltypeAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<LabelType> createLabelType(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
protected void registerRoleTypeItems(final RenderData data) {
data.register("roleTypeItems", roleTypeService.getRoleTypeList());
}

View file

@ -172,7 +172,6 @@ public class AdminOverlappinghostAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createOverlappingHost(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
overlappingHostService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -186,7 +185,6 @@ public class AdminOverlappinghostAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createOverlappingHost(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
overlappingHostService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -212,27 +210,20 @@ public class AdminOverlappinghostAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<OverlappingHost> createOverlappingHost(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<OverlappingHost> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final OverlappingHost entity = new OverlappingHost();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new OverlappingHost()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return overlappingHostService.getOverlappingHost(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return overlappingHostService.getOverlappingHost(((EditForm) form).id);
}
break;
default:
@ -241,6 +232,17 @@ public class AdminOverlappinghostAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<OverlappingHost> createOverlappingHost(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -173,7 +173,6 @@ public class AdminPathmappingAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createPathMapping(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
pathMappingService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -187,7 +186,6 @@ public class AdminPathmappingAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createPathMapping(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
pathMappingService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -213,27 +211,20 @@ public class AdminPathmappingAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<PathMapping> createPathMapping(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<PathMapping> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final PathMapping entity = new PathMapping();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new PathMapping()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return pathMappingService.getPathMapping(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return pathMappingService.getPathMapping(((EditForm) form).id);
}
break;
default:
@ -242,6 +233,17 @@ public class AdminPathmappingAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<PathMapping> createPathMapping(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -195,7 +195,6 @@ public class AdminRequestheaderAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createRequestHeader(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
requestHeaderService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -209,7 +208,6 @@ public class AdminRequestheaderAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createRequestHeader(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
requestHeaderService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -235,27 +233,20 @@ public class AdminRequestheaderAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<RequestHeader> createRequestHeader(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<RequestHeader> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final RequestHeader entity = new RequestHeader();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new RequestHeader()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return requestHeaderService.getRequestHeader(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return requestHeaderService.getRequestHeader(((EditForm) form).id);
}
break;
default:
@ -264,6 +255,17 @@ public class AdminRequestheaderAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<RequestHeader> createRequestHeader(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
protected void registerProtocolSchemeItems(final RenderData data) {
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
final Locale locale = LaRequestUtil.getRequest().getLocale();

View file

@ -174,8 +174,6 @@ public class AdminRoleAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
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(() -> {
@ -189,8 +187,6 @@ public class AdminRoleAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
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(() -> {
@ -216,19 +212,16 @@ public class AdminRoleAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<Role> createRole(final CreateForm form) {
private OptionalEntity<Role> getEntity(final CreateForm form) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final Role entity = new Role();
return OptionalEntity.of(entity);
return OptionalEntity.of(new Role());
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return roleService.getRole(((EditForm) form).id).map(entity -> {
return entity;
});
return roleService.getRole(((EditForm) form).id);
}
break;
default:
@ -237,6 +230,14 @@ public class AdminRoleAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<Role> createRole(final CreateForm form) {
return getEntity(form).map(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
entity.setId(Base64.getEncoder().encodeToString(entity.getName().getBytes(Constants.CHARSET_UTF_8)));
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -172,7 +172,6 @@ public class AdminRoletypeAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createRoleType(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
roleTypeService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -186,7 +185,6 @@ public class AdminRoletypeAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createRoleType(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
roleTypeService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -212,27 +210,20 @@ public class AdminRoletypeAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<RoleType> createRoleType(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<RoleType> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final RoleType entity = new RoleType();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new RoleType()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return roleTypeService.getRoleType(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return roleTypeService.getRoleType(((EditForm) form).id);
}
break;
default:
@ -241,6 +232,17 @@ public class AdminRoletypeAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<RoleType> createRoleType(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -268,35 +268,20 @@ public class AdminScheduledjobAction extends FessAdminAction {
form.available = entity.isEnabled() ? Constants.ON : null;
}
protected OptionalEntity<ScheduledJob> createScheduledJob(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<ScheduledJob> getEntity(final CreateForm form, final String username, final long 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);
return OptionalEntity.of(new ScheduledJob()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return 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;
});
return scheduledJobService.getScheduledJob(((EditForm) form).id);
}
break;
default:
@ -305,6 +290,20 @@ public class AdminScheduledjobAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<ScheduledJob> createScheduledJob(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).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;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -224,7 +224,6 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createSuggestBadWord(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
suggestBadWordService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -238,7 +237,6 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createSuggestBadWord(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
suggestBadWordService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -320,27 +318,20 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<SuggestBadWord> createSuggestBadWord(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<SuggestBadWord> getEntity(final CreateForm form, final String username, final long 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);
return OptionalEntity.of(new SuggestBadWord()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return 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;
});
return suggestBadWordService.getSuggestBadWord(((EditForm) form).id);
}
break;
default:
@ -349,6 +340,17 @@ public class AdminSuggestbadwordAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<SuggestBadWord> createSuggestBadWord(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -224,7 +224,6 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createSuggestElevateWord(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
suggestElevateWordService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -238,7 +237,6 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createSuggestElevateWord(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
suggestElevateWordService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -320,27 +318,20 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<SuggestElevateWord> createSuggestElevateWord(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<SuggestElevateWord> getEntity(final CreateForm form, final String username, final long 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);
return OptionalEntity.of(new SuggestElevateWord()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return 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;
});
return suggestElevateWordService.getSuggestElevateWord(((EditForm) form).id);
}
break;
default:
@ -349,6 +340,17 @@ public class AdminSuggestelevatewordAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<SuggestElevateWord> createSuggestElevateWord(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
// ===================================================================================
// Small Helper
// ============

View file

@ -203,8 +203,6 @@ public class AdminUserAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createUser(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude("crudMode", "password", "confirmPassword"));
entity.setId(Base64.getEncoder().encodeToString(entity.getName().getBytes(Constants.CHARSET_UTF_8)));
userService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -219,8 +217,6 @@ public class AdminUserAction extends FessAdminAction {
validate(form, messages -> {}, toEditHtml());
//verifyPassword(form);
createUser(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude("crudMode", "password", "confirmPassword"));
entity.setId(Base64.getEncoder().encodeToString(entity.getName().getBytes(Constants.CHARSET_UTF_8)));
userService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -246,20 +242,11 @@ public class AdminUserAction extends FessAdminAction {
//===================================================================================
// Assist Logic
// ============
protected OptionalEntity<User> createUser(final CreateForm form) {
private OptionalEntity<User> getEntity(final CreateForm form) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final User entity = new User();
sessionManager.getAttribute(TEMPORARY_PASSWORD, String.class).ifPresent(password -> {
entity.setPassword(password);
});
return OptionalEntity.of(entity);
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return userService.getUser(((EditForm) form).id).map(entity -> {
return OptionalEntity.of(new User()).map(entity -> {
sessionManager.getAttribute(TEMPORARY_PASSWORD, String.class).ifPresent(password -> {
entity.setPassword(password);
});
@ -267,12 +254,25 @@ public class AdminUserAction extends FessAdminAction {
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return userService.getUser(((EditForm) form).id);
}
break;
default:
break;
}
return OptionalEntity.empty();
}
protected OptionalEntity<User> createUser(final CreateForm form) {
return getEntity(form).map(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
entity.setId(Base64.getEncoder().encodeToString(entity.getName().getBytes(Constants.CHARSET_UTF_8)));
return entity;
});
}
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);

View file

@ -194,7 +194,6 @@ public class AdminWebauthenticationAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createWebAuthentication(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
webAuthenticationService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -208,7 +207,6 @@ public class AdminWebauthenticationAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createWebAuthentication(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
webAuthenticationService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -234,27 +232,20 @@ public class AdminWebauthenticationAction extends FessAdminAction {
//===================================================================================
// Assist Logic
// ============
protected OptionalEntity<WebAuthentication> createWebAuthentication(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<WebAuthentication> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final WebAuthentication entity = new WebAuthentication();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new WebAuthentication()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return webAuthenticationService.getWebAuthentication(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return webAuthenticationService.getWebAuthentication(((EditForm) form).id);
}
break;
default:
@ -263,6 +254,17 @@ public class AdminWebauthenticationAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<WebAuthentication> createWebAuthentication(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
protected void registerProtocolSchemeItems(final RenderData data) {
final List<Map<String, String>> itemList = new ArrayList<Map<String, String>>();
final Locale locale = LaRequestUtil.getRequest().getLocale();

View file

@ -185,7 +185,6 @@ public class AdminWebconfigAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.CREATE);
validate(form, messages -> {}, toEditHtml());
createWebConfig(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
webConfigService.store(entity);
saveInfo(messages -> messages.addSuccessCrudCreateCrudTable(GLOBAL));
}).orElse(() -> {
@ -199,7 +198,6 @@ public class AdminWebconfigAction extends FessAdminAction {
verifyCrudMode(form.crudMode, CrudMode.EDIT);
validate(form, messages -> {}, toEditHtml());
createWebConfig(form).ifPresent(entity -> {
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
webConfigService.store(entity);
saveInfo(messages -> messages.addSuccessCrudUpdateCrudTable(GLOBAL));
}).orElse(() -> {
@ -225,27 +223,20 @@ public class AdminWebconfigAction extends FessAdminAction {
// ===================================================================================
// Assist Logic
// ============
protected OptionalEntity<WebConfig> createWebConfig(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
private OptionalEntity<WebConfig> getEntity(final CreateForm form, final String username, final long currentTime) {
switch (form.crudMode) {
case CrudMode.CREATE:
if (form instanceof CreateForm) {
final WebConfig entity = new WebConfig();
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return OptionalEntity.of(entity);
return OptionalEntity.of(new WebConfig()).map(entity -> {
entity.setCreatedBy(username);
entity.setCreatedTime(currentTime);
return entity;
});
}
break;
case CrudMode.EDIT:
if (form instanceof EditForm) {
return webConfigService.getWebConfig(((EditForm) form).id).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
return entity;
});
return webConfigService.getWebConfig(((EditForm) form).id);
}
break;
default:
@ -254,6 +245,17 @@ public class AdminWebconfigAction extends FessAdminAction {
return OptionalEntity.empty();
}
protected OptionalEntity<WebConfig> createWebConfig(final CreateForm form) {
final String username = systemHelper.getUsername();
final long currentTime = systemHelper.getCurrentTimeAsLong();
return getEntity(form, username, currentTime).map(entity -> {
entity.setUpdatedBy(username);
entity.setUpdatedTime(currentTime);
copyBeanToBean(form, entity, op -> op.exclude(Constants.COMMON_CONVERSION_RULE));
return entity;
});
}
protected void registerRolesAndLabels(final RenderData data) {
data.register("roleTypeItems", roleTypeService.getRoleTypeList());
data.register("labelTypeItems", labelTypeService.getLabelTypeList());