public static ResultSet Read() throws ResponseException { ResultSet rs = null; PreparedStatement statement = null; String query = "select * from unlocked;"; Connection connect = null; CachedRowSet crs = null; IConnection c = MiscUtil.getIConnection(); try (CachedRowSet crs2 = RowSetProvider.newFactory().createCachedRowSet()) { connect = c.init(); statement = connect.prepareStatement(query); rs = statement.executeQuery(); crs2.populate(rs); crs = crs2.createCopy(); } catch (SQLException e) { logger.error("SQL Error", e); throw new ResponseException("SQL Error", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (ResponseException e) { throw e; } finally { try { if (statement != null) statement.close(); if (connect != null) connect.close(); } catch (SQLException e) { logger.error("SQL Error", e); } } return (crs); }
public static void Update(Unlocked p) throws ResponseException { PreparedStatement statement = null; String query = "Update unlocked SET fk_profile_id=?,bonus_info=?,content_info=? where fk_profile_id=?;"; Connection connect = null; IConnection c = MiscUtil.getIConnection(); try { connect = c.init(); statement = connect.prepareStatement(query); statement.setLong(1, p.getProfileId()); statement.setString(2, p.getBonusInfo()); statement.setString(3, p.getContentInfo()); statement.setLong(4, p.getProfileId()); statement.executeUpdate(); } catch (SQLException e) { logger.error("SQL Error", e); throw new ResponseException("SQL Error", HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } catch (ResponseException e) { throw e; } finally { try { if (statement != null) statement.close(); if (connect != null) connect.close(); } catch (SQLException e) { logger.error("SQL Error", e); } } }
private int getCurrentActiveLinksNbInput(int connectionCategory) { int nb = 0; for (IConnection connection : getIncomingConnections()) { if (connection.isActivate() && connection.getLineStyle().hasConnectionCategory(connectionCategory)) { nb++; } } return nb; }
/** * @param funcNr * @param extCall * @param argValue * @param retValue * @throws SDRException * @throws IOException */ public void call(int funcNr, boolean extCall, SDR argValue, SDR retValue) throws SDRException, IOException { try { if (m_connection == null) { throw new SDRException(SDRException.NOT_CONNECTED); } int id = -1; do { if (argValue != null) { argValue.reset(); } retValue.reset(); id = m_connection.send(m_connectionData.station, funcNr, argValue, retValue, extCall); } while (!m_connection.waitFor(id)); } catch (IOException ex) { // close connection because of error close(); throw ex; } }
/** * Will return the first item of the subprocess. If "withCondition" is true, if there is links * from type RunIf / RunAfter / RunBefore, it will return the first element found. If * "withCondition" is false, it will return the first element with no active link from type * Main/Ref/Iterate.<br> * <i><b>Note:</b></i> This function doesn't work if the node has several start points (will * return a random start node). * * @param withCondition * @return Start Node found. */ public INode getSubProcessStartNode(boolean withConditions) { if (!withConditions) { Map<INode, Integer> mapMerge = NodeUtil.getLinkedMergeInfo(this); if (mapMerge == null) { // no merge after, so must be sub process start. if ((getCurrentActiveLinksNbInput(EConnectionType.MAIN) == 0)) { return this; } } else { for (Integer i : mapMerge.values()) { if (i != 1) { // not first merge, so will take the last merge from the tree, and retrieve the main sub // process start. return mapMerge.keySet().iterator().next().getSubProcessStartNode(withConditions); } } if ((getCurrentActiveLinksNbInput(EConnectionType.MAIN) == 0)) { return this; // main branch here, so we got the correct sub process start. } } } else { int nb = 0; for (IConnection connection : getIncomingConnections()) { if (connection.isActivate()) { nb++; } } if (nb == 0) { return this; } } IConnection connec; for (int j = 0; j < getIncomingConnections().size(); j++) { connec = getIncomingConnections().get(j); if (((AbstractNode) connec.getSource()).isOnMainMergeBranch()) { if (!connec.getLineStyle().equals(EConnectionType.FLOW_REF)) { return connec.getSource().getSubProcessStartNode(withConditions); } } } return null; }
/** * Returns the socket where this client is connected to * * @return host */ public Socket getSocket() { if (m_connection != null) { return m_connection.getSocket(); } return null; }
public void setTimeout(int timeMillis) { if (m_connection != null) { m_connection.setTimeOut(timeMillis); } }
@Override public void addOutgoingConnection(IConnection conn) { assert (conn.getSource().equals(this)); this.outgoingConnections.add(conn); this.firePropertyChange(PropertyType.CONNECTIONS, null, conn); }
@Override public void addIncomingConnection(IConnection conn) { assert (conn.getTarget().equals(conn)); this.incomingConnections.add(conn); this.firePropertyChange(PropertyType.CONNECTIONS, null, conn); }