package com.bankaudit.rest.process.controller;

import java.util.List;

import org.jboss.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bankaudit.dto.process.AuditRatingComplianceObsScoreReportDto;
import com.bankaudit.dto.process.AuditRatingComplianceScoreDto;
import com.bankaudit.dto.process.AuditRatingCompositeScoreDto;
import com.bankaudit.dto.process.AuditRatingScoreDto;
import com.bankaudit.process.model.AuditRatingComplianceObsScore;
import com.bankaudit.process.model.AuditRatingCompositeCategoryScore;
import com.bankaudit.process.model.AuditRatingCompositeOverlay;
import com.bankaudit.process.model.AuditRatingCompositeScore;
import com.bankaudit.rest.process.service.AuditRatingComplianceScoreService;
import com.bankaudit.rest.process.service.AuditRatingCompositeService;
import com.bankaudit.service.BusinessDateService;
import com.bankaudit.util.BankAuditUtil;
import com.bankaudit.util.ServiceStatus;



@RestController

@RequestMapping("/api/auditRatingComposite")
public class AuditRatingCompositeController {
	@Autowired
	AuditRatingCompositeService auditRatingCompositeService;
	
	@Autowired
	BusinessDateService businessDateService;
	
	static final Logger logger = Logger.getLogger(AuditRatingCompositeController.class);	
	
	
@RequestMapping(value="/getCompositeScoreByAuditId/{legalEntityCode}/{auditId}/{auditTypeCode}/{unitId}/{userType}/{userId}/{compRatingStatus}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getCompositeScoreByAuditId(
			@PathVariable("legalEntityCode") Integer legalEntityCode,
			@PathVariable("auditId")String auditId,
			@PathVariable("auditTypeCode") String auditTypeCode,
			@PathVariable("unitId")String unitId,
			@PathVariable("userType")String userType,
			@PathVariable("userId")String userId,
			@PathVariable("compRatingStatus")String compRatingStatus){
		ServiceStatus serviceStatus=new ServiceStatus();
		
		if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId)){
			try {
				//List<AuditRatingCompositeScore> auditCmpLst=auditRatingCompositeService.getCompositeScoreByAuditId(legalEntityCode,auditId,auditTypeCode,unitId, userType,userId,compRatingStatus);
				AuditRatingCompositeScoreDto auditCmpScrDto=auditRatingCompositeService.getCompositeScoreByAuditId(legalEntityCode,auditId,auditTypeCode,unitId, userType,userId,compRatingStatus);
				if(auditCmpScrDto!=null){
					serviceStatus.setResult(auditCmpScrDto);
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfuly retrieved ");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("ids not found");
				}				
			} catch (Exception e) {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
				e.printStackTrace();
			}
			
		}else {
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("invalid parameter");
		}
				return serviceStatus;
	}
	
	// Verify whether IR csv uploaded into the system
	
@RequestMapping(value="/verifyCSVUpload/{legalEntityCode}/{auditId}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus verifyCSVUpload(
			@PathVariable("legalEntityCode") Integer legalEntityCode,
			@PathVariable("auditId")String auditId){
		ServiceStatus serviceStatus=new ServiceStatus();
		
		if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId)){
			try {
				boolean csvUpload=auditRatingCompositeService.verifyCSVUpload(legalEntityCode,auditId); 
				if(csvUpload){
					serviceStatus.setResult(csvUpload);
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfuly retrieved ");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("Please upload IR CSV file before initiating Composite Rating");
				}				
			} catch (Exception e) {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
				e.printStackTrace();
			}			
		}else {
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("invalid parameter");
		}
				return serviceStatus;
	}
	
	
