Example usage for javax.transaction SystemException printStackTrace

List of usage examples for javax.transaction SystemException printStackTrace

Introduction

In this page you can find the example usage for javax.transaction SystemException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:it.drwolf.ridire.util.fixingpos.AsyncPosFixer.java

@SuppressWarnings("unchecked")
@Asynchronous//from  ww  w  . jav  a 2s.c o m
public void doAsyncFix(PosFixerData posFixerData) {
    StrTokenizer strTokenizer = new StrTokenizer("\t");
    File destDir = new File(posFixerData.getDestDir());
    File reverseDestDir = new File(posFixerData.getReverseDestDir());
    if (!destDir.exists() || !destDir.isDirectory() || !reverseDestDir.exists()
            || !reverseDestDir.isDirectory()) {
        System.err.println("Not valid destination folder.");
        return;
    }
    this.ridireReTagger = new RIDIREReTagger(null);
    try {
        this.entityManager = (EntityManager) Component.getInstance("entityManager");
        this.userTx = (UserTransaction) org.jboss.seam.Component
                .getInstance("org.jboss.seam.transaction.transaction");
        this.userTx.setTransactionTimeout(1000 * 10 * 60);
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        String treeTaggerBin = this.entityManager
                .find(CommandParameter.class, CommandParameter.TREETAGGER_EXECUTABLE_KEY).getCommandValue();
        this.ridireReTagger.setTreetaggerBin(treeTaggerBin);
        this.entityManager.flush();
        this.entityManager.clear();
        this.userTx.commit();
        List<String> lines = FileUtils.readLines(new File(posFixerData.getFile()));
        int count = 0;
        for (String l : lines) {
            if (l == null || l.trim().length() < 1) {
                continue;
            }
            String digest = l.replaceAll("\\./", "").replaceAll("\\.vrt", "");
            if (!this.userTx.isActive()) {
                this.userTx.begin();
            }
            this.entityManager.joinTransaction();
            List<CrawledResource> crs = this.entityManager
                    .createQuery("from CrawledResource cr where cr.digest=:digest")
                    .setParameter("digest", digest).getResultList();
            if (crs.size() != 1) {
                System.err.println("PosFixer: " + l + " resource not found.");
            } else {
                CrawledResource cr = crs.get(0);
                String origFile = FilenameUtils.getFullPath(cr.getArcFile())
                        .concat(JobMapperMonitor.RESOURCESDIR).concat(digest.concat(".txt"));
                File toBeRetagged = new File(origFile);
                if (toBeRetagged.exists() && toBeRetagged.canRead()) {
                    String retaggedFile = this.ridireReTagger.retagFile(toBeRetagged);
                    int wordsNumber = this.wordCounter.countWordsFromPoSTagResource(new File(retaggedFile));
                    cr.setWordsNumber(wordsNumber);
                    this.entityManager.persist(cr);
                    this.vrtFilesBuilder.createVRTFile(retaggedFile, strTokenizer, cr, destDir);
                    String vrtFileName = destDir + System.getProperty("file.separator") + digest + ".vrt";
                    File vrtFile = new File(vrtFileName);
                    this.vrtFilesBuilder.reverseFile(reverseDestDir, vrtFile);
                }
            }
            this.userTx.commit();
            System.out.println(" Processed " + (++count) + " of " + lines.size());
        }
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            if (this.userTx != null && this.userTx.isActive()) {
                this.userTx.rollback();
            }
        } catch (IllegalStateException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SecurityException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SystemException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}

From source file:it.drwolf.ridire.session.async.JobMapperMonitor.java

private void create() {
    int transactionTimeoutSeconds = 240;
    try {/* www.  ja va 2s.c  o m*/
        ((javax.transaction.UserTransaction) org.jboss.seam.transaction.Transaction.instance())
                .setTransactionTimeout(transactionTimeoutSeconds);
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 8443));
    this.httpClient = new HttpClient();
    this.httpClient.getParams().setAuthenticationPreemptive(true);
    this.mainUserTx = (UserTransaction) org.jboss.seam.Component
            .getInstance("org.jboss.seam.transaction.transaction", ScopeType.APPLICATION);
    Credentials defaultcreds = null;
    int jobsToBeProcessed = 4;
    try {
        this.mainUserTx.setTransactionTimeout(10 * 10 * 60);
        // 10 mins
        this.mainUserTx.begin();
        this.eventEntityManager.joinTransaction();
        defaultcreds = new UsernamePasswordCredentials("admin", this.eventEntityManager
                .find(CommandParameter.class, CommandParameter.HERITRIX_ADMINPW_KEY).getCommandValue());
        jobsToBeProcessed = Integer.parseInt(this.eventEntityManager
                .find(Parameter.class, Parameter.JOBS_TO_BE_PROCESSED.getKey()).getValue());
        JobMapperMonitor.JOBSDIR = this.eventEntityManager.find(Parameter.class, Parameter.JOBS_DIR.getKey())
                .getValue();
        this.flagBearer.setHostname(
                this.eventEntityManager.find(Parameter.class, Parameter.HOSTNAME.getKey()).getValue());
        this.eventEntityManager.flush();
        this.mainUserTx.commit();
    } catch (Exception e) {
        e.printStackTrace();
    }
    this.httpClient.getState().setCredentials(
            new AuthScope(AuthScope.ANY_SCHEME, AuthScope.ANY_PORT, AuthScope.ANY_REALM), defaultcreds);
    Logger httpClientlogger = Logger.getLogger(this.httpClient.getClass());
    httpClientlogger.setLevel(Level.ERROR);
    Logger authChallengeProcessorLogger = Logger.getLogger(AuthChallengeProcessor.class);
    authChallengeProcessorLogger.setLevel(Level.ERROR);
    Logger httpMethodBaseLogger = Logger.getLogger(HttpMethodBase.class);
    httpMethodBaseLogger.setLevel(Level.ERROR);
    this.highPoolThreadFactory = new PoolThreadFactory(JobMapperMonitor.THREADS_PRIORITY);
    this.threadPool = new ThreadPoolExecutor(jobsToBeProcessed, jobsToBeProcessed, 100, TimeUnit.SECONDS,
            new LinkedBlockingQueue<Runnable>(), this.highPoolThreadFactory);
}

