@Override public void executeWorkItem(WorkItem workItem, WorkItemManager manager) { to = (String) workItem.getParameter("To"); from = (String) workItem.getParameter("From"); subject = (String) workItem.getParameter("Subject"); body = (String) workItem.getParameter("Body"); System.out.println("===================================="); System.out.println("Executing Email task: " + workItem); System.out.println("From: " + from); System.out.println("To: " + to); System.out.println("Subject: " + subject); System.out.println("Body: " + body); System.out.println("===================================="); // Assuming you are sending email from localhost String host = "localhost"; // Get system properties Properties properties = System.getProperties(); // Setup mail server properties.setProperty("mail.smtp.host", host); // Get the default Session object. Session session = Session.getDefaultInstance(properties); try { // Create a default MimeMessage object. MimeMessage message = new MimeMessage(session); // Set From: header field of the header. message.setFrom(new InternetAddress(from)); // Set To: header field of the header. message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); // Set Subject: header field message.setSubject(subject); // Now set the actual message message.setText(body); // Send message Transport.send(message); System.out.println("Sent message successfully...."); } catch (MessagingException mex) { mex.printStackTrace(); } manager.completeWorkItem(workItem.getId(), workItem.getResults()); }
/** * OIG exclusion screening. * * @param item the work item to abort * @param manager the work item manager */ public void executeWorkItem(WorkItem item, WorkItemManager manager) { log.log(Level.INFO, "Checking provider exclusion."); EnrollmentProcess processModel = (EnrollmentProcess) item.getParameter("model"); ProviderInformationType provider = XMLUtility.nsGetProvider(processModel); ScreeningResultsType screeningResults = XMLUtility.nsGetScreeningResults(processModel); ScreeningResultType screeningResultType = new ScreeningResultType(); screeningResults.getScreeningResult().add(screeningResultType); ExternalSourcesScreeningResultType results = null; try { OIGExclusionSearchClient client = new OIGExclusionSearchClient(); results = client.verify(XMLUtility.nsGetProvider(processModel)); VerificationStatusType verificationStatus = XMLUtility.nsGetVerificationStatus(processModel); if (!results.getSearchResults().getSearchResultItem().isEmpty()) { OIGExclusionServiceMatcher matcher = new OIGExclusionServiceMatcher(); MatchStatus status = matcher.match(provider, null, results); if (status == MatchStatus.EXACT_MATCH) { verificationStatus.setNonExclusion("N"); } else { verificationStatus.setNonExclusion("Y"); } } else { verificationStatus.setNonExclusion("Y"); } } catch (TransformerException e) { log.log(Level.ERROR, e); results = new ExternalSourcesScreeningResultType(); results.setStatus(XMLUtility.newStatus("ERROR")); } catch (JAXBException e) { log.log(Level.ERROR, e); results = new ExternalSourcesScreeningResultType(); results.setStatus(XMLUtility.newStatus("ERROR")); } catch (IOException e) { log.log(Level.ERROR, e); results = new ExternalSourcesScreeningResultType(); results.setStatus(XMLUtility.newStatus("ERROR")); } screeningResultType.setExclusionVerificationResult(results.getSearchResults()); screeningResultType.setScreeningType("EXCLUDED PROVIDERS"); screeningResultType.setStatus(XMLUtility.newStatus("SUCCESS")); item.getResults().put("model", processModel); manager.completeWorkItem(item.getId(), item.getResults()); }
@Override public void executeWorkItem(WorkItem workItem, WorkItemManager manager) { String url = HandlerUtils.getFirstTypedParameter(workItem.getParameters(), String.class); try { if (url == null) throw new Exception("No URL given"); DocumentInformation docInfo = docManager.getDocumentInformation(workItem); if (docInfo == null) throw new Exception("No document associated with this workflow"); Theo theo = docInfo.getTheo(); int theoOutput = theo.openWindow(docInfo, workItem.getProcessInstanceId(), "", url, 700, 600); workItem.getResults().put("wndIDOutput", theoOutput); } catch (Exception e) { log.error(e.getMessage()); e.printStackTrace(); } finally { manager.completeWorkItem(workItem.getId(), workItem.getResults()); } }
/* (non-Javadoc) * @see org.drools.runtime.process.WorkItemHandler#executeWorkItem(org.drools.runtime.process.WorkItem, org.drools.runtime.process.WorkItemManager) */ @Override public void executeWorkItem(WorkItem workItem, WorkItemManager manager) { CustomerAddressBP bp = new CustomerAddressBP(); Customer customer = new Customer( (String) workItem.getParameter("save_FirstName"), (String) workItem.getParameter("save_LastName"), (String) workItem.getParameter("save_NickName"), (String) workItem.getParameter("save_CustomerNumber")); Address address = new Address( (String) workItem.getParameter("save_AddressLine1"), (String) workItem.getParameter("save_AddressLine2"), (String) workItem.getParameter("save_City"), (String) workItem.getParameter("save_State"), (String) workItem.getParameter("save_Zipcode")); customer.addAddress(address); manager.completeWorkItem(workItem.getId(), null); }
@Override public void abortWorkItem(WorkItem workItem, WorkItemManager manager) { System.err.println("Email Task aborted: " + workItem); manager.abortWorkItem(workItem.getId()); }