/** * The method tests if all resources (JDBC connection and store resources) are closed, that means * that the resources are freeed and returned for reuse. * * @return <i>true</i> if all resources are closed, otherwise <i>false</i> is returned * @see #connectionStore * @see #storeStore */ public boolean allConnectionClosed() { boolean closed = true; for (ConnectionResource con : this.connectionStore) { if (con.isOpened()) { closed = false; break; } } if (closed) { for (StoreResource store : this.storeStore) { if (store.isOpened()) { closed = false; break; } } } return closed; }
/** * The executes is done without calling triggers and check of access rights. The method executes * the delete. For the object, a delete is made in all SQL tables from the type (if the SQL table * is not read only!). If a store is defined for the type, the checked in file is also deleted * (with the help of the store resource implementation; if the store resource implementation has * not implemented the delete, the file is not deleted!).<br> * It is not checked if the current context user has access to delete the eFaps object defined in * {@link #instance}. * * @see SQLTable#readOnly * @throws EFapsException on error */ public void executeWithoutTrigger() throws EFapsException { final Context context = Context.getThreadContext(); ConnectionResource con = null; try { con = context.getConnectionResource(); Statement stmt = null; try { stmt = con.getConnection().createStatement(); final SQLTable mainTable = getInstance().getType().getMainTable(); for (final SQLTable curTable : getInstance().getType().getTables()) { if ((curTable != mainTable) && !curTable.isReadOnly()) { final StringBuilder buf = new StringBuilder(); buf.append("delete from ").append(curTable.getSqlTable()).append(" "); buf.append("where ") .append(curTable.getSqlColId()) .append("=") .append(getInstance().getId()) .append(""); if (LOG.isTraceEnabled()) { LOG.trace(buf.toString()); } stmt.addBatch(buf.toString()); } } final StringBuilder buf = new StringBuilder(); buf.append("delete from ").append(mainTable.getSqlTable()).append(" "); buf.append("where ") .append(mainTable.getSqlColId()) .append("=") .append(getInstance().getId()) .append(""); if (LOG.isTraceEnabled()) { LOG.trace(buf.toString()); } stmt.addBatch(buf.toString()); stmt.executeBatch(); } catch (final SQLException e) { throw new EFapsException( getClass(), "executeWithoutAccessCheck.SQLException", e, this.instance); } finally { try { if (stmt != null) { stmt.close(); } } catch (final java.sql.SQLException e) { LOG.warn("Catched SQLException in class:" + Delete.class); } } con.commit(); } finally { if ((con != null) && con.isOpened()) { con.abort(); } } Resource storeRsrc = null; try { if (getInstance().getType().hasStore()) { storeRsrc = context.getStoreResource(getInstance()); storeRsrc.delete(); storeRsrc.commit(); } } finally { if ((storeRsrc != null) && storeRsrc.isOpened()) { storeRsrc.abort(); } } }