Example usage for org.hibernate Session load

List of usage examples for org.hibernate Session load

Introduction

In this page you can find the example usage for org.hibernate Session load.

Prototype

void load(Object object, Serializable id);

Source Link

Document

Read the persistent state associated with the given identifier into the given transient instance.

Usage

From source file:com.krawler.hrms.hrmsDashboard.java

License:Open Source License

public static StringBuilder getemployeeupdates(Session session, HttpServletRequest request,
        StringBuilder appendB) throws ServiceException {
    String result = "";
    String newleads = "";
    int goallimit = 5;
    List tabledata = null;/*from   w  w  w. j  av a 2s  .c o m*/
    int count = 0;
    String goaldate = "";
    int diff;
    String qry = "";
    String hql = "";
    Iterator ite = null;
    try {
        String empid = AuthHandler.getUserid(request);
        String companyid = AuthHandler.getCompanyid(request);
        String cmpsub = AuthHandler.getCmpSubscription(request);
        User user = (User) session.load(User.class, AuthHandler.getUserid(request));
        Date userdate = com.krawler.common.util.Timezone.toUserSystemTimezoneDate(session, request,
                fmt.format(new Date()), empid);
        //String qry = "from Appraisalmanagement where employee.userID=? and employeestatus=0 and (date(now()) between appcycle.submitstartdate and appcycle.submitenddate) order by appcycle.submitstartdate asc";
        if (PermissionHandler.isSubscribed(hrms_Modules.timesheet, cmpsub)) {
            DateFormat formatter = new SimpleDateFormat(AuthHandler.getDateFormat(request));
            Calendar cal = Calendar.getInstance();
            int weekday = cal.get(Calendar.DAY_OF_WEEK);
            cal.add(Calendar.DATE, -weekday + 1);
            Date sdate = cal.getTime();
            cal.add(Calendar.DATE, 6);
            Date edate = cal.getTime();

            String timesheet1 = "from Timesheet where datevalue between ? and ? and  userID.company.companyID=? and userID.userID=? group by approved";
            List timesheet = HibernateUtil.executeQuery(session, timesheet1,
                    new Object[] { sdate, edate, companyid, empid });
            Timesheet tmst = null;
            result = getContentDiv("pwndCommon hrmstimesheet");
            if (!timesheet.isEmpty()) {
                tmst = (Timesheet) timesheet.get(0);

                if (tmst.getApproved() == 0) {
                    result += "Your<a href='#' onclick='timesheet()'> Timesheet</a> from <font color='green'>"
                            + formatter.format(sdate) + "</font> to <font color='green'>"
                            + formatter.format(edate) + "</font> is <font color='green'>Pending</font> ";
                } else {
                    result += "Your Timesheet from <font color='green'>" + formatter.format(sdate)
                            + "</font> to <font color='green'>" + formatter.format(edate)
                            + "</font> has been <font color='green'>Approved</font> ";
                }
            } else {
                result += "Please,Fill<a href='#' onclick='timesheet()'> Timesheet  </a> from<font color='green'> "
                        + formatter.format(sdate) + "</font> to <font color='green'>" + formatter.format(edate)
                        + "</font>";
            }
            newleads += getContentSpan(result);
        }
        if (hrmsManager.isAppraiser(AuthHandler.getUserid(request), session, request)) {
            diff = 0;
            qry = "select distinct appm.appcycle from Appraisalmanagement appm where appm.manager.userID=? and appm.managerstatus=0 and ( appm.appcycle.submitstartdate<= ? and appm.appcycle.submitenddate>=? ) ";
            tabledata = HibernateUtil.executeQuery(session, qry,
                    new Object[] { AuthHandler.getUserid(request), userdate, userdate });
            ite = tabledata.iterator();
            while (ite.hasNext()) {
                Appraisalcycle app = (Appraisalcycle) ite.next();
                diff = (int) ((app.getSubmitenddate().getTime() - userdate.getTime()) / (1000 * 60 * 60 * 24))
                        + 1;
                result = getContentDiv("pwndHRMS hrmsappraisal");
                result += "Submit the <a href='#' onclick='competencyedit()'> appraisal form </a> for appraisal cycle "
                        + app.getCyclename() + " in <font color='green'> " + diff + "</font> day(s)";
                newleads += getContentSpan(result);
            }
        }
        if (PermissionHandler.isSubscribed(hrms_Modules.appraisal, cmpsub)
                && hrmsManager.checkModule("appraisal", session, request)) {
            qry = "select distinct appm.appcycle from Appraisalmanagement appm where appm.employee.userID=? and appm.employeestatus=0 and ( appm.appcycle.submitstartdate<=? and appm.appcycle.submitenddate>=? )";
            Object[] obj = { empid, userdate, userdate };
            tabledata = HibernateUtil.executeQuery(session, qry, obj);
            ite = tabledata.iterator();
            while (ite.hasNext()) {
                Appraisalcycle app = (Appraisalcycle) ite.next();
                diff = (int) ((app.getSubmitenddate().getTime() - userdate.getTime()) / (1000 * 60 * 60 * 24))
                        + 1;
                result = getContentDiv("pwndHRMS hrmsappraisal");
                result += "Fill the <a href='#' onclick='myAppraisal()'> appraisal form </a>in <font color='green'> "
                        + diff + "</font> day(s) for appraisal cycle " + app.getCyclename() + " initiated by "
                        + user.getCompany().getCreator().getFirstName() + " "
                        + user.getCompany().getCreator().getLastName();
                newleads += getContentSpan(result);
            }
            qry = "select distinct appm.appcycle, appm from Appraisalmanagement appm where appm.employee.userID=? and appm.reviewstatus=2";
            tabledata = HibernateUtil.executeQuery(session, qry,
                    new Object[] { AuthHandler.getUserid(request) });
            ite = tabledata.iterator();
            while (ite.hasNext()) {
                Object[] row = (Object[]) ite.next();
                Appraisalmanagement app = (Appraisalmanagement) row[1];
                if (app.getReviewersubmitdate() != null) {
                    diff = (int) ((userdate.getTime() - app.getReviewersubmitdate().getTime())
                            / (1000 * 60 * 60 * 24)) + 1;
                    if (diff < 10) {
                        result = getContentDiv("pwndHRMS hrmsappraisal");
                        result += "Your <a href='#' onclick='myfinalReport()'>appraisal</a> for appraisal cycle "
                                + app.getAppcycle().getCyclename() + " has been approved";
                        newleads += getContentSpan(result);
                    }
                }
            }
            //            if(hrmsHandler.isReviewer(session, request)){
            //                    diff=0;
            //                JSONObject commData=new JSONObject();
            //                    qry = "from Assignreviewer where reviewer.userID=?";
            //                    tabledata = HibernateUtil.executeQuery(session, qry, AuthHandler.getUserid(request));
            //                    ite = tabledata.iterator();
            //                    String users = "";
            //                    while (ite.hasNext()) {
            //                        Assignreviewer log = (Assignreviewer) ite.next();
            //                            users += "'" + log.getEmployee().getUserID() + "',";
            //                    }
            //                    if (users.length() > 0) {
            //                        users = users.substring(0, users.length() - 1);
            //                    }
            //                    qry = "from Appraisalmanagement appm where appm.employee.userID in (" + users + ") and appm.reviewstatus=0 and appm.managerstatus=1  and ( appm.appcycle.submitstartdate<=? and appm.appcycle.submitenddate>=? ) group by appm.appcycle,appm.employee.userID";
            //                    tabledata = HibernateUtil.executeQuery(session, qry, new Object[]{userdate,userdate});
            //                    ite = tabledata.iterator();
            //                    while (ite.hasNext()) {
            //                       //Object[] row = (Object[]) ite.next();
            //                       Appraisalmanagement app = (Appraisalmanagement) ite.next();
            //                       commData=hrmsManager.getAppraisalManagers(session,app.getEmployee().getUserID(),app.getAppcycle().getId(),commData);
            //                        if (Integer.parseInt(commData.getString("totalappraisal"))==Integer.parseInt(commData.getString("appraisalsubmitted"))) {
            //                            diff = (int) ((app.getAppcycle().getSubmitenddate().getTime() - userdate.getTime()) / (1000 * 60 * 60 * 24)) + 1;
            //                            result = getContentDiv("pwndHRMS hrmsappraisal");
            //                            result += "Review the <a href='#' onclick='reviewAppraisal()'> appraisal </a> for appraisal cycle " + app.getAppcycle().getCyclename() + " in <font color='green'> " + diff + "</font> day(s) for "+app.getEmployee().getFirstName()+" "+app.getEmployee().getLastName();
            //                        } else{
            //                            result = getContentDiv("pwndHRMS hrmsappraisal");
            //                            result += commData.getString("appraisalsubmitted")+" out of "+commData.getString("totalappraisal")+" appraiser(s) have submitted the appraisal form for appraisal cycle "+app.getAppcycle().getCyclename()+" for "+app.getEmployee().getFirstName()+" "+app.getEmployee().getLastName();
            //
            //                        }
            //                        newleads += getContentSpan(result);
            //                    }
            //                }

            hql = "from Finalgoalmanagement where userID.userID=? and userID.company.companyID=? and archivedflag=0 and deleted=? order by createdon desc";
            List goallst = HibernateUtil.executeQuery(session, hql, new Object[] { empid, companyid, false });
            int goalcnt = goallst.size();
            Finalgoalmanagement fgmt = null;
            if (!goallst.isEmpty()) {
                if (goalcnt < goallimit) {
                    for (int x = 0; x < goalcnt; x++) {
                        fgmt = (Finalgoalmanagement) goallst.get(x);
                        result = getContentDiv("pwndHRMS addgoal");
                        if (fgmt.getCreatedon() != null) {
                            goaldate = AuthHandler.getUserDateFormatter(request, session)
                                    .format(fgmt.getCreatedon());
                        } else {
                            goaldate = userdate.toString();
                        }
                        result += "<a href='#' onclick='myGoals()'>" + fgmt.getGoalname()
                                + "</a> goal assigned by<font color='green'> " + fgmt.getAssignedby()
                                + "</font> on <font color='green'>" + goaldate + "</font>";
                        newleads += getContentSpan(result);
                    }
                } else {
                    for (int x = 0; x < goallimit; x++) {
                        fgmt = (Finalgoalmanagement) goallst.get(x);
                        result = getContentDiv("pwndHRMS addgoal");
                        if (fgmt.getCreatedon() != null) {
                            goaldate = AuthHandler.getUserDateFormatter(request, session)
                                    .format(fgmt.getCreatedon());
                        } else {
                            goaldate = AuthHandler.getUserDateFormatter(request, session).format(userdate);
                        }
                        result += "<a href='#' onclick='myGoals()'>" + fgmt.getGoalname()
                                + "</a> goal assigned by<font color='green'> " + fgmt.getAssignedby()
                                + "</font> on <font color='green'>" + goaldate + "</font>";
                        newleads += getContentSpan(result);
                    }
                }

            }
        }

        if (PermissionHandler.isSubscribed(hrms_Modules.recruitment, cmpsub)
                && PermissionHandler.isManager(session, request)) {
            newleads += getDashboardjobUpdates(session, request);
        }
    } catch (Exception e) {
        throw ServiceException.FAILURE("hrmsDashboard.getemployeeupdates", e);
    } finally {
        appendB.append(newleads);
    }

    return appendB;
}

