Exemplo n.º 1
0
  /**
   * Esegue il process nel caso default.
   *
   * @param cas cas
   * @throws SQLException errore nel salvataggio
   */
  private void processDefaultCas(final JCas cas) throws SQLException {
    //      recupero le annotations presenti nella CAS
    String eventId = getEventIdAnnotation(cas).getValue();

    SystemAnnotation systemAnnotation = getSystemAnnotation(cas);
    String systemId = systemAnnotation.getSystemId();

    String title = getTitleAnnotation(cas).getValue();

    //      costruisco l'oggetto Hpm Event
    Event event = new Event();
    event.setHpmEventId(eventId);
    event.setHpmSystemId(systemId);

    //      associa all'oggetto Event i suoi metadati
    addEventMetadata(event, cas);

    //      aggiunge le proprietà
    addProperties(event, cas);

    String actionType = getActionTypeAnnotation(cas).getValue();

    if (checkValidAction(actionType)) {
      Email email = new Email();
      email.setAttachmentType(new AttachmentType(1));

      addEmailTo(email, cas);
      addEmailCc(email, cas);
      addEmailCcn(email, cas);
      addEmailFrom(email, cas);

      email.setEmailObject(title);
      email.setEmailBody(getEmailBody(cas));
      event.getAttachments().add(email);

      addDocuments(event, email, cas);
    } else {
      addDocuments(event, null, cas);
    }

    HpmDao dao = new HpmDao();
    dao.saveEventManager(event);
  }
Exemplo n.º 2
0
  /**
   * Imposta il campo fieldTo per l'oggetto Email.
   *
   * @param email email da popolare
   * @param cas cas da cui estrarre le annotations
   */
  private void addEmailTo(final Email email, final JCas cas) {

    Type annotationType =
        cas.getTypeSystem().getType(UserReceiverToAnnotation.class.getCanonicalName());
    FSIterator<Annotation> it = cas.getAnnotationIndex(annotationType).iterator();

    //  uso la mappa per evitare l'inserimento di email duplicate
    Hashtable<String, String> emailMap = new Hashtable<String, String>();

    while (it.hasNext()) {
      UserReceiverToAnnotation ann = (UserReceiverToAnnotation) it.next();
      emailMap.put(ann.getEmail(), "Y");
    }

    Enumeration<String> en = emailMap.keys();
    while (en.hasMoreElements()) {
      String element = en.nextElement();
      email.getEmailTo().add(element);
    }
  }
Exemplo n.º 3
0
  /**
   * aggiunge oggetti di tipo Document all'event. Nel caso di Communication associo anche la email
   * ai documenti.
   *
   * @param event oggetto a cui associare i Document
   * @param email email da salvare
   * @param cas cas da elaborare
   */
  private void addDocuments(final Event event, final Email email, final JCas cas) {

    AnnotationIndex<Annotation> aaIdx = cas.getAnnotationIndex(AttachmentAnnotation.type);
    FSIterator<Annotation> itAa = aaIdx.iterator();
    while (itAa.hasNext()) {
      AttachmentAnnotation aa = (AttachmentAnnotation) itAa.next();

      Document document = new Document();
      document.setAttachmentType(new AttachmentType(2));
      document.setGuid(aa.getUrlAttachment());
      document.setHashcode(aa.getHashcode());
      document.setAuthor(aa.getAuthor());
      document.setTemplate(false);
      document.setHpmAttachmentId(aa.getId());
      document.setName(aa.getAttachmentName());

      event.getAttachments().add(document);

      //          associo il documento alla mail (per il legame EMAIL-DOCUMENT)
      if (email != null) {
        email.getDocuments().add(document);
      }
    }
  }