Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOSIP-21290] Added util to remap duplicate uin and its vid to primary #1098

Open
wants to merge 1 commit into
base: 1.1.5.6
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions deployment/sandbox-v2/utils/id-repository-uin-remap-util/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SWAGGER UI: http://localhost:8888/idrepository/v1/remap/swagger-ui/index.html?configUrl=/idrepository/v1/remap/v3/api-docs/swagger-config

PATCH: http://localhost:8888/idrepository/v1/remap/remap

REQUEST:
{
"primaryUin": "4791867143",
"uinsToDeactivate": [
"6207103247"
]
}
126 changes: 126 additions & 0 deletions deployment/sandbox-v2/utils/id-repository-uin-remap-util/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.2.RELEASE</version>
</parent>
<groupId>io.mosip.idrepository</groupId>
<artifactId>id-repository-uin-remap-util</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.10</version>
</dependency>
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-core</artifactId>
<version>1.2.0</version>
<exclusions>
<exclusion>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>1.7.0</version>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>build-info</goal>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<licenses>
<license>
<name>MPL 2.0</name>
<url>https://www.mozilla.org/en-US/MPL/2.0/</url>
</license>
</licenses>
<developers>
<developer>
<name>Mosip</name>
<email>[email protected]</email>
<organization>io.mosip</organization>
<organizationUrl>https://github.com/mosip</organizationUrl>
</developer>
</developers>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.12.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.12.1</version>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<java.version>11</java.version>
<jkube.enricher.jkube-service.type>NodePort</jkube.enricher.jkube-service.type>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<jkube.docker.imagePullPolicy>Always</jkube.docker.imagePullPolicy>
<jkube.generator.from>openjdk:11</jkube.generator.from>
<jkube.generator.name>manojsp12/remaputil</jkube.generator.name>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.mosip.idrepository.remap.util;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;

/**
* @author Manoj SP
*
*/
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })
@ComponentScan(basePackages = { "io.mosip.idrepository.remap.util.*" })
public class RemapMainApplication {

public static void main(String[] args) throws Exception {
SpringApplication.run(RemapMainApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package io.mosip.idrepository.remap.util.config;

import java.util.HashMap;
import java.util.Map;

import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy;
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
*
* @author Manoj SP
*/
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = {
"io.mosip.idrepository.remap.util.identity.repository" }, entityManagerFactoryRef = "identityEntityManager", transactionManagerRef = "identityJpaTransactionManager")
public class IdentityRepoConfig {

/** The env. */
@Autowired
private Environment env;

/**
* Entity manager factory.
*
* @return the local container entity manager factory bean
*/
@Bean("identityEntityManager")
@Qualifier("identityEntityManager")
@Primary
public LocalContainerEntityManagerFactoryBean entityManagerFactory(@Qualifier("identityDataSource") DataSource identityDataSource) {
LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
em.setDataSource(identityDataSource);
em.setJpaVendorAdapter(new HibernateJpaVendorAdapter());
em.setPackagesToScan("io.mosip.idrepository.remap.util.identity.entity");
em.setJpaPropertyMap(additionalProperties());
return em;
}

/**
* Data source.
*
* @return the data source
*/
@Bean("identityDataSource")
@Qualifier("identityDataSource")
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setUrl(env.getProperty("mosip.idrepository.identity.db.url"));
dataSource.setUsername(env.getProperty("mosip.idrepository.identity.db.username"));
dataSource.setPassword(env.getProperty("mosip.idrepository.identity.db.password"));
dataSource.setDriverClassName(env.getProperty("mosip.idrepository.identity.db.driverClassName"));
dataSource.setSchema(env.getProperty("mosip.idrepository.identity.db.schemaName"));
return dataSource;
}

/**
* Jpa transaction manager.
*
* @param emf the emf
* @return the jpa transaction manager
*/
@Bean("identityJpaTransactionManager")
@Qualifier("identityJpaTransactionManager")
@Primary
public JpaTransactionManager jpaTransactionManager(EntityManagerFactory emf, @Qualifier("identityDataSource") DataSource identityDataSource) {
JpaTransactionManager jpaTransactionManager = new JpaTransactionManager();
jpaTransactionManager.setEntityManagerFactory(entityManagerFactory(identityDataSource).getObject());
jpaTransactionManager.setDataSource(dataSource());
return jpaTransactionManager;
}

/**
* Additional properties.
*
* @return the map
*/
private Map<String, Object> additionalProperties() {
Map<String, Object> jpaProperties = new HashMap<>();
jpaProperties.put("hibernate.implicit_naming_strategy", SpringImplicitNamingStrategy.class.getName());
jpaProperties.put("hibernate.physical_naming_strategy", SpringPhysicalNamingStrategy.class.getName());
jpaProperties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQL92Dialect");
return jpaProperties;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package io.mosip.idrepository.remap.util.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;

@Configuration
@ConfigurationProperties(prefix = "openapi")
@Data
public class OpenApiProperties {
private InfoProperty info;
private IdRepoVidServiceServer idRepoVidServiceServer;
}

@Data
class InfoProperty {
private String title;
private String description;
private String version;
private LicenseProperty license;
}

@Data
class LicenseProperty {
private String name;
private String url;
}

@Data
class IdRepoVidServiceServer {
private List<Server> servers;
}

@Data
class Server {
private String description;
private String url;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.mosip.idrepository.remap.util.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.servers.Server;

@Configuration
public class SwaggerConfig {

private static final Logger logger = LoggerFactory.getLogger(SwaggerConfig.class);

@Bean
public OpenAPI openApi(OpenApiProperties openApiProperties) {
String msg = "Swagger open api, ";
OpenAPI api = new OpenAPI()
.components(new Components());
if (null != openApiProperties.getInfo()) {
api.info(new Info()
.title(openApiProperties.getInfo().getTitle())
.version(openApiProperties.getInfo().getVersion())
.description(openApiProperties.getInfo().getDescription()));
if (null != openApiProperties.getInfo().getLicense()) {
api.getInfo().license(new License()
.name(openApiProperties.getInfo().getLicense().getName())
.url(openApiProperties.getInfo().getLicense().getUrl()));
logger.info(msg + "info license property is added");
} else {
logger.error(msg + "info license property is empty");
}
logger.info(msg + "info property is added");
} else {
logger.error(msg + "info property is empty");
}

if (null != openApiProperties.getIdRepoVidServiceServer().getServers()) {
openApiProperties.getIdRepoVidServiceServer().getServers().forEach(server -> {
api.addServersItem(new Server().description(server.getDescription()).url(server.getUrl()));
});
logger.info(msg + "server property is added");
} else {
logger.error(msg + "server property is empty");
}
return api;
}

}
Loading