From source file:com.krawler.hrms.hrmsDashboard.java

License:Open Source License

public static StringBuilder checkGraphs(Session session, HttpServletRequest request)
        throws ServiceException, SessionExpiredException, JSONException {
    StringBuilder finalString = new StringBuilder();
    StringBuilder newGraph = new StringBuilder();
    String result = "";
    String year = null;/* w w  w.  j  a  v  a2s  .  c om*/
    try {
        String cmpsub = AuthHandler.getCmpSubscription(request);
        if (PermissionHandler.isSubscribed(hrms_Modules.appraisal, cmpsub)) {
            JSONObject jobj = hrmsDbcon.getPerformanceData(13);
            JSONArray jarr = jobj.getJSONArray("data");
            jarr = jobj.getJSONArray("data");
            for (int j = 0; j < Integer.parseInt(jobj.get("totalCount").toString()); j++) {
                String Jsondata = hrmsManager.getChart(jarr.getJSONObject(j).get("name").toString(), session,
                        request);
                JSONObject obj = new JSONObject(Jsondata);
                if (obj.getInt("Count") > 0) {
                    result += "true";
                }
            }
            if (result.contains("true")) {
                newGraph.append(
                        "<div id='SalaryPanelHader' style='margin-top:15px;'><font size='3px' align= 'center' color='black' ><b>Employee Appraisal Rating Distribution </b></font></div>");
                newGraph.append(
                        "<div id='WorkOrderMonthlyPanel' class='graphposition'><script>createNewChart('../../scripts/graph/krwcolumn/krwpie/krwpie.swf','krwpie', '100%', '40%', '8', '#FFFFFF', '../../scripts/graph/krwcolumn/examples/LeadsBySource/LeadsBySource_settings.xml','../../jspfiles/chardata.jsp?flag=1', 'WorkOrderMonthlyPanel')</script></div>");
            }
        }

        if (PermissionHandler.isSubscribed(hrms_Modules.payroll, cmpsub)) {
            JSONObject payobj = payrollManager.getAnnualExpense(year, request);
            JSONArray jarr1 = payobj.getJSONArray("success");
            if (StringUtil.equal(jarr1.getString(0).toString(), "true")) {
                KWLCurrency currency = (KWLCurrency) session.load(KWLCurrency.class,
                        AuthHandler.getCurrencyID(request));
                newGraph.append(
                        "<div id='SalaryPanelHader' style='margin-top:15px;'><font size='3px' align= 'center' color='black' ><b>Monthly Payroll Expenditure ("
                                + currency.getName() + ") </b></font></div>");
                newGraph.append(
                        "<div id='SalaryPanel' class='graphposition'><script>createNewChart('../../scripts/HRMSGraph/krwcolumn.swf','krwcolumn', '700px', '300px', '8', '#FFFFFF', '../../scripts/HRMSGraph/setting.xml','../../jspfiles/chardata.jsp?flag=2', 'SalaryPanel')</script></div>");
            } else {
                newGraph.append("");
            }
        }

    } catch (JSONException e) {
        throw ServiceException.FAILURE("hrmsDashboard.checkGraphs", e);
    } finally {
        finalString.append(newGraph);
    }
    return finalString;
}

