Skip to content

Commit

Permalink
fix: delete mongo functionalities
Browse files Browse the repository at this point in the history
  • Loading branch information
davdarras committed Feb 20, 2024
1 parent 4b1fe6a commit 8354ba9
Show file tree
Hide file tree
Showing 38 changed files with 49 additions and 1,325 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ Batch using to implement QUEEN DB from xml files.

## Requirements
For building and running the application you need:
- [JDK 1.11](https://jdk.java.net/archive/)
- JDK 21
- Maven 3

# Add lunatic librairy to project
``` shell
mvn install:install-file -Dfile=lib/lunatic-model-2.2.3.jar -DgroupId=fr.insee.lunatic -DartifactId=lunatic-model -Dversion=2.2.3 -Dpackaging=jar
mvn install:install-file -Dfile=lib/lunatic-model-2.5.1.jar -DgroupId=fr.insee.lunatic -DartifactId=lunatic-model -Dversion=2.5.1 -Dpackaging=jar
```

## Install and excute unit tests and ent-to-end tests
Expand All @@ -19,7 +19,7 @@ mvn clean install
```

## Running batch
Use the folowing cmd :
Use the following cmd :
``` shell
echo $@
java8 -Xms64m -Xmx512m -classpath '/path/to/lib/*' -Dlog4j.configurationFile=file:/path/to/log4j2/config/log4j2.xml -Dproperties.path=/path/to/properties -DcheminLog=/path/to/log fr.insee.queen.batch.Lanceur $@
Expand All @@ -38,7 +38,6 @@ fr.insee.queen.persistence.database.schema = XXXXXXX
fr.insee.queen.persistence.database.user = XXXXXXX
fr.insee.queen.persistence.database.password = XXXXXXX
fr.insee.queen.persistence.database.driver = org.postgresql.Driver
fr.insee.queen.application.persistenceType = (JPA or MONGODB)
fr.insee.queen.folder.in=path/to/in
fr.insee.queen.folder.out=path/to/out
fr.insee.queen.paradata.id=idSu
Expand All @@ -58,7 +57,6 @@ Before committing code please ensure,
- spring-data-jpa
- commons-lang3
- postgresql
- mongoDb
- liquibase
- spring-test
- test-containers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.SingleConnectionDataSource;

import com.mongodb.ConnectionString;
import com.mongodb.MongoClientSettings;
import com.mongodb.client.MongoClient;
import com.mongodb.client.MongoClients;

@Configuration
@ComponentScan("fr.insee.queen.batch.*")
@PropertySource(value = {"classpath:/queen-bo.properties", "file:${properties.path}/queen-bo.properties"}, ignoreResourceNotFound = true)
Expand Down Expand Up @@ -72,7 +65,6 @@ public class ApplicationContext {
* @return new Datasource
*/
@Bean("dataSource")
@Conditional(value= ConditonJpa.class)
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName(dbDriver);
Expand All @@ -89,7 +81,6 @@ public DataSource dataSource() {
* @throws SQLException
*/
@Bean("connection")
@Conditional(value= ConditonJpa.class)
public Connection connection(@Autowired @Qualifier("dataSource") DataSource dataSource) throws SQLException {
return DataSourceUtils.getConnection(dataSource);
}
Expand All @@ -100,7 +91,6 @@ public Connection connection(@Autowired @Qualifier("dataSource") DataSource data
* @return JdbcTemplate
*/
@Bean("jdbcTemplate")
@Conditional(value= ConditonJpa.class)
public JdbcTemplate jdbcTemplate(@Autowired @Qualifier("dataSource") DataSource dataSource) {
JdbcTemplate jdbcTemplate = null;
try {
Expand All @@ -111,32 +101,7 @@ public JdbcTemplate jdbcTemplate(@Autowired @Qualifier("dataSource") DataSource
jdbcTemplate.setResultsMapCaseInsensitive(true);
return jdbcTemplate;
}

/**
* Method used to create the connection with the mongo database
* @return
*/
@Bean
@Conditional(value= ConditonMongo.class)
public MongoClient mongo() {
ConnectionString connectionString = new ConnectionString(String.format("mongodb://%s:%s/%s", dbHost, dbPort, dbSchema));
MongoClientSettings mongoClientSettings = MongoClientSettings.builder()
.applyConnectionString(connectionString)
.build();
return MongoClients.create(mongoClientSettings);
}

/**
* Method used to create the mongoTemplate
* @return
* @throws Exception
*/
@Conditional(value= ConditonMongo.class)
@Bean
public MongoTemplate mongoTemplate() throws Exception {
return new MongoTemplate(mongo(), dbSchema);
}


/**
* Bean to get the Folder_in value
* @return
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/fr/insee/queen/batch/config/ConditonJpa.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
Expand All @@ -16,11 +15,10 @@ public class ConditonJpa implements Condition{
/**
* This method override the Condition.class and checking if
* the application needs to be launch in JPA persistence mode
* There is no mongo anymore but we keep this class now as it is used by other jars
*/
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
Environment env = context.getEnvironment();
return null != env
&& "JPA".equals(env.getProperty("fr.insee.queen.application.persistenceType"));
return true;
}
}
7 changes: 3 additions & 4 deletions src/main/java/fr/insee/queen/batch/config/ConditonMongo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
Expand All @@ -16,11 +15,11 @@ public class ConditonMongo implements Condition{
/**
* This method override the Condition.class and checking if
* the application needs to be launch in MONGO persistence mode
*
* There is no mongo anymore but we keep this class now as it is used by other jars
*/
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
Environment env = context.getEnvironment();
return null != env
&& "MONGODB".equals(env.getProperty("fr.insee.queen.application.persistenceType"));
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import fr.insee.queen.batch.config.ConditonJpa;
import fr.insee.queen.batch.dao.CampaignDao;
import fr.insee.queen.batch.object.Campaign;

Expand All @@ -21,7 +18,6 @@
*
*/
@Service
@Conditional(value= ConditonJpa.class)
public class CampaignDaoJpaImpl implements CampaignDao {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@
import org.postgresql.util.PGobject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import fr.insee.queen.batch.config.ConditonJpa;
import fr.insee.queen.batch.dao.CommentDao;
import fr.insee.queen.batch.object.SurveyUnit;

Expand All @@ -22,7 +20,6 @@
*
*/
@Service
@Conditional(value= ConditonJpa.class)
public class CommentDaoJpaImpl implements CommentDao {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
import org.postgresql.util.PGobject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import fr.insee.queen.batch.config.ConditonJpa;
import fr.insee.queen.batch.dao.DataDao;
import fr.insee.queen.batch.object.SurveyUnit;

Expand All @@ -24,7 +22,6 @@
*
*/
@Service
@Conditional(value= ConditonJpa.class)
public class DataDaoJpaImpl implements DataDao {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
import org.postgresql.util.PGobject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import fr.insee.queen.batch.config.ConditonJpa;
import fr.insee.queen.batch.dao.NomenclatureDao;
import fr.insee.queen.batch.object.Nomenclature;

Expand All @@ -22,7 +20,6 @@
*
*/
@Service
@Conditional(value= ConditonJpa.class)
public class NomenclatureDaoJpaImpl implements NomenclatureDao {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.sql.SQLException;
import java.util.*;

import fr.insee.queen.batch.dao.mongo.impl.ParadataEventDaoMongoImpl;
import fr.insee.queen.batch.object.ParadataEvent;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
Expand All @@ -13,12 +12,10 @@
import org.postgresql.util.PGobject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import fr.insee.queen.batch.config.ConditonJpa;
import fr.insee.queen.batch.dao.ParadataEventDao;
import fr.insee.queen.batch.service.DatabaseService;

Expand All @@ -28,7 +25,6 @@
*
*/
@Service
@Conditional(value= ConditonJpa.class)
public class ParadataEventDaoJpaImpl implements ParadataEventDao{

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@
import org.postgresql.util.PGobject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import fr.insee.queen.batch.config.ConditonJpa;
import fr.insee.queen.batch.dao.PersonalizationDao;
import fr.insee.queen.batch.object.Personalization;
import fr.insee.queen.batch.object.SurveyUnit;
Expand All @@ -28,7 +26,6 @@
*
*/
@Service
@Conditional(value= ConditonJpa.class)
public class PersonalizationDaoJpaImpl implements PersonalizationDao{

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
import org.postgresql.util.PGobject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import fr.insee.queen.batch.config.ConditonJpa;
import fr.insee.queen.batch.dao.QuestionnaireModelDao;
import fr.insee.queen.batch.object.QuestionnaireModel;

Expand All @@ -23,7 +21,6 @@
*
*/
@Service
@Conditional(value= ConditonJpa.class)
public class QuestionnaireModelDaoJpaImpl implements QuestionnaireModelDao{

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import fr.insee.queen.batch.config.ConditonJpa;
import fr.insee.queen.batch.dao.RequiredNomenclatureDao;
import fr.insee.queen.batch.object.Nomenclature;

Expand All @@ -19,7 +17,6 @@
*
*/
@Service
@Conditional(value= ConditonJpa.class)
public class RequiredNomenclatureDaoJpaImpl implements RequiredNomenclatureDao{

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,18 @@

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import fr.insee.queen.batch.config.ConditonJpa;
import fr.insee.queen.batch.dao.StateDataDao;
import fr.insee.queen.batch.object.StateData;
import fr.insee.queen.batch.utils.PathUtils;

/**
* Service for the StateData entity that implements the interface associated
* @author scorcaud
*
*/
@Service
@Conditional(value= ConditonJpa.class)
public class StateDataDaoJpaImpl implements StateDataDao{

@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
import fr.insee.queen.batch.object.StateData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Conditional;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import fr.insee.queen.batch.config.ConditonJpa;
import fr.insee.queen.batch.dao.SurveyUnitDao;
import fr.insee.queen.batch.object.SurveyUnit;

Expand All @@ -25,7 +23,6 @@
*
*/
@Service
@Conditional(value= ConditonJpa.class)
public class SurveyUnitDaoJpaImpl implements SurveyUnitDao {

@Autowired
Expand Down
Loading

0 comments on commit 8354ba9

Please sign in to comment.