Commit d241e1a0 authored by kpandey's avatar kpandey

Created new Dao for saving and getting explore report in explore component

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@196137 ce508802-f39f-4f6c-b175-0d175dae99d5
parent da375d96
package ibase.dashboard.common.hibernate.dao;
import java.util.Date;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.query.Query;
import ibase.dashboard.common.hibernate.bean.ObjUserPref;
import ibase.hibernate.utility.HibernateUtil;
import ibase.utility.BaseLogger;
public class ObjUserPrefDao {
//Added by Kamal.P To saveExplore Report on click of save button on Explore Component START
public ObjUserPref saveExploreReport(String loginCode, String reportName, String reportConfig, String tranDB)
{
System.out.println("in save explore report");
ObjUserPref objUserPrefDoc = null;
try
{
System.out.println("inside try of save explore report");
Session session = HibernateUtil.getSessionFactory(tranDB).openSession();
objUserPrefDoc = getExploreReport(loginCode,reportName,tranDB);
System.out.println("userPrefSoc value from getExploreReport"+objUserPrefDoc);
Transaction tx = session.beginTransaction();
if( objUserPrefDoc == null )
{
System.out.println("if userPrefDoc is null");
objUserPrefDoc = new ObjUserPref();
objUserPrefDoc.setUserId(loginCode);
objUserPrefDoc.setObjName(reportName);
objUserPrefDoc.setAddDate(new Date());
objUserPrefDoc.setAddUser(loginCode);
objUserPrefDoc.setAddTerm(loginCode);
System.out.println("inside if userPrefData is null==>"+objUserPrefDoc);
}
objUserPrefDoc.setPrefName("EXP_RPT_PREF");
objUserPrefDoc.setPrefValue(reportConfig);
objUserPrefDoc.setPrefValueType("JSON");
objUserPrefDoc.setChgDate(new Date());
objUserPrefDoc.setChgUser(loginCode);
objUserPrefDoc.setChgTerm(loginCode);
System.out.println("userPrefData==>"+objUserPrefDoc);
session.saveOrUpdate(objUserPrefDoc);
session.flush();
tx.commit();
session.close();
}
catch (HibernateException e)
{
BaseLogger.log("0",null,null,"HibernateException inside insert in UserPref:");
BaseLogger.log("0",null,null,e.getMessage());
System.out.println("exception in hibernate for saveExploreReport"+e.getMessage());
}
catch (Exception e)
{
BaseLogger.log("0",null,null,"Exception inside insert in UserPref:");
BaseLogger.log("0",null,null,e.getMessage());
System.out.println("exception for hibernate for saveExploreReport"+e.getMessage());
}
return objUserPrefDoc;
}
//Added by Kamal.P To saveExplore Report on click of save button on Explore Component END
//Added by Kamal.P To Get ExploreReport which was saved previously on Explore Component START
public ObjUserPref getExploreReport(String loginCode, String reportName, String tranDB)
{
System.out.println("in get explore report");
ObjUserPref userPrefDoc = null;
try
{
Session session = HibernateUtil.getSessionFactory(tranDB).openSession();
// 2. Create Query
Query query = session.createQuery("from ObjUserPref where userId='"+loginCode+"' and objName='"+reportName+"'");
List<ObjUserPref> userPrefList = query.getResultList();
System.out.println("data for geting explore userPrefList"+userPrefList);
if(userPrefList.size() > 0)
{
userPrefDoc = userPrefList.get(0);
System.out.println("data for geting explore report data at util"+userPrefDoc);
}
}
catch (HibernateException e)
{
BaseLogger.log("0",null,null,"HibernateException :");
BaseLogger.log("0",null,null,e.getMessage());
System.out.println("exception for getExploreReprot"+e.getMessage());
}
return userPrefDoc;
}
//Added by Kamal.P To Get ExploreReport which was saved previously on Explore Component END
}
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