From source file:com.krawler.hrms.hrmsHandler.java

License:Open Source License

public static JSONObject InternalJobpositions(Session session, HttpServletRequest request)
        throws ServiceException, ParseException, SessionExpiredException, JSONException {
    Date date;/*from   w  w w  .ja  va 2 s  .co  m*/
    SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yyyy");
    boolean checkflag = true;
    JSONObject jobj = new JSONObject();
    try {
        Company cmp = (Company) session.load(Company.class, AuthHandler.getCompanyid(request));
        CompanyPreferences cmpPref = (CompanyPreferences) session.load(CompanyPreferences.class,
                cmp.getCompanyID());
        String jobidformat = (cmpPref.getJobidformat() == null ? "" : cmpPref.getJobidformat());
        if (StringUtil.isNullOrEmpty(request.getParameter("posid"))) {
            String jobid = (request.getParameter("jobid")).substring(jobidformat.length());
            checkflag = checkJobs(request.getParameter("position"), request.getParameter("department"),
                    request.getParameter("jobtype"), session, request);
            if (checkflag) {
                Positionmain posmain = new Positionmain();
                MasterData md = (MasterData) session.load(MasterData.class, request.getParameter("position"));
                MasterData dept = (MasterData) session.load(MasterData.class,
                        request.getParameter("department"));
                User man = (User) session.load(User.class, request.getParameter("manager"));
                date = (Date) fmt.parse(request.getParameter("startdate"));
                posmain.setStartdate(date);
                date = (Date) fmt.parse(request.getParameter("enddate"));
                posmain.setEnddate(date);
                posmain.setPosition(md);
                posmain.setDetails(request.getParameter("details"));
                posmain.setJobtype(request.getParameter("jobtype"));
                posmain.setJobidwthformat(Integer.parseInt(jobid));
                posmain.setJobid(jobidformat + (Integer.parseInt(jobid)));
                posmain.setDelflag(0);
                posmain.setCompany(cmp);
                posmain.setManager(man);
                posmain.setDepartmentid(dept);
                posmain.setNoofpos(Integer.parseInt(request.getParameter("nopos")));
                posmain.setCreatedBy((User) session.get(User.class, AuthHandler.getUserid(request)));
                posmain.setPositionsfilled(0);
                session.save(posmain);
                jobj.put("message",
                        MessageSourceProxy.getMessage("hrms.hrmshandler.msg.jobpositionupdatedsuccessfully",
                                null, "Job position added successfully",
                                LocaleUtil.getCompanyLocale(AuthHandler.getCompanyid(request), 0)));
            } else {
                jobj.put("message",
                        MessageSourceProxy.getMessage("hrms.hrmshandler.msg.jobpositionalreadypresent", null,
                                "Job position already present",
                                LocaleUtil.getCompanyLocale(AuthHandler.getCompanyid(request), 0)));
            }
        } else {
            Positionmain posmain = (Positionmain) session.load(Positionmain.class,
                    request.getParameter("posid"));
            if (request.getParameter("details") != null) {
                posmain.setDetails(request.getParameter("details"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("manager"))) {
                posmain.setManager((User) session.load(User.class, request.getParameter("manager")));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("department"))) {
                posmain.setDepartmentid(
                        (MasterData) session.load(MasterData.class, request.getParameter("department")));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("startdate"))) {
                date = (Date) fmt.parse(request.getParameter("startdate"));
                posmain.setStartdate(date);
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("enddate"))) {
                date = (Date) fmt.parse(request.getParameter("enddate"));
                if (new Date(fmt.format(new Date())).after(date)) {
                    posmain.setDelflag(2);
                } else {
                    posmain.setDelflag(0);
                }
                posmain.setEnddate(date);
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("nopos"))) {
                if (posmain.getPositionsfilled() == Integer.parseInt(request.getParameter("nopos"))) {
                    posmain.setDelflag(3);
                }
                posmain.setNoofpos(Integer.parseInt(request.getParameter("nopos")));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("jobshift"))) {
                posmain.setJobshift(request.getParameter("jobshift"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("location"))) {
                posmain.setLocation(request.getParameter("location"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("relocation"))) {
                posmain.setRelocation(request.getParameter("relocation"));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("expmonth"))) {
                posmain.setExperiencemonth(Integer.parseInt(request.getParameter("expmonth")));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("expyear"))) {
                posmain.setExperienceyear(Integer.parseInt(request.getParameter("expyear")));
            }
            if (!StringUtil.isNullOrEmpty(request.getParameter("travel"))) {
                posmain.setTravel(request.getParameter("travel"));
            }
            session.update(posmain);
            jobj.put("message",
                    MessageSourceProxy.getMessage("hrms.hrmshandler.msg.jobpositionupdatedsuccessfully.", null,
                            "Job position updated successfully.",
                            LocaleUtil.getCompanyLocale(AuthHandler.getCompanyid(request), 0)));
        }
        //@@ProfileHandler.insertAuditLog(session,
        //                    ("Internal".equals(request.getParameter("jobtype")) ? AuditAction.INTERNAL_JOB_ADDED : AuditAction.EXTERNAL_JOB_ADDED),
        //                    "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has added " + request.getParameter("jobtype") + " job", request);
    } catch (ServiceException ex) {
        throw ServiceException.FAILURE("InternalJobpositions", ex);
    } catch (ParseException ex) {
        throw ServiceException.FAILURE("InternalJobpositions", ex);
    } catch (SessionExpiredException ex) {
        throw ServiceException.FAILURE("InternalJobpositions", ex);
    } catch (JSONException ex) {
        throw new JSONException("InternalJobpositions");
    } finally {
    }
    return jobj;
}

