/** * estrae i metadati della cas e li associa all'oggetto Event. * * @param event event da salvare su hpm * @param cas oggetto cas */ private void addEventMetadata(final Event event, final JCas cas) { if (logger.isDebugEnabled()) { logger.debug("addEventMetadata - BEGIN"); } addEventMetadata("author", getUserAuthorAnnotation(cas).getEmail(), event); addEventMetadata("action-reference", getActionReferenceAnnotation(cas).getValue(), event); addEventMetadata("action-type", getActionTypeAnnotation(cas).getValue(), event); addEventMetadata("event-id", getEventIdAnnotation(cas).getValue(), event); SystemAnnotation systemAnnotation = getSystemAnnotation(cas); addEventMetadata("system-id", systemAnnotation.getSystemId(), event); addEventMetadata("system-type", systemAnnotation.getSystemType(), event); BodyAnnotation bodyAnnotation = getBodyAnnotation(cas); if (bodyAnnotation != null) { addEventMetadata("body-value", bodyAnnotation.getValue(), event); addEventMetadata("body-type", bodyAnnotation.getBodyType(), event); } addEventMetadata("creation-date", getDateCreationDateAnnotation(cas).getValue(), event); DetailsAnnotation detailsAnnotation = getDetailsAnnotation(cas); if (detailsAnnotation != null) { addEventMetadata("details", detailsAnnotation.getValue(), event); } addEventMetadata("title", getTitleAnnotation(cas).getValue(), event); logger.debug("addEventMetadata - END"); }
/** * 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); }