diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 53b048c..df6667c 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -5,10 +5,10 @@ on: tags: - 'v*.*.*' branches: - ["release-4.*.*", "release-5.*.*"] + ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] pull_request: branches: - ["release-4.*.*", "release-5.*.*"] + ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] jobs: @@ -59,7 +59,7 @@ jobs: - name: Delete package specific version uses: smartsquaregmbh/delete-old-packages@v0.4.0 with: - version: 5.1.0 # This should be same as in the pom.xml file, + version: 2.1.0 # This should be same as in the pom.xml file, # to delete only the pom specified version, not the other older versions names: | com.uci.dao @@ -69,4 +69,4 @@ jobs: env: GITHUB_USERNAME: ${{ secrets.USERNAME }} GITHUB_TOKEN: ${{ secrets.TOKEN }} - run: mvn -s $GITHUB_WORKSPACE/settings.xml clean install -Pgithub deploy -DskipTests \ No newline at end of file + run: mvn -s $GITHUB_WORKSPACE/settings.xml clean install -Pgithub deploy -DskipTests diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 61c73f3..844f3a4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -3,10 +3,10 @@ name: Maven Build on: push: branches: - ["release-4.*.*", "release-5.*.*"] + ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] pull_request: branches: - ["release-4.*.*", "release-5.*.*"] + ["release-4.*.*", "release-5.*.*", "release-v2.*.*"] jobs: build: @@ -52,4 +52,4 @@ jobs: env: GITHUB_USERNAME: ${{ secrets.USERNAME }} GITHUB_TOKEN: ${{ secrets.TOKEN }} - run: mvn -s $GITHUB_WORKSPACE/settings.xml clean install -DskipTests \ No newline at end of file + run: mvn -s $GITHUB_WORKSPACE/settings.xml clean install -DskipTests diff --git a/pom.xml b/pom.xml index 8fe2882..4194639 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ dao dao jar - 5.1.0 + 2.1.0 @@ -99,13 +99,13 @@ com.uci message-rosa - 5.1.0 + 5.0.0 compile com.uci utils - 5.1.0 + 5.0.0 compile diff --git a/src/main/java/com/uci/dao/config/CassandraConfig.java b/src/main/java/com/uci/dao/config/CassandraConfig.java index fb96a2d..21b33ff 100644 --- a/src/main/java/com/uci/dao/config/CassandraConfig.java +++ b/src/main/java/com/uci/dao/config/CassandraConfig.java @@ -2,16 +2,21 @@ import com.datastax.driver.core.Cluster; import com.datastax.driver.core.QueryLogger; +import com.datastax.oss.driver.api.core.CqlSessionBuilder; +import com.datastax.oss.driver.api.core.config.DefaultDriverOption; +import com.datastax.oss.driver.api.core.config.DriverConfigLoader; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.data.cassandra.config.AbstractReactiveCassandraConfiguration; import org.springframework.data.cassandra.config.SchemaAction; +import org.springframework.data.cassandra.config.SessionBuilderConfigurer; import org.springframework.data.cassandra.core.cql.keyspace.CreateKeyspaceSpecification; import org.springframework.data.cassandra.core.cql.keyspace.DropKeyspaceSpecification; import org.springframework.data.cassandra.core.cql.keyspace.KeyspaceOption; import org.springframework.data.cassandra.repository.config.EnableReactiveCassandraRepositories; +import java.time.Duration; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -73,6 +78,17 @@ protected List getKeyspaceCreations() { return Collections.singletonList(specification); } +// @Override +// protected SessionBuilderConfigurer getSessionBuilderConfigurer() { +// return new SessionBuilderConfigurer() { +// @Override +// public CqlSessionBuilder configure(CqlSessionBuilder cqlSessionBuilder) { +// return cqlSessionBuilder +// .withConfigLoader(DriverConfigLoader.programmaticBuilder().withDuration(DefaultDriverOption.REQUEST_TIMEOUT, Duration.ofMillis(15000)).build()); +// } +// }; +// } + /** * Get list of scripts run on startup * @return @@ -85,6 +101,10 @@ protected List getStartupScripts() { if (migrationCount > 0) { count = migrationCount; } + if(migrationCount > all.size()) { + count = all.size(); + } + System.out.println("Count: "+count+", migrationCount: "+migrationCount); } catch(NumberFormatException ex){ System.out.println("NumberFormatException: " + ex.getMessage()); } catch(Exception ex){ @@ -125,6 +145,7 @@ protected List getMigrationScripts() { 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("ALTER TABLE " + keyspace + ".XMessage ADD tags list;"); // 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 67e5f8e..6cf6073 100644 --- a/src/main/java/com/uci/dao/models/XMessageDAO.java +++ b/src/main/java/com/uci/dao/models/XMessageDAO.java @@ -15,6 +15,7 @@ import java.io.Serializable; import java.time.LocalDateTime; +import java.util.List; import java.util.UUID; import static org.springframework.data.cassandra.core.cql.PrimaryKeyType.CLUSTERED; @@ -69,4 +70,7 @@ public class XMessageDAO implements Serializable { @Column private UUID botUuid; + + @Column + private List tags; } diff --git a/src/main/java/com/uci/dao/repository/XMessageRepository.java b/src/main/java/com/uci/dao/repository/XMessageRepository.java index 6f8485a..2c33ee0 100644 --- a/src/main/java/com/uci/dao/repository/XMessageRepository.java +++ b/src/main/java/com/uci/dao/repository/XMessageRepository.java @@ -53,6 +53,12 @@ public interface XMessageRepository extends ReactiveCassandraRepository> findAllByUserIdInAndFromIdInAndTimestampAfterAndTimestampBeforeAndProvider(Pageable paging, List listUserId, List listFromId, Timestamp startDate, Timestamp endDate, String provider); + @AllowFiltering + Mono> findAllByAppAndTimestampAfterAndTimestampBeforeAndProviderAndTagsContains(Pageable paging, String name, Timestamp startDate, Timestamp endDate, String provider, String tag); + + @AllowFiltering + Mono> findAllByUserIdInAndFromIdInAndTimestampAfterAndTimestampBeforeAndProviderAndTagsContains(Pageable paging, List listUserId, List listFromId, Timestamp startDate, Timestamp endDate, String provider, String tag); + @AllowFiltering Flux findAllByMessageIdAndUserIdInAndFromIdIn(String messageId, List listUserId, List listFromId); diff --git a/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java b/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java index 14f05f1..187718a 100644 --- a/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java +++ b/src/main/java/com/uci/dao/utils/XMessageDAOUtils.java @@ -52,6 +52,7 @@ public static XMessageDAO convertXMessageToDAO(XMessage xmsg) { xmsgDao.setOwnerOrgId(xmsg.getOwnerOrgId()); xmsgDao.setOwnerId(xmsg.getOwnerId()); xmsgDao.setBotUuid(xmsg.getBotId()); + xmsgDao.setTags(xmsg.getTags()); LocalDateTime triggerTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(xmsg.getTimestamp()),