From source file:com.krawler.hrms.hrmsHandler.java

License:Open Source License

public static void addMasterField(Session session, HttpServletRequest request) throws ServiceException {
    int goalid = 0;
    try {//from w  ww . j  a  v a2  s  .c  o  m
        if (request.getParameter("action").equals("Add")) {
            Master gmst = new Master();
            Company cmp = (Company) session.load(Company.class, AuthHandler.getCompanyid(request));
            gmst.setName(request.getParameter("name"));
            // gmst.setCompany(cmp);
            session.save(gmst);
        } else {
            goalid = Integer.parseInt(request.getParameter("id"));
            Master gmst = (Master) session.load(Master.class, goalid);
            gmst.setName(request.getParameter("name"));
            session.save(gmst);
        }
    } catch (Exception ex) {
        throw ServiceException.FAILURE("hrmsHandler.addMasterField", ex);
    } finally {
    }

}

From source file:com.krawler.hrms.hrmsHandler.java

License:Open Source License

public static String insertTimeSheet(Session session, HttpServletRequest request) throws ServiceException {
    JSONObject msg = new JSONObject();
    int approved = 0;
    String apprmanager = "";
    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
    try {/*from ww  w . j  a  va 2s.c o  m*/
        msg.put("msg", "No data to change");
        User usr = null;
        if (StringUtil.isNullOrEmpty(request.getParameter("empid"))) {
            String empid = AuthHandler.getUserid(request);
            usr = (User) session.load(User.class, empid);
        } else {
            usr = (User) session.load(User.class, request.getParameter("empid"));
        }

        String jsondata = request.getParameter("jsondata");
        JSONArray jarr = new JSONArray("[" + jsondata + "]");
        String[] dateA = request.getParameterValues("colHeader");
        ArrayList timesheetIDs = new ArrayList();
        timesheetIDs.add(AuthHandler.getUserid(request));
        String marks = "";

        for (int i = 0; i < jarr.length(); i++) {
            JSONObject jobj = jarr.getJSONObject(i);
            for (int j = 1; j <= 7; j++) {
                String[] time = jobj.getString("col" + j).split(":");
                Date dateValue = fmt.parse(dateA[j - 1]);
                String jobtype = jobj.getString("jobtype");
                if (approved == 0) {
                    if (jobj.getString("colid" + j).equals("undefined")) {

                        String id = UUID.randomUUID().toString();
                        Timesheet tmsht = new Timesheet();
                        tmsht.setId(id);
                        tmsht.setDatevalue(dateValue);
                        tmsht.setUserID(usr);
                        tmsht.setJobtype(jobtype);
                        tmsht.setWorktime(Integer.parseInt(time[0]));
                        tmsht.setWorktimemin(Integer.parseInt(time[1]));
                        tmsht.setApproved(approved);
                        tmsht.setApprovedby(apprmanager);
                        session.save(tmsht);
                        marks += "?,";
                        timesheetIDs.add(tmsht.getId());
                        msg.put("msg",
                                MessageSourceProxy.getMessage("hrms.hrmshandler.msg.timesheetsavedsuccessfully",
                                        null, "Timesheet has been saved successfully",
                                        LocaleUtil.getCompanyLocale(AuthHandler.getCompanyid(request), 0)));
                    } else {
                        Timesheet tmsht = (Timesheet) session.load(Timesheet.class,
                                jobj.getString("colid" + j));
                        approved = tmsht.getApproved();
                        if (approved == 0) {
                            tmsht.setDatevalue(dateValue);
                            tmsht.setUserID(usr);
                            tmsht.setJobtype(jobtype);
                            tmsht.setWorktime(Integer.parseInt(time[0]));
                            tmsht.setWorktimemin(Integer.parseInt(time[1]));
                            tmsht.setApproved(approved);
                            tmsht.setApprovedby(apprmanager);
                            session.save(tmsht);
                            msg.put("msg",
                                    MessageSourceProxy.getMessage(
                                            "hrms.hrmshandler.msg.timesheetsavedsuccessfully", null,
                                            "Timesheet has been saved successfully",
                                            LocaleUtil.getCompanyLocale(AuthHandler.getCompanyid(request), 0)));
                        } else {
                            msg.put("msg",
                                    MessageSourceProxy.getMessage(
                                            "hrms.hrmshandler.msg.timesheetisalreadyapproved", null,
                                            "Timesheet is already approved",
                                            LocaleUtil.getCompanyLocale(AuthHandler.getCompanyid(request), 0)));
                        }
                        marks += "?,";
                        timesheetIDs.add(tmsht.getId());
                    }
                }

            }
        }
        //@@ProfileHandler.insertAuditLog(session, AuditAction.TIMESHEET_SUBMITTED, "Employee " + AuthHandler.getFullName(usr) + " has changed timesheet for the duration from " + dateA[0] +" to " +dateA[6],request);
    } catch (Exception ex) {
        throw ServiceException.FAILURE("hrmsHandler.TaskInsert", ex);
    } finally {
    }
    return msg.toString();
}