@RequestMapping(value="/insertAndGetAuditCompositeRatingByAuditId/{legalEntityCode}/{auditId}/{unitId}/{auditTypeCode}/{userId}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus insertAndGetAuditCompositeRatingByAuditId(
			@PathVariable("legalEntityCode") Integer legalEntityCode,
			@PathVariable("auditId")String auditId,
			@PathVariable("unitId")String unitId,
			@PathVariable("auditTypeCode")String auditTypeCode,
			@PathVariable("userId")String userId){
		ServiceStatus serviceStatus=new ServiceStatus();
		
		if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId) && !BankAuditUtil.isEmptyString(unitId) && !BankAuditUtil.isEmptyString(auditTypeCode)){
			try {
				List<AuditRatingCompositeScore> auditParamScrLst=auditRatingCompositeService.insertAndGetAuditCompositeRatingByAuditId(legalEntityCode,auditId,unitId,auditTypeCode,userId); 
				if(auditParamScrLst!=null){
					serviceStatus.setResult(auditParamScrLst);
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfuly retrieved ");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("Insertion failure");
				}				
			} catch (Exception e) {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
				e.printStackTrace();
			}			
		}else {
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("invalid parameter");
		}
		return serviceStatus;
	}
	
	
@RequestMapping(value="/executeAndUpdateAuditCompositeScoresFromIRCSV/{legalEntityCode}/{auditId}/{userType}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus executeAndUpdateAuditCompositeScoresFromIRCSV(
		@PathVariable("legalEntityCode") Integer legalEntityCode,
		@PathVariable("auditId")String auditId,
		@PathVariable("userType")String userType){
		ServiceStatus serviceStatus = new ServiceStatus();
		logger.info("Inside executeAndUpdateAuditCompositeScoresFromIRCSV .... ");
		try{
			if(auditId!=null ){
				auditRatingCompositeService.executeAndUpdateAuditCompositeScoresFromIRCSV(legalEntityCode, auditId, userType); 
				serviceStatus.setStatus("success");
				serviceStatus.setMessage("successfully updated");
			}else {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("No data tobe save...");
			}
					
		}catch (Exception e) {
			e.printStackTrace();
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure"+e.getMessage());
			if(e instanceof org.springframework.dao.DataIntegrityViolationException) {
				serviceStatus.setMessage("DATAINTGRTY_VIOLATION");
			}
		}
		return serviceStatus;
	}
	
	
@RequestMapping(value="/fetchAndUpdateAuditCompositeScoresFromSupervisoryRating/{legalEntityCode}/{auditId}/{userType}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus fetchAndUpdateAuditCompositeScoresFromSupervisoryRating(
		@PathVariable("legalEntityCode") Integer legalEntityCode,
		@PathVariable("auditId")String auditId,
		@PathVariable("userType")String userType){
		ServiceStatus serviceStatus = new ServiceStatus();
		logger.info("Inside fetchAndUpdateAuditCompositeScoresFromSupervisoryRating .... "+auditId);
		try{
				if(auditId!=null ){
					auditRatingCompositeService.fetchAndUpdateAuditCompositeScoresFromSupervisoryRating(legalEntityCode, auditId, userType); 
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfully created");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("No data tobe save...");
				}
			//}			
		}catch (Exception e) {
			e.printStackTrace();
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure"+e.getMessage());
			if(e instanceof org.springframework.dao.DataIntegrityViolationException) {
				serviceStatus.setMessage("DATAINTGRTY_VIOLATION");
			}
		}
		return serviceStatus;
	}
	
	// Updating Composite Score
	
