Commit 46e159d8 authored by msinkar's avatar msinkar

Adding the serdia dashboard component for assessment & coaching

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@187041 ce508802-f39f-4f6c-b175-0d175dae99d5
parent d023a805
package ibase.dashboard.sfa.ejb;
import ibase.system.config.ConnDriver;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.ejb.Stateless;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@Stateless
public class AssessMentEJB extends ValidatorEJB implements AssessMentEJBLocal,AssessMentEJBRemote
{
public AssessMentEJB()
{
}
// Added by mrunalini sinkar For AssessMent report for serdia Client 25-06-2018(start)
@Override
public String getAssessmentData(String loginCode, String dataSourceName, String fromDate, String toDate, String teamArgs ,String surveyId,String profileId) throws RemoteException,ITMException
{
JSONArray returnJsonArr = new JSONArray();
System.out.println("In AssessMentEJB loginCode["+loginCode+"] dataSourceName["+dataSourceName+"] fromDateStr["+fromDate+"] toDateStr["+toDate+"] teamArgs["+teamArgs+"] surveyId["+surveyId+"]");
Connection mConnection = null;
PreparedStatement mStatement = null;
ResultSet mResultSet = null;
ConnDriver connDriver = new ConnDriver();
E12GenericUtility e12genericUtil = new E12GenericUtility();
try
{
SimpleDateFormat dateFormat = new SimpleDateFormat(e12genericUtil.getApplDateFormat());
Date date = new Date();
if( "".equals( E12GenericUtility.checkNull(fromDate) ) )
{
fromDate = dateFormat.format(date);
System.out.println("fromDateStr:::["+fromDate+"]");
}
if( "".equals( E12GenericUtility.checkNull(toDate) ) )
{
toDate = dateFormat.format(date);
System.out.println("toDateStr:::["+toDate+"]");
}
if(mConnection == null)
{
mConnection = connDriver.getConnectDB( dataSourceName );
}
fromDate = e12genericUtil.getValidDateString(fromDate, e12genericUtil.getApplDateFormat(), e12genericUtil.getDBDateFormat());
toDate = e12genericUtil.getValidDateString(toDate, e12genericUtil.getApplDateFormat(), e12genericUtil.getDBDateFormat());
System.out.println("fromDateStr["+fromDate+"] toDateStr["+toDate+"]");
String query = ""; //$NON-NLS-1$
query=
"SELECT "+
"(CASE WHEN ee.emp_code IS NULL THEN 'VACANT' ELSE ee.emp_code END) as regional_manager_code, "+
"(CASE WHEN ee.emp_fname +' '+ ee.emp_lname IS NULL THEN 'VACANT' ELSE ee.emp_fname +' '+ ee.emp_lname END) as regional_manager, "+
"r.user_id as assessor_code, "+
"e.emp_fname +' '+ e.emp_lname as assessor_name, "+
"RP.ENTITY_CODE as assessee_code, "+
"RP.ENTITY_DESCR assessee_name, "+
"m.descr survey_code_descr, "+
"m.result_range_max, "+
"r.submit_date, "+
"r.tran_id, "+
"(SELECT SUM(m2.result_range_max) FROM SURVEY_MASTER M2,survey_result_det rd2 WHERE m2.survey_code=rd2.survey_code and rd2.tran_id=r.tran_id) as result_range_max_total, "+
"rd.result, "+
"( "+
"SELECT "+
"SUM( "+
"CASE "+
"WHEN "+
"( "+
"( "+
"RESULT NOT LIKE '%[A-Z]%' "+
") "+
"OR "+
"( "+
"RESULT NOT LIKE '%[a-z]%' "+
") "+
") "+
"THEN CAST(rd1.result AS DECIMAL(18,1)) "+
"ELSE 0 "+
"END) AS result "+
"FROM "+
"survey_result_det rd1 "+
"WHERE "+
"rd1.tran_id = r.tran_id "+
") "+
"total_result "+
"FROM "+
"SURVEY_FORM F, "+
"SURVEY_result r, "+
"survey_template t, "+
"survey_templ_det td, "+
"SURVEY_result_det rd "+
"LEFT OUTER JOIN survey_master m "+
"ON "+
"rd.survey_code = m.survey_code, "+
"SURVEY_result_appl rp, "+
"survey_config config, "+
"users u left outer join employee e on u.emp_code=e.emp_code left outer join employee ee on e.report_to=ee.emp_code "+
"WHERE "+
"r.user_id = u.code "+
"and f.tran_id = r.tran_id__form "+
"AND r.tran_id = rd.tran_id "+
"AND r.tran_id = rp.tran_id "+
"AND t.survey_templ = td.survey_templ "+
"AND td.survey_code = rd.survey_code "+
"AND config.survey_id = f.survey_id "+
"AND config.survey_templ = t.survey_templ "+
"AND rp.entity_code IN "+getFormattedUserId(teamArgs)+" "+
"AND f.survey_id = '"+surveyId+"' " +
"AND m.result_type!='T' "+
"AND r.submit_date BETWEEN ? AND ? ";
mStatement = mConnection.prepareStatement(query);
mStatement.setDate(1, java.sql.Date.valueOf(fromDate) );
mStatement.setDate(2, java.sql.Date.valueOf(toDate) );
mResultSet = mStatement.executeQuery();
while(mResultSet.next())
{
JSONObject rowDataVar = new JSONObject();
rowDataVar.put("REGIONAL_MANAGER_CODE", E12GenericUtility.checkNull(mResultSet.getString("regional_manager_code")));
rowDataVar.put("REGIONAL_MANAGER", E12GenericUtility.checkNull(mResultSet.getString("regional_manager")));
rowDataVar.put("ASSESSOR_CODE", E12GenericUtility.checkNull(mResultSet.getString("assessor_code")));
rowDataVar.put("ASSESSOR_NAME", E12GenericUtility.checkNull(mResultSet.getString("assessor_name")));
rowDataVar.put("ASSESSEE_CODE", E12GenericUtility.checkNull(mResultSet.getString("assessee_code")));
rowDataVar.put("ASSESSEE_NAME", E12GenericUtility.checkNull(mResultSet.getString("assessee_name")));
rowDataVar.put("SURVEY_CODE_DESCR", E12GenericUtility.checkNull(mResultSet.getString("survey_code_descr")));
rowDataVar.put("RESULT_RANGE_MAX", E12GenericUtility.checkNull(mResultSet.getString("result_range_max")));
rowDataVar.put("SUBMIT_DATE", e12genericUtil.getValidDateString( E12GenericUtility.checkNull(mResultSet.getDate("submit_date").toString()), e12genericUtil.getDBDateFormat(), e12genericUtil.getApplDateFormat()) );
rowDataVar.put("TRAN_ID", E12GenericUtility.checkNull(mResultSet.getString("tran_id")));
rowDataVar.put("RESULT_RANGE_MAX_TOTAL", E12GenericUtility.checkNull(mResultSet.getString("result_range_max_total")));
rowDataVar.put("RESULT", E12GenericUtility.checkNull(mResultSet.getString("result")));
rowDataVar.put("TOTAL_RESULT", E12GenericUtility.checkNull(mResultSet.getString("total_result")));
returnJsonArr.add(rowDataVar);
System.out.println("returnJsonArr is:["+returnJsonArr+"]");
}
if(mStatement!=null)
{
mStatement.close();
mStatement=null;
}
if(mResultSet!=null)
{
mResultSet.close();
mResultSet = null;
}
if(mConnection!= null && !mConnection.isClosed())
{
mConnection.close();
mConnection = null;
}
}
catch ( Exception e)
{
System.out.println("Exception in AssessMentEJB.getAssessmentData():["+e.getMessage()+"]");
e.printStackTrace();
JSONObject errMsgJson = new JSONObject();
errMsgJson.put("result", getResponseMessage("No Data Found ! ","Failure") );
return errMsgJson.toString();
//throw new ITMException(e);
}
finally
{
try
{
if(mStatement!=null)
{
mStatement.close();
mStatement=null;
}
if(mResultSet!=null)
{
mResultSet.close();
mResultSet = null;
}
if(mConnection!= null && !mConnection.isClosed())
{
mConnection.close();
mConnection = null;
}
}
catch(SQLException se)
{
System.out.println("HealthCareEJB.getHealthCareData.finally["+se.getMessage()+"]");
se.printStackTrace();
JSONObject errMsgJson = new JSONObject();
errMsgJson.put("result", getResponseMessage("No Data Found ! ","Failure") );
return errMsgJson.toString();
}
}
System.out.println("returnJsonArr:::["+returnJsonArr+"]");
return returnJsonArr.toString();
}
// Added by mrunalini sinkar For AssessMent report for serdia Client 25-06-2018(end)
public static String getFormattedUserId( String userId )
{
StringBuffer userIdSql = new StringBuffer();
try
{
System.out.println("@@@ getFormattedProfileId userId:::["+userId+"]");
if( userId.contains(",") )
{
userIdSql.append("(");
String[] pArr = userId.split(",");
for( int i = 0; i < pArr.length; i++ )
{
if( i == pArr.length - 1 )
{
userIdSql.append("'"+pArr[i]+"'");
}
else
{
userIdSql.append("'"+pArr[i]+"',");
}
}
userIdSql.append(")");
}
else
{
userIdSql.append("('"+userId+"')");
}
System.out.println("@@@ getFormattedProfileId profileIdSql:::["+userIdSql.toString()+"]");
}
catch( Exception e )
{
System.out.println("Exception : [E12GenericUtility][getFormattedProfileId] :==>\n"+e.getMessage());
e.printStackTrace();
}
return userIdSql.toString();
}
private JSONObject getResponseMessage(String successResponse, String status)
{
JSONObject respMessage = new JSONObject();
try
{
respMessage.put("message", successResponse);
respMessage.put("status", status);
}
catch (Exception e)
{
e.printStackTrace();
}
return respMessage;
}
}
package ibase.dashboard.sfa.ejb;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface AssessMentEJBLocal extends ValidatorLocal
{
public String getAssessmentData(String loginCode, String dataSourceName, String fromDate, String toDate, String teamArgs ,String surveyId,String profileId) throws RemoteException,ITMException;
}
package ibase.dashboard.sfa.ejb;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Remote
public interface AssessMentEJBRemote extends ValidatorRemote
{
public String getAssessmentData(String loginCode, String dataSourceName, String fromDate, String toDate, String teamArgs ,String surveyId,String profileId) throws RemoteException,ITMException;
}
package ibase.dashboard.sfa.ejb;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Local;
@Local
public interface CoachingSummaryEJBLocal extends ValidatorLocal
{
public String getCoachingData(String loginCode, String dataSourceName, String fromDate, String toDate, String teamArgs ,String surveyId,String profileId) throws RemoteException,ITMException;
}
package ibase.dashboard.sfa.ejb;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import javax.ejb.Remote;
@Remote
public interface CoachingSummaryEJBRemote extends ValidatorRemote
{
public String getCoachingData(String loginCode, String dataSourceName, String fromDate, String toDate, String teamArgs ,String surveyId,String profileId) throws RemoteException,ITMException;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment