Пример #1
0
  @Override
  public Feature getFeature(String key) {
    Connection conn = getConnection();
    // BSmySQL mysql = new BSmySQL();
    BSBeanUtils bu = new BSBeanUtils();

    Feature feature = new Feature();

    if (!bu.search(conn, feature, "cKey=?", key)) {
      feature = null;
    }

    return feature;
  }
Пример #2
0
  protected void service(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    License license = new License();

    String startDate = request.getParameter("StartDate");
    String endDate = request.getParameter("EndDate");
    String cause = request.getParameter("Cause");
    String document = request.getParameter("Document");
    String employeeId = readParameterOrAttribute(request, "cId");

    BSBeanUtils bu = new BSBeanUtils();
    Calendar date = BSDateTimeUtil.string2Calendar(request, startDate);
    date =
        BSDateTimeUtil.string2Calendar(
            startDate, getApplicationValue(request, "DateFormat").toString());
    license.setStartDate(BSDateTimeUtil.calendar2Date(date));
    date = BSDateTimeUtil.string2Calendar(request, endDate);
    license.setEndDate(BSDateTimeUtil.calendar2Date(date));

    license.setEmployee(Long.parseLong(employeeId));
    license.setLicenseCause(Long.parseLong(cause));
    license.setDocument(document);

    BSConnectionFactory cf = new BSConnectionFactory();
    Connection conn = cf.getConnection(request);

    // Connection conn = getConnection(request);
    bu.save(conn, license);

    String dateFormat = getApplicationValue(request, "DateFormat").toString();

    EventLogService eventLog = ServiceFactory.createEventLogService();
    eventLog.writeEntry(
        conn,
        getCurrentUser(request).getId(),
        "NEW_LICENSE",
        "Agregó licencia o permiso al empleado '%s' de manera online. Para el día %s al %s.",
        idToRut(conn, license.getEmployee()),
        BSDateTimeUtil.date2String(license.getStartDate(), dateFormat),
        BSDateTimeUtil.date2String(license.getEndDate(), dateFormat));
    cf.closeConnection(conn);

    request.setAttribute("cId", employeeId);
    forward(request, response, "/servlet/timectrl/employee/LicenseOfEmployee");
  }