예제 #1
0
  /**
   * Adds the scheduled notifications.
   *
   * @param reportDefinition the report definition
   * @param report the report
   */
  public void addScheduledNotifications(ReportDefinition reportDefinition, Report report) {
    // Note : there is a change in busineess requirement, that at firing time only we generate the
    // message/recipients
    // So only one Scheduled Notification per Planned Notification.
    if (CollectionUtils.isEmpty(reportDefinition.getPlannedNotifications())) return;

    Date now = nowFactory.getNow();
    Calendar cal = GregorianCalendar.getInstance();

    for (PlannedNotification plannedNotification : reportDefinition.getPlannedNotifications()) {
      ScheduledNotification scheduledNotification =
          plannedNotification.createScheduledNotification("dummy");

      if (plannedNotification instanceof PlannedEmailNotification) {
        ScheduledEmailNotification scheduledEmailNotification =
            (ScheduledEmailNotification) scheduledNotification;
        scheduledEmailNotification.setBody("dummy");
        scheduledEmailNotification.setSubjectLine("dummy");
      }

      // set the scheduled dates
      if (reportDefinition.getBaseDate() != null) cal.setTime(reportDefinition.getBaseDate());
      else cal.setTime(now);
      cal.add(
          reportDefinition.getTimeScaleUnitType().getCalendarTypeCode(),
          plannedNotification.getIndexOnTimeScale());
      scheduledNotification.setScheduledOn(cal.getTime());
      if (plannedNotification.getIndexOnTimeScale() == 0
          || DateUtils.compateDateAndTime(now, cal.getTime()) < 0)
        report.addScheduledNotification(scheduledNotification);
    }
  }
예제 #2
0
 /* (non-Javadoc)
  * @see java.lang.Object#toString()
  */
 public String toString() {
   StringBuilder sb = new StringBuilder("ReportDefintionWrapper [");
   sb.append(def.getName());
   if (substitute != null) {
     sb.append(" => ").append(substitute.getName());
   }
   sb.append(", ").append(String.valueOf(action));
   sb.append("]");
   return sb.toString();
 }
예제 #3
0
  /**
   * Creates a new Report object.
   *
   * @param reportDefinition the report definition
   * @param aeReport the ae report
   * @param baseDate the base date
   * @return the report
   */
  public Report createReport(
      final ReportDefinition reportDefinition,
      final ExpeditedAdverseEventReport aeReport,
      Date baseDate) {
    assert reportDefinition != null
        : "ReportDefinition must be not null. Unable to create a Report";
    assert aeReport != null
        : "ExpeditedAdverseEventReport should not be null. Unable to create a Report";

    Date now = nowFactory.getNow();

    Report report = reportDefinition.createReport();
    report.setCreatedOn(now);
    Date dueDate = reportDefinition.getExpectedDueDate(baseDate == null ? now : baseDate);
    report.setDueOn(dueDate);
    report.getLastVersion().setReportVersionId("0"); // default
    report.getLastVersion().setAmendmentNumber(new Integer(0));
    // attach the aeReport to report
    aeReport.addReport(report);

    addScheduledNotifications(reportDefinition, report);
    return report;
  }
예제 #4
0
  /**
   * Gets the readable message.
   *
   * @return the readable message
   */
  public String getReadableMessage() {
    StringBuilder sb = new StringBuilder();

    if (action == ActionType.AMEND) {
      sb.append("Amend ").append(def.getLabel());
      if (substitute != null) {
        sb.append(" with ").append(substitute.getLabel());
      }
    } else if (action == ActionType.WITHDRAW) {
      sb.append("Withdraw ").append(def.getLabel());
      if (substitute != null) {
        sb.append(" and replace with ").append(substitute.getLabel());
      }
    } else if (action == ActionType.EDIT) {
      sb.append("Edit ").append(def.getLabel());
    } else if (action == ActionType.CREATE) {
      sb.append("Create ").append(def.getLabel());
    }

    return sb.toString();
  }
예제 #5
0
파일: ReviewTab.java 프로젝트: gopuv/caaers
  @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;
  }
예제 #6
0
 /**
  * The logic for comparing these reports definitons is reverse in the sense that, lesser is the
  * period of reporting, higher is the priority In other words, we are comparing the priorties
  */
 public int compare(ReportDefinition o1, ReportDefinition o2) {
   long l1 = o1.getTimeScaleUnitType().getMilliSecondConversionFactor() * o1.getDuration();
   long l2 = o2.getTimeScaleUnitType().getMilliSecondConversionFactor() * o2.getDuration();
   return (int) (l2 - l1);
 }
예제 #7
0
 /* (non-Javadoc)
  * @see java.lang.Object#hashCode()
  */
 @Override
 public int hashCode() {
   return def.hashCode();
 }
예제 #8
0
 /* (non-Javadoc)
  * @see java.lang.Object#equals(java.lang.Object)
  */
 @Override
 public boolean equals(Object obj) {
   return def.equals(obj);
 }