Package evolaris.framework.async.datamodel

Examples of evolaris.framework.async.datamodel.Fragment


    long[] sourceFragmentIds = f.getSourceFragmentIds();
    if (sourceFragmentIds != null){  // at least one mapping
      long[] selectedFragmentIds = f.getSelectedFragmentIds();
      for (int i = 0; i < sourceFragmentIds.length; i++){
        long sourceFragmentId = sourceFragmentIds[i];
        Fragment sourceFragment = smsDbManager.getFragment(sourceFragmentId);
        if (sourceFragment == null){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SourceFragmentNotAvailableAnymore"),"fragment #" + sourceFragmentId + " not found",null,null);
        }
        checkAccessRights(req,sourceFragment.getGroup());
        long selectedFragmentId = selectedFragmentIds[i];
        if (selectedFragmentId <= 0){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.FragmentMappingSelectionMissing"),"sourceFragmentId = " + sourceFragmentId,null,null);
        }
        Fragment selectedFragment = smsDbManager.getFragment(selectedFragmentId);
        if (selectedFragment == null){
          throw new InputException(getResources(req).getMessage(locale, "smssvc.SelectedFragmentNotAvaliableAnymore"),"fragment #" + selectedFragmentId + " not found",null,null);
        }
        checkAccessRights(req,selectedFragment.getGroup());
        mappingSet.add(new Entry(sourceFragment), new Entry(selectedFragment));
      }
    }
   
    req.getSession().setAttribute("mappingSet", mappingSet);
View Full Code Here


   *      javax.servlet.http.HttpServletRequest,
   *      javax.servlet.http.HttpServletResponse)
   */
  public ActionForward createIncludingInteractions(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp)  {
    FragmentEnterOrEditForm f = (FragmentEnterOrEditForm)form;
    Fragment oldFragment = entryFromDatabase(f.getId());
    if (oldFragment == null){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"));
    }
    checkAccessRights(req,oldFragment.getGroup(),null);
    req.getSession().setAttribute("oldInteractionListId", oldFragment.getId());
    Set<CommandEntry> commandEntries = oldFragment.getCommandEntries();
    Fragment editedFragment = f.toEntry(new Fragment(), locale, session, getResources(req));
   
    // check for fragment with the same name already here to avoid error messages after selecting the mapping
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    Fragment existingFragment = smsDbManager.getFragment(f.getName(),editedFragment.getGroup());
    if (existingFragment != null){
      throw new InputException(MessageFormat.format(ResourceBundle.getBundle("SmsServices", locale).getString("FragmentP0AlreadyExists"),f.getName()));
    }

    req.getSession().setAttribute("newInteractionList", editedFragment)// needed when we duplicate or come back
View Full Code Here

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

    Object newEntry = req.getSession().getAttribute("newInteractionList");
    if (newEntry == null || !(newEntry instanceof Fragment)){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"),"new fragment entry not found in session",null,null);
    }
   
    // reload references in current session
    Fragment newFragment = (Fragment)newEntry;
    f.initialize(newFragment,locale,session,getResources(req));
    newFragment = new Fragment();
    f.toEntry(newFragment, locale, session, getResources(req));
    checkAccessRights(req, newFragment.getGroup(),null);
   
    // group assignment is not editable => perform source to destination automatically
    mappingSet.add(new Entry(oldFragment.getGroup()), new Entry(newFragment.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 = oldFragment.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(newFragment.getGroup(),mappingSet);
      Set<InteractionList> fragments = new TreeSet<InteractionList>();
      fragments.add(newFragment);
      duplicatedCommandEntry.setInteractionLists(fragments);
      commandEntryManager.create(duplicatedCommandEntry)// also sets the ID for sorting
      newCommandEntries.add(duplicatedCommandEntry);
    }
    newFragment.setCommandEntries(newCommandEntries);
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    smsDbManager.createFragment(newFragment);
     return mapping.findForward("duplicated");
  }
View Full Code Here

   * Inlines fragment interactions and delete the fragment
   * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
   */
  protected ActionForward inline(ActionMapping mapping, ActionForm form,HttpServletRequest req, HttpServletResponse resp){
    FragmentEnterOrEditForm f = (FragmentEnterOrEditForm)form;
    Fragment fragment = entryFromDatabase(f.getId());
    if (fragment == null){
      throw new InputException(getResources(req).getMessage(locale, "admin.entryNotAvailable"));
    }
    checkAccessRights(req,fragment.getGroup(),fragment);
    // TODO
    return mapping.findForward("deleted");
  }
View Full Code Here

      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"));
      req.setAttribute("information1Value",fragment.getFragmentName());
      req.setAttribute("information2Title", null)// second line not used
      req.getSession().setAttribute("interactionListType", "fragment")// required for cancelling
    } else {
      throw new BugException("can't do anything with list of type: " + interactionList.getClass().getName());
    }