@RequestMapping(value="/updateAuditRatingCompositeScores/{legalEntityCode}/{auditId}/{userType}",method=RequestMethod.PUT,produces=MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus updateAuditRatingCompositeScores(@RequestBody List<AuditRatingCompositeScore> auditRatingCompositeScores,
			@PathVariable Integer legalEntityCode, @PathVariable String auditId, @PathVariable String userType){
		ServiceStatus serviceStatus = new ServiceStatus();
		logger.info("Inside updateAuditRatingCompositeScores .... ");
		try{
				if(auditRatingCompositeScores!=null && auditRatingCompositeScores.size()>0){
					auditRatingCompositeService.updateAuditRatingCompositeScores(auditRatingCompositeScores, legalEntityCode, auditId, userType); 
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfully created");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("No data tobe save...");
				}
			//}			
		}catch (Exception e) {
			e.printStackTrace();
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure"+e.getMessage());
			if(e instanceof org.springframework.dao.DataIntegrityViolationException) {
				serviceStatus.setMessage("DATAINTGRTY_VIOLATION");
			}
		}
		return serviceStatus;
	}
	
	// Updating Composite Category Score
	
@RequestMapping(value="/updateAuditRatingCompositeCategoryScores/{legalEntityCode}/{auditId}/{userType}",method=RequestMethod.PUT,produces=MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus updateAuditRatingCompositeCategoryScores(@RequestBody List<AuditRatingCompositeCategoryScore> auditRatingCompositeCategoryScores,
			@PathVariable Integer legalEntityCode, @PathVariable String auditId, @PathVariable String userType){
		ServiceStatus serviceStatus = new ServiceStatus();
		logger.info("Inside updateAuditRatingCompositeCategoryScores .... ");
		try{
				if(auditRatingCompositeCategoryScores!=null && auditRatingCompositeCategoryScores.size()>0){
					auditRatingCompositeService.updateAuditRatingCompositeCategoryScores(auditRatingCompositeCategoryScores, legalEntityCode, auditId, userType); 
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfully created");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("No data tobe save...");
				}
			//}			
		}catch (Exception e) {
			e.printStackTrace();
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure"+e.getMessage());
			if(e instanceof org.springframework.dao.DataIntegrityViolationException) {
				serviceStatus.setMessage("DATAINTGRTY_VIOLATION");
			}
		}
		return serviceStatus;
	}
		
	// Updating CompositeOverlay
	
@RequestMapping(value="/updateAuditRatingCompositeOverlay/{legalEntityCode}/{auditId}/{userType}",method=RequestMethod.PUT,produces=MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus updateAuditRatingCompositeOverlay(@RequestBody List<AuditRatingCompositeOverlay> auditRatingCompositeOverlays,
			@PathVariable Integer legalEntityCode, @PathVariable String auditId, @PathVariable String userType){
		ServiceStatus serviceStatus = new ServiceStatus();
		logger.info("Inside updateAuditParamScores .... ");
		try{
				if(auditRatingCompositeOverlays!=null && auditRatingCompositeOverlays.size()>0){
					auditRatingCompositeService.updateAuditRatingCompositeOverlay(auditRatingCompositeOverlays, legalEntityCode, auditId,null, userType); 
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfully created");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("No data tobe save...");
				}
			//}			
		}catch (Exception e) {
			e.printStackTrace();
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure"+e.getMessage());
			if(e instanceof org.springframework.dao.DataIntegrityViolationException) {
				serviceStatus.setMessage("DATAINTGRTY_VIOLATION");
			}
		}
		return serviceStatus;
	}
	
	
@RequestMapping(value="/getCompositeCategoryScoreByAuditId/{legalEntityCode}/{auditId}/{auditTypeCode}/{userType}/{userId}/{compRatingStatus}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getCompositeCategoryScoreByAuditId(
			@PathVariable("legalEntityCode") Integer legalEntityCode,
			@PathVariable("auditId")String auditId,
			@PathVariable("auditTypeCode") String auditTypeCode,
			@PathVariable("userType")String userType,
			@PathVariable("userId")String userId,
			@PathVariable("compRatingStatus")String compRatingStatus){
		ServiceStatus serviceStatus=new ServiceStatus();
		
		if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId)){
			try {
				List<AuditRatingCompositeCategoryScore> auditCmpLst=auditRatingCompositeService.getCompositeCategoryScoreByAuditId(legalEntityCode,auditId,auditTypeCode, userType,compRatingStatus); 
				if(auditCmpLst!=null){
					serviceStatus.setResult(auditCmpLst);
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfuly retrieved ");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("ids not found");
				}				
			} catch (Exception e) {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
				e.printStackTrace();
			}
			
		}else {
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("invalid parameter");
		}
				return serviceStatus;
	}
	
	
@RequestMapping(value="/getAuditRatingCompositeOverlayByAuditId/{legalEntityCode}/{auditId}/{auditTypeCode}/{userType}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getAuditRatingCompositeOverlayByAuditId(
				@PathVariable("legalEntityCode") Integer legalEntityCode,
				@PathVariable("auditId")String auditId,
				@PathVariable("auditTypeCode") String auditTypeCode,
				@PathVariable("userType")String userType){
			ServiceStatus serviceStatus=new ServiceStatus();
			
			if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId)){
				try {
					List<AuditRatingCompositeOverlay> cmpOvrlyLst=auditRatingCompositeService.getAuditRatingCompositeOverlayByAuditId(legalEntityCode,auditId,auditTypeCode, userType); 
					if(cmpOvrlyLst!=null){
						serviceStatus.setResult(cmpOvrlyLst);
						serviceStatus.setStatus("success");
						serviceStatus.setMessage("successfuly retrieved ");
					}else {
						serviceStatus.setStatus("failure");
						serviceStatus.setMessage("ids not found");
					}				
				} catch (Exception e) {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("failure");
					e.printStackTrace();
				}
				
			}else {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("invalid parameter");
			}
			return serviceStatus;
	}
	
	