From source file:com.krawler.hrms.hrmsHandler.java

License:Open Source License

public static void insertGoal(Session session, HttpServletRequest request) throws ServiceException {
    int approved = 0;
    List tabledata = null;/*from www.  j  av  a2s  . co  m*/
    String apprmanager = "";
    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
    int logtext = 0;
    try {
        Finalgoalmanagement fgmt = null;
        if (StringUtil.isNullOrEmpty(request.getParameter("archive"))) {
            apprmanager = AuthHandler.getFullName(session, AuthHandler.getUserid(request));
            User usr = (User) session.load(User.class, request.getParameter("empid"));
            String jsondata = request.getParameter("jsondata");
            JSONArray jarr = new JSONArray("[" + jsondata + "]");
            for (int i = 0; i < jarr.length(); i++) {
                JSONObject jobj = jarr.getJSONObject(i);
                String id = UUID.randomUUID().toString();
                Date startdate = AuthHandler.getDateFormatter(request).parse(jobj.getString("gstartdate"));
                Date enddate = AuthHandler.getDateFormatter(request).parse(jobj.getString("genddate"));
                if (jobj.getString("gid").equals("undefined")) {
                    fgmt = new Finalgoalmanagement();
                    fgmt.setId(id);
                    fgmt.setCreatedon(new Date());
                    fgmt.setInternal(true);
                    logtext = 0;
                } else {
                    fgmt = (Finalgoalmanagement) session.load(Finalgoalmanagement.class, jobj.getString("gid"));
                    fgmt.setUpdatedon(new Date());
                    logtext = 1;
                }
                fgmt.setContext(jobj.getString("gcontext"));
                fgmt.setAssignedby(apprmanager);
                fgmt.setManager((User) session.load(User.class, AuthHandler.getUserid(request)));
                fgmt.setGoaldesc(jobj.getString("gdescription"));
                fgmt.setGoalwth(Integer.parseInt(jobj.getString("gwth")));
                fgmt.setGoalname(jobj.getString("gname"));
                fgmt.setStartdate(startdate);
                fgmt.setEnddate(enddate);
                fgmt.setPriority(jobj.getString("gpriority"));
                fgmt.setcomment(jobj.getString("gcomment"));
                fgmt.setUserID(usr);
                fgmt.setArchivedflag(0);
                fgmt.setCompleted(true);
                session.save(fgmt);
                if (logtext == 0) {
                    //@@ProfileHandler.insertAuditLog(session, AuditAction.GOAL_ADDED, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has assigned new goal " + fgmt.getGoalname()+  " to " + AuthHandler.getFullName(fgmt.getUserID()),request);
                } else {
                    //@@ProfileHandler.insertAuditLog(session, AuditAction.GOAL_EDITED, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has updated goal " + fgmt.getGoalname()+  " for " + AuthHandler.getFullName(fgmt.getUserID()),request);
                }
            }
        } else {
            String archiveids[] = request.getParameterValues("archiveid");
            for (int i = 0; i < archiveids.length; i++) {
                String hql = "from Finalgoalmanagement where id=?";
                tabledata = HibernateUtil.executeQuery(session, hql, archiveids[i]);
                if (!tabledata.isEmpty()) {
                    fgmt = (Finalgoalmanagement) tabledata.get(0);
                    fgmt.setArchivedflag(1);
                    session.update(fgmt);
                    //@@ProfileHandler.insertAuditLog(session, AuditAction.GOAL_ARCHIVED, "User " + AuthHandler.getFullName(session, AuthHandler.getUserid(request)) + " has archived " + AuthHandler.getFullName(fgmt.getUserID()) + "'s goal " + fgmt.getGoalname(),request);
                }
            }
        }
    } catch (Exception ex) {
        throw ServiceException.FAILURE("hrmsHandler.GoalInsert", ex);
    } finally {
    }

}

