log per creazione schema
aligned message to the one in storagehub model checking if forceExecution is needed log in creazione removed drop messages
This commit is contained in:
parent
aaebf474d0
commit
65b99b720c
|
@ -1,5 +1,7 @@
|
|||
package org.gcube.portal.databook.server;
|
||||
|
||||
import static org.gcube.portal.databook.server.Schema.CREATION_TIME;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
|
@ -117,17 +119,22 @@ public class CassandraClusterConnection {
|
|||
CqlSession session = connect();
|
||||
|
||||
Metadata metadata = session.getMetadata();
|
||||
_log.warn("checking if forceExecution is needed ");
|
||||
|
||||
for (String table : Arrays.asList(
|
||||
Schema.TABLE_MESSAGES_SENT,
|
||||
Schema.TABLE_MESSAGES_RECEIVED,
|
||||
Schema.TABLE_MESSAGES_ATTACHMENTS)) {
|
||||
if (forceExecution) {
|
||||
if (forceExecution) {
|
||||
break;
|
||||
}
|
||||
forceExecution = ! metadata.getKeyspace(keyspaceName)
|
||||
forceExecution = !metadata.getKeyspace(keyspaceName)
|
||||
.flatMap(ks -> ks.getTable(table))
|
||||
.isPresent();
|
||||
|
||||
if (!forceExecution) {
|
||||
_log.warn("missing table {}, forcingExecution of createSchema to update the schema", keyspaceName);
|
||||
}
|
||||
}
|
||||
|
||||
Metadata metaData = session.getMetadata();
|
||||
|
@ -249,6 +256,9 @@ public class CassandraClusterConnection {
|
|||
}
|
||||
|
||||
private void dropMessagesTables(CqlSession cqlSession) {
|
||||
|
||||
_log.info("Dropping all message tables and indexes");
|
||||
|
||||
// try {
|
||||
cqlSession.execute(
|
||||
SchemaBuilder.dropMaterializedView(Schema.TABLE_MESSAGES_RECEIVED_ACTIVE).ifExists().build());
|
||||
|
@ -265,12 +275,12 @@ public class CassandraClusterConnection {
|
|||
cqlSession.execute(SchemaBuilder.dropIndex(Schema.IDX_MESSAGES_SENT_ID).ifExists().build());
|
||||
cqlSession.execute(SchemaBuilder.dropIndex(Schema.IDX_MESSAGES_SENT_READ).ifExists().build());
|
||||
cqlSession.execute(SchemaBuilder.dropIndex(Schema.IDX_MESSAGES_SENT_DELETED).ifExists().build());
|
||||
cqlSession.execute(SchemaBuilder.dropIndex(Schema.IDX_MESSAGES_SENT_TIMESTAMP).ifExists().build());
|
||||
cqlSession.execute(SchemaBuilder.dropIndex(Schema.IDX_MESSAGES_SENT_CREATION_TIME).ifExists().build());
|
||||
|
||||
cqlSession.execute(SchemaBuilder.dropIndex(Schema.IDX_MESSAGES_RECEIVED_ID).ifExists().build());
|
||||
cqlSession.execute(SchemaBuilder.dropIndex(Schema.IDX_MESSAGES_RECEIVED_READ).ifExists().build());
|
||||
cqlSession.execute(SchemaBuilder.dropIndex(Schema.IDX_MESSAGES_RECEIVED_DELETED).ifExists().build());
|
||||
cqlSession.execute(SchemaBuilder.dropIndex(Schema.IDX_MESSAGES_RECEIVED_TIMESTAMP).ifExists().build());
|
||||
cqlSession.execute(SchemaBuilder.dropIndex(Schema.IDX_MESSAGES_RECEIVED_CREATION_TIME).ifExists().build());
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
@ -338,6 +348,7 @@ public class CassandraClusterConnection {
|
|||
|
||||
closeSession(cqlSession);
|
||||
} catch (Exception e) {
|
||||
_log.error("error creating the schema. {}", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -351,7 +362,7 @@ public class CassandraClusterConnection {
|
|||
.withCompactStorage()
|
||||
.build());
|
||||
|
||||
_log.info("+ Table '{}' has been created (if needed).", "USERNotificationsPreferences");
|
||||
_log.info("+ the Table '{}' has been created (if needed).", "USERNotificationsPreferences");
|
||||
}
|
||||
|
||||
private void createTableUSERNotifications(CqlSession cqlSession) {
|
||||
|
@ -631,7 +642,7 @@ public class CassandraClusterConnection {
|
|||
cqlSession.execute(SchemaBuilder.createTable(Schema.TABLE_MESSAGES_SENT)
|
||||
.ifNotExists()
|
||||
.withPartitionKey(Schema.FROM_ID, DataTypes.TEXT) // Partition key on sender ID
|
||||
.withClusteringColumn(Schema.TIMESTAMP, DataTypes.TIMESTAMP) // Clustering by timestamp for ordering
|
||||
.withClusteringColumn(Schema.CREATION_TIME, DataTypes.TIMESTAMP) // Clustering by timestamp for ordering
|
||||
.withClusteringColumn(Schema.MESSAGE_ID, DataTypes.UUID) // Clustering by message ID for uniqueness
|
||||
.withColumn(Schema.FROM_NAME, DataTypes.TEXT) // Sender's name
|
||||
.withColumn(Schema.RECIPIENTS, DataTypes.listOf(DataTypes.TEXT)) // List of recipients
|
||||
|
@ -641,9 +652,11 @@ public class CassandraClusterConnection {
|
|||
.withColumn(Schema.ISREAD, DataTypes.BOOLEAN) // Boolean flag for read status
|
||||
.withColumn(Schema.ISOPENED, DataTypes.BOOLEAN) // Boolean flag for opened status
|
||||
.withColumn(Schema.ISDELETED, DataTypes.BOOLEAN) // Boolean flag for deleted status
|
||||
.withClusteringOrder(Schema.TIMESTAMP, ClusteringOrder.DESC) // Descending order by timestamp
|
||||
.withClusteringOrder(Schema.CREATION_TIME, ClusteringOrder.DESC) // Descending order by timestamp
|
||||
.build());
|
||||
|
||||
_log.info("+ Table '{}' has been created (if needed).", Schema.TABLE_MESSAGES_SENT);
|
||||
|
||||
// Remove unnecessary indexes: no need for message_id or timestamp indexes
|
||||
// Retain only the index for deleted and read messages
|
||||
cqlSession.execute(SchemaBuilder.createIndex(Schema.IDX_MESSAGES_SENT_DELETED)
|
||||
|
@ -652,24 +665,28 @@ public class CassandraClusterConnection {
|
|||
.andColumn(Schema.ISDELETED)
|
||||
.build());
|
||||
|
||||
_log.info("+ Index '{}' has been created (if needed).", Schema.IDX_MESSAGES_SENT_DELETED);
|
||||
|
||||
cqlSession.execute(SchemaBuilder.createIndex(Schema.IDX_MESSAGES_SENT_READ)
|
||||
.ifNotExists()
|
||||
.onTable(Schema.TABLE_MESSAGES_SENT)
|
||||
.andColumn(Schema.ISREAD)
|
||||
.build());
|
||||
|
||||
_log.info("+ Index '{}' has been created (if needed).", Schema.IDX_MESSAGES_SENT_READ);
|
||||
|
||||
cqlSession.execute(SchemaBuilder.createIndex(Schema.IDX_MESSAGES_SENT_ID)
|
||||
.ifNotExists()
|
||||
.onTable(Schema.TABLE_MESSAGES_SENT)
|
||||
.andColumn(Schema.MESSAGE_ID)
|
||||
.build());
|
||||
|
||||
_log.info("+ Table '{}' has been created (if needed).", "messages_sent");
|
||||
_log.info("+ Index '{}' has been created (if needed).", Schema.IDX_MESSAGES_SENT_ID);
|
||||
}
|
||||
|
||||
private void createTableMessagesAttachments(CqlSession cqlSession) {
|
||||
|
||||
cqlSession.execute(SchemaBuilder.dropTable(Schema.TABLE_MESSAGES_ATTACHMENTS).ifExists().build());
|
||||
// cqlSession.execute(SchemaBuilder.dropTable(Schema.TABLE_MESSAGES_ATTACHMENTS).ifExists().build());
|
||||
|
||||
cqlSession.execute(SchemaBuilder.createTable(Schema.TABLE_MESSAGES_ATTACHMENTS)
|
||||
.ifNotExists()
|
||||
|
@ -689,7 +706,7 @@ public class CassandraClusterConnection {
|
|||
cqlSession.execute(SchemaBuilder.createTable(Schema.TABLE_MESSAGES_RECEIVED)
|
||||
.ifNotExists()
|
||||
.withPartitionKey(Schema.RECIPIENT_ID, DataTypes.TEXT) // Partition key on recipient ID
|
||||
.withClusteringColumn(Schema.TIMESTAMP, DataTypes.TIMESTAMP) // Clustering by timestamp for ordering
|
||||
.withClusteringColumn(Schema.CREATION_TIME, DataTypes.TIMESTAMP) // Clustering by timestamp for ordering
|
||||
.withClusteringColumn(Schema.MESSAGE_ID, DataTypes.UUID) // Clustering by message ID for uniqueness
|
||||
.withColumn(Schema.FROM_ID, DataTypes.TEXT) // Sender's ID
|
||||
.withColumn(Schema.FROM_NAME, DataTypes.TEXT) // Sender's name
|
||||
|
@ -700,7 +717,7 @@ public class CassandraClusterConnection {
|
|||
.withColumn(Schema.ISREAD, DataTypes.BOOLEAN) // Boolean flag for read status
|
||||
.withColumn(Schema.ISOPENED, DataTypes.BOOLEAN) // Boolean flag for opened status
|
||||
.withColumn(Schema.ISDELETED, DataTypes.BOOLEAN) // Boolean flag for deleted status
|
||||
.withClusteringOrder(Schema.TIMESTAMP, ClusteringOrder.DESC) // Descending order by timestamp
|
||||
.withClusteringOrder(Schema.CREATION_TIME, ClusteringOrder.DESC) // Descending order by timestamp
|
||||
.build());
|
||||
|
||||
// Remove unnecessary indexes: no need for message_id or timestamp indexes
|
||||
|
@ -726,134 +743,4 @@ public class CassandraClusterConnection {
|
|||
_log.info("+ Table '{}' has been created (if needed).", "messages_received");
|
||||
}
|
||||
|
||||
/*
|
||||
* // Method to create the materialized view for non-deleted sent messages
|
||||
* private void createViewMessagesActiveSent(CqlSession cqlSession) {
|
||||
* cqlSession.execute(SchemaBuilder.createMaterializedView(Schema.
|
||||
* TABLE_MESSAGES_SENT_ACTIVE)
|
||||
* .ifNotExists()
|
||||
* .asSelectFrom(Schema.TABLE_MESSAGES_SENT)
|
||||
* .column(Schema.FROM_ID)
|
||||
* .column(Schema.TIMESTAMP)
|
||||
* .column(Schema.MESSAGE_ID)
|
||||
* .column(Schema.FROM_NAME)
|
||||
* .column(Schema.RECIPIENTS)
|
||||
* .column(Schema.SUBJECT)
|
||||
* .column(Schema.BODY)
|
||||
* .column(Schema.WITH_ATTACH)
|
||||
* .column(Schema.ISREAD)
|
||||
* .column(Schema.ISOPENED)
|
||||
* .column(Schema.ISDELETED)
|
||||
* .whereColumn(Schema.FROM_ID).isNotNull()
|
||||
* .whereColumn(Schema.ISDELETED).isEqualTo(QueryBuilder.literal(false))
|
||||
* .whereColumn(Schema.TIMESTAMP).isNotNull()
|
||||
* .whereColumn(Schema.MESSAGE_ID).isNotNull()
|
||||
* .withPartitionKey(Schema.FROM_ID)
|
||||
* .withClusteringColumn(Schema.TIMESTAMP)
|
||||
* .withClusteringColumn(Schema.MESSAGE_ID)
|
||||
* .withClusteringOrder(Schema.TIMESTAMP, ClusteringOrder.DESC)
|
||||
* .build());
|
||||
*
|
||||
* _log.info("+ Materialized View '{}' has been created (if needed).",
|
||||
* "messages_active_sent");
|
||||
* }
|
||||
*
|
||||
* // Method to create the materialized view for non-deleted received messages
|
||||
* private void createViewMessagesActiveReceived(CqlSession cqlSession) {
|
||||
* cqlSession.execute(SchemaBuilder.createMaterializedView(Schema.
|
||||
* TABLE_MESSAGES_RECEIVED_ACTIVE)
|
||||
* .ifNotExists()
|
||||
* .asSelectFrom(Schema.TABLE_MESSAGES_RECEIVED)
|
||||
* .column(Schema.RECIPIENT_ID)
|
||||
* .column(Schema.TIMESTAMP)
|
||||
* .column(Schema.MESSAGE_ID)
|
||||
* .column(Schema.FROM_ID)
|
||||
* .column(Schema.FROM_NAME)
|
||||
* .column(Schema.RECIPIENTS)
|
||||
* .column(Schema.SUBJECT)
|
||||
* .column(Schema.BODY)
|
||||
* .column(Schema.WITH_ATTACH)
|
||||
* .column(Schema.ISREAD)
|
||||
* .column(Schema.ISOPENED)
|
||||
* .column(Schema.ISDELETED)
|
||||
* .whereColumn(Schema.RECIPIENT_ID).isNotNull()
|
||||
* .whereColumn(Schema.ISDELETED).isEqualTo(QueryBuilder.literal(false))
|
||||
* .whereColumn(Schema.TIMESTAMP).isNotNull()
|
||||
* .whereColumn(Schema.MESSAGE_ID).isNotNull()
|
||||
* .withPartitionKey(Schema.RECIPIENT_ID)
|
||||
* .withClusteringColumn(Schema.TIMESTAMP)
|
||||
* .withClusteringColumn(Schema.MESSAGE_ID)
|
||||
* .withClusteringOrder(Schema.TIMESTAMP, ClusteringOrder.DESC)
|
||||
* .build());
|
||||
*
|
||||
* _log.info("+ Materialized View '{}' has been created (if needed).",
|
||||
* "messages_active_received");
|
||||
* }
|
||||
*
|
||||
* // Method to create the materialized view for unread sent messages
|
||||
* private void createViewMessagesUnreadSent(CqlSession cqlSession) {
|
||||
* cqlSession.execute(SchemaBuilder.createMaterializedView(Schema.
|
||||
* TABLE_MESSAGES_SENT_READ)
|
||||
* .ifNotExists()
|
||||
* .asSelectFrom(Schema.TABLE_MESSAGES_SENT)
|
||||
* .column(Schema.FROM_ID)
|
||||
* .column(Schema.TIMESTAMP)
|
||||
* .column(Schema.MESSAGE_ID)
|
||||
* .column(Schema.FROM_NAME)
|
||||
* .column(Schema.RECIPIENTS)
|
||||
* .column(Schema.SUBJECT)
|
||||
* .column(Schema.BODY)
|
||||
* .column(Schema.WITH_ATTACH)
|
||||
* .column(Schema.ISREAD)
|
||||
* .column(Schema.ISOPENED)
|
||||
* .column(Schema.ISDELETED)
|
||||
* .whereColumn(Schema.FROM_ID).isNotNull()
|
||||
* .whereColumn(Schema.ISREAD).isEqualTo(QueryBuilder.literal(false))
|
||||
* .whereColumn(Schema.ISDELETED).isEqualTo(QueryBuilder.literal(false))
|
||||
* .whereColumn(Schema.TIMESTAMP).isNotNull()
|
||||
* .whereColumn(Schema.MESSAGE_ID).isNotNull()
|
||||
* .withPartitionKey(Schema.FROM_ID)
|
||||
* .withClusteringColumn(Schema.TIMESTAMP)
|
||||
* .withClusteringColumn(Schema.MESSAGE_ID)
|
||||
* .withClusteringOrder(Schema.TIMESTAMP, ClusteringOrder.DESC)
|
||||
* .build());
|
||||
*
|
||||
* _log.info("+ Materialized View '{}' has been created (if needed).",
|
||||
* "messages_unread_sent");
|
||||
* }
|
||||
*
|
||||
* // Method to create the materialized view for unread received messages
|
||||
* private void createViewMessagesUnreadReceived(CqlSession cqlSession) {
|
||||
* cqlSession.execute(SchemaBuilder.createMaterializedView(Schema.
|
||||
* TABLE_MESSAGES_RECEIVED_READ)
|
||||
* .ifNotExists()
|
||||
* .asSelectFrom(Schema.TABLE_MESSAGES_RECEIVED)
|
||||
* .column(Schema.RECIPIENT_ID)
|
||||
* .column(Schema.TIMESTAMP)
|
||||
* .column(Schema.MESSAGE_ID)
|
||||
* .column(Schema.FROM_ID)
|
||||
* .column(Schema.FROM_NAME)
|
||||
* .column(Schema.RECIPIENTS)
|
||||
* .column(Schema.SUBJECT)
|
||||
* .column(Schema.BODY)
|
||||
* .column(Schema.WITH_ATTACH)
|
||||
* .column(Schema.ISREAD)
|
||||
* .column(Schema.ISOPENED)
|
||||
* .column(Schema.ISDELETED)
|
||||
* .whereColumn(Schema.RECIPIENT_ID).isNotNull()
|
||||
* .whereColumn(Schema.ISREAD).isEqualTo(QueryBuilder.literal(false))
|
||||
* .whereColumn(Schema.ISDELETED).isEqualTo(QueryBuilder.literal(false))
|
||||
* .whereColumn(Schema.TIMESTAMP).isNotNull()
|
||||
* .whereColumn(Schema.MESSAGE_ID).isNotNull()
|
||||
* .withPartitionKey(Schema.RECIPIENT_ID)
|
||||
* .withClusteringColumn(Schema.TIMESTAMP)
|
||||
* .withClusteringColumn(Schema.MESSAGE_ID)
|
||||
* .withClusteringOrder(Schema.TIMESTAMP, ClusteringOrder.DESC)
|
||||
* .build());
|
||||
*
|
||||
* _log.info("+ Materialized View '{}' has been created (if needed).",
|
||||
* "messages_unread_received");
|
||||
* }
|
||||
*
|
||||
*/
|
||||
}
|
|
@ -4627,7 +4627,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
|
||||
// Add a condition to get messages with a timestamp less than the provided one
|
||||
if (timestamp != null) {
|
||||
select = select.whereColumn(Schema.TIMESTAMP).isLessThan(QueryBuilder.literal(timestamp.toInstant()));
|
||||
select = select.whereColumn(Schema.CREATION_TIME).isLessThan(QueryBuilder.literal(timestamp.toInstant()));
|
||||
}
|
||||
|
||||
// Add a condition to filter on deleted if filter_deleted is not null
|
||||
|
@ -4642,7 +4642,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
|
||||
// if (messageId == null) {
|
||||
// // Add ordering by timestamp in descending order
|
||||
// select = select.orderBy(Schema.TIMESTAMP, ClusteringOrder.DESC);
|
||||
// select = select.orderBy(Schema.CREATION_TIME, ClusteringOrder.DESC);
|
||||
// }
|
||||
|
||||
if (filter_deleted != null || filter_read != null) {
|
||||
|
@ -4671,7 +4671,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
row.getList(Schema.RECIPIENTS, String.class), // list of recipients
|
||||
row.getString(Schema.SUBJECT), // subject of the message
|
||||
row.getString(Schema.BODY), // body of the message
|
||||
Date.from(row.getInstant(Schema.TIMESTAMP)), // timestamp of the message
|
||||
Date.from(row.getInstant(Schema.CREATION_TIME)), // timestamp of the message
|
||||
row.getBoolean(Schema.WITH_ATTACH), // whether the message has attachments
|
||||
row.getBoolean(Schema.ISREAD), // whether the message is read
|
||||
row.getBoolean(Schema.ISOPENED), // whether the message is opened
|
||||
|
@ -4715,7 +4715,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
|
||||
// Add a condition to get messages with a timestamp less than the provided one
|
||||
if (timestamp != null) {
|
||||
select = select.whereColumn(Schema.TIMESTAMP).isLessThan(QueryBuilder.literal(timestamp.toInstant()));
|
||||
select = select.whereColumn(Schema.CREATION_TIME).isLessThan(QueryBuilder.literal(timestamp.toInstant()));
|
||||
}
|
||||
|
||||
// Add a condition to filter on deleted if filter_deleted is not null
|
||||
|
@ -4730,7 +4730,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
|
||||
// if (messageId == null) {
|
||||
// // Add ordering by timestamp in descending order
|
||||
// select = select.orderBy(Schema.TIMESTAMP, ClusteringOrder.DESC);
|
||||
// select = select.orderBy(Schema.CREATION_TIME, ClusteringOrder.DESC);
|
||||
// }
|
||||
|
||||
if (filter_deleted != null || filter_read != null) {
|
||||
|
@ -4760,7 +4760,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
row.getList(Schema.RECIPIENTS, String.class), // list of recipients (addresses)
|
||||
row.getString(Schema.SUBJECT), // subject of the message
|
||||
row.getString(Schema.BODY), // body of the message
|
||||
Date.from(row.getInstant(Schema.TIMESTAMP)), // timestamp of the message
|
||||
Date.from(row.getInstant(Schema.CREATION_TIME)), // timestamp of the message
|
||||
row.getBoolean(Schema.WITH_ATTACH), // whether the message has attachments
|
||||
row.getBoolean(Schema.ISREAD), // whether the message is read
|
||||
row.getBoolean(Schema.ISOPENED), // whether the message is opened
|
||||
|
@ -4868,7 +4868,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
|
||||
// search for not deleted message_sent. if we found it, we cannot delete
|
||||
// attachments
|
||||
MessageSent messageSent = getSentMessageById(message.getUserid(), message.getId(), false, null, session);
|
||||
MessageSent messageSent = getSentMessageById(message.getUser_id(), message.getId(), false, null, session);
|
||||
if (messageSent != null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -4896,7 +4896,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
deleteMessageReceived(recipientId, messageId, false, session);
|
||||
}
|
||||
|
||||
deleteMessageSent(message.getUserid(), messageId, true, session);
|
||||
deleteMessageSent(message.getUser_id(), messageId, true, session);
|
||||
return getSentMessageById(null, messageId, null, null, session);
|
||||
}
|
||||
|
||||
|
@ -4931,9 +4931,9 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
// Costruisci la query di aggiornamento usando il QueryBuilder
|
||||
Update update = QueryBuilder.update(Schema.TABLE_MESSAGES_SENT)
|
||||
.setColumn(Schema.ISDELETED, QueryBuilder.literal(true)) // Imposta il campo 'read' al valore fornito
|
||||
.whereColumn(Schema.FROM_ID).isEqualTo(QueryBuilder.literal(sentMessage.getUserid())) // Filtro per
|
||||
.whereColumn(Schema.FROM_ID).isEqualTo(QueryBuilder.literal(sentMessage.getUser_id())) // Filtro per
|
||||
// 'from_id'
|
||||
.whereColumn(Schema.TIMESTAMP).isEqualTo(QueryBuilder.literal(sentMessage.getTimestamp().toInstant()))
|
||||
.whereColumn(Schema.CREATION_TIME).isEqualTo(QueryBuilder.literal(sentMessage.getCreation_time().toInstant()))
|
||||
.whereColumn(Schema.MESSAGE_ID).isEqualTo(QueryBuilder.literal(sentMessage.getUUID())); // Filtro
|
||||
// per
|
||||
// 'message_id'
|
||||
|
@ -4945,7 +4945,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
session.execute(statement);
|
||||
|
||||
// Retrieve the message after marking it as deleted
|
||||
sentMessage = getSentMessageById(sentMessage.getUserid(), sentMessage.getId(), true, null, session);
|
||||
sentMessage = getSentMessageById(sentMessage.getUser_id(), sentMessage.getId(), true, null, session);
|
||||
|
||||
// Check if attachment deletion is required and the message has attachments
|
||||
if (checkAttachmentDeletion && sentMessage.isWith_attachments()) {
|
||||
|
@ -4986,11 +4986,11 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
// Costruisci la query di aggiornamento usando il QueryBuilder
|
||||
Update update = QueryBuilder.update(Schema.TABLE_MESSAGES_RECEIVED)
|
||||
.setColumn(Schema.ISDELETED, QueryBuilder.literal(true)) // Imposta il campo 'read' al valore fornito
|
||||
.whereColumn(Schema.RECIPIENT_ID).isEqualTo(QueryBuilder.literal(receivedMessage.getRecipientid())) // Filtro
|
||||
.whereColumn(Schema.RECIPIENT_ID).isEqualTo(QueryBuilder.literal(receivedMessage.getRecipient_id())) // Filtro
|
||||
// per
|
||||
// 'from_id'
|
||||
.whereColumn(Schema.TIMESTAMP)
|
||||
.isEqualTo(QueryBuilder.literal(receivedMessage.getTimestamp().toInstant()))
|
||||
.whereColumn(Schema.CREATION_TIME)
|
||||
.isEqualTo(QueryBuilder.literal(receivedMessage.getCreation_time().toInstant()))
|
||||
.whereColumn(Schema.MESSAGE_ID).isEqualTo(QueryBuilder.literal(receivedMessage.getUUID())); // Filtro
|
||||
// per
|
||||
// 'message_id'
|
||||
|
@ -5002,7 +5002,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
session.execute(statement);
|
||||
|
||||
// Retrieve the message after marking it as deleted
|
||||
receivedMessage = getReceivedMessageById(receivedMessage.getRecipientid(), receivedMessage.getId(), true, null,
|
||||
receivedMessage = getReceivedMessageById(receivedMessage.getRecipient_id(), receivedMessage.getId(), true, null,
|
||||
session);
|
||||
|
||||
// Check if attachment deletion is required and the message has attachments
|
||||
|
@ -5019,12 +5019,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
|
||||
RegularInsert insert = QueryBuilder.insertInto(Schema.TABLE_MESSAGES_SENT)
|
||||
.value(Schema.MESSAGE_ID, QueryBuilder.literal(UUID.fromString(message.getId())))
|
||||
.value(Schema.FROM_ID, QueryBuilder.literal(message.getUserid()))
|
||||
.value(Schema.FROM_ID, QueryBuilder.literal(message.getUser_id()))
|
||||
.value(Schema.FROM_NAME, QueryBuilder.literal(message.getUser_name()))
|
||||
.value(Schema.RECIPIENTS, QueryBuilder.literal(message.getAddresses()))
|
||||
.value(Schema.SUBJECT, QueryBuilder.literal(message.getSubject()))
|
||||
.value(Schema.BODY, QueryBuilder.literal(message.getBody()))
|
||||
.value(Schema.TIMESTAMP, QueryBuilder.literal(message.getTimestamp().toInstant()))
|
||||
.value(Schema.CREATION_TIME, QueryBuilder.literal(message.getCreation_time().toInstant()))
|
||||
.value(Schema.ISREAD, QueryBuilder.literal(false))
|
||||
.value(Schema.ISOPENED, QueryBuilder.literal(false))
|
||||
.value(Schema.ISDELETED, QueryBuilder.literal(false));
|
||||
|
@ -5043,12 +5043,12 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
RegularInsert insert = QueryBuilder.insertInto(Schema.TABLE_MESSAGES_RECEIVED)
|
||||
.value(Schema.MESSAGE_ID, QueryBuilder.literal(UUID.fromString(message.getId())))
|
||||
.value(Schema.RECIPIENT_ID, QueryBuilder.literal(recipientId))
|
||||
.value(Schema.FROM_ID, QueryBuilder.literal(message.getUserid()))
|
||||
.value(Schema.FROM_ID, QueryBuilder.literal(message.getUser_id()))
|
||||
.value(Schema.FROM_NAME, QueryBuilder.literal(message.getUser_name()))
|
||||
.value(Schema.RECIPIENTS, QueryBuilder.literal(message.getAddresses()))
|
||||
.value(Schema.SUBJECT, QueryBuilder.literal(message.getSubject()))
|
||||
.value(Schema.BODY, QueryBuilder.literal(message.getBody()))
|
||||
.value(Schema.TIMESTAMP, QueryBuilder.literal(message.getTimestamp().toInstant()))
|
||||
.value(Schema.CREATION_TIME, QueryBuilder.literal(message.getCreation_time().toInstant()))
|
||||
.value(Schema.ISREAD, QueryBuilder.literal(false))
|
||||
.value(Schema.ISOPENED, QueryBuilder.literal(false))
|
||||
.value(Schema.ISDELETED, QueryBuilder.literal(false));
|
||||
|
@ -5096,15 +5096,15 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
|
||||
boolean has_attachments = attachments != null && !attachments.isEmpty();
|
||||
message.setWith_attachments(has_attachments);
|
||||
if (message.getTimestamp() == null) {
|
||||
message.setTimestamp(new Date());
|
||||
if (message.getCreation_time() == null) {
|
||||
message.setCreation_time(new Date());
|
||||
}
|
||||
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException("message cannot be null or empty");
|
||||
}
|
||||
|
||||
if (message.getUserid() == null) {
|
||||
if (message.getUser_id() == null) {
|
||||
throw new IllegalArgumentException("message from cannot be null");
|
||||
}
|
||||
|
||||
|
@ -5121,7 +5121,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
|
||||
boolean sent = saveSentMessage(message, session);
|
||||
if (!sent) {
|
||||
_log.error("Sent Message failed to be saved: from " + message.getUserid());
|
||||
_log.error("Sent Message failed to be saved: from " + message.getUser_id());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -5131,7 +5131,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
boolean received = saveReceivedMessage(message, recipientId, session);
|
||||
|
||||
if (!received) {
|
||||
_log.error("Received message failed to be saved: from " + message.getUserid());
|
||||
_log.error("Received message failed to be saved: from " + message.getUser_id());
|
||||
// TODO: Manage error
|
||||
}
|
||||
// messagesReceived.add(received);
|
||||
|
@ -5219,7 +5219,7 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
Update update = QueryBuilder.update(Schema.TABLE_MESSAGES_SENT)
|
||||
.setColumn(Schema.ISREAD, QueryBuilder.literal(set_read)) // Imposta il campo 'read' al valore fornito
|
||||
.whereColumn(Schema.FROM_ID).isEqualTo(QueryBuilder.literal(fromId)) // Filtro per 'from_id'
|
||||
.whereColumn(Schema.TIMESTAMP).isEqualTo(QueryBuilder.literal(sentMessage.getTimestamp().toInstant()))
|
||||
.whereColumn(Schema.CREATION_TIME).isEqualTo(QueryBuilder.literal(sentMessage.getCreation_time().toInstant()))
|
||||
.whereColumn(Schema.MESSAGE_ID).isEqualTo(QueryBuilder.literal(UUID.fromString(messageId))); // Filtro
|
||||
// per
|
||||
// 'message_id'
|
||||
|
@ -5243,8 +5243,8 @@ public final class DBCassandraAstyanaxImpl implements DatabookStore {
|
|||
Update update = QueryBuilder.update(Schema.TABLE_MESSAGES_RECEIVED)
|
||||
.setColumn(Schema.ISREAD, QueryBuilder.literal(set_read)) // Set the 'read' column to the provided value
|
||||
.whereColumn(Schema.RECIPIENT_ID).isEqualTo(QueryBuilder.literal(recipientId))
|
||||
.whereColumn(Schema.TIMESTAMP)
|
||||
.isEqualTo(QueryBuilder.literal(receivedMessage.getTimestamp().toInstant()))
|
||||
.whereColumn(Schema.CREATION_TIME)
|
||||
.isEqualTo(QueryBuilder.literal(receivedMessage.getCreation_time().toInstant()))
|
||||
.whereColumn(Schema.MESSAGE_ID).isEqualTo(QueryBuilder.literal(UUID.fromString(messageId)));
|
||||
|
||||
// Execute the update query
|
||||
|
|
|
@ -85,13 +85,13 @@ public class Schema {
|
|||
public static final String IDX_MESSAGES_SENT_ID = "message_sent_id_idx";
|
||||
public static final String IDX_MESSAGES_SENT_READ = "message_sent_read_idx";
|
||||
public static final String IDX_MESSAGES_SENT_DELETED = "message_sent_deleted_idx";
|
||||
public static final String IDX_MESSAGES_SENT_TIMESTAMP = "message_sent_timestamp_idx";
|
||||
public static final String IDX_MESSAGES_SENT_CREATION_TIME = "message_sent_creation_time_idx";
|
||||
|
||||
|
||||
public static final String IDX_MESSAGES_RECEIVED_ID = "message_received_id_idx";
|
||||
public static final String IDX_MESSAGES_RECEIVED_READ = "message_received_read_idx";
|
||||
public static final String IDX_MESSAGES_RECEIVED_DELETED = "message_received_deleted_idx";
|
||||
public static final String IDX_MESSAGES_RECEIVED_TIMESTAMP = "message_received_timestamp_idx";
|
||||
public static final String IDX_MESSAGES_RECEIVED_CREATION_TIME = "message_received_creation_time_idx";
|
||||
|
||||
|
||||
|
||||
|
@ -111,7 +111,7 @@ public class Schema {
|
|||
|
||||
public static final String FROM_ID = "from_id"; //text
|
||||
public static final String FROM_NAME = "from_name"; //text
|
||||
// public static final String TIMESTAMP = "timestamp"; //text
|
||||
public static final String CREATION_TIME = "creation_time"; //text
|
||||
public static final String MESSAGE_ID = "message_id"; //text
|
||||
public static final String RECIPIENT_ID = "recipient_id"; //text
|
||||
public static final String RECIPIENTS = "addresses"; //text
|
||||
|
|
|
@ -47,7 +47,7 @@ public class Message implements Serializable, Comparable<Message> {
|
|||
protected boolean with_attachments;
|
||||
|
||||
// protected MessageUser sender;
|
||||
protected String userid;
|
||||
protected String user_id;
|
||||
protected String user_name;
|
||||
|
||||
protected List<String> addresses;
|
||||
|
@ -56,7 +56,7 @@ public class Message implements Serializable, Comparable<Message> {
|
|||
protected String body;
|
||||
|
||||
// protected Date creation_time;
|
||||
protected Date timestamp;
|
||||
protected Date creation_time;
|
||||
|
||||
public UUID getUUID() {
|
||||
return UUID.fromString(getId());
|
||||
|
@ -82,12 +82,12 @@ public class Message implements Serializable, Comparable<Message> {
|
|||
this.with_attachments = with_attachments;
|
||||
}
|
||||
|
||||
public String getUserid() {
|
||||
return userid;
|
||||
public String getUser_id() {
|
||||
return user_id;
|
||||
}
|
||||
|
||||
public void setUserid(String userid) {
|
||||
this.userid = userid;
|
||||
public void setUser_id(String userid) {
|
||||
this.user_id = userid;
|
||||
}
|
||||
|
||||
public String getUser_name() {
|
||||
|
@ -123,12 +123,12 @@ public class Message implements Serializable, Comparable<Message> {
|
|||
this.addresses = addresses;
|
||||
}
|
||||
|
||||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
public Date getCreation_time() {
|
||||
return creation_time;
|
||||
}
|
||||
|
||||
public void setTimestamp(Date timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
public void setCreation_time(Date timestamp) {
|
||||
this.creation_time = timestamp;
|
||||
}
|
||||
|
||||
public Message() {
|
||||
|
@ -144,22 +144,22 @@ public class Message implements Serializable, Comparable<Message> {
|
|||
Date timestamp, boolean with_attachments ) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.userid = userid;
|
||||
this.user_id = userid;
|
||||
this.user_name = user_name;
|
||||
this.addresses = addresses;
|
||||
this.subject = subject;
|
||||
this.body = body;
|
||||
this.timestamp = timestamp;
|
||||
this.creation_time = timestamp;
|
||||
this.with_attachments = with_attachments;
|
||||
}
|
||||
|
||||
public int compareTo(Message toCompare) {
|
||||
return this.getTimestamp().compareTo(toCompare.getTimestamp());
|
||||
return this.getCreation_time().compareTo(toCompare.getCreation_time());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Message [id=" + id + ", userid=" + userid + ", timestamp=" + timestamp
|
||||
return "Message [id=" + id + ", user_id=" + user_id + ", creation_time=" + creation_time
|
||||
+ ", addresses=" + addresses + ", subject=" + subject + ", body="
|
||||
+ body + ", with_attachments=" + with_attachments + "]";
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||
public class MessageReceived extends Message {
|
||||
protected boolean read;
|
||||
protected boolean opened;
|
||||
protected String recipientid;
|
||||
protected String recipient_id;
|
||||
protected boolean deleted;
|
||||
|
||||
public boolean isDeleted() {
|
||||
|
@ -17,19 +17,19 @@ public class MessageReceived extends Message {
|
|||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public String getRecipientid() {
|
||||
return recipientid;
|
||||
public String getRecipient_id() {
|
||||
return recipient_id;
|
||||
}
|
||||
|
||||
public void setRecipientid(String recipientid) {
|
||||
this.recipientid = recipientid;
|
||||
public void setRecipient_id(String recipientid) {
|
||||
this.recipient_id = recipientid;
|
||||
}
|
||||
|
||||
public MessageReceived(String id, String recipientid, String userid, String user_name, List<String> addresses,
|
||||
String subject, String body,
|
||||
Date timestamp, boolean with_attachments, boolean read, boolean opened, boolean deleted) {
|
||||
super(id, userid, user_name, addresses, subject, body, timestamp, with_attachments);
|
||||
this.recipientid = recipientid;
|
||||
this.recipient_id = recipientid;
|
||||
this.read = read;
|
||||
this.opened = opened;
|
||||
this.deleted = deleted;
|
||||
|
@ -37,9 +37,9 @@ public class MessageReceived extends Message {
|
|||
|
||||
public MessageReceived(Message message,
|
||||
String recipientid, boolean read, boolean opened, boolean deleted) {
|
||||
super(message.getId(), message.getUserid(), message.getUser_name(), message.getAddresses(),
|
||||
message.getSubject(), message.getBody(), message.getTimestamp(), message.isWith_attachments() );
|
||||
this.recipientid = recipientid;
|
||||
super(message.getId(), message.getUser_id(), message.getUser_name(), message.getAddresses(),
|
||||
message.getSubject(), message.getBody(), message.getCreation_time(), message.isWith_attachments() );
|
||||
this.recipient_id = recipientid;
|
||||
this.read = read;
|
||||
this.opened = opened;
|
||||
this.deleted = deleted;
|
||||
|
@ -47,10 +47,10 @@ public class MessageReceived extends Message {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Message [id=" + id + ", userid=" + userid + ", timestamp=" + timestamp
|
||||
return "ReceivedMessage [id=" + id + ", user_id=" + user_id + ", creation_time=" + creation_time
|
||||
+ ", addresses=" + addresses + ", subject=" + subject + ", body="
|
||||
+ body + ", with_attachments=" + with_attachments +
|
||||
", recipientid=" + recipientid + ", read=" + read + ", opened=" + opened + ", deleted=" + deleted + "]";
|
||||
", recipientid=" + recipient_id + ", read=" + read + ", opened=" + opened + ", deleted=" + deleted + "]";
|
||||
}
|
||||
|
||||
public boolean isRead() {
|
||||
|
|
|
@ -28,8 +28,8 @@ public class MessageSent extends Message {
|
|||
}
|
||||
|
||||
public MessageSent(Message message, boolean read, boolean opened, boolean deleted) {
|
||||
super(message.getId(), message.getUserid(), message.getUser_name(), message.getAddresses(),
|
||||
message.getSubject(), message.getBody(), message.getTimestamp(), message.isWith_attachments());
|
||||
super(message.getId(), message.getUser_id(), message.getUser_name(), message.getAddresses(),
|
||||
message.getSubject(), message.getBody(), message.getCreation_time(), message.isWith_attachments());
|
||||
this.deleted = deleted;
|
||||
this.read = read;
|
||||
this.opened = opened;
|
||||
|
@ -37,7 +37,7 @@ public class MessageSent extends Message {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Message [id=" + id + ", userid=" + userid + ", timestamp=" + timestamp
|
||||
return "SentMessage [id=" + id + ", user_id=" + user_id + ", creation_time=" + creation_time
|
||||
+ ", addresses=" + addresses + ", subject=" + subject + ", body="
|
||||
+ body + ", with_attachments=" + with_attachments + ", read="
|
||||
+ read + ", opened=" + opened + ", deleted=" + deleted + "]";
|
||||
|
|
|
@ -56,7 +56,7 @@ public class MessagesTest extends BaseDbTest{
|
|||
Message message = store.sendMessage(testFrom, recipients, subject, body, null);
|
||||
|
||||
assertNotNull("Message should not be null after creation", message);
|
||||
assertEquals("User ID does not match", testFrom, message.getUserid());
|
||||
assertEquals("User ID does not match", testFrom, message.getUser_id());
|
||||
assertEquals("Recipient does not match", recipient, message.getAddresses().get(0));
|
||||
assertEquals("Subject does not match", subject, message.getSubject());
|
||||
assertEquals("Body does not match", body, message.getBody());
|
||||
|
@ -64,7 +64,7 @@ public class MessagesTest extends BaseDbTest{
|
|||
MessageSent messageSent = store.getSentMessageById(testFrom, message.getId());
|
||||
|
||||
assertNotNull("Sent message should not be null", messageSent);
|
||||
assertEquals("User ID of sent message does not match", testFrom, messageSent.getUserid());
|
||||
assertEquals("User ID of sent message does not match", testFrom, messageSent.getUser_id());
|
||||
assertEquals("Recipient of sent message does not match", recipient, messageSent.getAddresses().get(0));
|
||||
assertEquals("Subject of sent message does not match", subject, messageSent.getSubject());
|
||||
assertEquals("Body of sent message does not match", body, messageSent.getBody());
|
||||
|
@ -72,16 +72,16 @@ public class MessagesTest extends BaseDbTest{
|
|||
MessageReceived messageReceived = store.getReceivedMessageById(recipient, message.getId());
|
||||
|
||||
assertNotNull("Received message should not be null", messageReceived);
|
||||
assertEquals("User ID of received message does not match", testFrom, messageReceived.getUserid());
|
||||
assertEquals("Recipient of received message does not match", recipient, messageReceived.getRecipientid());
|
||||
assertEquals("User ID of received message does not match", testFrom, messageReceived.getUser_id());
|
||||
assertEquals("Recipient of received message does not match", recipient, messageReceived.getRecipient_id());
|
||||
assertEquals("Subject of received message does not match", subject, messageReceived.getSubject());
|
||||
assertEquals("Body of received message does not match", body, messageReceived.getBody());
|
||||
|
||||
MessageReceived messageReceived2 = store.getReceivedMessageById(recipient2, message.getId());
|
||||
|
||||
assertNotNull("Received2 message should not be null", messageReceived2);
|
||||
assertEquals("User ID of received2 message does not match", testFrom, messageReceived2.getUserid());
|
||||
assertEquals("Recipient of received2 message does not match", recipient2, messageReceived2.getRecipientid());
|
||||
assertEquals("User ID of received2 message does not match", testFrom, messageReceived2.getUser_id());
|
||||
assertEquals("Recipient of received2 message does not match", recipient2, messageReceived2.getRecipient_id());
|
||||
assertEquals("Subject of received2 message does not match", subject, messageReceived2.getSubject());
|
||||
assertEquals("Body of received2 message does not match", body, messageReceived2.getBody());
|
||||
}
|
||||
|
@ -400,9 +400,9 @@ public class MessagesTest extends BaseDbTest{
|
|||
// Verifica che i messaggi siano ordinati in modo decrescente in base al
|
||||
|
||||
// timestamp
|
||||
Date timestamp1 = sentMessages.get(0).getTimestamp();
|
||||
Date timestamp2 = sentMessages.get(1).getTimestamp();
|
||||
Date timestamp3 = sentMessages.get(2).getTimestamp();
|
||||
Date timestamp1 = sentMessages.get(0).getCreation_time();
|
||||
Date timestamp2 = sentMessages.get(1).getCreation_time();
|
||||
Date timestamp3 = sentMessages.get(2).getCreation_time();
|
||||
|
||||
assertTrue("First message should be newer than second", timestamp1.after(timestamp2));
|
||||
assertTrue("Second message should be newer than third", timestamp2.after(timestamp3));
|
||||
|
@ -426,9 +426,9 @@ public class MessagesTest extends BaseDbTest{
|
|||
|
||||
// Verifica che i messaggi siano ordinati in modo decrescente in base al
|
||||
// timestamp
|
||||
Date timestamp1 = receivedMessages.get(0).getTimestamp();
|
||||
Date timestamp2 = receivedMessages.get(1).getTimestamp();
|
||||
Date timestamp3 = receivedMessages.get(2).getTimestamp();
|
||||
Date timestamp1 = receivedMessages.get(0).getCreation_time();
|
||||
Date timestamp2 = receivedMessages.get(1).getCreation_time();
|
||||
Date timestamp3 = receivedMessages.get(2).getCreation_time();
|
||||
|
||||
assertTrue("First message should be newer than second", timestamp1.after(timestamp2));
|
||||
assertTrue("Second message should be newer than third", timestamp2.after(timestamp3));
|
||||
|
@ -469,8 +469,8 @@ public class MessagesTest extends BaseDbTest{
|
|||
assertEquals("Sent messages list should contain 2 messages", 2, sentMessages.size());
|
||||
|
||||
// Verifica che i messaggi siano ordinati per timestamp decrescente
|
||||
Date timestamp1 = sentMessages.get(0).getTimestamp();
|
||||
Date timestamp2 = sentMessages.get(1).getTimestamp();
|
||||
Date timestamp1 = sentMessages.get(0).getCreation_time();
|
||||
Date timestamp2 = sentMessages.get(1).getCreation_time();
|
||||
assertTrue("First message should be newer than second", timestamp1.after(timestamp2));
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,7 @@ public class MessagesTest extends BaseDbTest{
|
|||
Message message3 = store.sendMessage(testFrom, recipients, subject + "3", body, null);
|
||||
|
||||
// Usa il timestamp del secondo messaggio per il test
|
||||
Date filterTimestamp = message2.getTimestamp();
|
||||
Date filterTimestamp = message2.getCreation_time();
|
||||
|
||||
// Recupera tutti i messaggi con timestamp <= filterTimestamp
|
||||
List<MessageSent> sentMessages = store.getSentMessagesBySender(testFrom, filterTimestamp, 10);
|
||||
|
@ -509,7 +509,7 @@ public class MessagesTest extends BaseDbTest{
|
|||
// Verifica che i messaggi abbiano timestamp <= filterTimestamp
|
||||
for (MessageSent message : sentMessages) {
|
||||
assertTrue("Message timestamp should be less than or equal to the filter timestamp",
|
||||
message.getTimestamp().compareTo(filterTimestamp) <= 0);
|
||||
message.getCreation_time().compareTo(filterTimestamp) <= 0);
|
||||
}
|
||||
|
||||
// Verifica che il terzo messaggio (con timestamp maggiore) non sia nella lista
|
||||
|
@ -527,7 +527,7 @@ public class MessagesTest extends BaseDbTest{
|
|||
Message message3 = store.sendMessage(testFrom, recipients, subject + "3", body, null);
|
||||
|
||||
// Usa il timestamp del secondo messaggio per il test
|
||||
Date filterTimestamp = message2.getTimestamp();
|
||||
Date filterTimestamp = message2.getCreation_time();
|
||||
|
||||
// Recupera tutti i messaggi ricevuti con timestamp <= filterTimestamp
|
||||
List<MessageReceived> receivedMessages = store.getReceivedMessagesByRecipient(recipient, filterTimestamp, 10);
|
||||
|
@ -538,7 +538,7 @@ public class MessagesTest extends BaseDbTest{
|
|||
// Verifica che i messaggi abbiano timestamp <= filterTimestamp
|
||||
for (MessageReceived message : receivedMessages) {
|
||||
assertTrue("Message timestamp should be less than or equal to the filter timestamp",
|
||||
message.getTimestamp().compareTo(filterTimestamp) <= 0);
|
||||
message.getCreation_time().compareTo(filterTimestamp) <= 0);
|
||||
}
|
||||
|
||||
// Verifica che il terzo messaggio (con timestamp maggiore) non sia nella lista
|
||||
|
|
Loading…
Reference in New Issue