Package evolaris.framework.async.datamodel

Examples of evolaris.framework.async.datamodel.Invocation


    SmsInteractionExecutionForm executionForm = (SmsInteractionExecutionForm)form;
   
    Long invocationId = executionForm.getId();
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
   
    Invocation invocation = smsDbManager.getInvocation(invocationId);
   
    if (invocation == null){
      throw new InputException(getResources(req).getMessage(locale, "sys.entryNotAvailable"),"id = " + executionForm.getId(),null,null);
    }
   
View Full Code Here


    SmsInteractionExecutionForm executionForm = (SmsInteractionExecutionForm)form;
   
    Long invocationId = executionForm.getId();
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
   
    Invocation invocation = smsDbManager.getInvocation(invocationId);
   
    if (invocation == null){
      throw new InputException(getResources(req).getMessage(locale, "sys.entryNotAvailable"),"id = " + executionForm.getId(),null,null);
    }

    LOGGER.info("processing sms service event #" + executionForm.getId() + " (Keyword: " + invocation.getKeywords() + "; group: " + invocation.getGroup().getGroupname() + ")");
   
    String msisdn = "";
    if(executionForm.getCountryCode() != null && executionForm.getCountryCode().trim().length() >= 1){
      msisdn = executionForm.getCountryCode();
    }

    if(executionForm.getMobileNumber() != null && executionForm.getMobileNumber().trim().length() >= 1){
      msisdn +=  Long.parseLong(executionForm.getMobileNumber()); //the convertion is used to cut the leading zero
    }
     
    // execute the commands 
    Set<CommandEntry> commandEntries = invocation.getCommandEntries();
    // table-driven action evaluation
    UserManager userManager = new UserManager(locale,session);
    User user = userManager.registerUserByMsisdn(Long.parseLong(msisdn), null, invocation.getGroup());
   
    InteractionLogManager interactionLogManager = new InteractionLogManager(locale, session);   
    EventParameters eventParameters = null;
   
    ReceivedSms receivedSms = new ReceivedSms();
    receivedSms.setSender(msisdn);
    receivedSms.setReceiver(invocation.getMsisdn() != null ? Long.toString(invocation.getMsisdn()) : "");
    receivedSms.setOperator("SIMULATOR");
    receivedSms.setContent(executionForm.getMessage());
    receivedSms.setSubject(executionForm.getMmsSubject());
    if (executionForm.getFile() != null && executionForm.getFile().getFileSize() > 0) {
      try {
View Full Code Here

    InteractionList interactionList = interactionListFromSession(req);

    // page title and information according to actual type; must be extended for additional types!
    MessageResources resources = getResources(req);
    if (interactionList instanceof Invocation) {
      Invocation invocation = (Invocation) interactionList;
      req.setAttribute("title",resources.getMessage(locale,"smssvc.EditServiceInteractions"));
      req.setAttribute("information1Title",resources.getMessage(locale,"smssvc.MSISDN") + " / " + resources.getMessage(locale,"smssvc.Keywords"));
      req.setAttribute("information1Value",invocation.getMsisdn() == null ? "" : (invocation.getMsisdn() + (invocation.getKeywords() == null ? "" : (" / " + invocation.getKeywords()))));
      req.setAttribute("information2Title",resources.getMessage(locale,"smssvc.ServiceId") + " / " + resources.getMessage(locale,"smssvc.Authentication"));
      req.setAttribute("information2Value",invocation.getServiceId() == null ? "" : (invocation.getServiceId() + (invocation.getAuthenticationKey() == null ? "" : (" / " + invocation.getAuthenticationKey()))));
      req.getSession().setAttribute("interactionListType", "invocation")// required for cancelling
    } else if (interactionList instanceof Fragment){
      Fragment fragment = (Fragment)interactionList;
      req.setAttribute("title",resources.getMessage(locale,"smssvc.EditFragmentInteractions"));
      req.setAttribute("information1Title", resources.getMessage(locale,"smssvc.FragmentName"));
View Full Code Here

   */
  @Override
  public EventParameters dummyEventParametersForList(HttpServletRequest req){
    InteractionList interactionList = interactionListFromSession(req);
    if (interactionList instanceof Invocation){  // used for services, SMS- and Email
      Invocation invocation = (Invocation)interactionList;
      if (invocation.getMsisdn() != null){
        return new SmsEventParameters(locale,session,null,null,null);
      }
      if (invocation.getEmail() != null){
        return new EmailEventParameters(locale,session,null,null,null);
      }
      return new ServiceEventParameters(locale,session,null,null,null);
    } else {
      return null// any types of parameters possible for fragment interactions
View Full Code Here

   */
  @Override
  public Invocation toEntry(Invocation invocation, Locale locale, Session session, MessageResources resources) {
    InvocationEnterOrEditForm f = this;
    if ((invocation == null)){
      invocation = new Invocation();
    }
    invocation.setId(f.getId());
    Date beginDateTime = getDateTime(f.getBeginDate(), f.getBeginTime(), true, locale, resources);
    Date endDateTime = getDateTime(f.getEndDate(), f.getEndTime(), false, locale, resources);
    invocation.setBeginAt(beginDateTime);
View Full Code Here

        ObjectMessage oMessage = (ObjectMessage)message;
        try {
          Object messageObject = oMessage.getObject();
          if(messageObject instanceof ReceivedMessage) {
            ReceivedMessage incomingMessage = (ReceivedMessage)messageObject;
            Invocation invocation = incomingMessage.getInvocation();
            Group group = invocation.getGroup()// group and group.clientProject must have been initialized (no lazy Hibernate loading possible here)
            Session session = HibernateSessions.startTransaction(getClass(),group.getId(),group.getClientProject().getHibernateConfigurationFile());
            try {
              session.load(invocation,invocation.getId())// reload because from different session; this may actually fail if the invocation entry was deleted

              UserManager userManager = new UserManager(Locale.GERMAN,session);
              User user;
              EventParameters eventParameters = null;
              InteractionLogManager interactionLogManager = new InteractionLogManager(Locale.GERMAN, session);
              InteractionLog log = new InteractionLog();

              if(messageObject instanceof ReceivedSms) {
                ReceivedSms sms = (ReceivedSms)messageObject;
                LOGGER.info("sms message: `" + sms.getContent() + "`; sender: " + sms.getSender() + "; invocationId: " + invocation.getId() + " (keyword=`" + invocation.getKeywords() + "`)");
                user = userManager.registerUserByMsisdn(Long.parseLong(sms.getSender()), sms.getOperator(), invocation.getGroup());
                eventParameters = new SmsEventParameters(Locale.GERMAN,session,user,invocation,sms);
                eventParameters.updateInteractionLog(log);
                interactionLogManager.writeInteractionLog(log);

              } else if(messageObject instanceof ReceivedEmail) {
                ReceivedEmail email = (ReceivedEmail)messageObject;
                LOGGER.info("email message: `" + email.getContent() + "`; subject: " + email.getSubject() + "`; sender: " + email.getEmailSender() + "; invocationId: " + invocation.getId() + " (keyword=`" + invocation.getKeywords() + "`)");
                user = userManager.registerUserByEmail(email.getEmailSender(), invocation.getGroup());
                eventParameters = new EmailEventParameters(Locale.GERMAN,session,user,invocation, email);
                eventParameters.updateInteractionLog(log);
                interactionLogManager.writeInteractionLog(log);
              } else {
                throw new BugException("unsupported message type: " + messageObject.getClass().getName());
              }

              interactionLogManager.writeInteractionLog(log);

              Set commandEntries = invocation.getCommandEntries();

              // table-driven action evaluation
              if (commandEntries.size() >= 1){
                EventVariables eventVariables = new EventVariables(eventParameters);
                MacroCommand macroCommand = new MacroCommand(eventParameters,eventVariables, commandEntries);
View Full Code Here

   *      javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward createIncludingInteractions(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp)  {
    InvocationEnterOrEditForm f = (InvocationEnterOrEditForm)form;
    Invocation oldInvocation = entryFromDatabase(f.getId());
    if (oldInvocation == null){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"));
    }
    checkAccessRights(req,oldInvocation.getGroup(),null);
    req.getSession().setAttribute("oldInteractionListId", oldInvocation.getId());
    Set<CommandEntry> commandEntries = oldInvocation.getCommandEntries();
    Invocation editedInvocation = f.toEntry(new Invocation(), locale, session, getResources(req));
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    req.getSession().setAttribute("newInteractionList", editedInvocation)// needed when we duplicate or come back
    smsDbManager.checkInvocationUniqueness(editedInvocation,false);
    smsDbManager.checkIfInvocationAllowed(editedInvocation,false);
   
    // mapping from command entries of the duplication source invocation
    MappingSet mappingSet = new MappingSet(commandEntries,editedInvocation.getGroup(), locale, session);
   
    req.getSession().setAttribute("mappingSet", mappingSet);
    req.getSession().setAttribute("destinationGroupId", editedInvocation.getGroup().getId());
    return mapping.findForward("duplicateIncludingInteractions");
  }
View Full Code Here

    InvocationEnterOrEditForm f = (InvocationEnterOrEditForm)form;
    Object newEntry = req.getSession().getAttribute("newInteractionList");
    if (newEntry == null || !(newEntry instanceof Invocation)){
      return mapping.findForward("cancelled");
    }
    Invocation invocation = (Invocation)newEntry;
    f.initialize(invocation,locale,session,getResources(req));
    prepareSelectionLists(form,req,invocation.getMsisdn(),invocation.getEmail());
    return mapping.findForward("continue");
  }
View Full Code Here

   
    Object oldInvocationId = req.getSession().getAttribute("oldInteractionListId");
    if (oldInvocationId == null || !(oldInvocationId instanceof Long)){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old invocation entry not found in session",null,null);
    }
    Invocation oldInvocation = new SmsDbManager(locale,session).getInvocation((Long)oldInvocationId);
    if (oldInvocation == null){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"old invocation entry #" + oldInvocationId + " not found",null,null);
    }
    checkAccessRights(req,oldInvocation.getGroup(),null);

    Object newEntry = req.getSession().getAttribute("newInteractionList");
    if (newEntry == null || !(newEntry instanceof Invocation)){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"new invocation entry not found in session",null,null);
    }
   
    // reload references in current session
    Invocation newInvocation = (Invocation)newEntry;
    f.initialize(newInvocation,locale,session,getResources(req));
    newInvocation = new Invocation();
    f.toEntry(newInvocation, locale, session, getResources(req));
    checkAccessRights(req, newInvocation.getGroup(),null);
   
    // group assignment is not editable => perform source to destination automatically
    mappingSet.add(new Entry(oldInvocation.getGroup()), new Entry(newInvocation.getGroup()));
   
    // Create duplicated command entries according to the original execution order
    CommandEntryManager commandEntryManager = new CommandEntryManager(locale,session);
    SortedSet<CommandEntry> newCommandEntries = new TreeSet<CommandEntry>(new CommandEntryManager.CommandEntryComparator());
    Set<CommandEntry> oldCommandEntries = oldInvocation.getCommandEntries();
    SortedSet<CommandEntry> sortedOldCommandEntries = new TreeSet<CommandEntry>(new CommandEntryManager.CommandEntryComparator());
    sortedOldCommandEntries.addAll(oldCommandEntries);
    for (CommandEntry oldCommandEntry : sortedOldCommandEntries) {
      CommandEntryExtender extender = commandEntryManager.createCommandEntryExtender(oldCommandEntry);
      CommandEntry duplicatedCommandEntry = extender.duplicateCommandEntry(newInvocation.getGroup(),mappingSet);
      Set<InteractionList> invocations = new TreeSet<InteractionList>();
      invocations.add(newInvocation);
      duplicatedCommandEntry.setInteractionLists(invocations);
      commandEntryManager.create(duplicatedCommandEntry)// also sets the ID for sorting
      newCommandEntries.add(duplicatedCommandEntry);
    }
    newInvocation.setCommandEntries(newCommandEntries);
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    smsDbManager.createInvocation(newInvocation);
     return mapping.findForward("duplicated");
  }
View Full Code Here

   */
  @Override
  protected ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse resp) {
    ActionForward actionForward = super.edit(mapping, form, req, resp);
    InvocationEnterOrEditForm f = (InvocationEnterOrEditForm)form;
    Invocation entry = entryFromDatabase(f.getId());
    prepareSelectionLists(form,req,entry.getMsisdn(),entry.getEmail());
    return actionForward;
  }
View Full Code Here

TOP

Related Classes of evolaris.framework.async.datamodel.Invocation

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.