Package pl.net.bluesoft.rnd.processtool

Examples of pl.net.bluesoft.rnd.processtool.ProcessToolContext


   
    private final static Logger logger = Logger.getLogger(SendMailStep.class.getName());

    @Override
    public String invoke(BpmStep step, Map<String, String> params) throws Exception {
        ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
        BpmNotificationService service = ctx.getRegistry().getRegisteredService(BpmNotificationService.class);
       
        Map<String, Object> data = new HashMap<String, Object>();
        String processId = step.getProcessInstance().getExternalKey();
        if (!Strings.hasText(processId))
          processId = step.getProcessInstance().getInternalId();
View Full Code Here


   
    public void onProcessStateChange(BpmTask task, ProcessInstance pi, UserData userData, boolean processStarted,
                   boolean processEnded, boolean enteringStep) {
     
        refreshConfigIfNecessary();
        ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();

//    logger.log(Level.INFO, "BpmNotificationEngine processes " + configCache.size() + " rules");
    
        for (BpmNotificationConfig cfg : configCache) {
            try {
View Full Code Here

    @Override
    public void setContext(ProcessStateConfiguration state, ProcessStateWidget configuration, I18NSource i18NSource,
                           ProcessToolBpmSession bpmSession, Application application, Set<String> permissions, boolean isOwner) {
        super.setContext(state, configuration, i18NSource, bpmSession,
                application, permissions, isOwner);
        ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
        processDictionaryRegistry = ctx.getProcessDictionaryRegistry();
    }
View Full Code Here

    ReportTemplate template = new ReportDAO().loadByName(reportName);
    if (template == null)
      throw new ReportException("Report template does not exist!");
    // COMPILE REPORT
    JasperReport jasperReport = null;
    ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
    try {
      ByteArrayInputStream contentInputStream = getContentInputStream(template.getContent());
      Thread t = Thread.currentThread();
      ClassLoader previousLoader = t.getContextClassLoader();
      try {
        ClassLoader newClassLoader = ctx.getRegistry().getModelAwareClassLoader(getClass().getClassLoader());
        t.setContextClassLoader(newClassLoader);
        jasperReport = JasperCompileManager.compileReport(contentInputStream);
      } finally {
        t.setContextClassLoader(previousLoader);
      }
    } catch (Exception e) {
      throw new ReportException("Report compilation failed!", e);
    }


    // PREPARE INPUT
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, DATETIME_PATTERN);
    parameters.put(JRParameter.REPORT_LOCALE, locale);
    parameters.put(PROCESS_CONTEXT_KEY, ctx);

    // FILL REPORT
    JasperPrint jasperPrint = null;
    try {
      Thread t = Thread.currentThread();
      ClassLoader previousLoader = t.getContextClassLoader();
      try {
        ClassLoader newClassLoader = ctx
            .getRegistry().getModelAwareClassLoader(getClass().getClassLoader());
        t.setContextClassLoader(newClassLoader);
        parameters.put(DICTIONARY_HELPER, new DictionaryHelperImpl(processInstance));
        if (jasperReport.getQuery() != null && jasperReport.getQuery().getLanguage().equals("xPath")) {
          XStream xs = new XStream();
          xs.registerConverter(new MyPersistentSetConverter(xs.getMapper()), XStream.PRIORITY_VERY_HIGH);
          xs.omitField(ProcessInstance.class, "definition");
          xs.omitField(ProcessInstance.class, "processLogs");
          String s = xs.toXML(processInstance);

          jasperPrint = JasperFillManager.fillReport(jasperReport,
                                                     parameters,
                                                     new JRXmlDataSource(
                                                         new ByteArrayInputStream(s.getBytes())
                                                     ));
        } else if (jasperReport.getQuery() != null && hasText(jasperReport.getQuery().getText())) {
          parameters.put(PROCESS_INSTANCE_ID_KEY, String.valueOf(processInstance.getId()));
          jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, ctx.getHibernateSession().connection());
        } else {
          parameters.put(PROCESS_INSTANCE_KEY, processInstance);
          jasperPrint = JasperFillManager.fillReport(jasperReport,
                                                     parameters,
                                                     new JREmptyDataSource());

        }
      } finally {
        t.setContextClassLoader(previousLoader);
      }
    } catch (Exception e) {
      throw new ReportException("Report filling failed!", e);
    }

    // EXPORT REPORT
    byte[] report = null;
    try {
      Thread t = Thread.currentThread();
      ClassLoader previousLoader = t.getContextClassLoader();
      try {
        ClassLoader newClassLoader = ctx
            .getRegistry().getModelAwareClassLoader(getClass().getClassLoader());
        t.setContextClassLoader(newClassLoader);
        report = exportReport(jasperPrint, format, encoding);
      } finally {
        t.setContextClassLoader(previousLoader);
View Full Code Here

        Thread t = Thread.currentThread();*/
        try {
            ReportTemplate template = new ReportDAO().loadByName(reportName);
            if (template == null)
                throw new Exception("Report template does not exist for name: ".concat(reportName));
            ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
            ByteArrayInputStream contentInputStream = new ByteArrayInputStream(Base64.decodeBase64(
                    (new String(template.getContent())).getBytes("UTF-8")));
//            previousLoader = t.getContextClassLoader();
//            ClassLoader newClassLoader = ctx.getRegistry().getModelAwareClassLoader(
//                    JasperReportingUtil.class.getClassLoader());
View Full Code Here

    public DictionaryHelperImpl(ProcessInstance processInstance) {
        init(processInstance);
    }
   
    private void init(ProcessInstance processInstance) {
        ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
        processDictionaryRegistry = ctx.getProcessDictionaryRegistry();
        processDefinitionConfig = processInstance.getDefinition();
        dictionaryMap = new HashMap<String, Map<String, String>>();
    }
View Full Code Here

        }
    }

    @Override
    public void withTransaction(final ProcessToolGuiCallback r) {
        ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
        r.callback(ctx, bpmSession);
    }
View Full Code Here

            }
        } else {
            PortletSession session = ((PortletApplicationContext2) (getContext())).getPortletSession();
            bpmSession = (ProcessToolBpmSession) session.getAttribute("bpmSession", PortletSession.APPLICATION_SCOPE);
            if (bpmSession == null) {
                ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
                session.setAttribute("bpmSession",
                        bpmSession = ctx.getProcessToolSessionFactory().createSession(user, userRoles),
                        PortletSession.APPLICATION_SCOPE);
            }
            setUser(user);
           
        }
View Full Code Here

    @Override
    public String invoke(BpmStep step, Map params) throws Exception {
        ProcessInstance processInstance = step.getProcessInstance();
        try {
            ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
            UserSubstitution userSubstitution = new UserSubstitution();
            userSubstitution.setUser(processInstance.getCreator());
            userSubstitution.setDateFrom(Formats.parseShortDate(processInstance.getSimpleAttributeValue("dateFrom")));
            userSubstitution.setDateTo(Formats.parseShortDate(processInstance.getSimpleAttributeValue("dateTo")));
            String substituteUserLogin = processInstance.getSimpleAttributeValue("userSubstitute");
            UserData substituteUser = ctx.getUserDataDAO().loadUserByLogin(substituteUserLogin);
            if (substituteUser == null) {
                substituteUser = LiferayBridge.getLiferayUser(substituteUserLogin,
                        processInstance.getCreator().getCompanyId());
                ctx.getUserDataDAO().saveOrUpdate(substituteUser);
                if (substituteUser == null) {
                    logger.warning("Unable to determine application user by login: " + substituteUserLogin);
                    return STATUS_ERROR;
                }
            }
            userSubstitution.setUserSubstitute(substituteUser);
            ctx.getUserSubstitutionDAO().saveOrUpdate(userSubstitution);
            logger.warning("Added substitution for user " + userSubstitution.getUser().getLogin());
            return STATUS_OK;
        }
        catch (Exception e) {
            logger.log(Level.SEVERE, e.getMessage(), e);
View Full Code Here

    if (application instanceof GenericVaadinPortlet2BpmApplication) {
      GenericVaadinPortlet2BpmApplication o = (GenericVaadinPortlet2BpmApplication) application;
      showKeys = o.showKeys();
    }

    ProcessToolContext ctx = ProcessToolContext.Util.getThreadProcessToolContext();
    ProcessDictionaryRegistry registry = ctx.getProcessDictionaryRegistry();

    List<ProcessDictionary> dictionaries = new ArrayList<ProcessDictionary>();

    for (ProcessDefinitionConfig definition : definitions) {
      ProcessDictionary dictProcess = registry.getSpecificOrDefaultProcessDictionary(definition, "db", dictionary, i18NSource.getLocale().toString());
View Full Code Here

TOP

Related Classes of pl.net.bluesoft.rnd.processtool.ProcessToolContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.