Skip to content

Commit

Permalink
Merge pull request #12 from fronzec/feature/fr-batch-service/migrate-…
Browse files Browse the repository at this point in the history
…to-spring-boot-3

Feature/fr batch service/migrate to spring boot 3
  • Loading branch information
fronzec authored Oct 3, 2024
2 parents 09a0317 + 24f00b0 commit b43f856
Show file tree
Hide file tree
Showing 18 changed files with 747 additions and 654 deletions.
8 changes: 4 additions & 4 deletions fr-batch-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.18</version><!-- https://spring.io/projects/spring-boot#support -->
<version>3.3.4</version><!-- https://spring.io/projects/spring-boot#support -->
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.fronzec</groupId>
Expand Down Expand Up @@ -90,7 +90,7 @@
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.33</version>
<version>8.2.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -213,7 +213,7 @@
<endWithNewline/>
<indent>
<tabs>true</tabs>
<spacesPerTab>4</spacesPerTab>
<spacesPerTab>2</spacesPerTab>
</indent>
</format>
</formats>
Expand Down Expand Up @@ -241,7 +241,7 @@
optionally, Spotless can set copyright years by digging
through git history (see "license" section below) -->
<licenseHeader>
<content>/* (C)$YEAR */</content> <!-- or <file>${project.basedir}/license-header</file> -->
<content>/* $YEAR */</content> <!-- or <file>${project.basedir}/license-header</file> -->
</licenseHeader>
</java>
</configuration>
Expand Down
31 changes: 31 additions & 0 deletions fr-batch-service/qodana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"

#Specify inspection profile for code analysis
profile:
name: qodana.starter

#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>

#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>

projectJDK: 22 #(Applied in CI/CD pipeline)

#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh

#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)

#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-jvm:latest
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* (C)2024 */
/* 2024 */
package com.fronzec.frbatchservice.batchjobs;

import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -12,12 +11,7 @@
@Configuration
public class BatchConfiguration {

/** JobBuilderFactory for JobBuilder which sets the JobRepository automatically */
public final JobBuilderFactory jobBuilderFactory;

public BatchConfiguration(JobBuilderFactory jobBuilderFactory) {
this.jobBuilderFactory = jobBuilderFactory;
}
public BatchConfiguration() {}

/**
* If we need allow launch a job from an HTTP request we need to launch async, To launch a Job we
Expand All @@ -28,7 +22,7 @@ public BatchConfiguration(JobBuilderFactory jobBuilderFactory) {
*/
@Bean
public JobLauncher asyncJobLauncher(JobRepository jobRepository) throws Exception {
var jobLauncher = new SimpleJobLauncher();
var jobLauncher = new TaskExecutorJobLauncher();
jobLauncher.setJobRepository(jobRepository);
jobLauncher.setTaskExecutor(
new SimpleAsyncTaskExecutor("asyncJobExecutor")); // Job exexutor
Expand All @@ -44,7 +38,7 @@ public JobLauncher asyncJobLauncher(JobRepository jobRepository) throws Exceptio
*/
@Bean
public JobLauncher syncJobLauncher(JobRepository jobRepository) throws Exception {
var jobLauncher = new SimpleJobLauncher();
var jobLauncher = new TaskExecutorJobLauncher();
jobLauncher.setJobRepository(jobRepository);
jobLauncher.afterPropertiesSet();
return jobLauncher;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* (C)2024 */
/* 2024 */
package com.fronzec.frbatchservice.batchjobs;

import com.fronzec.frbatchservice.utils.JsonUtils;
import com.fronzec.frbatchservice.web.SingleJobDataRequest;
import jakarta.annotation.PostConstruct;
import java.time.LocalDate;
import java.util.*;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.Job;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,111 +1,112 @@
/* 2024 */
package com.fronzec.frbatchservice.batchjobs.dispatchedgroups;

import jakarta.persistence.Basic;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.time.LocalDateTime;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

@Entity
@Table(name = "dispatched_group")
public class DispatchedGroupEntity {

@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "id", nullable = false)
private long id;

@Basic
@Column(name = "uuid_v4", nullable = false, length = 36)
private String uuidV4;

@Column(name = "dispatch_status", nullable = false, length = 10)
@Enumerated(EnumType.STRING)
private DispatchStatus dispatchStatus = DispatchStatus.UNKNOWN;

@Basic
@Column(name = "records_included", nullable = false)
private int recordsIncluded = 0;

@CreationTimestamp
@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;

@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getUuidV4() {
return uuidV4;
}

public void setUuidV4(String uuidV4) {
this.uuidV4 = uuidV4;
}

public DispatchStatus getDispatchStatus() {
return dispatchStatus;
}

public void setDispatchStatus(DispatchStatus dispatchStatus) {
this.dispatchStatus = dispatchStatus;
}

public int getRecordsIncluded() {
return recordsIncluded;
}

public void setRecordsIncluded(int recordsIncluded) {
this.recordsIncluded = recordsIncluded;
}

public LocalDateTime getCreatedAt() {
return createdAt;
}

public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}

public LocalDateTime getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(LocalDateTime updatedAt) {
this.updatedAt = updatedAt;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DispatchedGroupEntity that = (DispatchedGroupEntity) o;
return (id == that.id
&& uuidV4.equals(that.uuidV4)
&& dispatchStatus.equals(that.dispatchStatus)
&& recordsIncluded == that.recordsIncluded
&& createdAt.equals(that.createdAt)
&& updatedAt.equals(that.updatedAt));
}

@Override
public int hashCode() {
return Objects.hash(id, uuidV4, dispatchStatus, recordsIncluded, createdAt, updatedAt);
}
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "id", nullable = false)
private long id;

@Basic
@Column(name = "uuid_v4", nullable = false, length = 36)
private String uuidV4;

@Column(name = "dispatch_status", nullable = false, length = 10)
@Enumerated(EnumType.STRING)
private DispatchStatus dispatchStatus = DispatchStatus.UNKNOWN;

@Basic
@Column(name = "records_included", nullable = false)
private int recordsIncluded = 0;

@CreationTimestamp
@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;

@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getUuidV4() {
return uuidV4;
}

public void setUuidV4(String uuidV4) {
this.uuidV4 = uuidV4;
}

public DispatchStatus getDispatchStatus() {
return dispatchStatus;
}

public void setDispatchStatus(DispatchStatus dispatchStatus) {
this.dispatchStatus = dispatchStatus;
}

public int getRecordsIncluded() {
return recordsIncluded;
}

public void setRecordsIncluded(int recordsIncluded) {
this.recordsIncluded = recordsIncluded;
}

public LocalDateTime getCreatedAt() {
return createdAt;
}

public void setCreatedAt(LocalDateTime createdAt) {
this.createdAt = createdAt;
}

public LocalDateTime getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(LocalDateTime updatedAt) {
this.updatedAt = updatedAt;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DispatchedGroupEntity that = (DispatchedGroupEntity) o;
return (id == that.id
&& uuidV4.equals(that.uuidV4)
&& dispatchStatus.equals(that.dispatchStatus)
&& recordsIncluded == that.recordsIncluded
&& createdAt.equals(that.createdAt)
&& updatedAt.equals(that.updatedAt));
}

@Override
public int hashCode() {
return Objects.hash(id, uuidV4, dispatchStatus, recordsIncluded, createdAt, updatedAt);
}
}
Loading

0 comments on commit b43f856

Please sign in to comment.