Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update WorkflowServiceImpl.java #7

Draft
wants to merge 4 commits into
base: cbrelease-3.0.1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/org/sunbird/workflow/config/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<String, Object> response1 = (Map<String, Object>) requestServiceImpl.fetchResultUsingGet(builder);
Workflow workFlow = (Workflow) response1;
WorkFlowModel workFlowModel = mapper.readValue(workFlow.getConfiguration(), WorkFlowModel.class);
WfStatus wfStatus = getWfStatus(state, workFlowModel);
List<HashMap<String, Object>> nextActionArray = new ArrayList<>();
Expand Down
13 changes: 7 additions & 6 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
sunbird.user.search.endpoint=private/user/v1/search
workflow.config.endpoint=api/data/v1/system/settings/get/workFlowConfig