@RequestMapping(value="/getAuditRatingCompositeEscalationMatrixByAuditId/{legalEntityCode}/{auditId}/{auditTypeCode}/{userType}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getAuditRatingCompositeEscalationMatrixByAuditId(
				@PathVariable("legalEntityCode") Integer legalEntityCode,
				@PathVariable("auditId")String auditId,
				@PathVariable("auditTypeCode") String auditTypeCode,
				@PathVariable("userType")String userType){
			ServiceStatus serviceStatus=new ServiceStatus();
			
			if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId)){
				try {
					/*List<AuditRatingCompositeOverlay> cmpOvrlyLst=auditRatingCompositeService.getAuditRatingCompositeEscalationMatrixByAuditId(legalEntityCode,auditId,auditTypeCode, userType); 
					if(cmpOvrlyLst!=null){
						serviceStatus.setResult(cmpOvrlyLst);
						serviceStatus.setStatus("success");
						serviceStatus.setMessage("successfuly retrieved ");
					}else {
						serviceStatus.setStatus("failure");
						serviceStatus.setMessage("ids not found");
					}*/		
				} catch (Exception e) {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("failure");
					e.printStackTrace();
				}
				
			}else {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("invalid parameter");
			}
			return serviceStatus;
		}
	
	
@RequestMapping(value="/getCompositeCategoryScoreEscalationMtrxByAuditId/{legalEntityCode}/{auditId}/{auditTypeCode}/{userType}/{compRatingStatus}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getCompositeCategoryScoreEscalationMtrxByAuditId(
				@PathVariable("legalEntityCode") Integer legalEntityCode,
				@PathVariable("auditId")String auditId,
				@PathVariable("auditTypeCode") String auditTypeCode,
				@PathVariable("userType")String userType,
				@PathVariable("compRatingStatus")String compRatingStatus){
			ServiceStatus serviceStatus=new ServiceStatus();
			
			if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId)){
				try {
					AuditRatingCompositeScoreDto cmpCatEscMtrxScrLst=auditRatingCompositeService.getCompositeCategoryScoreEscalationMtrxByAuditId(legalEntityCode,auditId,auditTypeCode, userType,compRatingStatus); 
					if(cmpCatEscMtrxScrLst!=null){
						serviceStatus.setResult(cmpCatEscMtrxScrLst);
						serviceStatus.setStatus("success");
						serviceStatus.setMessage("successfuly retrieved ");
					}else {
						serviceStatus.setStatus("failure");
						serviceStatus.setMessage("ids not found");
					}	
				} catch (Exception e) {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("failure");
					e.printStackTrace();
				}
				
			}else {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("invalid parameter");
			}
			return serviceStatus;
		}
	
	
	// Updating CompositeOverlay
	
