diff --git a/src/main/java/org/sunbird/workflow/config/Configuration.java b/src/main/java/org/sunbird/workflow/config/Configuration.java index f94ecdd..a613813 100644 --- a/src/main/java/org/sunbird/workflow/config/Configuration.java +++ b/src/main/java/org/sunbird/workflow/config/Configuration.java @@ -33,6 +33,9 @@ public class Configuration { @Value("${userrole.search.endpoint}") private String userRoleSearchEndpoint; + @Value("${workflow.config.endpoint}") + private String workflowConfigEndpoint; + @Value("${kafka.topics.workflow.request}") private String workflowApplicationTopic; @@ -54,6 +57,14 @@ public class Configuration { @Value("${hub.profile.search}") private String hubProfileSearchEndPoint; + public String getWorkflowConfigEndpoint() { + return workflowConfigEndpoint; + } + + public void setWorkflowConfigEndpoint(String workflowConfigEndpoint) { + this.workflowConfigEndpoint = workflowConfigEndpoint; + } + @Value("${kafka.topics.workflow.notification}") private String workFlowNotificationTopic; diff --git a/src/main/java/org/sunbird/workflow/config/db/BodhiConfig.java b/src/main/java/org/sunbird/workflow/config/db/SunbirdConfig.java similarity index 75% rename from src/main/java/org/sunbird/workflow/config/db/BodhiConfig.java rename to src/main/java/org/sunbird/workflow/config/db/SunbirdConfig.java index fd3919a..0a3c80c 100644 --- a/src/main/java/org/sunbird/workflow/config/db/BodhiConfig.java +++ b/src/main/java/org/sunbird/workflow/config/db/SunbirdConfig.java @@ -15,30 +15,30 @@ import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; @Configuration -@ConfigurationProperties("spring.data.cassandra.bodhi") -@EnableCassandraRepositories(basePackages = "org.sunbird.workflow.repository.cassandra.bodhi", cassandraTemplateRef = "bodhiTemplate") -public class BodhiConfig extends CassandraConfig { +@ConfigurationProperties("spring.data.cassandra.sunbird") +@EnableCassandraRepositories(basePackages = "org.sunbird.workflow.repository.cassandra.sunbird", cassandraTemplateRef = "sunbirdTemplate") +public class SunbirdConfig extends CassandraConfig { - private Logger logger = LoggerFactory.getLogger(BodhiConfig.class); + private Logger logger = LoggerFactory.getLogger(SunbirdConfig.class); - @Value("${spring.data.cassandra.bodhi.username}") - private String bodhiUser; + @Value("${spring.data.cassandra.sunbird.username}") + private String sunbirdUser; - @Value("${spring.data.cassandra.bodhi.password}") - private String bodhiPassword; + @Value("${spring.data.cassandra.sunbird.password}") + private String sunbirdPassword; @Override @Primary - @Bean(name = "bodhiTemplate") + @Bean(name = "sunbirdTemplate") public CassandraAdminTemplate cassandraTemplate() throws Exception { return new CassandraAdminTemplate(session().getObject(), cassandraConverter()); } @Override - @Bean(name = "bodhiSession") + @Bean(name = "sunbirdSession") public CassandraSessionFactoryBean session() { - AuthProvider authProvider = new PlainTextAuthProvider(bodhiUser, bodhiPassword); + AuthProvider authProvider = new PlainTextAuthProvider(sunbirdUser, sunbirdPassword); CassandraSessionFactoryBean session = new CassandraSessionFactoryBean(); session.setCluster(Cluster.builder().addContactPoint(getContactPoints()).withPort(getPort()) diff --git a/src/main/java/org/sunbird/workflow/repository/cassandra/bodhi/WfRepo.java b/src/main/java/org/sunbird/workflow/repository/cassandra/bodhi/WfRepo.java deleted file mode 100644 index 975037a..0000000 --- a/src/main/java/org/sunbird/workflow/repository/cassandra/bodhi/WfRepo.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.sunbird.workflow.repository.cassandra.bodhi; - - -import org.springframework.data.cassandra.repository.CassandraRepository; -import org.springframework.data.cassandra.repository.Query; -import org.springframework.stereotype.Repository; -import org.sunbird.workflow.models.cassandra.WfPrimaryKey; -import org.sunbird.workflow.models.cassandra.Workflow; - -@Repository -public interface WfRepo extends CassandraRepository { - - @Query("SELECT * FROM work_flow WHERE root_org=?0 AND org=?1 AND service=?2;") - Workflow getWorkFlowForService(String rootOrg, String org, String service); - -} diff --git a/src/main/java/org/sunbird/workflow/service/impl/NotificationServiceImpl.java b/src/main/java/org/sunbird/workflow/service/impl/NotificationServiceImpl.java index 5628aa6..5666fb3 100644 --- a/src/main/java/org/sunbird/workflow/service/impl/NotificationServiceImpl.java +++ b/src/main/java/org/sunbird/workflow/service/impl/NotificationServiceImpl.java @@ -16,7 +16,7 @@ import org.sunbird.workflow.models.notification.Template; import org.sunbird.workflow.postgres.entity.WfStatusEntity; import org.sunbird.workflow.postgres.repo.WfStatusRepo; -import org.sunbird.workflow.repository.cassandra.bodhi.WfRepo; +import org.sunbird.workflow.repository.cassandra.sunbird.WfRepo; import org.sunbird.workflow.service.Workflowservice; import java.util.*; diff --git a/src/main/java/org/sunbird/workflow/service/impl/WorkflowServiceImpl.java b/src/main/java/org/sunbird/workflow/service/impl/WorkflowServiceImpl.java index 5a0be49..5a8dd51 100644 --- a/src/main/java/org/sunbird/workflow/service/impl/WorkflowServiceImpl.java +++ b/src/main/java/org/sunbird/workflow/service/impl/WorkflowServiceImpl.java @@ -27,7 +27,7 @@ import org.sunbird.workflow.postgres.repo.WfAuditRepo; import org.sunbird.workflow.postgres.repo.WfStatusRepo; import org.sunbird.workflow.producer.Producer; -import org.sunbird.workflow.repository.cassandra.bodhi.WfRepo; +import org.sunbird.workflow.repository.cassandra.sunbird.WfRepo; import org.sunbird.workflow.service.UserProfileWfService; import org.sunbird.workflow.service.Workflowservice; @@ -405,7 +405,11 @@ public Response getApplicationHistoryOnWfId(String rootOrg, String wfId, String public Response getNextActionForState(String rootOrg, String org, String serviceName, String state) { Response response = new Response(); try { - Workflow workFlow = wfRepo.getWorkFlowForService(rootOrg, org, serviceName); + StringBuilder builder = new StringBuilder(); + String endPoint = configuration.getWorkflowConfigEndpoint(); + builder.append(configuration.getLexCoreServiceHost()).append(endPoint); + Map response1 = (Map) requestServiceImpl.fetchResultUsingGet(builder); + Workflow workFlow = (Workflow) response1; WorkFlowModel workFlowModel = mapper.readValue(workFlow.getConfiguration(), WorkFlowModel.class); WfStatus wfStatus = getWfStatus(state, workFlowModel); List> nextActionArray = new ArrayList<>(); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0b776d8..9e54dd8 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,10 +1,10 @@ server.port=5099 -spring.data.cassandra.bodhi.contact-points=localhost -spring.data.cassandra.bodhi.port=9042 -spring.data.cassandra.bodhi.keyspace-name=bodhi -spring.data.cassandra.bodhi.username=cassandra -spring.data.cassandra.bodhi.password=cassandra +spring.data.cassandra.sunbird.contact-points=localhost +spring.data.cassandra.sunbird.port=9042 +spring.data.cassandra.sunbird.keyspace-name=sunbird +spring.data.cassandra.sunbird.username=cassandra +spring.data.cassandra.sunbird.password=cassandra #spring data jpa for postgres spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true @@ -58,4 +58,5 @@ notify.service.path=v1/notification/send/sync portal.departmentupdate.path=portal/updateuserroledept sunbird.learner.service.host=http://learner-service:9000/ -sunbird.user.search.endpoint=private/user/v1/search \ No newline at end of file +sunbird.user.search.endpoint=private/user/v1/search +workflow.config.endpoint=api/data/v1/system/settings/get/workFlowConfig \ No newline at end of file