From 1ad64ee896d2000f7b8ff1391088d31146e509b6 Mon Sep 17 00:00:00 2001 From: Surabhi Date: Tue, 19 Jul 2022 12:21:06 +0530 Subject: [PATCH 1/2] Bot uuid in cassandra db --- .../com/uci/dao/config/CassandraConfig.java | 2 +- .../java/com/uci/dao/models/XMessageDAO.java | 3 ++ .../dao/repository/XMessageRepository.java | 30 ------------------- .../com/uci/dao/utils/XMessageDAOUtils.java | 1 + 4 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/uci/dao/config/CassandraConfig.java b/src/main/java/com/uci/dao/config/CassandraConfig.java index 6376ff9..fb96a2d 100644 --- a/src/main/java/com/uci/dao/config/CassandraConfig.java +++ b/src/main/java/com/uci/dao/config/CassandraConfig.java @@ -124,7 +124,7 @@ protected List getMigrationScripts() { allScripts.add("ALTER TABLE " + keyspace + ".XMessage ADD sessionId uuid;"); allScripts.add("ALTER TABLE " + keyspace + ".XMessage ADD ownerOrgId text;"); allScripts.add("ALTER TABLE " + keyspace + ".XMessage ADD ownerId text;"); - + allScripts.add("ALTER TABLE " + keyspace + ".XMessage ADD botUuid uuid;"); // allScripts.add("CREATE INDEX IF NOT EXISTS message_state_index\n" + // "ON "+keyspace diff --git a/src/main/java/com/uci/dao/models/XMessageDAO.java b/src/main/java/com/uci/dao/models/XMessageDAO.java index da00b7e..67e5f8e 100644 --- a/src/main/java/com/uci/dao/models/XMessageDAO.java +++ b/src/main/java/com/uci/dao/models/XMessageDAO.java @@ -66,4 +66,7 @@ public class XMessageDAO implements Serializable { @Column private String ownerId; + + @Column + private UUID botUuid; } diff --git a/src/main/java/com/uci/dao/repository/XMessageRepository.java b/src/main/java/com/uci/dao/repository/XMessageRepository.java index ae53ab8..7584262 100644 --- a/src/main/java/com/uci/dao/repository/XMessageRepository.java +++ b/src/main/java/com/uci/dao/repository/XMessageRepository.java @@ -26,57 +26,27 @@ public interface XMessageRepository extends ReactiveCassandraRepository existsByUserId(String userID); - - Flux> findAllByFromIdOrderByTimestampDesc(String fromID); - - Flux findFirstByFromIdOrderByTimestampDesc(String fromID); - - Flux findFirstByAppOrderByTimestampDesc(String appName); - - @AllowFiltering - Flux findAllByUserId(Pageable pageable, String userID); - - Flux findByMessageId(String messageID); - - Flux findFirstByReplyIdOrderByTimestampDesc(String replyId); - - Flux findFirstByCauseIdAndMessageStateOrderByTimestampDesc(String causeId, String messageState); - - @AllowFiltering - Flux> findAllByUserIdOrderByTimestampDesc(String userID); @AllowFiltering Flux findAllByUserIdAndTimestampAfter(String userID, LocalDateTime timestamp); - Flux findTopByFromIdAndMessageStateOrderByTimestampDesc(String fromId, String messageState); - Flux findFirstByUserIdAndCauseIdAndMessageStateOrderByTimestampDesc(String userId, String causeId, String messageState); - Flux findTopByUserIdOrderByTimestampDesc(String userId); - @AllowFiltering Flux findAllByFromIdAndTimestampAfter(String userID, LocalDateTime timestamp); @AllowFiltering Flux findById(UUID uuid); - Flux findByXMessageAndUserId(XMessage xmsg, String userID); - @AllowFiltering Flux findFirstByAppAndUserIdAndFromIdAndMessageStateOrderByTimestampDesc(String app, String userID, String fromId, String messageState); - @AllowFiltering - Flux findAllByUserIdOrderByTimestamp(String userID); - @AllowFiltering Flux> findAllByUserIdAndFromId(Pageable paging, String userID, String fromID); @AllowFiltering Mono> findAllByAppAndTimestampAfterAndTimestampBeforeAndProvider(Pageable paging, String name, Timestamp startDate, Timestamp endDate, String provider); - @AllowFiltering - Mono> findAllByUserIdAndTimestampAfterAndTimestampBeforeAndProvider(Pageable paging, String userId, Timestamp startDate, Timestamp endDate, String provider); - @AllowFiltering Mono> findAllByUserIdInAndFromIdInAndTimestampAfterAndTimestampBeforeAndProvider(Pageable paging, List listUserId, List listFromId, Timestamp startDate, Timestamp endDate, String provider); diff --git a/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java b/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java index 60ebcab..40593cc 100644 --- a/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java +++ b/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java @@ -51,6 +51,7 @@ public static XMessageDAO convertXMessageToDAO(XMessage xmsg) { xmsgDao.setSessionId(xmsg.getSessionId()); xmsgDao.setOwnerOrgId(xmsg.getOwnerOrgId()); xmsgDao.setOwnerId(xmsg.getOwnerId()); + xmsgDao.setBotUuid(xmsg.getBotUuid()); LocalDateTime triggerTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(xmsg.getTimestamp()), From 53784531d0aafb59f27a8a1223465c948188d4b1 Mon Sep 17 00:00:00 2001 From: Surabhi Date: Tue, 19 Jul 2022 12:24:11 +0530 Subject: [PATCH 2/2] minor change --- src/main/java/com/uci/dao/utils/XMessageDAOUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java b/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java index 40593cc..14f05f1 100644 --- a/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java +++ b/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java @@ -51,7 +51,7 @@ public static XMessageDAO convertXMessageToDAO(XMessage xmsg) { xmsgDao.setSessionId(xmsg.getSessionId()); xmsgDao.setOwnerOrgId(xmsg.getOwnerOrgId()); xmsgDao.setOwnerId(xmsg.getOwnerId()); - xmsgDao.setBotUuid(xmsg.getBotUuid()); + xmsgDao.setBotUuid(xmsg.getBotId()); LocalDateTime triggerTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(xmsg.getTimestamp()),