View Full Code Here

   */
  public void initialize(FragmentCommandEntry entry, Locale locale, Session session, MessageResources resources) {
    FragmentInteractionEnterOrEditForm f = this;
    f.setCommandEntryId(entry.getId());
    f.setSortLabel(entry.getSortLabel());
    Fragment fragment = entry.getFragment();
    f.setFragmentId(fragment == null ? -1 : fragment.getId());
    f.setOperationPrefix(entry.getOperationPrefix());
  }
View Full Code Here

    if (f.getSortLabel() == null ||  f.getSortLabel().equals("")){
      throw new InputException(resources.getMessage(locale, "smssvc.labelMustBeProvided"));
    }
    entry.setSortLabel(f.getSortLabel());
    SmsDbManager smsDbManager = new SmsDbManager(locale,session);
    Fragment fragment = smsDbManager.getFragment(f.getFragmentId());
    if (fragment == null || fragment.getGroup() != entry.getGroup()){
      throw new InputException(resources.getMessage(locale, "smssvc.selectedFragmentDoesNotExistAnymore"));
    }
    entry.setFragment(fragment);
    entry.setOperationPrefix(f.getOperationPrefix().trim().length() == 0 ? null : f.getOperationPrefix());
    return entry;
View Full Code Here

   */
  @Override
  public Fragment toEntry(Fragment fragment, Locale locale, Session session, MessageResources resources) {
    FragmentEnterOrEditForm f = this;
    if ((fragment == null)){
      fragment = new Fragment();
    }
    fragment.setId(f.getId());
    fragment.setFragmentName(f.getName());
    fragment.setDescription(f.getDescription() == null || f.getDescription().trim().length() == 0 ? null : f.getDescription());
    GroupManager groupMgr = new GroupManager(locale, session);
View Full Code Here

      }
     
      // expand and check fragments and include if required
      if (commandEntry instanceof FragmentCommandEntry){
        FragmentCommandEntry fragmentCommandEntry = (FragmentCommandEntry)commandEntry;
        Fragment fragment = fragmentCommandEntry.getFragment();
        if (expandFragments){
          interaction.setInteractionDescription(((FragmentCommandEntryExtender) commandEntryExtender).readableCommandDescription(req,false))// do not show operation prefix, because it will be visible in the embedded entries
        }
        SortedSet<CommandEntry> sortedFragmentCommandEntries = CommandEntryManager.sortedCommandEntries(fragment.getCommandEntries());
        String addedOperationPrefix = fragmentCommandEntry.getOperationPrefix();
        String combinedOperationPrefix = operationPrefix == null ? addedOperationPrefix : (operationPrefix + (addedOperationPrefix == null ? "" : addedOperationPrefix));
        nestedInteractionList = subInteractionList(req, group, sortedFragmentCommandEntries,isFragment, expandFragments, withinLoop, contactAvailable, combinedOperationPrefix,
            indentation, new SortLabelStack(sortLabelStack,sortLabel));
        if (nestedInteractionList == null){
View Full Code Here

TOP

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

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.