Skip to content

Commit 1e16dd2

Browse files
rename columns to english
1 parent 4d9a0ca commit 1e16dd2

File tree

5 files changed

+23
-18
lines changed

5 files changed

+23
-18
lines changed

src/main/java/org/gridsuite/useradmin/server/repository/ConnectionEntity.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@
2727
@Entity
2828
@Table(name = "connection", indexes = {@Index(name = "connection_sub_index", columnList = "sub")})
2929
public class ConnectionEntity extends AbstractUserEntity {
30-
@Column(name = "firstConnexionDate", nullable = false)
31-
private LocalDateTime firstConnexionDate;
30+
@Column(name = "firstConnectionDate", nullable = false)
31+
private LocalDateTime firstConnectionDate;
3232

33-
@Column(name = "lastConnexionDate", nullable = false)
34-
private LocalDateTime lastConnexionDate;
33+
@Column(name = "lastConnectionDate", nullable = false)
34+
private LocalDateTime lastConnectionDate;
3535

3636
@Column(name = "connectionAccepted", nullable = false)
3737
private Boolean connectionAccepted;
3838

39-
public ConnectionEntity(String sub, LocalDateTime firstConnexionDate, LocalDateTime lastConnexionDate, Boolean connectionAccepted) {
39+
public ConnectionEntity(String sub, LocalDateTime firstConnectionDate, LocalDateTime lastConnectionDate, Boolean connectionAccepted) {
4040
super(sub);
41-
this.firstConnexionDate = firstConnexionDate;
42-
this.lastConnexionDate = lastConnexionDate;
41+
this.firstConnectionDate = firstConnectionDate;
42+
this.lastConnectionDate = lastConnectionDate;
4343
this.connectionAccepted = connectionAccepted;
4444
}
4545
}

src/main/java/org/gridsuite/useradmin/server/repository/ConnectionRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public interface ConnectionRepository extends JpaRepository<ConnectionEntity, UU
2828
@Modifying
2929
default void recordNewConnection(@NonNull final String sub, final boolean connectionAccepted) {
3030
this.findBySub/*IgnoreCase*/(sub).ifPresentOrElse(
31-
conn -> this.save(conn.setLastConnexionDate(LocalDateTime.now()).setConnectionAccepted(connectionAccepted)),
31+
conn -> this.save(conn.setLastConnectionDate(LocalDateTime.now()).setConnectionAccepted(connectionAccepted)),
3232
() -> this.save(new ConnectionEntity(sub, LocalDateTime.now(), LocalDateTime.now(), connectionAccepted))
3333
);
3434
}

src/main/java/org/gridsuite/useradmin/server/service/ConnectionsService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void recordConnectionAttempt(String sub, Boolean isAllowed) {
3838
connectionEntity = new ConnectionEntity(sub, LocalDateTime.now().truncatedTo(ChronoUnit.MICROS), LocalDateTime.now().truncatedTo(ChronoUnit.MICROS), isAllowed);
3939
connectionRepository.save(connectionEntity);
4040
} else {
41-
connectionEntity.setLastConnexionDate(LocalDateTime.now().truncatedTo(ChronoUnit.MICROS));
41+
connectionEntity.setLastConnectionDate(LocalDateTime.now().truncatedTo(ChronoUnit.MICROS));
4242
connectionEntity.setConnectionAccepted(isAllowed);
4343
}
4444
}
@@ -51,11 +51,11 @@ public List<ConnectionEntity> removeDuplicates() {
5151
connectionsBySub.keySet().forEach(sub ->
5252
connectionsBySub.get(sub).stream().skip(1).forEach(connectionEntity -> {
5353
ConnectionEntity groupedEntity = connectionsBySub.get(sub).get(0);
54-
if (connectionEntity.getLastConnexionDate().isAfter(groupedEntity.getLastConnexionDate())) {
55-
groupedEntity.setLastConnexionDate(connectionEntity.getLastConnexionDate());
54+
if (connectionEntity.getLastConnectionDate().isAfter(groupedEntity.getLastConnectionDate())) {
55+
groupedEntity.setLastConnectionDate(connectionEntity.getLastConnectionDate());
5656
}
57-
if (connectionEntity.getFirstConnexionDate().isBefore(groupedEntity.getFirstConnexionDate())) {
58-
groupedEntity.setFirstConnexionDate(connectionEntity.getFirstConnexionDate());
57+
if (connectionEntity.getFirstConnectionDate().isBefore(groupedEntity.getFirstConnectionDate())) {
58+
groupedEntity.setFirstConnectionDate(connectionEntity.getFirstConnectionDate());
5959
}
6060
connectionRepository.delete(connectionEntity);
6161
})

src/main/resources/db/changelog/changesets/changelog_20240109T161028Z.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
22
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
3-
<changeSet author="chuinetri" id="1704818243021-0">
3+
<changeSet author="chuinetri" id="1704818243021-1">
44
<comment>Deduplicate rows before adding unique constraint</comment>
55
<delete tableName="user_infos">
66
<where>id in (select id from (select row_number() over (partition by sub) as rnb, * from user_infos) subquery where rnb > 1)</where>
@@ -26,8 +26,13 @@
2626
</delete>
2727
</changeSet>
2828

29-
<changeSet author="chuinetri" id="1704818243021-1">
29+
<changeSet author="chuinetri" id="1704818243021-2">
3030
<addUniqueConstraint columnNames="sub" constraintName="UC_USER_INFOSSUB_COL" tableName="user_infos"/>
3131
<addUniqueConstraint columnNames="sub" constraintName="UC_CONNECTIONSUB_COL" tableName="connection"/>
3232
</changeSet>
33+
34+
<changeSet author="chuinetri" id="1704818243021-3">
35+
<renameColumn tableName="connection" oldColumnName="first_connexion_date" newColumnName="first_connection_date"/>
36+
<renameColumn tableName="connection" oldColumnName="last_connexion_date" newColumnName="last_connection_date"/>
37+
</changeSet>
3338
</databaseChangeLog>

src/test/java/org/gridsuite/useradmin/server/UserAdminTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ public void testUserAdmin() throws Exception {
116116
assertEquals(3, connectionRepository.findAll().size());
117117
assertTrue(connectionRepository.findBySub(USER_SUB).get().getConnectionAccepted());
118118
assertFalse(connectionRepository.findBySub("UNKNOWN").get().getConnectionAccepted());
119-
LocalDateTime firstConnectionDate = connectionRepository.findBySub(USER_SUB).get().getFirstConnexionDate();
119+
LocalDateTime firstConnectionDate = connectionRepository.findBySub(USER_SUB).get().getFirstConnectionDate();
120120
//firstConnectionDate and lastConnectionDate are equals cause this is the first connection for this user
121-
assertTrue(firstConnectionDate.toEpochSecond(ZoneOffset.UTC) < connectionRepository.findBySub(USER_SUB).get().getLastConnexionDate().toEpochSecond(ZoneOffset.UTC) + 2);
121+
assertTrue(firstConnectionDate.toEpochSecond(ZoneOffset.UTC) < connectionRepository.findBySub(USER_SUB).get().getLastConnectionDate().toEpochSecond(ZoneOffset.UTC) + 2);
122122

123123
mockMvc.perform(head("/" + UserAdminApi.API_VERSION + "/users/{sub}", USER_SUB))
124124
.andExpect(status().isOk())
125125
.andReturn();
126-
assertEquals(firstConnectionDate, connectionRepository.findBySub(USER_SUB).get().getFirstConnexionDate());
126+
assertEquals(firstConnectionDate, connectionRepository.findBySub(USER_SUB).get().getFirstConnectionDate());
127127

128128
mockMvc.perform(delete("/" + UserAdminApi.API_VERSION + "/users/{id}", userId)
129129
.header("userId", ADMIN_USER)

0 commit comments

Comments
 (0)