Exemplo 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();
 }
 @Override
 protected String doBuildRelationString(String dm) {
   StringBuilder sb = new StringBuilder();
   if (_member != null && _member.isPresent()) {
     sb.append(dm).append("member");
   }
   if (_product != null && _product.isPresent()) {
     sb.append(dm).append("product");
   }
   if (_purchasePaymentList != null && !_purchasePaymentList.isEmpty()) {
     sb.append(dm).append("purchasePaymentList");
   }
   if (sb.length() > dm.length()) {
     sb.delete(0, dm.length()).insert(0, "(").append(")");
   }
   return sb.toString();
 }
 @Override
 protected String doBuildStringWithRelation(String li) {
   StringBuilder sb = new StringBuilder();
   if (_member != null && _member.isPresent()) {
     sb.append(li).append(xbRDS(_member, "member"));
   }
   if (_product != null && _product.isPresent()) {
     sb.append(li).append(xbRDS(_product, "product"));
   }
   if (_purchasePaymentList != null) {
     for (PurchasePayment et : _purchasePaymentList) {
       if (et != null) {
         sb.append(li).append(xbRDS(et, "purchasePaymentList"));
       }
     }
   }
   return sb.toString();
 }
Exemplo n.º 4
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();
 }
Exemplo n.º 5
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();
 }
 protected <ET extends Entity> String xbRDS(org.dbflute.optional.OptionalEntity<ET> et, String name) { // buildRelationDisplayString()
     return et.get().buildDisplayString(name, true, true);
 }
 /**
  * [get] (商品)PRODUCT by my PRODUCT_ID, named 'product'. <br>
  * Optional: alwaysPresent(), ifPresent().orElse(), get(), ...
  *
  * @return The entity of foreign property 'product'. (NotNull, EmptyAllowed: when e.g. null FK
  *     column, no setupSelect)
  */
 public OptionalEntity<Product> getProduct() {
   if (_product == null) {
     _product = OptionalEntity.relationEmpty(this, "product");
   }
   return _product;
 }
 /**
  * [get] (会員)MEMBER by my MEMBER_ID, named 'member'. <br>
  * Optional: alwaysPresent(), ifPresent().orElse(), get(), ...
  *
  * @return The entity of foreign property 'member'. (NotNull, EmptyAllowed: when e.g. null FK
  *     column, no setupSelect)
  */
 public OptionalEntity<Member> getMember() {
   if (_member == null) {
     _member = OptionalEntity.relationEmpty(this, "member");
   }
   return _member;
 }