📄 xlobsessionimpl.java
字号:
.append(FIELDS) .append(") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); ps = getConnection().prepareStatement(sb.toString()); int i = 1; ps.setString(i++, this.prefix); ps.setString(i++, fei.getEngineId()); ps.setString(i++, fei.getInitialEngineId()); ps.setString(i++, fei.getWorkflowDefinitionUrl()); ps.setString(i++, fei.getWorkflowDefinitionName()); ps.setString(i++, fei.getWorkflowDefinitionRevision()); ps.setString(i++, fei.getWorkflowInstanceId()); ps.setString(i++, fei.getExpressionName()); ps.setString(i++, fei.getExpressionId()); final java.io.StringReader reader = new java.io.StringReader(sXml); ps.setCharacterStream(i++, reader, sXml.length()); ps.executeUpdate(); } catch (final Exception e) { throw new XlobException ("update failure for "+fei, e); } finally { close(ps); releaseConnection(); } } /** * Updates or inserts an XML document for a given fei. */ public void remove (final FlowExpressionId fei) throws XlobException { java.sql.PreparedStatement ps = null; try { ps = prepareStatement("DELETE ", fei); ps.executeUpdate(); } catch (final Throwable t) { throw new XlobException("removal failure", t); } finally { close(ps); releaseConnection(); } } /** * Finds the document matching precisely the given fei. */ public org.jdom.Document find (final FlowExpressionId fei) throws XlobException { java.sql.ResultSet rs = null; try { rs = doQuery(null, fei); toNext(rs); return extract(rs); } finally { close(rs); releaseConnection(); } } /** * Retrieves the corresponding XML doc and turns it into its original * bean (openwfe.org.xml.XmlCoder). */ public Object findBean (final FlowExpressionId fei) throws XlobException { try { return XmlCoder.decode(find(fei).getRootElement()); } catch (final XmlCodingException xce) { throw new XlobException("decoding failure", xce); } } /** * Will return true if the given fei points to a stored document. */ public boolean isStored (final FlowExpressionId fei) throws XlobException { java.sql.ResultSet rs = null; try { rs = doQuery("count(*)", fei); toNext(rs); return rs.getInt(1) > 0; } catch (final java.sql.SQLException se) { throw new XlobException("failure", se); } finally { close(rs); releaseConnection(); } } /** * Given a partial fei (not all fields set), returns a set of * matching workitems. * The fei fields may contain SQL wildcards... */ public java.util.Set query (final FlowExpressionId fei) throws XlobException { return query(fei, -1); } /** * Given a partial fei (not all fields set), returns a set of * matching xml documents, but no more than a limit count. * The fei fields may contain SQL wildcards... */ public java.util.Set query (FlowExpressionId fei, int limit) throws XlobException { java.sql.ResultSet rs = null; try { rs = doQuery(null, fei); final java.util.Set set = new java.util.HashSet(); int count = 0; while (toNext(rs)) { if (limit > 0 && count >= limit) break; set.add(extract(rs)); count++; } return set; } finally { close(rs); releaseConnection(); } } /** * Given a partial fei (not all fields set), returns a set of * matching workitems. * The fei fields may contain SQL wildcards... */ public java.util.Set queryBeans (final FlowExpressionId fei) throws XlobException { return queryBeans(fei, -1); } /** * Given a partial fei (not all fields set), returns a set of * matching workitems, but no more than 'limit' count. * The fei fields may contain SQL wildcards... */ public java.util.Set queryBeans (final FlowExpressionId fei, final int limit) throws XlobException { java.sql.ResultSet rs = null; try { rs = doQuery(null, fei); final java.util.Set set = new java.util.HashSet(); int count = 0; while (toNext(rs)) { if (limit > 0 && count >= limit) break; set.add(extractBean(rs)); count++; } return set; } finally { close(rs); releaseConnection(); } } /** * Given a partial fei returns the count of matching docs. * The fei fields may contain SQL wildcards... If fei is null, * will return the total count. */ public int count (FlowExpressionId fei) throws XlobException { java.sql.ResultSet rs = null; if (fei == null) fei = new FlowExpressionId(); try { rs = doQuery("count(*)", fei); toNext(rs); return rs.getInt(1); } catch (final java.sql.SQLException se) { throw new XlobException("count failure", se); } finally { close(rs); releaseConnection(); } } /** * Returns a list of all the flow expression ids. */ public java.util.List listExpressionIds () throws XlobException { final StringBuffer sb = new StringBuffer(); sb .append("SELECT ") .append(FEI_FIELDS) .append(" FROM xldocument") .append(" WHERE prefix = ?"); java.sql.PreparedStatement st = null; java.sql.ResultSet rs = null; try { final java.util.List result = new java.util.ArrayList(50); st = getConnection().prepareStatement(sb.toString()); st.setString(1, getPrefix()); rs = st.executeQuery(); while (rs.next()) result.add(extractExpressionId(rs)); return result; } catch (final java.sql.SQLException e) { throw new XlobException ("failed to list expression ids", e); } finally { close(rs); close(st); releaseConnection(); } } /** * Returns the prefix used by this session. */ public String getPrefix () { return this.prefix; } /** * Lists all prefixes (including the one for this * session) used in the current db. */ public java.util.List listPrefixes () throws XlobException { java.sql.Statement st = null; java.sql.ResultSet rs = null; try { st = getConnection().createStatement(); rs = st.executeQuery("SELECT prefix FROM xldocument"); final java.util.List l = new java.util.ArrayList(20); while (rs.next()) { l.add(rs.getString(1)); } return l; } catch (final java.sql.SQLException se) { throw new XlobException ("failed to list prefixes", se); } finally { close(st); close(rs); releaseConnection(); } } // // STATIC METHODS /** * A shortcut method for getting an XlobSession. */ public static XlobSession getXlobSession (final java.sql.Connection con, final String prefix) { final XlobSession s = new XlobSessionImpl(); s.init(con, prefix); return s; } /** * A shortcut method for getting an XlobSession. */ public static XlobSession getXlobSession (final OwfeDataSource ds, final String prefix) { final XlobSession s = new XlobSessionImpl(); s.init(ds, prefix); return s; } /** * Buils an XlobSession according to the instructions found * in the context and in the service params. */ public static XlobSession createSession (final ApplicationContext context, final java.util.Map serviceParams) throws ServiceException { final OwfeDataSource ds = SqlUtils.lookupDataSource(context, serviceParams); final String prefix = MapUtils .getAsString(serviceParams, P_PREFIX, context.getName()); return getXlobSession(ds, prefix); } /** * Buils an XlobSession according to the instructions found * in the context and in the service params. */ public static XlobSession createSession (final String prefix, final ApplicationContext context, final java.util.Map serviceParams) throws ServiceException { final OwfeDataSource ds = SqlUtils.lookupDataSource(context, serviceParams); return getXlobSession(ds, prefix); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -