Package com.agiletec.plugins.jpwebdynamicform.aps.system.services.message.model

Examples of com.agiletec.plugins.jpwebdynamicform.aps.system.services.message.model.MessageTypeNotifierConfig


  }

  public void testSave() throws Throwable {
    ConfigInterface configManager = (ConfigInterface) this.getService(SystemConstants.BASE_CONFIG_MANAGER);
    String originaryConfig = configManager.getConfigItem(JpwebdynamicformSystemConstants.MESSAGE_NOTIFIER_CONFIG_ITEM);
    MessageTypeNotifierConfig orginaryComConfig = this._messageManager.getNotifierConfig("COM");
    try {
      Map<String, Object> params = new HashMap<String, Object>();
      params.put("typeCode", "PER");
      params.put("store", "true");
      params.put("mailAttrName", "eMail");
      params.put("notifiable", "true");
      params.put("senderCode", "CODE1");
      params.put("bodyModel", "Mail Body");
      params.put("subjectModel", "Mail Subject");
      String[] recipientsTo = new String[] { "indirizzo1@inesistente.it" };
      String[] recipientsCc = new String[] { "indirizzo2@inesistente.it", "indirizzo3@inesistente.it" };
      String[] recipientsBcc = new String[] { "indirizzo1@inesistente.it", "indirizzo2@inesistente.it" };
      String result = this.executeSave("admin", params, recipientsTo, recipientsCc, recipientsBcc);
      assertEquals(Action.SUCCESS, result);
      String newConfig = configManager.getConfigItem(JpwebdynamicformSystemConstants.MESSAGE_NOTIFIER_CONFIG_ITEM);
      assertFalse(newConfig.equals(originaryConfig));
      MessageTypeNotifierConfig newComConfig = this._messageManager.getNotifierConfig("COM");
      this.checkConfigs(orginaryComConfig, newComConfig);

      MessageTypeNotifierConfig newPerConfig = this._messageManager.getNotifierConfig("PER");
      assertEquals("PER", newPerConfig.getTypeCode());
      assertTrue(newPerConfig.isStore());
      assertEquals("eMail", newPerConfig.getMailAttrName());
      assertTrue(newPerConfig.isNotifiable());
      assertEquals("CODE1", newPerConfig.getSenderCode());
      MessageModel model = newPerConfig.getMessageModel();
      assertEquals("Mail Body", model.getBodyModel());
      assertEquals("Mail Subject", model.getSubjectModel());
      this.checkStrings(recipientsTo, newPerConfig.getRecipientsTo());
      this.checkStrings(recipientsCc, newPerConfig.getRecipientsCc());
      this.checkStrings(recipientsBcc, newPerConfig.getRecipientsBcc());
    } catch (Throwable t) {
      throw t;
    } finally {
      configManager.updateConfigItem(JpwebdynamicformSystemConstants.MESSAGE_NOTIFIER_CONFIG_ITEM, originaryConfig);
    }
View Full Code Here


    this.checkOriginaryConfig(newConfig);
  }
 
  private void checkOriginaryConfig(Map<String, MessageTypeNotifierConfig> config) {
    assertEquals(2, config.size());
    MessageTypeNotifierConfig config1 = config.get("PER");
    assertEquals("PER", config1.getTypeCode());
    assertTrue(config1.isStore());
    assertEquals("CODE1", config1.getSenderCode());
    assertEquals("eMail", config1.getMailAttrName());
    assertEquals(2, config1.getRecipientsTo().length);
    assertEquals(1, config1.getRecipientsCc().length);
    assertEquals(1, config1.getRecipientsBcc().length);
   
    assertNotNull(config1.getMessageModel());
   
    MessageTypeNotifierConfig config2 = config.get("COM");
    assertEquals("COM", config2.getTypeCode());
    assertFalse(config2.isStore());
    assertEquals("CODE2", config2.getSenderCode());
    assertEquals("eMail", config2.getMailAttrName());
    assertEquals(3, config2.getRecipientsTo().length);
    assertEquals(2, config2.getRecipientsCc().length);
    assertEquals(1, config2.getRecipientsBcc().length);
   
    MessageModel messageModelIt = config2.getMessageModel();
    assertEquals("Corpo della mail COM", messageModelIt.getBodyModel());
    assertEquals("Oggetto della mail COM", messageModelIt.getSubjectModel());
  }
View Full Code Here

  public Map<String, MessageTypeNotifierConfig> extractConfig(String xml) throws ApsSystemException {
    Map<String, MessageTypeNotifierConfig> config = new HashMap<String, MessageTypeNotifierConfig>();
    Element root = this.getRootElement(xml);
    List<Element> messageTypeElements = root.getChildren(MESSAGETYPE_ELEM);
    for (Element messageTypeElem : messageTypeElements) {
      MessageTypeNotifierConfig messageTypeConfig = this.extractMessageTypeNotifierConfig(messageTypeElem);
      config.put(messageTypeConfig.getTypeCode(), messageTypeConfig);
    }
    return config;
  }
