Skip to content
Snippets Groups Projects
Commit 506dab31 authored by gwen-soleil's avatar gwen-soleil
Browse files

modify connection to DB API to pass a DataParameters object

parent c214b398
No related branches found
No related tags found
No related merge requests found
...@@ -11,9 +11,11 @@ ...@@ -11,9 +11,11 @@
<groupId>fr.soleil.lib</groupId> <groupId>fr.soleil.lib</groupId>
<artifactId>snapArchivingApi</artifactId> <artifactId>snapArchivingApi</artifactId>
<version>1.8.6</version> <version>1.9.0</version>
<name>snapArchivingApi</name> <name>snapArchivingApi</name>
<description>Snap Archiving API</description> <description>Snap Archiving API</description>
<developers> <developers>
<developer> <developer>
<id>abeille</id> <id>abeille</id>
...@@ -40,9 +42,9 @@ ...@@ -40,9 +42,9 @@
</developers> </developers>
<scm> <scm>
<connection>${scm.connection.svn.tango-cs}:archiving/api/snapArchivingApi/trunk</connection> <connection>git@gitlab.synchrotron-soleil.fr:software-control-system/tango-controls-archiving/SnapArchivingApi.git</connection>
<developerConnection>${scm.developerConnection.svn.tango-cs}:archiving/api/snapArchivingApi/trunk</developerConnection> <developerConnection>git@gitlab.synchrotron-soleil.fr:software-control-system/tango-controls-archiving/SnapArchivingApi.git</developerConnection>
<url>${scm.url.svn.tango-cs}/archiving/api/snapArchivingApi/trunk</url> <url>git@gitlab.synchrotron-soleil.fr:software-control-system/tango-controls-archiving/SnapArchivingApi.git</url>
</scm> </scm>
<dependencies> <dependencies>
......
...@@ -172,36 +172,6 @@ ...@@ -172,36 +172,6 @@
//-====================================================================== //-======================================================================
package fr.soleil.archiving.snap.api; package fr.soleil.archiving.snap.api;
import java.lang.reflect.Array;
/*
* Import classes
*/
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.statement.Query;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.esrf.Tango.AttrDataFormat; import fr.esrf.Tango.AttrDataFormat;
import fr.esrf.Tango.AttrWriteType; import fr.esrf.Tango.AttrWriteType;
import fr.esrf.Tango.ErrSeverity; import fr.esrf.Tango.ErrSeverity;
...@@ -221,6 +191,30 @@ import fr.soleil.archiving.snap.api.tools.TangoJAVAUtils; ...@@ -221,6 +191,30 @@ import fr.soleil.archiving.snap.api.tools.TangoJAVAUtils;
import fr.soleil.database.connection.AbstractDataBaseConnector; import fr.soleil.database.connection.AbstractDataBaseConnector;
import fr.soleil.database.connection.DataBaseParameters; import fr.soleil.database.connection.DataBaseParameters;
import fr.soleil.database.connection.DataBaseParameters.DataBaseType; import fr.soleil.database.connection.DataBaseParameters.DataBaseType;
import org.jdbi.v3.core.Handle;
import org.jdbi.v3.core.statement.Query;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Array;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.stream.Collectors;
/** /**
* <b>Description : </b> This class hides the loading of drivers, the * <b>Description : </b> This class hides the loading of drivers, the
...@@ -256,56 +250,25 @@ public class DataBaseAPI { ...@@ -256,56 +250,25 @@ public class DataBaseAPI {
/** /**
* Constructor using host name, user name, password and database name. * Constructor using host name, user name, password and database name.
* *
* @param dbHostName * @param params Database connection parameters
* Identifier (name or IP adress) of the machine which supplies
* the service data base
* @param dbName
* Name of the data base used
* @param dbSchemaName
* Name of the database's schema used
* @param userName
* Name to use to connect
* @param password
* Password to use to connect
*/ */
public DataBaseAPI(final String dbHostName, final String dbName, final String dbSchemaName, final String userName, public DataBaseAPI(DataBaseParameters params) throws ArchivingException {
final String password, final boolean isRac) { if (params.getHost().equals("")) {
params = new DataBaseParameters();
params.setHost(dbHostName);
params.setName(dbName);
params.setSchema(dbSchemaName);
params.setUser(userName);
params.setPassword(password);
if (!dbSchemaName.equals("")) {
params.setSchema(dbSchemaName);
} else {
params.setSchema(dbName);
}
if (dbHostName.equals("")) {
params.setDbType(DataBaseType.H2); params.setDbType(DataBaseType.H2);
try {
connector = ConnectionFactory.connect(params); connector = ConnectionFactory.connect(params);
return; } else {
} catch (ArchivingException e) {
e.printStackTrace();
}
}
try { try {
params.setDbType(DataBaseType.ORACLE); params.setDbType(DataBaseType.ORACLE);
connector = ConnectionFactory.connect(params); connector = ConnectionFactory.connect(params);
} catch (Exception e) { } catch (Exception e) {
params.setDbType(DataBaseType.MYSQL); params.setDbType(DataBaseType.MYSQL);
try {
connector = ConnectionFactory.connect(params); connector = ConnectionFactory.connect(params);
} catch (ArchivingException e1) {
e1.printStackTrace();
} }
} }
this.params = params;
} }
/** /**
* <b>Description : </b> Gets the database name * <b>Description : </b> Gets the database name
* *
...@@ -366,10 +329,8 @@ public class DataBaseAPI { ...@@ -366,10 +329,8 @@ public class DataBaseAPI {
* <b>Description</b> : Methods that counts the number of non null rows in * <b>Description</b> : Methods that counts the number of non null rows in
* an array * an array
* *
* @param arr * @param arr an array of Strings
* an array of Strings * @throws NullPointerException *************************************************************
* @throws NullPointerException
* *************************************************************
* * *********** * * ***********
*/ */
public int getArrayCount(final String[] arr) { public int getArrayCount(final String[] arr) {
...@@ -390,8 +351,7 @@ public class DataBaseAPI { ...@@ -390,8 +351,7 @@ public class DataBaseAPI {
* ************************************************************************ * ************************************************************************
* <b>Description : </b> Closes the connection with the database * <b>Description : </b> Closes the connection with the database
* *
* @throws SnapshotingException * @throws SnapshotingException *************************************************************
* *************************************************************
* * ********* * * *********
*/ */
public void close(final Connection conn) { public void close(final Connection conn) {
...@@ -411,11 +371,9 @@ public class DataBaseAPI { ...@@ -411,11 +371,9 @@ public class DataBaseAPI {
* <b>Description : </b> Gets for a specified attribute its ID as defined in * <b>Description : </b> Gets for a specified attribute its ID as defined in
* SnapDb * SnapDb
* *
* @param att_name * @param att_name The attribute's name
* The attribute's name
* @return The <I>SnapDb</I>'s ID that caracterize the given attribute * @return The <I>SnapDb</I>'s ID that caracterize the given attribute
* @throws SnapshotingException * @throws SnapshotingException *************************************************************
* *************************************************************
* * ********* * * *********
*/ */
public int getAttID(final String att_name) throws SnapshotingException { public int getAttID(final String att_name) throws SnapshotingException {
...@@ -467,8 +425,7 @@ public class DataBaseAPI { ...@@ -467,8 +425,7 @@ public class DataBaseAPI {
* already registered in <I>SnapDb</I> (and more particularly in the table * already registered in <I>SnapDb</I> (and more particularly in the table
* of the definitions). * of the definitions).
* *
* @param att_name * @param att_name The name of the attribute to check.
* The name of the attribute to check.
* @return boolean * @return boolean
* @throws SnapshotingException * @throws SnapshotingException
*/ */
...@@ -527,7 +484,6 @@ public class DataBaseAPI { ...@@ -527,7 +484,6 @@ public class DataBaseAPI {
} }
/** /**
* This method retrives from the the database, the list of all registered * This method retrives from the the database, the list of all registered
* contexts (or 'snap-patterns) which subscribe to the clause and/or have * contexts (or 'snap-patterns) which subscribe to the clause and/or have
...@@ -603,8 +559,7 @@ public class DataBaseAPI { ...@@ -603,8 +559,7 @@ public class DataBaseAPI {
* Retrieves the context identifier to wich the given snapshot identifier is * Retrieves the context identifier to wich the given snapshot identifier is
* associated. * associated.
* *
* @param snapID * @param snapID the snapshot identifier
* the snapshot identifier
* @return the associated context identifier * @return the associated context identifier
* @throws SnapshotingException * @throws SnapshotingException
*/ */
...@@ -678,7 +633,6 @@ public class DataBaseAPI { ...@@ -678,7 +633,6 @@ public class DataBaseAPI {
} }
private void selectRO(final List<SnapAttributeExtract> attributes, int snapID, private void selectRO(final List<SnapAttributeExtract> attributes, int snapID,
final String tableName) throws SnapshotingException, SQLException { final String tableName) throws SnapshotingException, SQLException {
...@@ -818,11 +772,9 @@ public class DataBaseAPI { ...@@ -818,11 +772,9 @@ public class DataBaseAPI {
/** /**
* Retrieve a snapshot results' * Retrieve a snapshot results'
* *
* @param attributes * @param attributes the attributes to retrieve. Will contain results after
* the attributes to retrieve. Will contain results after
* execution * execution
* @param snapID * @param snapID The snap ID
* The snap ID
* @throws SnapshotingException * @throws SnapshotingException
*/ */
public void getSnapResults(final List<SnapAttributeExtract> attributes, final int snapID) public void getSnapResults(final List<SnapAttributeExtract> attributes, final int snapID)
...@@ -895,9 +847,6 @@ public class DataBaseAPI { ...@@ -895,9 +847,6 @@ public class DataBaseAPI {
} }
public void closeResultSet(final ResultSet resultSet) { public void closeResultSet(final ResultSet resultSet) {
if (resultSet == null) { if (resultSet == null) {
return; return;
...@@ -947,7 +896,6 @@ public class DataBaseAPI { ...@@ -947,7 +896,6 @@ public class DataBaseAPI {
} }
private NullableData<?> getSpectrumValue(final String readStr, final String writeStr, final int dataType, private NullableData<?> getSpectrumValue(final String readStr, final String writeStr, final int dataType,
final boolean returnAsReadWrite) { final boolean returnAsReadWrite) {
int readSize = 0, writeSize = 0; int readSize = 0, writeSize = 0;
...@@ -1046,8 +994,7 @@ public class DataBaseAPI { ...@@ -1046,8 +994,7 @@ public class DataBaseAPI {
* This methos does not take care of id parameter of the given attribute as * This methos does not take care of id parameter of the given attribute as
* this parameter is managed in the database side (autoincrement). * this parameter is managed in the database side (autoincrement).
* *
* @param snapAttributeHeavy * @param snapAttributeHeavy the attribute to register
* the attribute to register
* @throws SnapshotingException * @throws SnapshotingException
*/ */
public void registerAttribute(final AttributeHeavy snapAttributeHeavy) throws SnapshotingException { public void registerAttribute(final AttributeHeavy snapAttributeHeavy) throws SnapshotingException {
...@@ -1131,8 +1078,7 @@ public class DataBaseAPI { ...@@ -1131,8 +1078,7 @@ public class DataBaseAPI {
/** /**
* This method registers a new context in the database for snapshots. * This method registers a new context in the database for snapshots.
* *
* @param snapContext * @param snapContext the new context to register into the database for snapshots.
* the new context to register into the database for snapshots.
* @return the context identifier (int) associated to the new registered * @return the context identifier (int) associated to the new registered
* context. * context.
* @throws SnapshotingException * @throws SnapshotingException
...@@ -1338,8 +1284,7 @@ public class DataBaseAPI { ...@@ -1338,8 +1284,7 @@ public class DataBaseAPI {
/** /**
* Retrieve ID, data_type, data_format, writable of some attributes * Retrieve ID, data_type, data_format, writable of some attributes
* *
* @param attributeNames * @param attributeNames The attribute names
* The attribute names
* @return * @return
* @throws SnapshotingException * @throws SnapshotingException
*/ */
...@@ -1419,8 +1364,7 @@ public class DataBaseAPI { ...@@ -1419,8 +1364,7 @@ public class DataBaseAPI {
/** /**
* This method returns the list of attributes associated to a context * This method returns the list of attributes associated to a context
* *
* @param id_context * @param id_context The given context's identifier
* The given context's identifier
* @return The list of attributes associated to the given context * @return The list of attributes associated to the given context
* @throws SnapshotingException * @throws SnapshotingException
* @see SnapAttributeLight * @see SnapAttributeLight
...@@ -1550,11 +1494,9 @@ public class DataBaseAPI { ...@@ -1550,11 +1494,9 @@ public class DataBaseAPI {
/** /**
* This method registers a new snapshots and retrieves its identifier * This method registers a new snapshots and retrieves its identifier
* *
* @param contextID * @param contextID the context identifier to wich the new registered snapshots
* the context identifier to wich the new registered snapshots
* belongs to. * belongs to.
* @param timestamp * @param timestamp the registration timestamp
* the registration timestamp
* @return the identifier for the new registered snapshot * @return the identifier for the new registered snapshot
* @throws SnapshotingException * @throws SnapshotingException
* @see #getMaxContextID() * @see #getMaxContextID()
...@@ -1575,11 +1517,9 @@ public class DataBaseAPI { ...@@ -1575,11 +1517,9 @@ public class DataBaseAPI {
/** /**
* This method registers a new snapshots and retrieves its identifier * This method registers a new snapshots and retrieves its identifier
* *
* @param contextID * @param contextID the context identifier to wich the new registered snapshots
* the context identifier to wich the new registered snapshots
* belongs to. * belongs to.
* @param timestamp * @param timestamp the registration timestamp
* the registration timestamp
* @return the identifier for the new registered snapshot * @return the identifier for the new registered snapshot
* @throws SnapshotingException * @throws SnapshotingException
* @see #getMaxContextID() * @see #getMaxContextID()
...@@ -1621,11 +1561,9 @@ public class DataBaseAPI { ...@@ -1621,11 +1561,9 @@ public class DataBaseAPI {
/** /**
* This method registers a new snapshots and retrieves its identifier * This method registers a new snapshots and retrieves its identifier
* *
* @param contextID * @param contextID the context identifier to wich the new registered snapshots
* the context identifier to wich the new registered snapshots
* belongs to. * belongs to.
* @param timestamp * @param timestamp the registration timestamp
* the registration timestamp
* @return the identifier for the new registered snapshot * @return the identifier for the new registered snapshot
* @throws SnapshotingException * @throws SnapshotingException
* @see #getMaxContextID() * @see #getMaxContextID()
...@@ -1744,8 +1682,7 @@ public class DataBaseAPI { ...@@ -1744,8 +1682,7 @@ public class DataBaseAPI {
/** /**
* Get the comment of a snapshot * Get the comment of a snapshot
* *
* @param snapID * @param snapID the snapshot ID
* the snapshot ID
* @return the comment * @return the comment
* @throws SnapshotingException * @throws SnapshotingException
*/ */
...@@ -1870,8 +1807,7 @@ public class DataBaseAPI { ...@@ -1870,8 +1807,7 @@ public class DataBaseAPI {
} }
/** /**
* @param currentSpectrumDimX * @param currentSpectrumDimX The currentSpectrumDimX to set.
* The currentSpectrumDimX to set.
*/ */
public void setCurrentSpectrumDimX(final int currentSpectrumDimX) { public void setCurrentSpectrumDimX(final int currentSpectrumDimX) {
this.currentSpectrumDimX = currentSpectrumDimX; this.currentSpectrumDimX = currentSpectrumDimX;
......
...@@ -94,15 +94,6 @@ ...@@ -94,15 +94,6 @@
package fr.soleil.archiving.snap.api.manager; package fr.soleil.archiving.snap.api.manager;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.esrf.Tango.AttrDataFormat; import fr.esrf.Tango.AttrDataFormat;
import fr.esrf.Tango.AttrWriteType; import fr.esrf.Tango.AttrWriteType;
import fr.esrf.Tango.DevFailed; import fr.esrf.Tango.DevFailed;
...@@ -117,10 +108,10 @@ import fr.esrf.TangoApi.DeviceAttribute; ...@@ -117,10 +108,10 @@ import fr.esrf.TangoApi.DeviceAttribute;
import fr.esrf.TangoApi.DeviceData; import fr.esrf.TangoApi.DeviceData;
import fr.esrf.TangoApi.DeviceProxy; import fr.esrf.TangoApi.DeviceProxy;
import fr.esrf.TangoDs.TangoConst; import fr.esrf.TangoDs.TangoConst;
import fr.soleil.archiving.common.api.exception.ArchivingException;
import fr.soleil.archiving.common.api.tools.AttributeHeavy; import fr.soleil.archiving.common.api.tools.AttributeHeavy;
import fr.soleil.archiving.common.api.tools.AttributeLight; import fr.soleil.archiving.common.api.tools.AttributeLight;
import fr.soleil.archiving.snap.api.DataBaseAPI; import fr.soleil.archiving.snap.api.DataBaseAPI;
import fr.soleil.archiving.snap.api.SnapConnectionParameters;
import fr.soleil.archiving.snap.api.tools.Criterions; import fr.soleil.archiving.snap.api.tools.Criterions;
import fr.soleil.archiving.snap.api.tools.SnapAttributeExtract; import fr.soleil.archiving.snap.api.tools.SnapAttributeExtract;
import fr.soleil.archiving.snap.api.tools.SnapConst; import fr.soleil.archiving.snap.api.tools.SnapConst;
...@@ -128,29 +119,32 @@ import fr.soleil.archiving.snap.api.tools.SnapContext; ...@@ -128,29 +119,32 @@ import fr.soleil.archiving.snap.api.tools.SnapContext;
import fr.soleil.archiving.snap.api.tools.Snapshot; import fr.soleil.archiving.snap.api.tools.Snapshot;
import fr.soleil.archiving.snap.api.tools.SnapshotLight; import fr.soleil.archiving.snap.api.tools.SnapshotLight;
import fr.soleil.archiving.snap.api.tools.SnapshotingException; import fr.soleil.archiving.snap.api.tools.SnapshotingException;
import fr.soleil.database.connection.DataBaseParameters;
import fr.soleil.database.connection.DataBaseParameters.DataBaseType; import fr.soleil.database.connection.DataBaseParameters.DataBaseType;
import fr.soleil.lib.project.math.NumberArrayUtils; import fr.soleil.lib.project.math.NumberArrayUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class SnapManagerApi { public class SnapManagerApi {
// Device class
public static final String SNAP_ARCHIVER_DEVICE_CLASS = "SnapArchiver";
public static final String SNAP_MANAGER_DEVICE_CLASS = "SnapManager";
public static final String SNAP_EXTRACTOR_DEVICE_CLASS = "SnapExtractor";
private static final Logger LOGGER = LoggerFactory.getLogger(SnapManagerApi.class); private static final Logger LOGGER = LoggerFactory.getLogger(SnapManagerApi.class);
private static final String NAN_ARRAY = "[NaN]"; private static final String NAN_ARRAY = "[NaN]";
private static final String NAN = "NaN"; private static final String NAN = "NaN";
private static final String DATA_BASE_API_NOT_INIT = "DataBaseAPI not initialized"; private static final String DATA_BASE_API_NOT_INIT = "DataBaseAPI not initialized";
// Command name // Command name
private static final String LAUNCH_SNAPHOT = "LaunchSnapShot"; private static final String LAUNCH_SNAPHOT = "LaunchSnapShot";
private static final String CREATE_CONTEXT = "CreateNewContext"; private static final String CREATE_CONTEXT = "CreateNewContext";
private static final String TRIGGER_LAUNCH_SNAPHOT = "TriggerLaunchSnapShot"; private static final String TRIGGER_LAUNCH_SNAPHOT = "TriggerLaunchSnapShot";
// Device class
public static final String SNAP_ARCHIVER_DEVICE_CLASS = "SnapArchiver";
public static final String SNAP_MANAGER_DEVICE_CLASS = "SnapManager";
public static final String SNAP_EXTRACTOR_DEVICE_CLASS = "SnapExtractor";
// Snap Data Base // Snap Data Base
private static DataBaseAPI snapDataBase = null; private static DataBaseAPI snapDataBase = null;
...@@ -225,8 +219,7 @@ public class SnapManagerApi { ...@@ -225,8 +219,7 @@ public class SnapManagerApi {
* This method returns the name of one of the running devices, according to * This method returns the name of one of the running devices, according to
* the given class * the given class
* *
* @param deviceClass * @param deviceClass The device's class
* The device's class
* @return The device's name * @return The device's name
* @throws DevFailed * @throws DevFailed
*/ */
...@@ -355,37 +348,16 @@ public class SnapManagerApi { ...@@ -355,37 +348,16 @@ public class SnapManagerApi {
return argout; return argout;
} }
public static synchronized void initFullSnapConnection(final String host, final String name, final String schema, public static synchronized void initSnapConnection(DataBaseParameters parameters) throws ArchivingException {
final String user, final String pass, final String isRac) throws SnapshotingException { snapDataBase = new DataBaseAPI(parameters);
SnapConnectionParameters.initFromArgumentsProperties(host, name, schema, user, pass, isRac);
SnapConnectionParameters.initFromSystemProperties();
SnapConnectionParameters.initFromClassProperties();
SnapConnectionParameters.initFromDefaultProperties();
snapDataBase = new DataBaseAPI(SnapConnectionParameters.getSnapHost(), SnapConnectionParameters.getSnapName(),
SnapConnectionParameters.getSnapSchema(), SnapConnectionParameters.getSnapUser(),
SnapConnectionParameters.getSnapPassword(), SnapConnectionParameters.isSnapRac());
LOGGER.info(SnapConnectionParameters.appendSnapConnectionInfoLog(new StringBuilder("Connection info:\n"))
.toString());
}
public static synchronized void initSnapConnection(final String host, final String name, final String schema,
final String user, final String pass, final String isRac) throws SnapshotingException {
snapDataBase = new DataBaseAPI(host, name, schema, user, pass, Boolean.parseBoolean(isRac));
} }
/** /**
* This method gets informations on a given attribute and registers the * This method gets informations on a given attribute and registers the
* attribute into the database "Snap" * attribute into the database "Snap"
* *
* @param att_complete_name * @param att_complete_name the given attribute
* the given attribute * @throws SnapshotingException exception throwned in case of communications problems with
* @throws SnapshotingException
* exception throwned in case of communications problems with
* the device or database * the device or database
*/ */
private static void register(String att_complete_name) throws SnapshotingException { private static void register(String att_complete_name) throws SnapshotingException {
...@@ -452,8 +424,7 @@ public class SnapManagerApi { ...@@ -452,8 +424,7 @@ public class SnapManagerApi {
/** /**
* This method insure that a given attribute was registered into Snap DB * This method insure that a given attribute was registered into Snap DB
* *
* @param attributeName * @param attributeName the attribute name.
* the attribute name.
*/ */
public static void insureRegitration(final String attributeName) throws SnapshotingException { public static void insureRegitration(final String attributeName) throws SnapshotingException {
if (snapDataBase == null) { if (snapDataBase == null) {
...@@ -545,8 +516,7 @@ public class SnapManagerApi { ...@@ -545,8 +516,7 @@ public class SnapManagerApi {
* TODO LG Description : Extracts the clause SQL from the given criterions * TODO LG Description : Extracts the clause SQL from the given criterions
* and gets the contexts which subscribe to thoses conditions * and gets the contexts which subscribe to thoses conditions
* *
* @param criterions * @param criterions Conditions related to the fields of the context table
* Conditions related to the fields of the context table
* @return a list of contexts which subscribe to the given conditions * @return a list of contexts which subscribe to the given conditions
* (Criterions) * (Criterions)
* @throws SnapshotingException * @throws SnapshotingException
...@@ -585,8 +555,7 @@ public class SnapManagerApi { ...@@ -585,8 +555,7 @@ public class SnapManagerApi {
* This method triggers the snapshoting oh attributes that belong to the * This method triggers the snapshoting oh attributes that belong to the
* context identified by the the given contextID * context identified by the the given contextID
* *
* @param contextID * @param contextID The context identifier
* The context identifier
* @return The 'SnapManagerResult.OK_SNAPLAUNCH' if success, * @return The 'SnapManagerResult.OK_SNAPLAUNCH' if success,
* 'SnapManagerResult.ERROR_SNAPLAUNCH' otherwise * 'SnapManagerResult.ERROR_SNAPLAUNCH' otherwise
*/ */
...@@ -630,10 +599,8 @@ public class SnapManagerApi { ...@@ -630,10 +599,8 @@ public class SnapManagerApi {
* context identified by the given id_context and subscribe to the given * context identified by the given id_context and subscribe to the given
* conditions (criterions) * conditions (criterions)
* *
* @param id_context * @param id_context The context identifier
* The context identifier * @param criterions Conditions related to fields of the context table
* @param criterions
* Conditions related to fields of the context table
* @return a list of attributes that belong to the context identified by the * @return a list of attributes that belong to the context identified by the
* given id_context and subscribe to the given conditions * given id_context and subscribe to the given conditions
* (criterions) * (criterions)
...@@ -662,7 +629,6 @@ public class SnapManagerApi { ...@@ -662,7 +629,6 @@ public class SnapManagerApi {
} }
/** /**
*
* @param snapshot * @param snapshot
* @param contextID * @param contextID
* @return * @return
...@@ -686,7 +652,6 @@ public class SnapManagerApi { ...@@ -686,7 +652,6 @@ public class SnapManagerApi {
} }
public static int getMaxID() throws SnapshotingException { public static int getMaxID() throws SnapshotingException {
if (snapDataBase == null) { if (snapDataBase == null) {
throw new SnapshotingException(DATA_BASE_API_NOT_INIT); throw new SnapshotingException(DATA_BASE_API_NOT_INIT);
...@@ -695,13 +660,11 @@ public class SnapManagerApi { ...@@ -695,13 +660,11 @@ public class SnapManagerApi {
} }
/** /**
* TODO LG Description : Extracts the clause SQL from the given criterions * TODO LG Description : Extracts the clause SQL from the given criterions
* and gets the snapshots which subscribe to thoses conditions * and gets the snapshots which subscribe to thoses conditions
* *
* @param criterions * @param criterions Conditions related to the fields of the snapshot table
* Conditions related to the fields of the snapshot table
* @return a list of snapshots which subscribe to the given conditions * @return a list of snapshots which subscribe to the given conditions
* (Criterions) * (Criterions)
* @throws SnapshotingException * @throws SnapshotingException
...@@ -768,8 +731,7 @@ public class SnapManagerApi { ...@@ -768,8 +731,7 @@ public class SnapManagerApi {
/** /**
* Get the comment of a snapshot * Get the comment of a snapshot
* *
* @param snapID * @param snapID the snapshot ID
* the snapshot ID
* @return the comment * @return the comment
* @throws SnapshotingException * @throws SnapshotingException
*/ */
...@@ -943,7 +905,6 @@ public class SnapManagerApi { ...@@ -943,7 +905,6 @@ public class SnapManagerApi {
} }
/** /**
*
* @param cmd_name * @param cmd_name
* @param option * @param option
* @param id_snap * @param id_snap
......
...@@ -10,6 +10,8 @@ import static org.junit.Assert.assertTrue; ...@@ -10,6 +10,8 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import fr.soleil.archiving.common.api.exception.ArchivingException;
import fr.soleil.database.connection.DataBaseParameters;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
...@@ -25,8 +27,14 @@ public class DataBaseAPITest extends AbstractTest { ...@@ -25,8 +27,14 @@ public class DataBaseAPITest extends AbstractTest {
DataBaseAPI dbApi; DataBaseAPI dbApi;
@Before @Before
public void initDataBaseAPI() { public void initDataBaseAPI() throws ArchivingException {
dbApi = new DataBaseAPI("", "public", "public", "snap", "snap", false); DataBaseParameters parameters = new DataBaseParameters();
parameters.setHost("");
parameters.setName("public");
parameters.setSchema("public");
parameters.setUser("snap");
parameters.setPassword("snap");
dbApi = new DataBaseAPI(parameters);
} }
@Test @Test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment