Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import java.util.ArrayList;
import java.util.List;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.iemr.admin.data.employeemaster.M_Community;
import com.iemr.admin.data.employeemaster.M_Gender;
import com.iemr.admin.data.employeemaster.M_ProviderServiceMap1;
Expand Down Expand Up @@ -60,7 +62,8 @@ public interface EmployeeMasterInter {

ArrayList<M_UserLangMapping> mapLanguage(List<M_UserLangMapping> resList);

ArrayList<M_UserServiceRoleMapping2> mapRole(List<M_UserServiceRoleMapping2> resList1, String authToken);
// ArrayList<M_UserServiceRoleMapping2> mapRole(List<M_UserServiceRoleMapping2> resList1, String authToken);
public ArrayList<M_UserServiceRoleMapping2> mapRole(List<M_UserServiceRoleMapping2> resList1, String authToken) throws JsonMappingException, JsonProcessingException;

M_UserDemographics mdedit(Integer userID);

Expand Down Expand Up @@ -154,7 +157,8 @@ Boolean checkingEmpDetails(String userName, String aadhaarNo, String getpAN, Str

M_UserServiceRoleMapping2 getDataUsrId(Integer uSRMappingID);

M_UserServiceRoleMapping2 saveRoleMappingeditedData(M_UserServiceRoleMapping2 usrRole, String string);
// M_UserServiceRoleMapping2 saveRoleMappingeditedData(M_UserServiceRoleMapping2 usrRole, String string);
public M_UserServiceRoleMapping2 saveRoleMappingeditedData(M_UserServiceRoleMapping2 usrRole, String authToken) throws JsonMappingException, JsonProcessingException;

// ArrayList<M_UserLangMapping> getMappedLanguge();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.PBEKeySpec;
Expand All @@ -42,10 +44,19 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.JsonParser;
import com.iemr.admin.data.blocking.M_Providerservicemapping_Blocking;
import com.iemr.admin.data.employeemaster.M_Community;
Expand Down Expand Up @@ -85,12 +96,15 @@
import com.iemr.admin.repository.provideronboard.M_ServiceMasterRepo;
import com.iemr.admin.repository.rolemaster.M_UserservicerolemappingForRoleProviderAdminRepo;
import com.iemr.admin.service.user.EncryptUserPassword;
import com.iemr.admin.utils.CookieUtil;
import com.iemr.admin.utils.config.ConfigProperties;
import com.iemr.admin.utils.exception.IEMRException;
import com.iemr.admin.utils.http.HttpUtils;
import com.iemr.admin.utils.mapper.InputMapper;
import com.iemr.admin.utils.response.OutputResponse;

import jakarta.servlet.http.HttpServletRequest;

@Service
public class EmployeeMasterServiceImpl implements EmployeeMasterInter {

Expand Down Expand Up @@ -124,6 +138,8 @@ public class EmployeeMasterServiceImpl implements EmployeeMasterInter {

@Autowired
private EncryptUserPassword encryptUserPassword;
@Autowired
private CookieUtil cookieUtil;
private InputMapper inputMapper = new InputMapper();
private Logger logger = LoggerFactory.getLogger(EmployeeMasterServiceImpl.class);

Expand Down Expand Up @@ -305,7 +321,7 @@ public ArrayList<M_UserLangMapping> mapLanguage(List<M_UserLangMapping> resList)
}

@Override
public ArrayList<M_UserServiceRoleMapping2> mapRole(List<M_UserServiceRoleMapping2> resList1, String authToken) {
public ArrayList<M_UserServiceRoleMapping2> mapRole(List<M_UserServiceRoleMapping2> resList1, String authToken) throws JsonMappingException, JsonProcessingException {
ArrayList<M_UserServiceRoleMapping2> reslist = (ArrayList<M_UserServiceRoleMapping2>) employeeMasterRepo
.saveAll(resList1);
if (ENABLE_CTI_USER_CREATION) {
Expand Down Expand Up @@ -375,7 +391,7 @@ public boolean equals(Object obj) {
}

@Async
private void updateSupervisorRoleInCTI(List<M_UserServiceRoleMapping2> resList1, String authToken) {
private void updateSupervisorRoleInCTI(List<M_UserServiceRoleMapping2> resList1, String authToken) throws JsonMappingException, JsonProcessingException {
Map<Integer, UserServiceLine> userServiceLineMap = new HashMap<Integer, UserServiceLine>();
Set<Integer> providerMapIds = new HashSet<Integer>();
for (M_UserServiceRoleMapping2 userRole : resList1) {
Expand Down Expand Up @@ -443,25 +459,31 @@ private void updateSupervisorRoleInCTI(List<M_UserServiceRoleMapping2> resList1,
}
}

private Set<String> getCTICampaignRoles(String campaignName, String authToken) {
private Set<String> getCTICampaignRoles(String campaignName, String authToken) throws JsonMappingException, JsonProcessingException {
RestTemplate restTemplate = new RestTemplate();
ObjectMapper objectMapper = new ObjectMapper();
HttpServletRequest requestHeader = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
String jwtTokenFromCookie = cookieUtil.getJwtTokenFromCookie(requestHeader);
Set<String> resultSet = new HashSet<String>();
HttpUtils httpUtils = new HttpUtils();
HashMap<String, Object> headers = new HashMap<String, Object>();
headers.put("Authorization", authToken);
String getRolesURL = configProperties.getPropertyByName("common-url")
+ configProperties.getPropertyByName("campaign-roles-url");
JSONObject request = new JSONObject();
request.put("campaign", campaignName);

OutputResponse response = inputMapper.gson().fromJson(httpUtils.post(getRolesURL, request.toString(), headers),
OutputResponse.class);
MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>();
headers.add("Content-Type", "application/json");
headers.add("AUTHORIZATION", authToken);
headers.add("Jwttoken", jwtTokenFromCookie);
String url = configProperties.getPropertyByName("common-url") + configProperties.getPropertyByName("create-feedback");
HttpEntity<Object> request1 = new HttpEntity<Object>(campaignName, headers);
ResponseEntity<String> responseStr = restTemplate.exchange(url, HttpMethod.POST, request1, String.class);
OutputResponse response = objectMapper.readValue(responseStr.getBody(), OutputResponse.class);
if (response.isSuccess()) {
JSONObject obj = new JSONObject(response.getData());
JSONArray roles = obj.getJSONArray("roles");
for (int roleIndex = 0; roleIndex < roles.length(); roleIndex++) {
resultSet.add(roles.getString(roleIndex));
}
}
// JSONObject request = new JSONObject();
// request.put("campaign", campaignName);

return resultSet;
}

Expand Down Expand Up @@ -906,7 +928,7 @@ public M_UserServiceRoleMapping2 getDataUsrId(Integer uSRMappingID) {
}

@Override
public M_UserServiceRoleMapping2 saveRoleMappingeditedData(M_UserServiceRoleMapping2 usrRole, String authToken) {
public M_UserServiceRoleMapping2 saveRoleMappingeditedData(M_UserServiceRoleMapping2 usrRole, String authToken) throws JsonMappingException, JsonProcessingException {

M_UserServiceRoleMapping2 data = employeeMasterRepo.save(usrRole);
if (ENABLE_CTI_USER_CREATION) {
Expand Down
Loading