示例#1
0
  @Override
  public Map<String, Object> referenceData(
      HttpServletRequest request, ReportDefinitionCommand command) {

    Map<String, Object> map = new LinkedHashMap<String, Object>();
    BeanWrapper wrappedCommand = new BeanWrapperImpl(command);

    // basic details tab fields
    TabWithFields<ReportDefinitionCommand> tab = getTabFromFlow(getFlow(), BasicsTab.class);
    Map<String, InputFieldGroup> fieldGroupMap = tab.createFieldGroups(command);
    InputFieldGroup fieldGroup = fieldGroupMap.get("reportDefinitionOrganization");
    List<Pair> fieldList = fetchFieldValues(fieldGroup, wrappedCommand);
    fieldGroup = fieldGroupMap.get("reportDefinitionFieldGroup"); // the name of the
    // fieldgroup
    fieldList.addAll(fetchFieldValues(fieldGroup, wrappedCommand));
    map.put(tab.getShortTitle(), fieldList);

    // report definition tab

    List<ReportDeliveryDefinition> deliveries =
        command.getReportDefinition().getDeliveryDefinitions();
    if (deliveries != null) {
      List<Pair> pairs = new ArrayList<Pair>();
      for (ReportDeliveryDefinition rdd : deliveries) {
        if (rdd.getEntityType() == ReportDeliveryDefinition.ENTITY_TYPE_PERSON) {
          Pair p = new Pair("Person", rdd.getEntityName());
          p.setAttribute1(rdd.getEndPoint());
          p.setAttribute2(rdd.getFormat().getDisplayName());
          pairs.add(p);
        }
        if (rdd.getEntityType() == ReportDeliveryDefinition.ENTITY_TYPE_ROLE) {
          Pair p = new Pair("Role", rdd.getEntityName());
          p.setAttribute1(String.valueOf(command.getRoles().get(rdd.getEndPoint())));
          p.setAttribute2(rdd.getFormat().getDisplayName());
          pairs.add(p);
        }
      }
      for (ReportDeliveryDefinition rdd : deliveries) {
        if (rdd.getEntityType() == ReportDeliveryDefinition.ENTITY_TYPE_SYSTEM) {
          Pair p = new Pair("System", rdd.getEntityName());
          p.setAttribute1(rdd.getEndPoint());
          p.setAttribute2(rdd.getFormat().getDisplayName());
          pairs.add(p);
        }
      }
      map.put("rdd", pairs);
    }

    // Mandatory Field Definition Tab
    tab = getTabFromFlow(getFlow(), ReportMandatoryFieldDefinitionTab.class);
    fieldGroupMap = tab.createFieldGroups(command);
    map.put("mandatoryFields", fieldGroupMap);

    // Notification details tab
    tab = getTabFromFlow(getFlow(), NotificationsTab.class);
    fieldGroupMap = tab.createFieldGroups(command);
    Map<String, Object> pnfMap = new LinkedHashMap<String, Object>();
    int i = 0;
    for (PlannedNotification nf : command.getReportDefinition().getPlannedNotifications()) {
      PlannedEmailNotification penf = (PlannedEmailNotification) nf;
      List<Pair> pairs = new ArrayList<Pair>();
      i++;

      // - recipient
      StringBuilder sb = new StringBuilder();
      for (Recipient r : penf.getRecipients()) {
        if (sb.length() > 0) sb.append(",");
        if (r instanceof RoleBasedRecipient) {
          sb.append(command.getRoles().get(r.getContact()));
        } else {
          sb.append(r.getContact());
        }
      }

      pairs.add(new Pair("Recipients", sb.toString()));

      // - subject
      pairs.add(new Pair("Subject", penf.getSubjectLine()));
      // - body
      NotificationBodyContent body = penf.getNotificationBodyContent();
      if (body != null) {
        pairs.add(new Pair("Message", body.getBody()));
      } else {
        pairs.add(new Pair("Message", null));
      }

      ReportDefinition rep = command.getReportDefinition();
      TimeScaleUnit unit = null;
      if (rep != null) {
        unit = rep.getTimeScaleUnitType();
      }
      if (unit != null) {
        pnfMap.put(
            "Notification " + i + " of " + unit.getDisplayName() + " " + penf.getIndexOnTimeScale(),
            pairs);
      } else {
        pnfMap.put("Notification " + i + " of UNKNOWN " + penf.getIndexOnTimeScale(), pairs);
      }
    }

    map.put("PENF", pnfMap);

    Map<String, Object> refDataMap = super.referenceData(command);
    refDataMap.put("FIELDS", map);
    return refDataMap;
  }
示例#2
0
 /*
  * (non-Javadoc)
  *
  * @see gov.nih.nci.cabig.ctms.web.tabs.Tab#postProcess(javax.servlet.http.HttpServletRequest,
  *      java.lang.Object, org.springframework.validation.Errors)
  */
 @Override
 public void postProcess(HttpServletRequest req, ReportDefinitionCommand nfCmd, Errors errors) {
   super.postProcess(req, nfCmd, errors);
 }