From source file:com.krawler.hrms.hrmsHandler.java

License:Open Source License

public static void addMasterDataField(Session session, HttpServletRequest request) throws ServiceException {
    String goalid = "";
    String auditID = "";
    String auditMsg = "";
    String masterGroup = "";
    try {/*w  ww . jav  a 2  s. c  om*/
        Master master = (Master) session.load(Master.class, Integer.parseInt(request.getParameter("configid")));
        MasterData gmst;
        User user = (User) session.load(User.class, AuthHandler.getUserid(request));
        String fullName = AuthHandler.getFullName(user);
        if (request.getParameter("action").equals("Add")) {
            gmst = new MasterData();
            gmst.setValue(request.getParameter("name"));
            gmst.setMasterid(master);
            gmst.setCompany((Company) session.get(Company.class, AuthHandler.getCompanyid(request)));
            auditID = com.krawler.common.util.AuditAction.MASTER_ADDED;
            auditMsg = "added ";
            session.save(gmst);
        } else {
            goalid = request.getParameter("id");
            gmst = (MasterData) session.load(MasterData.class, goalid);
            gmst.setValue(request.getParameter("name"));
            gmst.setMasterid(master);
            auditID = com.krawler.common.util.AuditAction.MASTER_EDITED;
            auditMsg = " updated ";
            session.save(gmst);
        }
        //@@ProfileHandler.insertAuditLog(session, auditID, "User <b>"+fullName+"</b> "+auditMsg+"master item <b>"+gmst.getValue()+"</b> of master group <b>"+master.getName()+".</b>", request);
    } catch (Exception ex) {
        throw ServiceException.FAILURE("hrmsHandler.addMasterField", ex);
    } finally {
    }

}