From source file:it.drwolf.ridire.index.cwb.CWBFrequencyList.java

@Asynchronous
public void calculateFrequencyListForEachCorpora() {
    this.entityManager = (EntityManager) Component.getInstance("entityManager");
    this.userTx = (UserTransaction) org.jboss.seam.Component
            .getInstance("org.jboss.seam.transaction.transaction");
    try {/*from   www. j  av a2  s .c  om*/
        this.userTx.setTransactionTimeout(10 * 10 * 60);
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        List<SemanticMetadatum> resultList = this.entityManager.createQuery("from SemanticMetadatum sm")
                .getResultList();
        this.entityManager.flush();
        this.entityManager.clear();
        this.userTx.commit();
        for (SemanticMetadatum sm : resultList) {
            this.createFreqTable("lemma", sm.getDescription().replaceAll("\\s", "_"), null, sm.getId() + "",
                    "-1");
            this.createFreqTable("forma", sm.getDescription().replaceAll("\\s", "_"), null, sm.getId() + "",
                    "-1");
            this.createFreqTable("PoS", sm.getDescription().replaceAll("\\s", "_"), null, sm.getId() + "",
                    "-1");
            this.createFreqTable("easypos", sm.getDescription().replaceAll("\\s", "_"), null, sm.getId() + "",
                    "-1");
        }
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        List<FunctionalMetadatum> resultList2 = this.entityManager.createQuery("from FunctionalMetadatum fm")
                .getResultList();
        this.entityManager.flush();
        this.entityManager.clear();
        this.userTx.commit();
        for (FunctionalMetadatum fm : resultList2) {
            this.createFreqTable("lemma", null, fm.getDescription().replaceAll("\\s", "_"), "-1",
                    fm.getId() + "");
            this.createFreqTable("forma", null, fm.getDescription().replaceAll("\\s", "_"), "-1",
                    fm.getId() + "");
            this.createFreqTable("PoS", null, fm.getDescription().replaceAll("\\s", "_"), "-1",
                    fm.getId() + "");
            this.createFreqTable("easypos", null, fm.getDescription().replaceAll("\\s", "_"), "-1",
                    fm.getId() + "");
        }
        this.createFreqTable("lemma", null, null, "-1", "-1");
        this.createFreqTable("forma", null, null, "-1", "-1");
        this.createFreqTable("PoS", null, null, "-1", "-1");
        this.createFreqTable("easypos", null, null, "-1", "-1");
        this.corpusSizeParams.init();
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:it.drwolf.ridire.index.sketch.SketchCreator.java

@Asynchronous
public void createSketches(SketchCreatorData sketchCreatorData) {
    this.entityManager = (EntityManager) Component.getInstance("entityManager");
    this.userTx = (UserTransaction) org.jboss.seam.Component
            .getInstance("org.jboss.seam.transaction.transaction");
    try {/*from ww w  . j av a  2s . co  m*/
        this.userTx.setTransactionTimeout(1000 * 10 * 60);
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        String cqpExecutable = this.entityManager.find(Parameter.class, Parameter.CQP_EXECUTABLE.getKey())
                .getValue();
        String cqpRegistry = this.entityManager.find(Parameter.class, Parameter.CQP_REGISTRY.getKey())
                .getValue();
        String cqpCorpusName = this.entityManager
                .find(Parameter.class, Parameter.CQP_CORPUSNAME_FOR_SKETCHES.getKey()).getValue();
        LocalResourcesManager localResourcesManager = (LocalResourcesManager) Component
                .getInstance("localResourcesManager");
        AsyncSketchCreator asyncSketchCreator = (AsyncSketchCreator) Component
                .getInstance("asyncSketchCreator");
        Set<String> functionalMetadata = localResourcesManager.getAllFunctionalMetadataMap().keySet();
        Set<String> semanticMetadata = localResourcesManager.getAllSemanticMetadataMap().keySet();
        Map<String, List<String>> toBeProcessed = new HashMap<String, List<String>>();
        for (String pos : SketchCreator.POSS) {
            toBeProcessed.put(pos, this.getToBeProcessed(pos, sketchCreatorData.getIndexWriter(),
                    functionalMetadata, semanticMetadata, sketchCreatorData.getWorkingDir()));
        }
        for (String pos : SketchCreator.POSS) {
            this.processList(cqpExecutable, cqpRegistry, cqpCorpusName, toBeProcessed.get(pos), pos,
                    sketchCreatorData, asyncSketchCreator);
        }
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            if (this.userTx != null && this.userTx.isActive()) {
                this.userTx.rollback();
            }
        } catch (IllegalStateException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SecurityException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SystemException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}

From source file:it.drwolf.ridire.index.cwb.scripts.VRTFilesBuilder.java

@Asynchronous
public void buildFiles(VRTFilesBuilderData vrtFilesBuilderData) {
    this.entityManager = (EntityManager) Component.getInstance("entityManager");
    this.userTx = (UserTransaction) org.jboss.seam.Component
            .getInstance("org.jboss.seam.transaction.transaction");
    try {/*from  w ww  .  ja  v  a  2  s . c o  m*/
        this.userTx.setTransactionTimeout(1000 * 10 * 60);
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        List<Integer> validatedJobsId = this.entityManager
                .createQuery("select j.id from Job j where j.validationStatus=:validated")
                .setParameter("validated", Job.VALIDATED_OK).getResultList();
        this.entityManager.flush();
        this.entityManager.clear();
        this.userTx.commit();
        int countJob = 1;
        for (Integer jobId : validatedJobsId) {
            System.out.println("Creating VRT files; job " + countJob + " of " + validatedJobsId.size());
            ++countJob;
            this.processResourcesOfJob(jobId, vrtFilesBuilderData);
        }
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            if (this.userTx != null && this.userTx.isActive()) {
                this.userTx.rollback();
            }
        } catch (IllegalStateException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SecurityException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SystemException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}

From source file:it.drwolf.ridire.index.cwb.scripts.VRTFilesBuilder.java

@Asynchronous
public void buildFilesFromJobNames(VRTFilesBuilderData vrtFilesBuilderData) {
    String[] jobNames = StringUtils.split(vrtFilesBuilderData.getJobsList(), "\n");
    this.entityManager = (EntityManager) Component.getInstance("entityManager");
    this.userTx = (UserTransaction) org.jboss.seam.Component
            .getInstance("org.jboss.seam.transaction.transaction");
    try {//from  w  w w.j  av  a 2  s  . c  o m
        this.userTx.setTransactionTimeout(1000 * 10 * 60);
        List<Integer> jobIds = new ArrayList<Integer>();
        int countJob = 1;
        for (String jobName : jobNames) {
            if (!this.userTx.isActive()) {
                this.userTx.begin();
            }
            this.entityManager.joinTransaction();
            jobName = jobName.replaceAll("completed-", "");
            jobIds = this.entityManager.createQuery("select j.id from Job j where j.name=:name ")
                    .setParameter("name", jobName.trim()).getResultList();
            this.entityManager.flush();
            this.entityManager.clear();
            this.userTx.commit();
            if (jobIds.size() == 1) {
                System.out.println("Creating VRT files; job " + countJob + " of " + jobNames.length);
                ++countJob;
                this.processResourcesOfJob(jobIds.get(0), vrtFilesBuilderData);
            }
        }
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            if (this.userTx != null && this.userTx.isActive()) {
                this.userTx.rollback();
            }
        } catch (IllegalStateException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SecurityException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SystemException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
}

From source file:it.drwolf.ridire.index.cwb.CWBCollocatesExtractor.java

@Create
public void init() {
    this.userTx = (UserTransaction) org.jboss.seam.Component
            .getInstance("org.jboss.seam.transaction.transaction");
    this.entityManager = (EntityManager) Component.getInstance("entityManager");
    try {/*from   ww w.  jav a 2  s.  c o m*/
        this.userTx.setTransactionTimeout(CWBCollocatesExtractor.CWB_COLLOCATES_EXTRACTOR_TIMEOUT);
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        this.cqpExecutable = this.entityManager.find(Parameter.class, Parameter.CQP_EXECUTABLE.getKey())
                .getValue();
        this.cqpCorpusName = this.entityManager.find(Parameter.class, Parameter.CQP_CORPUSNAME.getKey())
                .getValue();
        this.cqpRegistry = this.entityManager.find(Parameter.class, Parameter.CQP_REGISTRY.getKey()).getValue();
        this.entityManager.flush();
        this.entityManager.clear();
        this.userTx.commit();
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    this.conversationId = Conversation.instance().getId();
}

From source file:it.drwolf.ridire.index.cwb.scripts.VRTFilesBuilder.java

@SuppressWarnings("unchecked")
@Asynchronous/*from  w w w  . jav  a 2s .  co m*/
public void retagFiles(VRTFilesBuilderData vrtFilesBuilderData) {
    String destDir = vrtFilesBuilderData.getDestDir();
    StrTokenizer strTokenizer = new StrTokenizer("\t");
    this.ridirePlainTextCleaner = new RIDIREPlainTextCleaner(null);
    this.ridireReTagger = new RIDIREReTagger(null);
    this.entityManager = (EntityManager) Component.getInstance("entityManager");
    this.userTx = (UserTransaction) org.jboss.seam.Component
            .getInstance("org.jboss.seam.transaction.transaction");
    try {
        this.userTx.setTransactionTimeout(1000 * 10 * 60);
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        String treeTaggerBin = this.entityManager
                .find(CommandParameter.class, CommandParameter.TREETAGGER_EXECUTABLE_KEY).getCommandValue();
        this.ridireReTagger.setTreetaggerBin(treeTaggerBin);
        this.entityManager.flush();
        this.entityManager.clear();
        this.userTx.commit();

        String strangeFilesList = vrtFilesBuilderData.getOrigDir();
        File strangeFilesListFile = new File(strangeFilesList);
        if (strangeFilesListFile.exists() && strangeFilesListFile.canRead()) {
            List<String> posFilesName = FileUtils.readLines(strangeFilesListFile);
            int count = 0;
            int size = posFilesName.size();
            for (String posFName : posFilesName) {
                String digest = FilenameUtils.getBaseName(posFName.trim()).replaceAll(".txt", "");
                if (this.vrtFileExists(destDir, digest)) {
                    System.out.println("Skipping: " + digest);
                    continue;
                }
                if (!this.userTx.isActive()) {
                    this.userTx.begin();
                }
                this.entityManager.joinTransaction();
                List<CrawledResource> crs = this.entityManager
                        .createQuery("from CrawledResource cr where cr.digest=:digest")
                        .setParameter("digest", digest).getResultList();
                if (crs != null && crs.size() > 0) {
                    CrawledResource cr = crs.get(0);
                    File fToBeCleaned = new File(posFName.trim().replace(".pos", ""));
                    try {
                        this.ridirePlainTextCleaner.cleanTextFile(fToBeCleaned);
                        this.ridireReTagger.retagFile(fToBeCleaned);
                        if (fToBeCleaned != null) {
                            Integer wordsNumber = Mapper
                                    .countWordsFromPoSTagResource(fToBeCleaned.getAbsolutePath());
                            cr.setWordsNumber(wordsNumber);
                            this.entityManager.persist(cr);
                            this.createVRTFile(posFName.trim(), strTokenizer, cr, new File(destDir));
                        }
                    } catch (ExecuteException ee) {
                        ee.printStackTrace();
                    }
                }
                this.entityManager.flush();
                this.entityManager.clear();
                this.userTx.commit();
                ++count;
                if (count % 100 == 0) {
                    System.out.println("Retagging: " + count + " of " + size);
                }
            }
        }
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NotSupportedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (SecurityException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalStateException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (RollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicMixedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (HeuristicRollbackException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
        try {
            if (this.userTx != null && this.userTx.isActive()) {
                this.userTx.rollback();
            }
        } catch (IllegalStateException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SecurityException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SystemException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
    System.out.println("Retagging done.");
}

From source file:org.alfresco.reporting.action.executer.HarvestingExecuter.java

private void processWorkflows(NodeRef harvestDefinition) {

    logger.debug("enter processWorkflows");
    try {//w ww . j  a  va 2  s .  co  m
        String tableName = Constants.TABLE_WOKFLOW_INSTANCE;
        logger.debug("Starting WorkflowInstance Harvest");
        if (!dbhb.tableIsRunning(tableName)) {
            Date theDate = new Date((new Date()).getTime() - Constants.HARVESTING_SAFETY_MARGIN); // substract 1 second. Otherwise test will fail
            String nowFormattedDate = reportingHelper.getSimpleDateFormat().format(theDate);
            String formattedDate = dbhb.getLastTimestampStatus(tableName);

            dbhb.createEmptyTables(tableName);
            ProcessProcessor pp = new ProcessProcessor(serviceRegistry, dbhb, reportingHelper);
            pp.havestNodes();
            Properties defs = pp.processQueueDefinition(tableName);

            pp.setTableDefinition(tableName, defs);

            logger.debug("Process instances=" + defs);
            pp.processQueueValues(tableName);
            pp = null;
            dbhb.setLastTimestampAndStatusDone(tableName, nowFormattedDate);
        } else {
            logger.fatal("Table " + tableName + " is already running! (or another table)");
        }
    } catch (SystemException se) {
        se.printStackTrace();
    } catch (Exception e) {

        e.printStackTrace();
    }

    logger.debug("exit processWorkflows");
}

From source file:org.alfresco.reporting.action.executer.HarvestingExecuter.java

private void processTasks(NodeRef harvestDefinition) {

    logger.debug("enter processTasks");
    try {/*  ww w.  ja  v  a 2s.  c o m*/
        String tableName = Constants.TABLE_WOKFLOW_TASK;
        logger.debug("Starting WorkflowTask Harvest");
        if (!dbhb.tableIsRunning(tableName)) {
            Date theDate = new Date((new Date()).getTime() - Constants.HARVESTING_SAFETY_MARGIN); // substract 1 second. Otherwise test will fail
            String nowFormattedDate = reportingHelper.getSimpleDateFormat().format(theDate);

            dbhb.createEmptyTables(tableName);
            WorkflowTaskPropertyProcessor wfp = new WorkflowTaskPropertyProcessor(serviceRegistry, dbhb,
                    reportingHelper);
            wfp.havestNodes();
            Properties defs = wfp.processQueueDefinition(tableName);

            wfp.setTableDefinition(tableName, defs);

            logger.debug("Task definitions=" + defs);
            wfp.processQueueValues(tableName);
            wfp = null;
            dbhb.setLastTimestampAndStatusDone(tableName, nowFormattedDate);
        } else {
            logger.fatal("Table " + tableName + " is already running! (or another table)");
        }
    } catch (SystemException se) {
        se.printStackTrace();
    } catch (Exception e) {

        e.printStackTrace();
    }

    logger.debug("exit processTasks");
}