예제 #1
0
 private Map<String, Object> toStringRecord(Object o, String entityName) {
   Map<String, Object> words = new HashMap<>();
   PersistenceUnit pu = UPA.getPersistenceUnit();
   Record r =
       (o instanceof Record)
           ? ((Record) o)
           : pu.getEntity(entityName).getBuilder().objectToRecord(o, true);
   if (r != null) {
     for (Map.Entry<String, Object> entry : r.entrySet()) {
       String k = entry.getKey();
       Object v = entry.getValue();
       if (v != null) {
         Entity ve = pu.findEntity(v.getClass());
         if (ve != null) {
           Object mv = ve.getBuilder().getMainValue(v);
           String v2 = String.valueOf(mv);
           if (!StringUtils.isEmpty(v2)) {
             words.put(k, (v2));
           }
         } else if (v instanceof String) {
           if (!StringUtils.isEmpty(v.toString())) {
             words.put(k, (v));
           }
         } else {
           words.put(k, (v));
         }
       }
     }
   }
   return words;
 }
예제 #2
0
  public void startExec() {
    VrApp.getBean(VrNotificationSession.class).clear(CorePlugin.SEND_EXTERNAL_MAIL_QUEUE);
    SendExternalMailConfig c = new SendExternalMailConfig();
    c.setEmailType((RecipientType) getModel().getEmailType().getValue());
    Object value = getModel().getMailboxMessageFormat().getValue();
    if (value instanceof NamedId) {
      value =
          UPA.getPersistenceUnit().findById(MailboxMessageFormat.class, ((NamedId) value).getId());
    }
    MailboxMessageFormat mailboxMessageFormat = (MailboxMessageFormat) value;
    c.setTemplateId(mailboxMessageFormat == null ? null : mailboxMessageFormat.getId());

    //        core.runThread(new Runnable() {
    //            @Override
    //            public void run() {
    try {
      ArticlesItem obj = (ArticlesItem) VrApp.getBean(ObjCtrl.class).getCurrentEntityObject();
      mailbox.sendExternalMail(obj, VrUtils.formatJSONObject(c));
    } catch (Exception e) {
      FacesUtils.addErrorMessage(e.getMessage());
      e.printStackTrace();
    }
    //            }
    //        });
  }