View Full Code Here

    String xml = new XMLOutputter().outputString(doc);
    return xml;
  }
 
  protected MessageTypeNotifierConfig extractMessageTypeNotifierConfig(Element messageTypeElem) {
    MessageTypeNotifierConfig messageTypeConfig = new MessageTypeNotifierConfig();
   
    String typeCode = messageTypeElem.getAttributeValue(MESSAGETYPE_TYPECODE_ATTR);
    messageTypeConfig.setTypeCode(typeCode);
   
    String store = messageTypeElem.getAttributeValue(MESSAGETYPE_STORE_ATTR);
    messageTypeConfig.setStore(store == null || "true".equalsIgnoreCase(store));
   
    String mailAttrName = messageTypeElem.getAttributeValue(MESSAGETYPE_MAILATTRNAME_ATTR);
    messageTypeConfig.setMailAttrName(mailAttrName);
   
    String notifiable = messageTypeElem.getAttributeValue(MESSAGETYPE_NOTIFIABLE_ATTR);
    messageTypeConfig.setNotifiable(notifiable == null || "true".equalsIgnoreCase(notifiable));
   
    String senderCode = messageTypeElem.getAttributeValue(MESSAGETYPE_SENDERCODE_ATTR);
    messageTypeConfig.setSenderCode(senderCode);
   
    Element recipentsElem = messageTypeElem.getChild(RECIPIENTS_ELEM);
    messageTypeConfig.setRecipientsTo(this.extractRecipients(recipentsElem, RECIPIENTS_TO_CHILD));
    messageTypeConfig.setRecipientsCc(this.extractRecipients(recipentsElem, RECIPIENTS_CC_CHILD));
    messageTypeConfig.setRecipientsBcc(this.extractRecipients(recipentsElem, RECIPIENTS_BCC_CHILD));
   
    Element modelElem = messageTypeElem.getChild(MODEL_ELEM);
    MessageModel messageModel = this.extractMessageModel(modelElem);
    messageTypeConfig.setMessageModel(messageModel);
   
    return messageTypeConfig;
  }
View Full Code Here

  @Override
  public String edit() {
    try {
      String typeCode = this.getTypeCode();
      if (this.getMessageManager().getSmallMessageTypesMap().get(typeCode)!=null) {
        MessageTypeNotifierConfig config = this.getMessageManager().getNotifierConfig(typeCode);
        this.populateForm(config);
      } else {
        this.addActionError(this.getText("Errors.messageType.notExistant", new String[] { typeCode }));
        return "wrongType";
      }
View Full Code Here

  @Override
  public String save() {
    try {
      String typeCode = this.getTypeCode();
      if (this.getMessageManager().getSmallMessageTypesMap().get(typeCode)!=null) {
        MessageTypeNotifierConfig config = this.prepareConfig();
        this.getMessageManager().saveNotifierConfig(config);
      } else {
        this.addActionError(this.getText("Errors.messageType.notExistant", new String[] { typeCode }));
        return "wrongType";
      }
View Full Code Here

      }
    }
  }
 
  private MessageTypeNotifierConfig prepareConfig() {
    MessageTypeNotifierConfig config = new MessageTypeNotifierConfig();
    config.setTypeCode(this.getTypeCode());
    config.setSenderCode(this.getSenderCode());
    config.setMailAttrName(this.getMailAttrName());
    Boolean store = this.getStore();
    config.setStore(store!=null && store.booleanValue());
    Boolean notifiable = this.getNotifiable();
    config.setNotifiable(notifiable!=null && notifiable.booleanValue());
    config.setRecipientsTo(this.convertRecipients(this.getRecipientsTo()));
    config.setRecipientsCc(this.convertRecipients(this.getRecipientsCc()));
    config.setRecipientsBcc(this.convertRecipients(this.getRecipientsBcc()));
   
    MessageModel messageModel = new MessageModel();
    messageModel.setSubjectModel(this.getSubjectModel());
    messageModel.setBodyModel(this.getBodyModel());
    config.setMessageModel(messageModel);
   
    return config;
  }
View Full Code Here

          String typeCode = event.getOldEntityType().getTypeCode();
          this.removeNotifierConfig(typeCode);
          ApsSystemUtils.getLogger().trace("Removed notifier configuration for entity type " + typeCode);
          break;
        case EntityTypesChangingEvent.INSERT_OPERATION_CODE:
          MessageTypeNotifierConfig config = new MessageTypeNotifierConfig();
          config.setTypeCode(event.getNewEntityType().getTypeCode());
          config.setStore(true);
          this.saveNotifierConfig(config);
          break;
        default:
          break;
        }
View Full Code Here

    this._smallMessageTypes = smallMessageTypes;
  }

  @Override
  public String getMailAttributeName(String typeCode) {
    MessageTypeNotifierConfig config = this.getNotifierConfig(typeCode);
    String mailAttrName = null;
    if (config != null) {
      mailAttrName = config.getMailAttrName();
    }
    return mailAttrName;
  }
View Full Code Here

  }

  @Override
  public void addMessage(Message message) throws ApsSystemException {
    try {
      MessageTypeNotifierConfig config = this.getNotifierConfig(message.getTypeCode());
      if (config == null || config.isStore()) {
        int key = this.getKeyGeneratorManager().getUniqueKeyCurrentValue();
        String id = message.getTypeCode() + key;
        message.setId(id);
        this.getMessageDAO().addEntity(message);
      }
View Full Code Here

TOP

Related Classes of com.agiletec.plugins.jpwebdynamicform.aps.system.services.message.model.MessageTypeNotifierConfig

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.