import java.util.Collection;
import java.util.Comparator;
import java.util.Enumeration;
-import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Stack;
* String
* originFileName
* ,
- */final String archiveName,
- final XemeliosUser user) throws DataAccessException, DataConfigurationException, UnauthorizedException {
+ */final String archiveName, final XemeliosUser user)
+ throws DataAccessException, DataConfigurationException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des fichiers");
}
// 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);
}
@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 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");
}
try {
con = this.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 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 = this.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 = this.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);
}
@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;
return manifeste;
}
- @Override
- public boolean removeArchive(final HashMap<String, DocumentModel> dms, final String archiveName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
- if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données.");
- }
- Connection con = null;
- PreparedStatement ps = null;
-
- final StringBuilder log = new StringBuilder();
-
- // Suppression des données à partir des docId du manifeste
- try {
- con = this.getConnection();
- for (final DocumentModel dm : dms.values()) {
- final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
- for (final TEtat etat : pc.getEtats()) {
- // Suppression des documents index
- for (final TTable table : pc.getEtat(etat.getId()).getIndexTables()) {
- final StringBuilder sb = new StringBuilder();
- sb.append("DELETE FROM ").append(table.getBaseName()).append(" WHERE ARCHIVE_NAME = ?");
-
- ps = con.prepareStatement(sb.toString());
- ps.setString(1, archiveName);
-
- ps.executeUpdate();
- ps.close();
- log.append(sb.toString()).append("; // ").append(archiveName).append("\n");
- }
- // Suppression des documents de l'etat
- final StringBuilder queryDocument = new StringBuilder();
- queryDocument.append("DELETE FROM ").append(pc.getEtat(etat.getId()).getDocumentTable().getBaseName()).append(" WHERE ARCHIVE_NAME = ?");
- ps = con.prepareStatement(queryDocument.toString());
- ps.setString(1, archiveName);
- ps.executeUpdate();
- log.append(queryDocument.toString()).append("; // ").append(archiveName).append("\n");
- ps.close();
-
- // Suppression des special keys du doc
- if (pc.getSpecialKeyTable() != null) {
- final StringBuilder querySps = new StringBuilder();
- querySps.append("DELETE FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE ARCHIVE_NAME = ?");
- ps = con.prepareStatement(querySps.toString());
- ps.setString(1, archiveName);
- ps.executeUpdate();
- log.append(querySps.toString()).append("; // ").append(archiveName).append("\n");
- ps.close();
- }
-
- // Suppression des budegt/collectivite du doc
- final StringBuilder queryBc = new StringBuilder();
- queryBc.append("DELETE FROM ").append(pc.getListBcTable().getBaseName()).append(" WHERE ARCHIVE_NAME = ?");
- ps = con.prepareStatement(queryBc.toString());
- ps.setString(1, archiveName);
- ps.executeUpdate();
- log.append(queryBc.toString()).append("; // ").append(archiveName).append("\n");
- ps.close();
- }
- }
- // suppression de l'entrée dans IMPORTED_ARCHIVES
- ps = con.prepareStatement("DELETE FROM IMPORTED_ARCHIVES WHERE ARCHIVE_NAME=?");
- ps.setString(1, archiveName);
- ps.executeUpdate();
- log.append("DELETE FROM IMPORTED_ARCHIVES WHERE ARCHIVE_NAME=?; // ").append(archiveName).append("\n");
- ps.close();
-
- // on ne touche pas la traçabilité ici, ce n'est pas du ressort de la persistence, mais du métier de l'importeur d'archive
-
- // logger.debug(log.toString());
- } catch (final Throwable t) {
- throw new DataConfigurationException("Problème lors de la suppression des données de l'archive !", t);
- } finally {
- if (ps != null) {
- try {
- ps.close();
- } catch (final Throwable t) {
- MySqlDataLayer.logger.info("can not close ps !", t);
- }
- }
- if (con != null) {
- this.releaseConnection(con);
- con = null;
- }
- }
- return true;
- }
-
@Override
public boolean updateManifeste(final String archiveName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
boolean retour = true;
}
@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 = this.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:StringIsNull", "est nul"), */
- 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:StringIsNull", "est nul"), */
+ 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)) {
whereClause.append(" WHERE ");
- whereClause.append(mainTable.getBaseName()).append("." + pc.getCollectiviteCodeColname() + "='").append(StringEscapeUtils.escapeSql(collectivite.key)).append("' AND ").append(mainTable.getBaseName())
- .append("." + pc.getBudgetCodeColname() + "='").append(StringEscapeUtils.escapeSql(budget.key)).append("' AND ( (");
+ whereClause.append(mainTable.getBaseName()).append("." + pc.getCollectiviteCodeColname() + "='").append(StringEscapeUtils.escapeSql(collectivite.key)).append("' AND ").append(mainTable.getBaseName()).append("." + pc.getBudgetCodeColname() + "='")
+ .append(StringEscapeUtils.escapeSql(budget.key)).append("' AND ( (");
for (final CritereModel cm : criterias) {
final TCriteria sci = (TCriteria) cm.getAdditionnalData();
if (sci.getSqlIndexId() == null) {
for (final TTable sti : sec.getIndexTables()) {
if (!sti.isMainTable() && criteriasUsedTables.contains(sti)) {
- fromClause.append(" LEFT OUTER JOIN ").append(sti.getBaseName()).append(" ON ").append(sec.getMaintable().getBaseName()).append(".DOC_ID=").append(sti.getBaseName()).append(".DOC_ID AND ").append(sec.getMaintable().getBaseName())
- .append("." + pc.getCollectiviteCodeColname() + "=").append(sti.getBaseName()).append("." + pc.getCollectiviteCodeColname() + " AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=")
- .append(sti.getBaseName()).append("." + pc.getBudgetCodeColname() + "");
+ fromClause.append(" LEFT OUTER JOIN ").append(sti.getBaseName()).append(" ON ").append(sec.getMaintable().getBaseName()).append(".DOC_ID=").append(sti.getBaseName()).append(".DOC_ID AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getCollectiviteCodeColname() + "=")
+ .append(sti.getBaseName()).append("." + pc.getCollectiviteCodeColname() + " AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=").append(sti.getBaseName()).append("." + pc.getBudgetCodeColname() + "");
}
}
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();) {
// if(!user.hasCollectivite(pj.getCollectivite())) throw new
// UnauthorizedException("Vous n'êtes pas autorisé à importer des données pour cette collectivité");
PreparedStatement ps = null;
- ResultSet rs = null;
+ final ResultSet rs = null;
Connection con = null;
try {
con = this.getConnection();
- final String s = "SELECT 1 FROM ATTACHMENTS WHERE COLLECTIVITE=? AND PJ_NAME=?";
- ps = con.prepareStatement(s);
+
+ ps = con.prepareStatement("DELETE FROM ATTACHMENTS WHERE COLLECTIVITE=? AND PJ_NAME=?");
ps.setString(1, pj.getCollectivite());
ps.setString(2, pj.getPjName());
- rs = ps.executeQuery();
- if (rs.next()) {
- ps.close();
- ps = con.prepareStatement("DELETE FROM ATTACHMENTS WHERE COLLECTIVITE=? AND PJ_NAME=?");
- ps.setString(1, pj.getCollectivite());
- ps.setString(2, pj.getPjName());
- ps.executeUpdate();
- }
+ ps.executeUpdate();
ps.close();
+
ps = con.prepareStatement("INSERT INTO ATTACHMENTS (COLLECTIVITE,ARCHIVE_NAME,PJ_NAME,FILE_NAME,DATA) VALUES (?,?,?,?,?)");
ps.setString(1, pj.getCollectivite());
if (archiveName != null) {
}
@Override
- public PJRef getPj(final Pair collectivite, final PJRefInfo pjRefInfo, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public PJRef getPj(final Pair collectivite, final String pjId, 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 String pjName = pjRefInfo.getNom();
-
// TODO
// if(!user.hasCollectivite(collectivite.key)) throw new
// UnauthorizedException("Vous n'êtes pas autorisé à rechercher des données pour cette collectivité "+collectivite.libelle!=null?"("+collectivite.libelle+")":"");
Connection con = null;
PreparedStatement ps = null;
PJRef pj = null;
- MySqlDataLayer.logger.debug("getting " + pjName + " in " + collectivite.key);
+ MySqlDataLayer.logger.debug("getting " + pjId + " in " + collectivite.key);
try {
con = this.getConnection();
final StringBuilder sb = new StringBuilder();
- sb.append("SELECT FILE_NAME, DATA FROM ATTACHMENTS WHERE COLLECTIVITE=? AND FILE_NAME=?");
+ sb.append("SELECT FILE_NAME, DATA FROM ATTACHMENTS WHERE COLLECTIVITE=? AND PJ_NAME=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
- ps.setString(2, pjName);
+ ps.setString(2, pjId);
final ResultSet rs = ps.executeQuery();
if (rs.next()) {
pj = new PJRef();
try {
con = this.getConnection();
final StringBuilder sb = new StringBuilder();
- sb.append("SELECT 1 FROM ATTACHMENTS WHERE COLLECTIVITE=? AND FILE_NAME=?");
+ sb.append("SELECT 1 FROM ATTACHMENTS WHERE COLLECTIVITE=? AND PJ_NAME=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
- ps.setString(2, pjRefInfo.getNom());
+ ps.setString(2, pjRefInfo.getId());
final ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret = true;
}
@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");
}
}
@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");
}
if (this.isTableExists(mainTable, connection)) {
final StringBuilder sb = new StringBuilder();
sb.append(
- "SELECT " + docPersistenceConfig.getCollectiviteCodeColname() + ", " + docPersistenceConfig.getCollectiviteLibColname() + ", " + docPersistenceConfig.getBudgetCodeColname() + ", " + docPersistenceConfig.getBudgetLibColname()
- + ", " + docPersistenceConfig.getInitialDocNameColname() + " FROM ").append(mainTable);
+ "SELECT " + docPersistenceConfig.getCollectiviteCodeColname() + ", " + docPersistenceConfig.getCollectiviteLibColname() + ", " + docPersistenceConfig.getBudgetCodeColname() + ", " + docPersistenceConfig.getBudgetLibColname() + ", "
+ + docPersistenceConfig.getInitialDocNameColname() + " FROM ").append(mainTable);
if (coll != null) {
sb.append(" WHERE " + docPersistenceConfig.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 = this.getConnection();
- final String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "SIZE, " + "PRIORITY, " + "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<DATE_ADD(CURDATE(),INTERVAL '7' DAY)) AND CLEANED IS NULL";
+ final String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "SIZE, " + "PRIORITY, " + "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<DATE_ADD(CURDATE(),INTERVAL '7' DAY)) 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 = this.getConnection();
- final String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "SIZE, " + "PRIORITY, " + "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, " + "SIZE, " + "PRIORITY, " + "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);
}
}
+ protected String adaptSqlForDatabaseEngine(final String sql) {
+
+ return sql;
+ }
+
+ protected void adaptCommitForDatabaseEngine(final Connection connection) throws SQLException {
+ // pas de commit, la transaction est en auto-commit
+ }
+
}