import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.net.InetAddress;
+import java.net.URL;
import java.net.UnknownHostException;
import java.nio.charset.Charset;
import java.sql.Connection;
* @author cmarchand
*/
public class OracleDataLayer extends AbstractDataImpl implements MessageEntries {
+ /**
+ *
+ */
+ private static final String ORACLE_QUERIES_PROPERTIES = "oracle-queries.properties";
public static final transient String LAYER_NAME = "oracle";
static {
DataLayerManager.regiterDataImpl(OracleDataLayer.LAYER_NAME, OracleDataLayer.class);
}
@Override
- public void registerBudgetCollectivite(final DocumentModel dm, final Pair codeBudget, final Pair collectivite, final Pair[] parentCollectivites, final String docName, final String archiveName, final XemeliosUser user)
- throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public void registerBudgetCollectivite(final DocumentModel dm, final Pair codeBudget, final Pair collectivite, final Pair[] parentCollectivites, final String docName, final String archiveName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des fichiers");
}
if (!rs.next()) {
sb = new StringBuilder();
final StringBuffer binds = new StringBuffer();
- sb.append("INSERT INTO ")
- .append(pc.getListBcTable().getBaseName())
+ sb.append("INSERT INTO ").append(pc.getListBcTable().getBaseName())
.append(" (" + pc.getBudgetCodeColname() + "," + pc.getCollectiviteCodeColname() + "," + pc.getInitialDocNameColname() + "," + pc.getArchiveNameColname() + "," + pc.getBudgetLibColname() + "," + pc.getCollectiviteLibColname());
binds.append(" VALUES (?,?,?,?,?,?");
for (int i = 0; i < parentCollectivites.length; i++) {
}
@Override
- public boolean importElement(final DocumentModel dm, final EtatModel currentEtat, final Pair codeBudget, final Pair collectivite, final String sourceFileName, final String elementName, final byte[] data, final String encoding,
- final String archiveName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean importElement(final DocumentModel dm, final EtatModel currentEtat, final Pair codeBudget, final Pair collectivite, final String sourceFileName, final String elementName, final byte[] data, final String encoding, final String archiveName, final XemeliosUser user)
+ throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
throw new UnauthorizedException(String.format(this.getMessages().getString(MessageEntries.NOT_ALLOWED_ROLE), this.getMessages().getString(MessageEntries.ROLE_IMPORT)));
}
// inserting document
final StringBuilder sb = new StringBuilder();
- sb.append("INSERT INTO ").append(sec.getDocumentTable().getBaseName())
- .append(" (" + pc.getBudgetCodeColname() + "," + pc.getCollectiviteCodeColname() + ", " + pc.getInitialDocNameColname() + ", DOC_ID, DOC, " + pc.getArchiveNameColname() + ") VALUES (?,?,?,?,?,?)");
+ sb.append("INSERT INTO ").append(sec.getDocumentTable().getBaseName()).append(" (" + pc.getBudgetCodeColname() + "," + pc.getCollectiviteCodeColname() + ", " + pc.getInitialDocNameColname() + ", DOC_ID, DOC, " + pc.getArchiveNameColname() + ") VALUES (?,?,?,?,?,?)");
ps = con.prepareStatement(sb.toString());
ps.setString(1, codeBudget.key);
ps.setString(2, collectivite.key);
StringBuilder sql = null;
for (final TTable ixTable : sec.getIndexTables()) {
sql = new StringBuilder();
- sql.append("DELETE FROM ").append(ixTable.getBaseName()).append(" WHERE ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ").append(pc.getInitialDocNameColname())
- .append("=?");
+ sql.append("DELETE FROM ").append(ixTable.getBaseName()).append(" WHERE ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ").append(pc.getInitialDocNameColname()).append("=?");
ps = con.prepareStatement(sql.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
// delete from special keys
if (pc.getSpecialKeyTable() != null) {
sql = new StringBuilder();
- sql.append("delete from ").append(pc.getSpecialKeyTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ")
- .append(pc.getInitialDocNameColname()).append("=?");
+ sql.append("delete from ").append(pc.getSpecialKeyTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ").append(pc.getInitialDocNameColname()).append("=?");
ps = con.prepareStatement(sql.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
}
// delete from documents
sql = new StringBuilder();
- sql.append("delete from ").append(sec.getDocumentTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ")
- .append(pc.getInitialDocNameColname()).append("=?");
+ sql.append("delete from ").append(sec.getDocumentTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ").append(pc.getInitialDocNameColname()).append("=?");
ps = con.prepareStatement(sql.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
ps.executeUpdate();
// delete from list bud/coll
sql = new StringBuilder();
- sql.append("delete from ").append(pc.getListBcTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ")
- .append(pc.getInitialDocNameColname()).append("=?");
+ sql.append("delete from ").append(pc.getListBcTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ").append(pc.getInitialDocNameColname()).append("=?");
ps = con.prepareStatement(sql.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
}
@Override
- public void saveSpecialKeys(final DocumentModel dm, final Pair budget, final Pair collectivite, final String docName, final String archiveName, final Pair sk1, final Pair sk2, final Pair sk3, final XemeliosUser user)
- throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public void saveSpecialKeys(final DocumentModel dm, final Pair budget, final Pair collectivite, final String docName, final String archiveName, final Pair sk1, final Pair sk2, final Pair sk3, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des fichiers");
}
}
@Override
- public Vector<Pair> getSpecialKeys2(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final boolean distinct, final XemeliosUser user) throws DataConfigurationException, DataAccessException,
- UnauthorizedException {
+ public Vector<Pair> getSpecialKeys2(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final boolean distinct, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
try {
con = PoolManager.getInstance().getConnection();
final StringBuilder sb = new StringBuilder();
- sb.append("SELECT ").append(distinct ? "DISTINCT " : " ").append("KEY2,LIB2 FROM ").append(pc.getSpecialKeyTable().getBaseName())
- .append(" WHERE KEY1=? AND " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND KEY2 is not null");
+ sb.append("SELECT ").append(distinct ? "DISTINCT " : " ").append("KEY2,LIB2 FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE KEY1=? AND " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND KEY2 is not null");
ps = con.prepareStatement(sb.toString());
ps.setString(1, key1.key);
ps.setString(2, collectivite.key);
}
@Override
- public Vector<Pair> getSpecialKeys3(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final Pair key2, final boolean distinct, final XemeliosUser user) throws DataConfigurationException, DataAccessException,
- UnauthorizedException {
+ public Vector<Pair> getSpecialKeys3(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final Pair key2, final boolean distinct, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
try {
con = PoolManager.getInstance().getConnection();
final StringBuilder sb = new StringBuilder();
- sb.append("SELECT ").append(distinct ? "DISTINCT " : " ").append("KEY3,LIB3 FROM ").append(pc.getSpecialKeyTable().getBaseName())
- .append(" WHERE KEY1=? AND KEY2=? AND " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=?");
+ sb.append("SELECT ").append(distinct ? "DISTINCT " : " ").append("KEY3,LIB3 FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE KEY1=? AND KEY2=? AND " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, key1.key);
ps.setString(2, key2.key);
try {
con = PoolManager.getInstance().getConnection();
final StringBuilder sb = new StringBuilder();
- sb.append("SELECT DISTINCT " + pc.getBudgetCodeColname() + ", " + pc.getBudgetLibColname() + " FROM ").append(pc.getListBcTable().getBaseName())
- .append(" WHERE " + pc.getCollectiviteCodeColname() + "=? ORDER BY " + pc.getBudgetLibColname());
+ sb.append("SELECT DISTINCT " + pc.getBudgetCodeColname() + ", " + pc.getBudgetLibColname() + " FROM ").append(pc.getListBcTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? ORDER BY " + pc.getBudgetLibColname());
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
final ResultSet rs = ps.executeQuery();
}
@Override
- public Collection<Pair> queryRepository(final DocumentModel dm, final Pair collectivite, final RecherchePaireModel rpm, final Pair refNomenclature, final XemeliosUser user) throws DataConfigurationException, DataAccessException,
- UnauthorizedException {
+ public Collection<Pair> queryRepository(final DocumentModel dm, final Pair collectivite, final RecherchePaireModel rpm, final Pair refNomenclature, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
final TTable sti = sec.getIndexTable(si.getTableId());
final StringBuilder sb = new StringBuilder();
sb.append("SELECT DISTINCT(").append(si.getColumn()).append(") FROM ").append(sti.getBaseName()).append(" ");
- sb.append("WHERE " + pc.getCollectiviteCodeColname() + "='").append(StringEscapeUtils.escapeSql(collectivite.key)).append("' AND " + pc.getBudgetCodeColname() + "='").append(StringEscapeUtils.escapeSql(budget.key)).append("' AND ")
- .append(si.getColumn()).append(" IS NOT NULL ORDER BY 1");
+ sb.append("WHERE " + pc.getCollectiviteCodeColname() + "='").append(StringEscapeUtils.escapeSql(collectivite.key)).append("' AND " + pc.getBudgetCodeColname() + "='").append(StringEscapeUtils.escapeSql(budget.key)).append("' AND ").append(si.getColumn()).append(" IS NOT NULL ORDER BY 1");
final Vector<String> vRet = new Vector<String>();
Connection con = null;
}
@Override
- public boolean removeSpecialKey3(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final Pair key2, final Pair key3, final XemeliosUser user) throws DataConfigurationException, DataAccessException,
- UnauthorizedException {
+ public boolean removeSpecialKey3(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final Pair key2, final Pair key3, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_CLEAN)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données");
}
try {
con = PoolManager.getInstance().getConnection();
final StringBuilder sb = new StringBuilder();
- sb.append("SELECT " + pc.getInitialDocNameColname() + " FROM ").append(pc.getSpecialKeyTable().getBaseName())
- .append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND KEY1=? AND KEY2=? AND KEY3=?");
+ sb.append("SELECT " + pc.getInitialDocNameColname() + " FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND KEY1=? AND KEY2=? AND KEY3=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
}
@Override
- public DataResultSet search(final ElementModel elementModel, final Pair collectivite, final Pair budget, final String xPath, final ListeResultatModel lrm, final Vector<CritereModel> models, final XemeliosUser user)
- throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public DataResultSet search(final ElementModel elementModel, final Pair collectivite, final Pair budget, final String xPath, final ListeResultatModel lrm, final Vector<CritereModel> models, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
@Override
public Pair[] getOperators(final String datatype) {
if ("string".equals(datatype)) {
- return new Pair[] { new Pair("starts-with", "commence par"), new Pair("contains", "contient"), new Pair("xem:does-not-contain", "ne contient pas"), new Pair("xem:ends-with", "fini par"), new Pair("xem:StringEquals", "égal à "),
- new Pair("xem:StringDiffers", "diffère de"), new Pair("xem:StringIsNotNull", "n'est pas nul") };
+ return new Pair[] { new Pair("starts-with", "commence par"), new Pair("contains", "contient"), new Pair("xem:does-not-contain", "ne contient pas"), new Pair("xem:ends-with", "fini par"), new Pair("xem:StringEquals", "égal à "), new Pair("xem:StringDiffers", "diffère de"),
+ new Pair("xem:StringIsNotNull", "n'est pas nul") };
} else if ("numeric".equals(datatype)) {
return new Pair[] { new Pair("=", "="), new Pair(">=", ">="), new Pair(">", ">"), new Pair("<", "<"), new Pair("<=", "<="), new Pair("!=", "!=") };
} else if ("date".equals(datatype)) {
}
@Override
- public ArrayList<String> getDocumentListFromSpecialKeys(final ElementModel em, final String collectivite, final String budget, final String sp1, final String sp2, final String sp3, final XemeliosUser user) throws DataConfigurationException,
- DataAccessException, UnauthorizedException {
+ public ArrayList<String> getDocumentListFromSpecialKeys(final ElementModel em, final String collectivite, final String budget, final String sp1, final String sp2, final String sp3, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
}
@Override
- public String calculateAggregate(final DocumentModel dm, final EtatModel em, String columnXPath, final String operator, final ChampModel cm, final DataResultSet rs, final XemeliosUser user) throws DataConfigurationException, DataAccessException,
- UnauthorizedException {
+ public String calculateAggregate(final DocumentModel dm, final EtatModel em, String columnXPath, final String operator, final ChampModel cm, final DataResultSet rs, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
try {
con = PoolManager.getInstance().getConnection();
final StringBuilder sb = new StringBuilder();
- sb.append("SELECT " + pc.getCollectiviteCodeColname() + ", " + pc.getCollectiviteLibColname() + ", " + pc.getBudgetCodeColname() + ", " + pc.getBudgetLibColname() + ", " + pc.getInitialDocNameColname() + " FROM ").append(
- pc.getListBcTable().getBaseName());
+ sb.append("SELECT " + pc.getCollectiviteCodeColname() + ", " + pc.getCollectiviteLibColname() + ", " + pc.getBudgetCodeColname() + ", " + pc.getBudgetLibColname() + ", " + pc.getInitialDocNameColname() + " FROM ").append(pc.getListBcTable().getBaseName());
if (coll != null) {
sb.append(" WHERE " + pc.getCollectiviteCodeColname() + "=? ");
}
}
@Override
- public DataResultSet getDataResultSetForExport(final int whatToExport, final ElementModel em, final Pair coll, final Pair budg, final String fic, final Pair SK1, final Pair SK2, final XemeliosUser user) throws DataConfigurationException,
- SQLException, UnauthorizedException {
+ public DataResultSet getDataResultSetForExport(final int whatToExport, final ElementModel em, final Pair coll, final Pair budg, final String fic, final Pair SK1, final Pair SK2, final XemeliosUser user) throws DataConfigurationException, SQLException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_EXPORT)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des exports");
}
Connection con = null;
try {
con = PoolManager.getInstance().getConnection();
- final String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "EXPORT_SIZE, " + "PRIORITY, " + "EXPORT_STATUS, " + "SUBMIT_DATE, " + "RUN_DATE, "
- + "DOWNLOAD_DATE, " + "ERROR_MESSAGE, " + "GENERATED_FILE_NAME, " + "CLEANED, " + "UTI_LOGIN " + "FROM EXPORT_JOBS " + "WHERE UTI_LOGIN=? " + "AND (DOWNLOAD_DATE IS NULL OR DOWNLOAD_DATE<(SYSDATE+7)) AND CLEANED IS NULL";
+ final String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "EXPORT_SIZE, " + "PRIORITY, " + "EXPORT_STATUS, " + "SUBMIT_DATE, " + "RUN_DATE, " + "DOWNLOAD_DATE, " + "ERROR_MESSAGE, "
+ + "GENERATED_FILE_NAME, " + "CLEANED, " + "UTI_LOGIN " + "FROM EXPORT_JOBS " + "WHERE UTI_LOGIN=? " + "AND (DOWNLOAD_DATE IS NULL OR DOWNLOAD_DATE<(SYSDATE+7)) AND CLEANED IS NULL";
final PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, user.getId());
final ResultSet rs = ps.executeQuery();
Connection con = null;
try {
con = PoolManager.getInstance().getConnection();
- final String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "EXPORT_SIZE, " + "PRIORITY, " + "EXPORT_STATUS, " + "SUBMIT_DATE, " + "RUN_DATE, "
- + "DOWNLOAD_DATE, " + "ERROR_MESSAGE, " + "GENERATED_FILE_NAME, " + "CLEANED, " + "DRS, " + "UTI_LOGIN " + "FROM EXPORT_JOBS " + "WHERE EXPORT_ID=? " + "AND UTI_LOGIN=?";
+ final String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "EXPORT_SIZE, " + "PRIORITY, " + "EXPORT_STATUS, " + "SUBMIT_DATE, " + "RUN_DATE, " + "DOWNLOAD_DATE, " + "ERROR_MESSAGE, "
+ + "GENERATED_FILE_NAME, " + "CLEANED, " + "DRS, " + "UTI_LOGIN " + "FROM EXPORT_JOBS " + "WHERE EXPORT_ID=? " + "AND UTI_LOGIN=?";
final PreparedStatement ps = con.prepareStatement(sql);
ps.setLong(1, exportId);
ps.setString(2, user);
}
@Override
- public String getInitialDocNameFromDocId(final EtatModel em, final String collectivite, final String budget, final String docId, final Connection con, final XemeliosUser user) throws DataConfigurationException, SQLException,
- UnauthorizedException {
+ public String getInitialDocNameFromDocId(final EtatModel em, final String collectivite, final String budget, final String docId, final Connection con, final XemeliosUser user) throws DataConfigurationException, SQLException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
* @param con
* @throws SQLException
*/
- private void ensureTablesExists(final TDocument pc, final TEtat sec, /*
- * Pair codeBudget, Pair collectivite,
- */final Connection con) throws SQLException {
+ private synchronized void ensureTablesExists(final TDocument pc, final TEtat sec, final Connection con) throws SQLException {
final Statement st = con.createStatement();
this.createTable(pc.getListBcTable(), st);
this.createTable(pc.getRepositoryTable(), st);
* @param st
* @throws SQLException
*/
- private void createTable(final TTable sti, final Statement st) throws SQLException {
+ private synchronized void createTable(final TTable sti, final Statement st) throws SQLException {
if (sti == null) {
return;
}
private TDocument pc = null;
private Stack<QName> stack = null;
private String key1 = null, key2 = null, key3 = null, key4 = null, key5 = null, key6 = null, key7 = null, key8 = null, key9 = null, key10 = null;
- private String pathToResetKey1 = null, pathToResetKey2 = null, pathToResetKey3 = null, pathToResetKey4 = null, pathToResetKey5 = null, pathToResetKey6 = null, pathToResetKey7 = null, pathToResetKey8 = null, pathToResetKey9 = null,
- pathToResetKey10 = null;
+ private String pathToResetKey1 = null, pathToResetKey2 = null, pathToResetKey3 = null, pathToResetKey4 = null, pathToResetKey5 = null, pathToResetKey6 = null, pathToResetKey7 = null, pathToResetKey8 = null, pathToResetKey9 = null, pathToResetKey10 = null;
private String collectivite = null, budget = null, docId = null;
private SQLException sqlEx = null;
private long indexDuration = 0L;
this.pathToResetKey10 = null;
}
- public IndexerHandler(final TEtat sec, final String codeBudget, final String codeCollectivite, final String elementName, final Connection con, final NamespaceContext nsCtx, final String originFileName, final String archiveName)
- throws SQLException {
+ public IndexerHandler(final TEtat sec, final String codeBudget, final String codeCollectivite, final String elementName, final Connection con, final NamespaceContext nsCtx, final String originFileName, final String archiveName) throws SQLException {
super();
this.sec = sec;
this.pc = sec.getParent();
}
//
final StringBuilder sql = new StringBuilder();
- sql.append("INSERT INTO ").append(elementTable.getBaseName())
- .append(" (" + this.pc.getCollectiviteCodeColname() + "," + this.pc.getBudgetCodeColname() + ",DOC_ID," + this.pc.getInitialDocNameColname() + ", " + this.pc.getArchiveNameColname() + ",");
+ sql.append("INSERT INTO ").append(elementTable.getBaseName()).append(" (" + this.pc.getCollectiviteCodeColname() + "," + this.pc.getBudgetCodeColname() + ",DOC_ID," + this.pc.getInitialDocNameColname() + ", " + this.pc.getArchiveNameColname() + ",");
final Vector<Object> valuesToWrite = new Vector<Object>();
final Vector<TSqlIndex> indexesToWrite = new Vector<TSqlIndex>();
for (final Enumeration<TSqlIndex> enumer = this.cachedData.keys(); enumer.hasMoreElements();) {
}
final StringBuilder sql = new StringBuilder();
- sql.append("INSERT INTO ").append(elementTable.getBaseName())
- .append(" (" + this.pc.getCollectiviteCodeColname() + "," + this.pc.getBudgetCodeColname() + ",DOC_ID," + this.pc.getInitialDocNameColname() + "," + this.pc.getArchiveNameColname() + ",");
+ sql.append("INSERT INTO ").append(elementTable.getBaseName()).append(" (" + this.pc.getCollectiviteCodeColname() + "," + this.pc.getBudgetCodeColname() + ",DOC_ID," + this.pc.getInitialDocNameColname() + "," + this.pc.getArchiveNameColname() + ",");
final Vector<Object> valuesToWrite = new Vector<Object>();
final Vector<TSqlIndex> indexesToWrite = new Vector<TSqlIndex>();
for (final Enumeration<TSqlIndex> enumer = this.cachedData.keys(); enumer.hasMoreElements();) {
}
}
- protected String adaptSqlForDatabaseEngine(String sql) {
+ protected String adaptSqlForDatabaseEngine(final String sql) {
/* -- commentaire original -- */
// en oracle, ceci n'a pas de sens :
connection.commit();
}
+ @Override
+ protected URL getSpecificQueryFile() {
+ return OracleDataLayer.class.getResource(ORACLE_QUERIES_PROPERTIES);
+ }
+
+ public long createImportJob(final Connection connection, final String archiveName, final String exercice, final String userLogin, final String importScheme) throws SQLException {
+ long resultId;
+ final PreparedStatement ps1 = connection.prepareStatement(this.queryProvider.getQuery("createImportJob.getNextId"));
+ try {
+ final ResultSet rs = ps1.executeQuery();
+ rs.next();
+ resultId = rs.getLong(1);
+ } finally {
+ ps1.close();
+ }
+
+ final PreparedStatement ps2 = connection.prepareStatement(this.queryProvider.getQuery("createImportJob.insert"));
+ try {
+ ps2.setLong(1, resultId);
+ ps2.setString(2, archiveName);
+ ps2.setString(3, exercice);
+ ps2.setString(4, userLogin);
+ ps2.setString(5, importScheme);
+ ps2.executeUpdate();
+ } finally {
+ ps2.close();
+ }
+
+ return resultId;
+ }
+
}