Esempio n. 1
0
 public OptionalEntity<DictionaryFile<? extends DictionaryItem>> getDictionaryFile(
     final String id) {
   for (final DictionaryFile<? extends DictionaryItem> dictFile : getDictionaryFiles()) {
     if (dictFile.getId().equals(id)) {
       return OptionalEntity.of(dictFile);
     }
   }
   return OptionalEntity.empty();
 }
Esempio n. 2
0
 // ===================================================================================
 //                                                                        Assist Logic
 //                                                                        ============
 private OptionalEntity<FileConfig> getEntity(
     final CreateForm form, final String username, final long currentTime) {
   switch (form.crudMode) {
     case CrudMode.CREATE:
       return OptionalEntity.of(new FileConfig())
           .map(
               entity -> {
                 entity.setCreatedBy(username);
                 entity.setCreatedTime(currentTime);
                 return entity;
               });
     case CrudMode.EDIT:
       if (form instanceof EditForm) {
         return fileConfigService.getFileConfig(((EditForm) form).id);
       }
       break;
     default:
       break;
   }
   return OptionalEntity.empty();
 }
Esempio n. 3
0
 // ===================================================================================
 //                                                                        Assist Logic
 //                                                                        ============
 private OptionalEntity<Role> getEntity(final CreateForm form) {
   switch (form.crudMode) {
     case CrudMode.CREATE:
       return OptionalEntity.of(new Role())
           .map(
               entity -> {
                 entity.setId(
                     Base64.getEncoder()
                         .encodeToString(form.name.getBytes(Constants.CHARSET_UTF_8)));
                 return entity;
               });
     case CrudMode.EDIT:
       if (form instanceof EditForm) {
         return roleService.getRole(((EditForm) form).id);
       }
       break;
     default:
       break;
   }
   return OptionalEntity.empty();
 }