@RequestMapping(value="/updateAuditRatingScores/{legalEntityCode}/{auditId}/{userId}/{userType}",method=RequestMethod.PUT,produces=MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus updateAuditRatingScores(@RequestBody AuditRatingScoreDto auditRatingScoreDto,
			@PathVariable Integer legalEntityCode, @PathVariable String auditId, @PathVariable String userId, @PathVariable String userType){
		ServiceStatus serviceStatus = new ServiceStatus();
		logger.info("Inside updateAuditParamScores .... ");
		try{
				if(auditRatingScoreDto!=null ){
					auditRatingCompositeService.updateAuditRatingScores(auditRatingScoreDto, legalEntityCode, auditId,userId, userType); 
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfully created");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("No data tobe save...");
				}
			//}			
		}catch (Exception e) {
			e.printStackTrace();
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("failure"+e.getMessage());
			if(e instanceof org.springframework.dao.DataIntegrityViolationException) {
				serviceStatus.setMessage("DATAINTGRTY_VIOLATION");
			}
		}
		return serviceStatus;
	}
	
	// Verify whether IR finalized and Supervisory rating authorized before Authorising the Composite Rating
	
@RequestMapping(value="/verifyIRFinalisedAndSupervisoryRatingSubmitted/{legalEntityCode}/{auditTypeCode}/{auditId}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus verifyIRFinalisedAndSupervisoryRatingSubmitted(
			@PathVariable("legalEntityCode") Integer legalEntityCode,
			@PathVariable("auditTypeCode") String auditTypeCode,
			@PathVariable("auditId")String auditId){
		ServiceStatus serviceStatus=new ServiceStatus();
		
		if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId)){
			try {
				String verifySubmission=auditRatingCompositeService.verifyIRFinalisedAndSupervisoryRatingSubmitted(legalEntityCode,auditTypeCode,auditId); 
				if("YES".equals(verifySubmission)){
					serviceStatus.setResult(verifySubmission);
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("IR finalised and Supervisory rating submitted");
				}else if("IRNO".equals(verifySubmission)){
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("Please finalise the IR before authorising the Composite rating");
				}else if("SRNO".equals(verifySubmission)){
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("Please submit the Supervisory rating  before authorising the Composite rating");
				}				
			} catch (Exception e) {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
				e.printStackTrace();
			}			
		}else {
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("invalid parameter");
		}
				return serviceStatus;
	}
	
	/*
@RequestMapping(value="/insertAuditComplianceObsScore/{legalEntityCode}/{auditId}/{unitId}/{auditTypeCode}/{userId}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus insertAuditComplianceObsScore(
			@PathVariable("legalEntityCode") Integer legalEntityCode,
			@PathVariable("auditId")String auditId,
			@PathVariable("unitId")String unitId,
			@PathVariable("auditTypeCode")String auditTypeCode,
			@PathVariable("userId")String userId){
		ServiceStatus serviceStatus=new ServiceStatus();
		
		if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId) && !BankAuditUtil.isEmptyString(unitId) && !BankAuditUtil.isEmptyString(auditTypeCode)){
			try {
				List<AuditRatingComplianceObsScore> auditParamScrLst=auditRatingComplianceScoreService.insertAuditComplianceObsScore(legalEntityCode,auditId,unitId,auditTypeCode,userId); 
				if(auditParamScrLst!=null){
					serviceStatus.setResult(auditParamScrLst);
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfuly retrieved ");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("Insertion failure");
				}				
			} catch (Exception e) {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
				e.printStackTrace();
			}			
		}else {
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("invalid parameter");
		}
		return serviceStatus;
	}
	
	
	
	
	
	
	
@RequestMapping(value="/getAuditRatingComplObsScore/{legalEntityCode}/{auditId}/{ratingType}/{userType}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getAuditRatingComplianceScores(
			@PathVariable("legalEntityCode") Integer legalEntityCode,
			@PathVariable("auditId")String auditId,
			@PathVariable("ratingType") String ratingType,
			@PathVariable("userType") String userType){
		ServiceStatus serviceStatus=new ServiceStatus();
		
		if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId)){
			try {
				AuditRatingComplianceScoreDto auditRatingCompScores=auditRatingComplianceScoreService.getAuditRatingComplianceScores(legalEntityCode,auditId,ratingType,userType); 
				if(auditRatingCompScores!=null){
					serviceStatus.setResult(auditRatingCompScores);
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfuly retrieved ");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("ids not found");
				}				
			} catch (Exception e) {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
				e.printStackTrace();
			}			
		}else {
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("invalid parameter");
		}
		return serviceStatus;
	}
	
	
@RequestMapping(value="/getComplianceObsScoreReportByAuditId/{legalEntityCode}/{auditId}/{userType}/{compRatingStatus}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getComplianceObsScoreReportByAuditId(
			@PathVariable("legalEntityCode") Integer legalEntityCode,
			@PathVariable("auditId")String auditId,
			@PathVariable("userType")String userType,
			@PathVariable("compRatingStatus")String compRatingStatus){
		ServiceStatus serviceStatus=new ServiceStatus();
		
		if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId)){
			try {
				List<AuditRatingComplianceObsScore> auditCompObsLst=auditRatingComplianceScoreService.getComplianceObsScoreReportByAuditId(legalEntityCode,auditId,userType,compRatingStatus); 
				
				if(auditCompObsLst!=null){
					serviceStatus.setResult(auditCompObsLst);
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfuly retrieved ");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("ids not found");
				}
				
			} catch (Exception e) {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
				e.printStackTrace();
			}
			
		}else {
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("invalid parameter");
		}
				return serviceStatus;
	}
	
	// Report for individual Rating based on Desk or Field
	
@RequestMapping(value="/getComplianceObsScoreReportByAuditIdAndRatingType/{legalEntityCode}/{auditId}/{ratingType}/{userType}/{compRatingStatus}/{recordsWithNA}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
	ServiceStatus getComplianceObsScoreReportByAuditIdAndRatingType(
			@PathVariable("legalEntityCode") Integer legalEntityCode,
			@PathVariable("auditId")String auditId,
			@PathVariable("ratingType") String ratingType,
			@PathVariable("userType")String userType,
			@PathVariable("compRatingStatus")String compRatingStatus,
			@PathVariable(value="recordsWithNA",required=false)  String recordsNA){ // recordsWithNA=Y -> scores with NA  && recordsWithNA=N -> scores with out NA 
		ServiceStatus serviceStatus=new ServiceStatus();
		
		if(legalEntityCode!=null && !BankAuditUtil.isEmptyString(auditId)){
			try {
				AuditRatingComplianceObsScoreReportDto auditCompObsDto=auditRatingComplianceScoreService.getComplianceObsScoreReportByAuditIdAndRatingType(legalEntityCode,auditId,ratingType, userType,compRatingStatus, recordsNA); 
				
				if(auditCompObsDto!=null){
					serviceStatus.setResult(auditCompObsDto);
					serviceStatus.setStatus("success");
					serviceStatus.setMessage("successfuly retrieved ");
				}else {
					serviceStatus.setStatus("failure");
					serviceStatus.setMessage("ids not found");
				}
				
			} catch (Exception e) {
				serviceStatus.setStatus("failure");
				serviceStatus.setMessage("failure");
				e.printStackTrace();
			}
			
		}else {
			serviceStatus.setStatus("failure");
			serviceStatus.setMessage("invalid parameter");
		}
				return serviceStatus;
	}
	*/
	
}
