List of usage examples for org.apache.commons.pipeline StageException StageException
public StageException(Stage source, Throwable cause)
StageException
with the specified detail message and cause From source file:edu.scripps.fl.pubchem.app.relations.DeleteRelationsStage.java
@Override public void process(Object obj) throws StageException { Integer id = (Integer) obj; try {/*from w ww . ja va 2 s.c om*/ Query query = getSession().createQuery("delete from Relation where fromId = ? and fromDb = ?"); query.setInteger(0, id); query.setString(1, "pcassay"); query.executeUpdate(); emit(id); } catch (Exception ex) { throw new StageException(this, ex); } }
From source file:edu.scripps.fl.pubchem.app.summary.NodesStage.java
@Override public void innerProcess(Object obj) throws StageException { Document document = (Document) obj; try {//from w w w . j av a 2s. c om Element setElem = (Element) document.selectSingleNode("/eSummaryResult/DocumentSummarySet"); Iterator<Node> iter = setElem.nodeIterator(); for (; iter.hasNext();) { Node node = iter.next(); if ("DocumentSummary".equals(node.getName())) // eUtils version 2.0 emit(node); } } catch (Exception ex) { throw new StageException(this, ex); } }
From source file:edu.scripps.fl.pipeline.DocumentStage.java
@Override public void innerProcess(Object obj) throws StageException { File file = (File) obj; try {//from w w w . j ava 2s.com Document document = EUtilsWebSession.getInstance().getDocument(new FileInputStream(file)); file.deleteOnExit(); emit(document); } catch (Exception ex) { log.error(String.format("Problem with file %s: %s", file, ex.getMessage())); throw new StageException(this, ex); } }
From source file:edu.scripps.fl.pubchem.app.cids.FetchSDFStage.java
@Override public void process(Object obj) throws StageException { List<Number> ids = (List<Number>) obj; try {//from w w w . j a va2 s . c om int[] list = (int[]) ConvertUtils.convert(ids, int[].class); URL url = PUGSoapFactory.getInstance().getSDFilefromCIDs(list); System.out.println("SDF File URL: " + url); emit(url); } catch (Exception ex) { ex.printStackTrace(); throw new StageException(this, ex); } }
From source file:edu.scripps.fl.pubchem.app.relations.ProcessRelationsStage.java
@Override public void process(Object obj) throws StageException { Document document = (Document) obj; try {/* ww w . j a va2 s . co m*/ int relations = PubChemFactory.getInstance().populateRelations(getSession(), document); } catch (Exception ex) { throw new StageException(this, ex); } }
From source file:edu.scripps.fl.pubchem.app.results.DownloadCsvStage.java
@Override public void process(Object obj) throws StageException { Integer aid = (Integer) obj; try {/*from w ww.java 2 s . c om*/ InputStream is = PubChemFactory.getInstance().getCsv(getDataUrl(), aid); emit(new Object[] { aid, is }); } catch (IOException ex) { throw new StageException(this, ex); } }
From source file:edu.scripps.fl.pubchem.app.relations.ELinkStage.java
@Override public void preprocess() throws StageException { try {//from w w w . j a v a2 s . com Set<String> dbs = EUtilsWebSession.getInstance().getDatabases(); dbs.remove("pccompound"); dbs.remove("pcsubstance"); databases = StringUtils.join(dbs, ","); } catch (Exception ex) { throw new StageException(this, ex); } }
From source file:edu.scripps.fl.pubchem.app.results.DeleteResultsStage.java
@Override public void process(Object obj) throws StageException { Integer aid = (Integer) obj; try {/*w ww .j a v a 2 s .c om*/ Query query = getSession().createQuery("from PCAssay where AID = :aid"); query.setParameter("aid", aid); PCAssay assay = (PCAssay) query.uniqueResult(); query = getSession().createQuery("delete from PCAssayResult where assay.id = :id"); query.setParameter("id", assay.getId()); int deleted = query.executeUpdate(); emit(aid); } catch (Exception ex) { throw new StageException(this, ex); } }
From source file:edu.scripps.fl.pubchem.app.summary.ESummaryStage.java
@Override public void innerProcess(Object obj) throws StageException { try {/*w ww . ja v a 2s.c o m*/ Thread.sleep(333); List<Long> aids = (List<Long>) obj; InputStream in = EUtilsWebSession.getInstance().getSummaries(aids, "pcassay"); File file = File.createTempFile("pubchem", "summary.xml"); log.info(String.format("Downloaded %s summaries to %s", aids.size(), file)); IOUtils.copy(in, new FileOutputStream(file)); emit(file); } catch (Exception ex) { throw new StageException(this, ex); } }
From source file:edu.scripps.fl.pipeline.StatelessCommitStage.java
@Override public void process(Object obj) throws StageException { try {/* www .j a va2 s. c om*/ StatelessSession session = getStatelessSession(); int count = counter.incrementAndGet(); doSave(obj); if (count % getCommitFrequency() == 0) { getTransaction().commit(); setTransaction(session.beginTransaction()); } } catch (Exception ex) { throw new StageException(this, ex); } }