Example usage for java.util GregorianCalendar add

List of usage examples for java.util GregorianCalendar add

Introduction

In this page you can find the example usage for java.util GregorianCalendar add.

Prototype

@Override
public void add(int field, int amount) 

Source Link

Document

Adds the specified (signed) amount of time to the given calendar field, based on the calendar's rules.

Usage

From source file:ffsutils.TaskUtils.java

public static ArrayList<Tasks> getTaskToMeComp(Connection conn, UserAccount Username, String onlyUser)
        throws SQLException {
    System.out.println("getTaskToMeComp " + Username);
    Date date = new Date();
    Calendar cal = Calendar.getInstance();
    GregorianCalendar cal121 = new GregorianCalendar();
    cal121.setTime(date);//from   ww  w.  ja v a 2 s .  c o  m
    cal121.add(Calendar.DATE, 3);
    Date days3 = cal121.getTime();

    String year = Integer.toString(cal.get(Calendar.YEAR));
    String month = Integer.toString(cal.get(Calendar.MONTH) + 1);
    String day = Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
    String hour = Integer.toString(cal.get(Calendar.HOUR_OF_DAY));
    String minute = Integer.toString(cal.get(Calendar.MINUTE));
    if (onlyUser == null) {
        onlyUser = "";
    }
    String sql = "";
    if (onlyUser.equals(null) | onlyUser.length() < 4) {
        sql = "select * from " + Username.getcompany()
                + ".tasks where (((taskto1 = ?) and (taskstat1 = 'Completed')) or ((taskto2 = ?) and (taskstat2 = 'Completed')) or ((taskto3 = ?) and (taskstat3 = 'Completed')) or ((taskto4 = ?) and (taskstat4 = 'Completed')) or ((taskto5 = ?) and (taskstat5 = 'Completed'))  or ((taskto6 = ?) and (taskstat6 = 'Completed'))  or ((taskto7 = ?) and (taskstat7 = 'Completed'))  or ((taskto8 = ?) and (taskstat8 = 'Completed')) or ((taskto9 = ?) and (taskstat9 = 'Completed'))  or ((taskto10 = ?) and (taskstat10 = 'Completed')) or ((taskto11 = ?) and (taskstat11 = 'Completed')) or ((taskto12 = ?) and (taskstat12 = 'Completed')) or ((taskto13 = ?) and (taskstat13 = 'Completed')) or ((taskto14 = ?) and (taskstat14 = 'Completed')) or ((taskto15 = ?) and (taskstat15 = 'Completed')) )  and (recur = '0')";
    } else {
        sql = "select * from " + Username.getcompany()
                + ".tasks where ((((taskto1 = ?) and (taskstat1 = 'Completed')) or ((taskto2 = ?) and (taskstat2 = 'Completed')) or ((taskto3 = ?) and (taskstat3 = 'Completed')) or ((taskto4 = ?) and (taskstat4 = 'Completed')) or ((taskto5 = ?) and (taskstat5 = 'Completed'))  or ((taskto6 = ?) and (taskstat6 = 'Completed'))  or ((taskto7 = ?) and (taskstat7 = 'Completed'))  or ((taskto8 = ?) and (taskstat8 = 'Completed')) or ((taskto9 = ?) and (taskstat9 = 'Completed'))  or ((taskto10 = ?) and (taskstat10 = 'Completed')) or ((taskto11 = ?) and (taskstat11 = 'Completed')) or ((taskto12 = ?) and (taskstat12 = 'Completed')) or ((taskto13 = ?) and (taskstat13 = 'Completed')) or ((taskto14 = ?) and (taskstat14 = 'Completed')) or ((taskto15 = ?) and (taskstat15 = 'Completed')) )  and (recur = '0')) and (taskfrom = '"
                + onlyUser + "')";
    }
    PreparedStatement pstm = conn.prepareStatement(sql);
    pstm.setString(1, Username.getUserName());
    pstm.setString(2, Username.getUserName());
    pstm.setString(3, Username.getUserName());
    pstm.setString(4, Username.getUserName());
    pstm.setString(5, Username.getUserName());
    pstm.setString(6, Username.getUserName());
    pstm.setString(7, Username.getUserName());
    pstm.setString(8, Username.getUserName());
    pstm.setString(9, Username.getUserName());
    pstm.setString(10, Username.getUserName());
    pstm.setString(11, Username.getUserName());
    pstm.setString(12, Username.getUserName());
    pstm.setString(13, Username.getUserName());
    pstm.setString(14, Username.getUserName());
    pstm.setString(15, Username.getUserName());

    ResultSet rs = pstm.executeQuery();
    ArrayList<Tasks> list = new ArrayList<Tasks>();
    while (rs.next()) {
        Date date1 = new Date();
        Calendar cal1 = new GregorianCalendar();
        if (rs.getTimestamp("revdate") == null) {
            cal1.setTime(rs.getTimestamp("startdate"));
        } else {
            cal1.setTime(rs.getTimestamp("revdate"));
        }
        String year1 = Integer.toString(cal1.get(Calendar.YEAR));
        String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1);
        String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH));
        String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY));
        String minute1 = Integer.toString(cal1.get(Calendar.MINUTE));
        if (hour1.length() == 1) {
            hour1 = "0" + hour1;
        }
        if (minute1.length() == 1) {
            minute1 = "0" + minute1;
        }
        if (month1.length() == 1) {
            month1 = "0" + month1;
        }
        if (day1.length() == 1) {
            day1 = "0" + day1;
        }
        Date date2 = new Date();
        Calendar cal2 = new GregorianCalendar();

        cal2.setTime(rs.getTimestamp("enddate"));
        String year2 = Integer.toString(cal2.get(Calendar.YEAR));
        String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1);
        String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH));
        String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY));
        String minute2 = Integer.toString(cal2.get(Calendar.MINUTE));
        if (hour2.length() == 1) {
            hour2 = "0" + hour2;
        }
        if (minute2.length() == 1) {
            minute2 = "0" + minute2;
        }
        if (month2.length() == 1) {
            month2 = "0" + month2;
        }
        if (day2.length() == 1) {
            day2 = "0" + day2;
        }
        Date date3 = new Date();
        Calendar cal3 = new GregorianCalendar();

        cal3.setTime(rs.getTimestamp("startdate"));
        String year3 = Integer.toString(cal3.get(Calendar.YEAR));
        String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1);
        String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH));
        String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY));
        String minute3 = Integer.toString(cal3.get(Calendar.MINUTE));
        if (hour3.length() == 1) {
            hour3 = "0" + hour3;
        }
        if (minute3.length() == 1) {
            minute3 = "0" + minute3;
        }
        if (month3.length() == 1) {
            month3 = "0" + month3;
        }
        if (day3.length() == 1) {
            day3 = "0" + day3;
        }
        String tranid = rs.getString("tranid");
        String taskfrom = rs.getString("taskfrom");
        String description = rs.getString("description");
        String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1;
        String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2;
        String taskstat;
        if (rs.getString("taskstat") == null) {
            taskstat = "Not Started";
        } else {
            taskstat = rs.getString("taskstat");
        }
        //String taskstat = rs.getString("taskstat");
        String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3;
        Tasks task = new Tasks();
        task.setTranid(tranid);
        task.setTaskfrom(taskfrom);
        task.setDescription(description);
        task.setRevdate(revdate);
        task.setEnddate(enddate);
        task.setTaskstat(taskstat);
        task.setStartdate(startdate);
        String color1 = "";
        if (date.after(rs.getTimestamp("revdate"))) {
            color1 = "red";
        }
        if (color1 == "" && days3.after(rs.getTimestamp("revdate"))) {
            color1 = "orange";
        }
        if (color1 == "") {
            color1 = "green";
        }
        task.setlinkup1(color1);
        String color2 = "black";
        if ((Username.equals(rs.getString("taskto1")) && (!"Y".equals(rs.getString("newt1"))))
                || (Username.equals(rs.getString("taskto2")) && (!"Y".equals(rs.getString("newt2"))))
                || (Username.equals(rs.getString("taskto3")) && (!"Y".equals(rs.getString("newt3"))))
                || (Username.equals(rs.getString("taskto4")) && (!"Y".equals(rs.getString("newt4"))))
                || (Username.equals(rs.getString("taskto5")) && (!"Y".equals(rs.getString("newt5"))))
                || (Username.equals(rs.getString("taskto6")) && (!"Y".equals(rs.getString("newt6"))))
                || (Username.equals(rs.getString("taskto7")) && (!"Y".equals(rs.getString("newt7"))))
                || (Username.equals(rs.getString("taskto8")) && (!"Y".equals(rs.getString("newt8"))))
                || (Username.equals(rs.getString("taskto9")) && (!"Y".equals(rs.getString("newt9"))))
                || (Username.equals(rs.getString("taskto10")) && (!"Y".equals(rs.getString("newt10"))))
                || (Username.equals(rs.getString("taskto11")) && (!"Y".equals(rs.getString("newt11"))))
                || (Username.equals(rs.getString("taskto12")) && (!"Y".equals(rs.getString("newt12"))))
                || (Username.equals(rs.getString("taskto13")) && (!"Y".equals(rs.getString("newt13"))))
                || (Username.equals(rs.getString("taskto14")) && (!"Y".equals(rs.getString("newt14"))))
                || (Username.equals(rs.getString("taskto15")) && (!"Y".equals(rs.getString("newt15"))))) {
            color2 = "green";
        }
        task.setlinkup2(color2);

        list.add(task);

    }

    String sql1 = "select * from " + Username.getcompany()
            + ".tasks where (recur =1) and (((taskto1 = ?) and ((taskstat1 = 'Completed') or (recurdate1 > enddate))) or((taskto2 = ?) and ((taskstat2 = 'Completed') or (recurdate2 > enddate))) or((taskto3 = ?) and ((taskstat3 = 'Completed') or (recurdate3 > enddate))) or((taskto4 = ?) and ((taskstat4 = 'Completed') or (recurdate4 > enddate))) or ((taskto5 = ?) and ((taskstat5 = 'Completed') or (recurdate5 > enddate))) or ((taskto6 = ?) and ((taskstat6 = 'Completed') or (recurdate6 > enddate))) or ((taskto7 = ?) and ((taskstat7 = 'Completed') or (recurdate7 > enddate))) or ((taskto8 = ?) and ((taskstat8 = 'Completed') or (recurdate8 > enddate))) or((taskto9 = ?) and ((taskstat9 = 'Completed') or (recurdate9 > enddate))) or ((taskto11 = ?) and ((taskstat11 = 'Completed') or (recurdate11 > enddate))) or ((taskto12 = ?) and ((taskstat12 = 'Completed') or (recurdate12 > enddate))) or ((taskto13 = ?) and ((taskstat13 = 'Completed') or (recurdate13 > enddate))) or ((taskto14 = ?) and ((taskstat14 = 'Completed') or (recurdate14 > enddate))) or ((taskto15 = ?) and ((taskstat15 = 'Completed') or (recurdate15 > enddate))) or ((taskto10 = ?) and ((taskstat10 = 'Completed') or (recurdate10 > enddate))))";
    PreparedStatement pstm1 = conn.prepareStatement(sql1);

    pstm1.setString(1, Username.getUserName());
    pstm1.setString(2, Username.getUserName());
    pstm1.setString(3, Username.getUserName());
    pstm1.setString(4, Username.getUserName());
    pstm1.setString(5, Username.getUserName());
    pstm1.setString(6, Username.getUserName());
    pstm1.setString(7, Username.getUserName());
    pstm1.setString(8, Username.getUserName());
    pstm1.setString(9, Username.getUserName());
    pstm1.setString(10, Username.getUserName());
    pstm1.setString(11, Username.getUserName());
    pstm1.setString(12, Username.getUserName());
    pstm1.setString(13, Username.getUserName());
    pstm1.setString(14, Username.getUserName());
    pstm1.setString(15, Username.getUserName());

    ResultSet rs1 = pstm1.executeQuery();

    while (rs1.next()) {
        Date date1 = new Date();
        Calendar cal1 = new GregorianCalendar();
        if (rs1.getTimestamp("revdate") == null) {
            cal1.setTime(rs1.getTimestamp("enddate"));
        } else {
            cal1.setTime(rs1.getTimestamp("revdate"));
        }
        // cal1.setTime(rs1.getTimestamp("revdate"));
        String year1 = Integer.toString(cal1.get(Calendar.YEAR));
        String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1);
        String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH));
        String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY));
        String minute1 = Integer.toString(cal1.get(Calendar.MINUTE));
        if (hour1.length() == 1) {
            hour1 = "0" + hour1;
        }
        if (minute1.length() == 1) {
            minute1 = "0" + minute1;
        }
        if (month1.length() == 1) {
            month1 = "0" + month1;
        }
        if (day1.length() == 1) {
            day1 = "0" + day1;
        }
        Date date2 = new Date();
        Calendar cal2 = new GregorianCalendar();

        cal2.setTime(rs1.getTimestamp("enddate"));
        String year2 = Integer.toString(cal2.get(Calendar.YEAR));
        String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1);
        String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH));
        String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY));
        String minute2 = Integer.toString(cal2.get(Calendar.MINUTE));
        if (hour2.length() == 1) {
            hour2 = "0" + hour2;
        }
        if (minute2.length() == 1) {
            minute2 = "0" + minute2;
        }
        if (month2.length() == 1) {
            month2 = "0" + month2;
        }
        if (day2.length() == 1) {
            day2 = "0" + day2;
        }
        Date date3 = new Date();
        Calendar cal3 = new GregorianCalendar();

        cal3.setTime(rs1.getTimestamp("startdate"));
        String year3 = Integer.toString(cal3.get(Calendar.YEAR));
        String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1);
        String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH));
        String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY));
        String minute3 = Integer.toString(cal3.get(Calendar.MINUTE));
        if (hour3.length() == 1) {
            hour3 = "0" + hour3;
        }
        if (minute3.length() == 1) {
            minute3 = "0" + minute3;
        }
        if (month3.length() == 1) {
            month3 = "0" + month3;
        }
        if (day3.length() == 1) {
            day3 = "0" + day3;
        }
        String tranid = rs1.getString("tranid");
        String taskfrom = rs1.getString("taskfrom");
        String description = rs1.getString("description");
        String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1;
        String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2;
        String taskstat;
        if (rs1.getString("taskstat") == null) {
            taskstat = "Not Started";
        } else {
            taskstat = rs1.getString("taskstat");
        }
        //String taskstat = rs1.getString("taskstat");
        String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3;
        Tasks task = new Tasks();
        task.setTranid(tranid);
        task.setTaskfrom(taskfrom);
        task.setDescription(description);
        task.setRevdate(revdate);
        task.setEnddate(enddate);
        task.setTaskstat(taskstat);
        task.setStartdate(startdate);
        String color1 = "";
        if (date.after(rs.getTimestamp("revdate"))) {
            color1 = "red";
        }
        if (color1 == "" && days3.after(rs.getTimestamp("revdate"))) {
            color1 = "orange";
        }
        if (color1 == "") {
            color1 = "green";
        }
        task.setlinkup1(color1);
        String color2 = "black";
        if ((Username.equals(rs.getString("taskto1")) && (!"Y".equals(rs.getString("newt1"))))
                || (Username.equals(rs.getString("taskto2")) && (!"Y".equals(rs.getString("newt2"))))
                || (Username.equals(rs.getString("taskto3")) && (!"Y".equals(rs.getString("newt3"))))
                || (Username.equals(rs.getString("taskto4")) && (!"Y".equals(rs.getString("newt4"))))
                || (Username.equals(rs.getString("taskto5")) && (!"Y".equals(rs.getString("newt5"))))
                || (Username.equals(rs.getString("taskto6")) && (!"Y".equals(rs.getString("newt6"))))
                || (Username.equals(rs.getString("taskto7")) && (!"Y".equals(rs.getString("newt7"))))
                || (Username.equals(rs.getString("taskto8")) && (!"Y".equals(rs.getString("newt8"))))
                || (Username.equals(rs.getString("taskto9")) && (!"Y".equals(rs.getString("newt9"))))
                || (Username.equals(rs.getString("taskto10")) && (!"Y".equals(rs.getString("newt10"))))
                || (Username.equals(rs.getString("taskto11")) && (!"Y".equals(rs.getString("newt11"))))
                || (Username.equals(rs.getString("taskto12")) && (!"Y".equals(rs.getString("newt12"))))
                || (Username.equals(rs.getString("taskto13")) && (!"Y".equals(rs.getString("newt13"))))
                || (Username.equals(rs.getString("taskto14")) && (!"Y".equals(rs.getString("newt14"))))
                || (Username.equals(rs.getString("taskto15")) && (!"Y".equals(rs.getString("newt15"))))) {
            color2 = "green";
        }
        task.setlinkup2(color2);

        list.add(task);

    }

    return list;
}

From source file:ffsutils.TaskUtils.java

public static ArrayList<Tasks> getUrgentTasks(Connection conn, UserAccount Username, String onlyUser)
        throws SQLException {
    System.out.println("getUrgentTasks " + Username);
    Date date = new Date();
    Calendar cal = Calendar.getInstance();
    GregorianCalendar cal121 = new GregorianCalendar();
    cal121.setTime(date);/*from www.j  av  a 2  s  .c o m*/
    cal121.add(Calendar.DATE, 3);
    Date days3 = cal121.getTime();
    String username = Username.getUserName();
    cal.add(Calendar.DATE, 3);
    String year = Integer.toString(cal.get(Calendar.YEAR));
    String month = Integer.toString(cal.get(Calendar.MONTH) + 1);
    String day = Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
    String hour = Integer.toString(cal.get(Calendar.HOUR_OF_DAY));
    String minute = Integer.toString(cal.get(Calendar.MINUTE));

    Date date1 = new Date();
    Calendar cal1 = Calendar.getInstance();

    cal1.add(Calendar.DATE, 4);
    String year1 = Integer.toString(cal1.get(Calendar.YEAR));
    String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1);
    String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH));
    String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY));
    String minute1 = Integer.toString(cal1.get(Calendar.MINUTE));
    String sql = "";
    if (onlyUser == null) {
        sql = "select * from " + Username.getcompany() + ".tasks where ((taskfrom = '" + username
                + "' ) or (taskto1 = '" + username + "') or (taskto2 = '" + username + "') or (taskto3 = '"
                + username + "') or (taskto4 = '" + username + "') or (taskto5 = '" + username
                + "') or (taskto6 = '" + username + "') or (taskto7 = '" + username + "') or (taskto8 = '"
                + username + "') or (taskto9 = '" + username + "') or (taskto10 = '" + username
                + "') or (taskto11 = '" + username + "') or (taskto12 = '" + username + "') or (taskto13 = '"
                + username + "') or (taskto14 = '" + username + "') or (taskto15 = '" + username
                + "'))and (taskstat <> 'Completed') and (revdate > '" + year + "/" + month + "/" + day
                + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/" + day1 + " 23:59')";
    } else {
        if (onlyUser.length() < 3) {
            sql = "select * from " + Username.getcompany() + ".tasks where ((taskfrom = '" + username
                    + "' ) or (taskto1 = '" + username + "') or (taskto2 = '" + username + "') or (taskto3 = '"
                    + username + "') or (taskto4 = '" + username + "') or (taskto5 = '" + username
                    + "') or (taskto6 = '" + username + "') or (taskto7 = '" + username + "') or (taskto8 = '"
                    + username + "') or (taskto9 = '" + username + "') or (taskto10 = '" + username
                    + "') or (taskto11 = '" + username + "') or (taskto12 = '" + username
                    + "') or (taskto13 = '" + username + "') or (taskto14 = '" + username
                    + "') or (taskto15 = '" + username + "'))and (taskstat <> 'Completed') and (revdate > '"
                    + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/"
                    + day1 + " 23:59')";
        } else {
            sql = "select * from " + Username.getcompany() + ".tasks where (taskfrom = '" + onlyUser
                    + "' ) and ((taskto1 = '" + username + "') or (taskto2 = '" + username
                    + "') or (taskto3 = '" + username + "') or (taskto4 = '" + username + "') or (taskto5 = '"
                    + username + "') or (taskto6 = '" + username + "') or (taskto7 = '" + username
                    + "') or (taskto8 = '" + username + "') or (taskto9 = '" + username + "') or (taskto10 = '"
                    + username + "') or (taskto11 = '" + username + "') or (taskto12 = '" + username
                    + "') or (taskto13 = '" + username + "') or (taskto14 = '" + username
                    + "') or (taskto15 = '" + username + "')) and (taskstat <> 'Completed') and (revdate > '"
                    + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/"
                    + day1 + " 23:59')";
        }
    }

    PreparedStatement pstm = conn.prepareStatement(sql);
    // pstm.setString(1, Username);

    ResultSet rs = pstm.executeQuery();
    ArrayList<Tasks> list = new ArrayList<Tasks>();
    while (rs.next()) {
        Date date10 = new Date();
        Calendar cal10 = new GregorianCalendar();
        if (rs.getTimestamp("revdate") == null) {
            cal1.setTime(rs.getTimestamp("enddate"));
        } else {
            cal1.setTime(rs.getTimestamp("revdate"));
        }
        String year10 = Integer.toString(cal10.get(Calendar.YEAR));
        String month10 = Integer.toString(cal10.get(Calendar.MONTH) + 1);
        String day10 = Integer.toString(cal10.get(Calendar.DAY_OF_MONTH));
        String hour10 = Integer.toString(cal10.get(Calendar.HOUR_OF_DAY));
        String minute10 = Integer.toString(cal10.get(Calendar.MINUTE));
        if (hour10.length() == 1) {
            hour10 = "0" + hour10;
        }
        if (minute10.length() == 1) {
            minute10 = "0" + minute10;
        }
        if (month10.length() == 1) {
            month10 = "0" + month10;
        }
        if (day10.length() == 1) {
            day10 = "0" + day10;
        }
        Date date2 = new Date();
        Calendar cal2 = new GregorianCalendar();

        cal2.setTime(rs.getTimestamp("enddate"));
        String year2 = Integer.toString(cal2.get(Calendar.YEAR));
        String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1);
        String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH));
        String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY));
        String minute2 = Integer.toString(cal2.get(Calendar.MINUTE));
        if (hour2.length() == 1) {
            hour2 = "0" + hour2;
        }
        if (minute2.length() == 1) {
            minute2 = "0" + minute2;
        }
        if (month2.length() == 1) {
            month2 = "0" + month2;
        }
        if (day2.length() == 1) {
            day2 = "0" + day2;
        }
        Date date3 = new Date();
        Calendar cal3 = new GregorianCalendar();

        cal3.setTime(rs.getTimestamp("startdate"));
        String year3 = Integer.toString(cal3.get(Calendar.YEAR));
        String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1);
        String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH));
        String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY));
        String minute3 = Integer.toString(cal3.get(Calendar.MINUTE));
        if (hour3.length() == 1) {
            hour3 = "0" + hour3;
        }
        if (minute3.length() == 1) {
            minute3 = "0" + minute3;
        }
        if (month3.length() == 1) {
            month3 = "0" + month3;
        }
        if (day3.length() == 1) {
            day3 = "0" + day3;
        }
        String tranid = rs.getString("tranid");
        String taskfrom = rs.getString("taskfrom");
        String description = rs.getString("description");
        String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1;
        String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2;
        String taskstat;
        if (rs.getString("taskstat") == null) {
            taskstat = "Not Started";
        } else {
            taskstat = rs.getString("taskstat");
        }
        //String taskstat = rs.getString("taskstat");
        String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3;
        Tasks task = new Tasks();
        task.setTranid(tranid);
        task.setTaskfrom(taskfrom);
        task.setDescription(description);
        task.setRevdate(revdate);
        task.setEnddate(enddate);
        task.setTaskstat(taskstat);
        task.setStartdate(startdate);
        String color1 = "";
        if (date.after(rs.getTimestamp("revdate"))) {
            color1 = "red";
        }
        if (color1 == "" && days3.after(rs.getTimestamp("revdate"))) {
            color1 = "orange";
        }
        if (color1 == "") {
            color1 = "green";
        }
        task.setlinkup1(color1);

        String color2 = "black";
        if ((Username.equals(rs.getString("taskto1")) && (!"Y".equals(rs.getString("newt1"))))
                || (Username.equals(rs.getString("taskto2")) && (!"Y".equals(rs.getString("newt2"))))
                || (Username.equals(rs.getString("taskto3")) && (!"Y".equals(rs.getString("newt3"))))
                || (Username.equals(rs.getString("taskto4")) && (!"Y".equals(rs.getString("newt4"))))
                || (Username.equals(rs.getString("taskto5")) && (!"Y".equals(rs.getString("newt5"))))
                || (Username.equals(rs.getString("taskto6")) && (!"Y".equals(rs.getString("newt6"))))
                || (Username.equals(rs.getString("taskto7")) && (!"Y".equals(rs.getString("newt7"))))
                || (Username.equals(rs.getString("taskto8")) && (!"Y".equals(rs.getString("newt8"))))
                || (Username.equals(rs.getString("taskto9")) && (!"Y".equals(rs.getString("newt9"))))
                || (Username.equals(rs.getString("taskto10")) && (!"Y".equals(rs.getString("newt10"))))
                || (Username.equals(rs.getString("taskto11")) && (!"Y".equals(rs.getString("newt11"))))
                || (Username.equals(rs.getString("taskto12")) && (!"Y".equals(rs.getString("newt12"))))
                || (Username.equals(rs.getString("taskto13")) && (!"Y".equals(rs.getString("newt13"))))
                || (Username.equals(rs.getString("taskto14")) && (!"Y".equals(rs.getString("newt14"))))
                || (Username.equals(rs.getString("taskto15")) && (!"Y".equals(rs.getString("newt15"))))) {
            color2 = "green";
        }
        task.setlinkup2(color2);
        list.add(task);

    }
    String sql1 = "";
    if (onlyUser == null) {
        sql1 = "select * from " + Username.getcompany()
                + ".tasks where (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is null))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is null))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is null))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is null))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is null))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is null))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is null))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is null))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is null))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is null))) or((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is null))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is null))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is null))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is null))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is null)))) and (taskstat <> 'Completed') and (revdate > '"
                + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/"
                + day1 + " 23:59')";
    } else {
        if (onlyUser.length() < 3) {
            sql1 = "select * from " + Username.getcompany()
                    + ".tasks where (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is null))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is null))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is null))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is null))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is null))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is null))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is null))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is null))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is null))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is null))) or((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is null))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is null))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is null))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is null))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is null)))) and (taskstat <> 'Completed') and (revdate > '"
                    + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/"
                    + day1 + " 23:59')";
        } else {
            sql1 = "select * from " + Username.getcompany()
                    + ".tasks where (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is null))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is null))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is null))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is null))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is null))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is null))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is null))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is null))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is null))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is null))) or((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is null))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is null))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or(taskstat13 is null))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is null))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is null)))) and (taskstat <> 'Completed') and (revdate > '"
                    + year + "/" + month + "/" + day + " 00:01') and (revdate < '" + year1 + "/" + month1 + "/"
                    + day1 + " 23:59') and (taskfrom = '" + onlyUser + "')";
        }
    }
    PreparedStatement pstm1 = conn.prepareStatement(sql1);

    pstm1.setString(1, Username.getUserName());
    pstm1.setString(2, Username.getUserName());
    pstm1.setString(3, Username.getUserName());
    pstm1.setString(4, Username.getUserName());
    pstm1.setString(5, Username.getUserName());
    pstm1.setString(6, Username.getUserName());
    pstm1.setString(7, Username.getUserName());
    pstm1.setString(8, Username.getUserName());
    pstm1.setString(9, Username.getUserName());
    pstm1.setString(10, Username.getUserName());
    pstm1.setString(11, Username.getUserName());
    pstm1.setString(12, Username.getUserName());
    pstm1.setString(13, Username.getUserName());
    pstm1.setString(14, Username.getUserName());
    pstm1.setString(15, Username.getUserName());

    ResultSet rs1 = pstm1.executeQuery();

    while (rs1.next()) {
        Date date11 = new Date();
        Calendar cal11 = new GregorianCalendar();
        if (rs1.getTimestamp("revdate") == null) {
            cal1.setTime(rs.getTimestamp("enddate"));
        } else {
            cal1.setTime(rs1.getTimestamp("revdate"));
        }
        //            cal1.setTime(rs1.getTimestamp("revdate"));
        String year11 = Integer.toString(cal11.get(Calendar.YEAR));
        String month11 = Integer.toString(cal11.get(Calendar.MONTH) + 1);
        String day11 = Integer.toString(cal11.get(Calendar.DAY_OF_MONTH));
        String hour11 = Integer.toString(cal11.get(Calendar.HOUR_OF_DAY));
        String minute11 = Integer.toString(cal11.get(Calendar.MINUTE));
        if (hour11.length() == 1) {
            hour11 = "0" + hour11;
        }
        if (minute11.length() == 1) {
            minute11 = "0" + minute11;
        }
        if (month11.length() == 1) {
            month11 = "0" + month11;
        }
        if (day11.length() == 1) {
            day11 = "0" + day11;
        }
        Date date2 = new Date();
        Calendar cal2 = new GregorianCalendar();

        cal2.setTime(rs1.getTimestamp("enddate"));
        String year2 = Integer.toString(cal2.get(Calendar.YEAR));
        String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1);
        String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH));
        String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY));
        String minute2 = Integer.toString(cal2.get(Calendar.MINUTE));
        if (hour2.length() == 1) {
            hour2 = "0" + hour2;
        }
        if (minute2.length() == 1) {
            minute2 = "0" + minute2;
        }
        if (month2.length() == 1) {
            month2 = "0" + month2;
        }
        if (day2.length() == 1) {
            day2 = "0" + day2;
        }
        Date date3 = new Date();
        Calendar cal3 = new GregorianCalendar();

        cal3.setTime(rs1.getTimestamp("startdate"));
        String year3 = Integer.toString(cal3.get(Calendar.YEAR));
        String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1);
        String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH));
        String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY));
        String minute3 = Integer.toString(cal3.get(Calendar.MINUTE));
        if (hour3.length() == 1) {
            hour3 = "0" + hour3;
        }
        if (minute3.length() == 1) {
            minute3 = "0" + minute3;
        }
        if (month3.length() == 1) {
            month3 = "0" + month3;
        }
        if (day3.length() == 1) {
            day3 = "0" + day3;
        }
        String tranid = rs1.getString("tranid");
        String taskfrom = rs1.getString("taskfrom");
        String description = rs1.getString("description");
        String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1;
        String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2;
        String taskstat;
        if (rs1.getString("taskstat") == null) {
            taskstat = "Not Started";
        } else {
            taskstat = rs1.getString("taskstat");
        }
        //String taskstat = rs1.getString("taskstat");
        String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3;
        Tasks task = new Tasks();
        task.setTranid(tranid);
        task.setTaskfrom(taskfrom);
        task.setDescription(description);
        task.setRevdate(revdate);
        task.setEnddate(enddate);
        task.setTaskstat(taskstat);
        task.setStartdate(startdate);
        String color1 = "";
        if (date.after(rs1.getTimestamp("revdate"))) {
            color1 = "red";
        }
        if (color1 == "" && days3.after(rs1.getTimestamp("revdate"))) {
            color1 = "orange";
        }
        if (color1 == "") {
            color1 = "green";
        }
        task.setlinkup1(color1);
        String color2 = "black";
        if ((Username.equals(rs1.getString("taskto1")) && (!"Y".equals(rs1.getString("newt1"))))
                || (Username.equals(rs1.getString("taskto2")) && (!"Y".equals(rs1.getString("newt2"))))
                || (Username.equals(rs1.getString("taskto3")) && (!"Y".equals(rs1.getString("newt3"))))
                || (Username.equals(rs1.getString("taskto4")) && (!"Y".equals(rs1.getString("newt4"))))
                || (Username.equals(rs1.getString("taskto5")) && (!"Y".equals(rs1.getString("newt5"))))
                || (Username.equals(rs1.getString("taskto6")) && (!"Y".equals(rs1.getString("newt6"))))
                || (Username.equals(rs1.getString("taskto7")) && (!"Y".equals(rs1.getString("newt7"))))
                || (Username.equals(rs1.getString("taskto8")) && (!"Y".equals(rs1.getString("newt8"))))
                || (Username.equals(rs1.getString("taskto9")) && (!"Y".equals(rs1.getString("newt9"))))
                || (Username.equals(rs1.getString("taskto10")) && (!"Y".equals(rs1.getString("newt10"))))
                || (Username.equals(rs1.getString("taskto11")) && (!"Y".equals(rs1.getString("newt11"))))
                || (Username.equals(rs1.getString("taskto12")) && (!"Y".equals(rs1.getString("newt12"))))
                || (Username.equals(rs1.getString("taskto13")) && (!"Y".equals(rs1.getString("newt13"))))
                || (Username.equals(rs1.getString("taskto14")) && (!"Y".equals(rs1.getString("newt14"))))
                || (Username.equals(rs1.getString("taskto15")) && (!"Y".equals(rs1.getString("newt15"))))) {
            color2 = "green";
        }
        task.setlinkup2(color2);

        list.add(task);

    }

    return list;
}

From source file:ffsutils.TaskUtils.java

public static ArrayList<Tasks> getTask(Connection conn, UserAccount Username, String onlyUser)
        throws SQLException {
    System.out.println("getTask " + Username.getUserName() + " " + onlyUser);
    Date date = new Date();
    Calendar cal = Calendar.getInstance();
    Calendar cal7 = Calendar.getInstance();

    GregorianCalendar cal121 = new GregorianCalendar();
    cal121.setTime(date);//from w w w .ja  v  a  2s  .  c  o  m
    cal121.add(Calendar.DATE, 3);
    Date days3 = cal121.getTime();

    String year = Integer.toString(cal.get(Calendar.YEAR));
    String month = Integer.toString(cal.get(Calendar.MONTH) + 1);
    String day = Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
    String hour = Integer.toString(cal.get(Calendar.HOUR_OF_DAY));
    String minute = Integer.toString(cal.get(Calendar.MINUTE));

    String sql = "";
    if (onlyUser == null) {
        onlyUser = "";
    }
    if (onlyUser.equals(null) | onlyUser.length() < 4) {
        sql = "select * from " + Username.getcompany() + ".tasks where (recur = '0') and (startdate < '" + year
                + "/" + month + "/" + day
                + " 23:59') and ((taskstat <> 'Completed') or (taskstat is NULL)) and (((taskto1 = ? ) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL))) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL)))) ";
    } else {

        sql = "select * from " + Username.getcompany() + ".tasks where (recur = '0') and (startdate < '" + year
                + "/" + month + "/" + day
                + " 23:59') and ((taskstat <> 'Completed') or (taskstat is NULL)) and (((taskto1 = ? ) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL))) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL)))) and (taskfrom = '"
                + onlyUser + "')";
    }
    PreparedStatement pstm = conn.prepareStatement(sql);
    pstm.setString(1, Username.getUserName());
    pstm.setString(2, Username.getUserName());
    pstm.setString(3, Username.getUserName());
    pstm.setString(4, Username.getUserName());
    pstm.setString(5, Username.getUserName());
    pstm.setString(6, Username.getUserName());
    pstm.setString(7, Username.getUserName());
    pstm.setString(8, Username.getUserName());
    pstm.setString(9, Username.getUserName());
    pstm.setString(10, Username.getUserName());
    pstm.setString(11, Username.getUserName());
    pstm.setString(12, Username.getUserName());
    pstm.setString(13, Username.getUserName());
    pstm.setString(14, Username.getUserName());
    pstm.setString(15, Username.getUserName());

    ResultSet rs = pstm.executeQuery();
    ArrayList<Tasks> list = new ArrayList<Tasks>();
    while (rs.next()) {
        Date date1 = new Date();
        Calendar cal1 = new GregorianCalendar();
        if (rs.getTimestamp("revdate") == null) {
            cal1.setTime(rs.getTimestamp("enddate"));
        } else {
            cal1.setTime(rs.getTimestamp("revdate"));
        }
        // cal1.setTime(rs.getTimestamp("revdate"));
        String year1 = Integer.toString(cal1.get(Calendar.YEAR));
        String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1);
        String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH));
        String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY));
        String minute1 = Integer.toString(cal1.get(Calendar.MINUTE));
        if (hour1.length() == 1) {
            hour1 = "0" + hour1;
        }
        if (minute1.length() == 1) {
            minute1 = "0" + minute1;
        }
        if (month1.length() == 1) {
            month1 = "0" + month1;
        }
        if (day1.length() == 1) {
            day1 = "0" + day1;
        }
        Date date2 = new Date();
        Calendar cal2 = new GregorianCalendar();

        cal2.setTime(rs.getTimestamp("enddate"));
        String year2 = Integer.toString(cal2.get(Calendar.YEAR));
        String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1);
        String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH));
        String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY));
        String minute2 = Integer.toString(cal2.get(Calendar.MINUTE));
        if (hour2.length() == 1) {
            hour2 = "0" + hour2;
        }
        if (minute2.length() == 1) {
            minute2 = "0" + minute2;
        }
        if (month2.length() == 1) {
            month2 = "0" + month2;
        }
        if (day2.length() == 1) {
            day2 = "0" + day2;
        }
        Date date3 = new Date();
        Calendar cal3 = new GregorianCalendar();

        cal3.setTime(rs.getTimestamp("startdate"));
        String year3 = Integer.toString(cal3.get(Calendar.YEAR));
        String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1);
        String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH));
        String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY));
        String minute3 = Integer.toString(cal3.get(Calendar.MINUTE));
        if (hour3.length() == 1) {
            hour3 = "0" + hour3;
        }
        if (minute3.length() == 1) {
            minute3 = "0" + minute3;
        }
        if (month3.length() == 1) {
            month3 = "0" + month3;
        }
        if (day3.length() == 1) {
            day3 = "0" + day3;
        }
        String tranid = rs.getString("tranid");
        String taskfrom = rs.getString("taskfrom");
        String description = rs.getString("description");
        String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1;
        String taskstat;
        if (rs.getString("taskstat") == null) {
            taskstat = "Not Started";
        } else {
            taskstat = rs.getString("taskstat");
        }
        String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2;
        //String taskstat = rs.getString("taskstat");
        String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3;

        Tasks task = new Tasks();
        task.setTranid(tranid);
        task.setTaskfrom(taskfrom);
        task.setDescription(description);
        task.setRevdate(revdate);
        task.setEnddate(enddate);
        task.setTaskstat(taskstat);
        task.setStartdate(startdate);
        String color1 = "";
        String color2 = "black";
        if (rs.getTimestamp("revdate") == null) {
            cal7.setTime(rs.getTimestamp("enddate"));
        } else {
            cal7.setTime(rs.getTimestamp("revdate"));
        }
        if (date.after(cal7.getTime())) {
            color1 = "red";
        }
        if (color1 == "" && days3.after(cal7.getTime())) {
            color1 = "orange";
        }
        //            if (date.after(rs.getTimestamp("revdate"))) {
        //                color1 = "red";
        //            }
        //            if (color1 == "" && days3.after(rs.getTimestamp("revdate"))) {
        //                color1 = "orange";
        //            }
        if (color1 == "") {
            color1 = "green";
        }
        task.setlinkup1(color1);
        //            System.out.println("getTask " + color1 );
        if ((Username.equals(rs.getString("taskto1")) && (!"Y".equals(rs.getString("newt1"))))
                || (Username.equals(rs.getString("taskto2")) && (!"Y".equals(rs.getString("newt2"))))
                || (Username.equals(rs.getString("taskto3")) && (!"Y".equals(rs.getString("newt3"))))
                || (Username.equals(rs.getString("taskto4")) && (!"Y".equals(rs.getString("newt4"))))
                || (Username.equals(rs.getString("taskto5")) && (!"Y".equals(rs.getString("newt5"))))
                || (Username.equals(rs.getString("taskto6")) && (!"Y".equals(rs.getString("newt6"))))
                || (Username.equals(rs.getString("taskto7")) && (!"Y".equals(rs.getString("newt7"))))
                || (Username.equals(rs.getString("taskto8")) && (!"Y".equals(rs.getString("newt8"))))
                || (Username.equals(rs.getString("taskto9")) && (!"Y".equals(rs.getString("newt9"))))
                || (Username.equals(rs.getString("taskto10")) && (!"Y".equals(rs.getString("newt10"))))
                || (Username.equals(rs.getString("taskto11")) && (!"Y".equals(rs.getString("newt11"))))
                || (Username.equals(rs.getString("taskto12")) && (!"Y".equals(rs.getString("newt12"))))
                || (Username.equals(rs.getString("taskto13")) && (!"Y".equals(rs.getString("newt13"))))
                || (Username.equals(rs.getString("taskto14")) && (!"Y".equals(rs.getString("newt14"))))
                || (Username.equals(rs.getString("taskto15")) && (!"Y".equals(rs.getString("newt15"))))) {
            color2 = "green";
        }
        task.setlinkup2(color2);

        list.add(task);

    }

    String sql1 = "select * from " + Username.getcompany()
            + ".tasks where (recur =1) and ((taskstat <> 'Completed') or (taskstat is NULL)) and  (startdate <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL)) and (RECURDATE1 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate1 < enddate)) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL)) and (RECURDATE2 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate2 < enddate)) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL)) and (RECURDATE3 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate3 < enddate)) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL)) and (RECURDATE4 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate4 < enddate)) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL)) and (RECURDATE5 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate5 < enddate)) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL)) and (RECURDATE6 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate6 < enddate)) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL)) and (RECURDATE7 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate7 < enddate)) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL)) and (RECURDATE8 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate8 < enddate)) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL)) and (RECURDATE9 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate9 < enddate)) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL)) and (RECURDATE11 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate11 < enddate)) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL)) and (RECURDATE12 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate12 < enddate)) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL)) and (RECURDATE13 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate13 < enddate)) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL)) and (RECURDATE14 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate14 < enddate)) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL)) and (RECURDATE15 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate15 < enddate)) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL)) and (RECURDATE10 <= '"
            + year + "/" + month + "/" + day + " " + hour + ":" + minute
            + ":00') and (recurdate10 < enddate)))";
    PreparedStatement pstm1 = conn.prepareStatement(sql1);

    pstm1.setString(1, Username.getUserName());
    pstm1.setString(2, Username.getUserName());
    pstm1.setString(3, Username.getUserName());
    pstm1.setString(4, Username.getUserName());
    pstm1.setString(5, Username.getUserName());
    pstm1.setString(6, Username.getUserName());
    pstm1.setString(7, Username.getUserName());
    pstm1.setString(8, Username.getUserName());
    pstm1.setString(9, Username.getUserName());
    pstm1.setString(10, Username.getUserName());
    pstm1.setString(11, Username.getUserName());
    pstm1.setString(12, Username.getUserName());
    pstm1.setString(13, Username.getUserName());
    pstm1.setString(14, Username.getUserName());
    pstm1.setString(15, Username.getUserName());

    ResultSet rs1 = pstm1.executeQuery();

    while (rs1.next()) {
        Date date1 = new Date();
        Calendar cal1 = new GregorianCalendar();
        if (rs1.getTimestamp("revdate") == null) {
            cal1.setTime(rs1.getTimestamp("enddate"));
        } else {
            cal1.setTime(rs1.getTimestamp("revdate"));
        }
        // cal1.setTime(rs1.getTimestamp("revdate"));
        String year1 = Integer.toString(cal1.get(Calendar.YEAR));
        String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1);
        String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH));
        String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY));
        String minute1 = Integer.toString(cal1.get(Calendar.MINUTE));
        if (hour1.length() == 1) {
            hour1 = "0" + hour1;
        }
        if (minute1.length() == 1) {
            minute1 = "0" + minute1;
        }
        if (month1.length() == 1) {
            month1 = "0" + month1;
        }
        if (day1.length() == 1) {
            day1 = "0" + day1;
        }
        Date date2 = new Date();
        Calendar cal2 = new GregorianCalendar();

        cal2.setTime(rs1.getTimestamp("enddate"));
        String year2 = Integer.toString(cal2.get(Calendar.YEAR));
        String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1);
        String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH));
        String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY));
        String minute2 = Integer.toString(cal2.get(Calendar.MINUTE));
        if (hour2.length() == 1) {
            hour2 = "0" + hour2;
        }
        if (minute2.length() == 1) {
            minute2 = "0" + minute2;
        }
        if (month2.length() == 1) {
            month2 = "0" + month2;
        }
        if (day2.length() == 1) {
            day2 = "0" + day2;
        }
        Date date3 = new Date();
        Calendar cal3 = new GregorianCalendar();

        cal3.setTime(rs1.getTimestamp("startdate"));
        String year3 = Integer.toString(cal3.get(Calendar.YEAR));
        String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1);
        String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH));
        String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY));
        String minute3 = Integer.toString(cal3.get(Calendar.MINUTE));
        if (hour3.length() == 1) {
            hour3 = "0" + hour3;
        }
        if (minute3.length() == 1) {
            minute3 = "0" + minute3;
        }
        if (month3.length() == 1) {
            month3 = "0" + month3;
        }
        if (day3.length() == 1) {
            day3 = "0" + day3;
        }
        String tranid = rs1.getString("tranid");
        String taskfrom = rs1.getString("taskfrom");
        String description = rs1.getString("description");
        String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1;
        String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2;
        String taskstat;
        if (rs1.getString("taskstat") == null) {
            taskstat = "Not Started";
        } else {
            taskstat = rs1.getString("taskstat");
        }
        //String taskstat = rs1.getString("taskstat");
        String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3;
        Tasks task = new Tasks();
        task.setTranid(tranid);
        task.setTaskfrom(taskfrom);
        task.setDescription(description);
        task.setRevdate(revdate);
        task.setEnddate(enddate);
        task.setTaskstat(taskstat);
        task.setStartdate(startdate);
        String color1 = "";
        if (date.after(rs1.getTimestamp("revdate"))) {
            color1 = "red";
        }
        if (color1 == "" && days3.after(rs1.getTimestamp("revdate"))) {
            color1 = "orange";
        }
        if (color1 == "") {
            color1 = "green";
        }
        task.setlinkup1(color1);

        String color2 = "black";
        if ((Username.equals(rs1.getString("taskto1")) && (!"Y".equals(rs1.getString("newt1"))))
                || (Username.equals(rs1.getString("taskto2")) && (!"Y".equals(rs1.getString("newt2"))))
                || (Username.equals(rs1.getString("taskto3")) && (!"Y".equals(rs1.getString("newt3"))))
                || (Username.equals(rs1.getString("taskto4")) && (!"Y".equals(rs1.getString("newt4"))))
                || (Username.equals(rs1.getString("taskto5")) && (!"Y".equals(rs1.getString("newt5"))))
                || (Username.equals(rs1.getString("taskto6")) && (!"Y".equals(rs1.getString("newt6"))))
                || (Username.equals(rs1.getString("taskto7")) && (!"Y".equals(rs1.getString("newt7"))))
                || (Username.equals(rs1.getString("taskto8")) && (!"Y".equals(rs1.getString("newt8"))))
                || (Username.equals(rs1.getString("taskto9")) && (!"Y".equals(rs1.getString("newt9"))))
                || (Username.equals(rs1.getString("taskto10")) && (!"Y".equals(rs1.getString("newt10"))))
                || (Username.equals(rs1.getString("taskto11")) && (!"Y".equals(rs1.getString("newt11"))))
                || (Username.equals(rs1.getString("taskto12")) && (!"Y".equals(rs1.getString("newt12"))))
                || (Username.equals(rs1.getString("taskto13")) && (!"Y".equals(rs1.getString("newt13"))))
                || (Username.equals(rs1.getString("taskto14")) && (!"Y".equals(rs1.getString("newt14"))))
                || (Username.equals(rs1.getString("taskto15")) && (!"Y".equals(rs1.getString("newt15"))))) {
            color2 = "green";
        }
        task.setlinkup2(color2);

        list.add(task);

    }

    return list;
}

From source file:ffsutils.TaskUtils.java

public static ArrayList<Tasks> getTaskInFuture(Connection conn, UserAccount Username, String onlyUser)
        throws SQLException {

    System.out.println("getTaskInFuture " + onlyUser);
    Date date = new Date();
    Calendar cal = Calendar.getInstance();
    GregorianCalendar cal121 = new GregorianCalendar();
    cal121.setTime(date);// w w w .  j  a v  a 2 s . c  o  m
    cal121.add(Calendar.DATE, 3);
    Date days3 = cal121.getTime();

    String year = Integer.toString(cal.get(Calendar.YEAR));
    String month = Integer.toString(cal.get(Calendar.MONTH) + 1);
    String day = Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
    String hour = Integer.toString(cal.get(Calendar.HOUR_OF_DAY));
    String minute = Integer.toString(cal.get(Calendar.MINUTE));

    String sql = "";
    if (onlyUser == null) {
        onlyUser = "";
    }
    if (onlyUser.equals(null) | onlyUser.length() < 4) {
        sql = "select * from " + Username.getcompany() + ".tasks where (startdate > '" + year + "/" + month
                + "/" + day + " " + hour + ":" + minute
                + ":00') and ( recur = '0') and (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL))) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL)))) and (taskstat <> 'Completed')";
    } else {
        sql = "select * from " + Username.getcompany() + ".tasks where (startdate > '" + year + "/" + month
                + "/" + day + " " + hour + ":" + minute
                + ":00') and ( recur = '0') and (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL))) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL))) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL))) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL))) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL))) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL))) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL))) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL))) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL))) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL))) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL))) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL))) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL))) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL))) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL)))) and (taskstat <> 'Completed') and (taskfrom = '"
                + onlyUser + "')";
    }
    PreparedStatement pstm = conn.prepareStatement(sql);
    pstm.setString(1, Username.getUserName());
    pstm.setString(2, Username.getUserName());
    pstm.setString(3, Username.getUserName());
    pstm.setString(4, Username.getUserName());
    pstm.setString(5, Username.getUserName());
    pstm.setString(6, Username.getUserName());
    pstm.setString(7, Username.getUserName());
    pstm.setString(8, Username.getUserName());
    pstm.setString(9, Username.getUserName());
    pstm.setString(10, Username.getUserName());
    pstm.setString(11, Username.getUserName());
    pstm.setString(12, Username.getUserName());
    pstm.setString(13, Username.getUserName());
    pstm.setString(14, Username.getUserName());
    pstm.setString(15, Username.getUserName());

    ResultSet rs = pstm.executeQuery();
    ArrayList<Tasks> list = new ArrayList<Tasks>();
    while (rs.next()) {
        Date date1 = new Date();
        Calendar cal1 = new GregorianCalendar();
        if (rs.getTimestamp("revdate") == null) {
            cal1.setTime(rs.getTimestamp("startdate"));
        } else {
            cal1.setTime(rs.getTimestamp("revdate"));
        }
        String year1 = Integer.toString(cal1.get(Calendar.YEAR));
        String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1);
        String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH));
        String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY));
        String minute1 = Integer.toString(cal1.get(Calendar.MINUTE));
        if (hour1.length() == 1) {
            hour1 = "0" + hour1;
        }
        if (minute1.length() == 1) {
            minute1 = "0" + minute1;
        }
        if (month1.length() == 1) {
            month1 = "0" + month1;
        }
        if (day1.length() == 1) {
            day1 = "0" + day1;
        }
        Date date2 = new Date();
        Calendar cal2 = new GregorianCalendar();

        cal2.setTime(rs.getTimestamp("enddate"));
        String year2 = Integer.toString(cal2.get(Calendar.YEAR));
        String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1);
        String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH));
        String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY));
        String minute2 = Integer.toString(cal2.get(Calendar.MINUTE));
        if (hour2.length() == 1) {
            hour2 = "0" + hour2;
        }
        if (minute2.length() == 1) {
            minute2 = "0" + minute2;
        }
        if (month2.length() == 1) {
            month2 = "0" + month2;
        }
        if (day2.length() == 1) {
            day2 = "0" + day2;
        }
        Date date3 = new Date();
        Calendar cal3 = new GregorianCalendar();

        cal3.setTime(rs.getTimestamp("startdate"));
        String year3 = Integer.toString(cal3.get(Calendar.YEAR));
        String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1);
        String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH));
        String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY));
        String minute3 = Integer.toString(cal3.get(Calendar.MINUTE));
        if (hour3.length() == 1) {
            hour3 = "0" + hour3;
        }
        if (minute3.length() == 1) {
            minute3 = "0" + minute3;
        }
        if (month3.length() == 1) {
            month3 = "0" + month3;
        }
        if (day3.length() == 1) {
            day3 = "0" + day3;
        }
        String tranid = rs.getString("tranid");
        String taskfrom = rs.getString("taskfrom");
        String description = rs.getString("description");
        String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1;
        String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2;
        String taskstat;
        if (rs.getString("taskstat") == null) {
            taskstat = "Not Started";
        } else {
            taskstat = rs.getString("taskstat");
        }
        //String taskstat = rs.getString("taskstat");
        String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3;
        Tasks task = new Tasks();
        task.setTranid(tranid);
        task.setTaskfrom(taskfrom);
        task.setDescription(description);
        task.setRevdate(revdate);
        task.setEnddate(enddate);
        task.setTaskstat(taskstat);
        task.setStartdate(startdate);
        String color1 = "";
        if (date.after(rs.getTimestamp("revdate"))) {
            color1 = "red";
        }
        if (color1 == "" && days3.after(rs.getTimestamp("revdate"))) {
            color1 = "orange";
        }
        if (color1 == "") {
            color1 = "green";
        }
        task.setlinkup1(color1);
        String color2 = "black";
        if ((Username.equals(rs.getString("taskto1")) && (!"Y".equals(rs.getString("newt1"))))
                || (Username.equals(rs.getString("taskto2")) && (!"Y".equals(rs.getString("newt2"))))
                || (Username.equals(rs.getString("taskto3")) && (!"Y".equals(rs.getString("newt3"))))
                || (Username.equals(rs.getString("taskto4")) && (!"Y".equals(rs.getString("newt4"))))
                || (Username.equals(rs.getString("taskto5")) && (!"Y".equals(rs.getString("newt5"))))
                || (Username.equals(rs.getString("taskto6")) && (!"Y".equals(rs.getString("newt6"))))
                || (Username.equals(rs.getString("taskto7")) && (!"Y".equals(rs.getString("newt7"))))
                || (Username.equals(rs.getString("taskto8")) && (!"Y".equals(rs.getString("newt8"))))
                || (Username.equals(rs.getString("taskto9")) && (!"Y".equals(rs.getString("newt9"))))
                || (Username.equals(rs.getString("taskto10")) && (!"Y".equals(rs.getString("newt10"))))
                || (Username.equals(rs.getString("taskto11")) && (!"Y".equals(rs.getString("newt11"))))
                || (Username.equals(rs.getString("taskto12")) && (!"Y".equals(rs.getString("newt12"))))
                || (Username.equals(rs.getString("taskto13")) && (!"Y".equals(rs.getString("newt13"))))
                || (Username.equals(rs.getString("taskto14")) && (!"Y".equals(rs.getString("newt14"))))
                || (Username.equals(rs.getString("taskto15")) && (!"Y".equals(rs.getString("newt15"))))) {
            color2 = "green";
        }
        task.setlinkup2(color2);

        list.add(task);

    }
    String sql1 = "";
    if (onlyUser == null) {
        onlyUser = "";
    }
    if (onlyUser.equals(null) | onlyUser.length() < 4) {
        sql1 = "select * from " + Username.getcompany()
                + ".tasks where (recur =1) and (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL)) and (RECURDATE1 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate1 < enddate)) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL)) and (RECURDATE2 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate2 < enddate)) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL)) and (RECURDATE3 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate3 < enddate)) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL)) and (RECURDATE4 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate4 < enddate)) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL)) and (RECURDATE5 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate5 < enddate)) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL)) and (RECURDATE6 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate6 < enddate)) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL)) and (RECURDATE7 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate7 < enddate)) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL)) and (RECURDATE8 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate8 < enddate)) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL)) and (RECURDATE9 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate9 < enddate)) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL)) and (RECURDATE11 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate11 < enddate)) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL)) and (RECURDATE12 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate12 < enddate)) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL)) and (RECURDATE13 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate13 < enddate)) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL)) and (RECURDATE14 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate14 < enddate)) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL)) and (RECURDATE15 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate15 < enddate)) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL)) and (RECURDATE10 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate10 < enddate)))";
    } else {
        sql1 = "select * from " + Username.getcompany()
                + ".tasks where (recur =1) and (((taskto1 = ?) and ((taskstat1 <> 'Completed') or (taskstat1 is NULL)) and (RECURDATE1 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate1 < enddate)) or ((taskto2 = ?) and ((taskstat2 <> 'Completed') or (taskstat2 is NULL)) and (RECURDATE2 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate2 < enddate)) or ((taskto3 = ?) and ((taskstat3 <> 'Completed') or (taskstat3 is NULL)) and (RECURDATE3 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate3 < enddate)) or ((taskto4 = ?) and ((taskstat4 <> 'Completed') or (taskstat4 is NULL)) and (RECURDATE4 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate4 < enddate)) or ((taskto5 = ?) and ((taskstat5 <> 'Completed') or (taskstat5 is NULL)) and (RECURDATE5 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate5 < enddate)) or ((taskto6 = ?) and ((taskstat6 <> 'Completed') or (taskstat6 is NULL)) and (RECURDATE6 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate6 < enddate)) or ((taskto7 = ?) and ((taskstat7 <> 'Completed') or (taskstat7 is NULL)) and (RECURDATE7 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate7 < enddate)) or ((taskto8 = ?) and ((taskstat8 <> 'Completed') or (taskstat8 is NULL)) and (RECURDATE8 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate8 < enddate)) or ((taskto9 = ?) and ((taskstat9 <> 'Completed') or (taskstat9 is NULL)) and (RECURDATE9 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate9 < enddate)) or ((taskto11 = ?) and ((taskstat11 <> 'Completed') or (taskstat11 is NULL)) and (RECURDATE11 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate11 < enddate)) or ((taskto12 = ?) and ((taskstat12 <> 'Completed') or (taskstat12 is NULL)) and (RECURDATE12 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate12 < enddate)) or ((taskto13 = ?) and ((taskstat13 <> 'Completed') or (taskstat13 is NULL)) and (RECURDATE13 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate13 < enddate)) or ((taskto14 = ?) and ((taskstat14 <> 'Completed') or (taskstat14 is NULL)) and (RECURDATE14 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate14 < enddate)) or ((taskto15 = ?) and ((taskstat15 <> 'Completed') or (taskstat15 is NULL)) and (RECURDATE15 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate15 < enddate)) or ((taskto10 = ?) and ((taskstat10 <> 'Completed') or (taskstat10 is NULL)) and (RECURDATE10 >'"
                + year + "/" + month + "/" + day + " " + hour + ":" + minute
                + ":00') and (recurdate10 < enddate))) and (taskfrom ='" + onlyUser + "')";
    }
    PreparedStatement pstm1 = conn.prepareStatement(sql1);

    pstm1.setString(1, Username.getUserName());
    pstm1.setString(2, Username.getUserName());
    pstm1.setString(3, Username.getUserName());
    pstm1.setString(4, Username.getUserName());
    pstm1.setString(5, Username.getUserName());
    pstm1.setString(6, Username.getUserName());
    pstm1.setString(7, Username.getUserName());
    pstm1.setString(8, Username.getUserName());
    pstm1.setString(9, Username.getUserName());
    pstm1.setString(10, Username.getUserName());
    pstm1.setString(11, Username.getUserName());
    pstm1.setString(12, Username.getUserName());
    pstm1.setString(13, Username.getUserName());
    pstm1.setString(14, Username.getUserName());
    pstm1.setString(15, Username.getUserName());

    ResultSet rs1 = pstm1.executeQuery();

    while (rs1.next()) {
        Date date1 = new Date();
        Calendar cal1 = new GregorianCalendar();
        if (rs1.getTimestamp("revdate") == null) {
            cal1.setTime(rs1.getTimestamp("enddate"));
        } else {
            cal1.setTime(rs1.getTimestamp("revdate"));
        }
        // cal1.setTime(rs1.getTimestamp("revdate"));
        String year1 = Integer.toString(cal1.get(Calendar.YEAR));
        String month1 = Integer.toString(cal1.get(Calendar.MONTH) + 1);
        String day1 = Integer.toString(cal1.get(Calendar.DAY_OF_MONTH));
        String hour1 = Integer.toString(cal1.get(Calendar.HOUR_OF_DAY));
        String minute1 = Integer.toString(cal1.get(Calendar.MINUTE));
        if (hour1.length() == 1) {
            hour1 = "0" + hour1;
        }
        if (minute1.length() == 1) {
            minute1 = "0" + minute1;
        }
        if (month1.length() == 1) {
            month1 = "0" + month1;
        }
        if (day1.length() == 1) {
            day1 = "0" + day1;
        }
        Date date2 = new Date();
        Calendar cal2 = new GregorianCalendar();

        cal2.setTime(rs1.getTimestamp("enddate"));
        String year2 = Integer.toString(cal2.get(Calendar.YEAR));
        String month2 = Integer.toString(cal2.get(Calendar.MONTH) + 1);
        String day2 = Integer.toString(cal2.get(Calendar.DAY_OF_MONTH));
        String hour2 = Integer.toString(cal2.get(Calendar.HOUR_OF_DAY));
        String minute2 = Integer.toString(cal2.get(Calendar.MINUTE));
        if (hour2.length() == 1) {
            hour2 = "0" + hour2;
        }
        if (minute2.length() == 1) {
            minute2 = "0" + minute2;
        }
        if (month2.length() == 1) {
            month2 = "0" + month2;
        }
        if (day2.length() == 1) {
            day2 = "0" + day2;
        }
        Date date3 = new Date();
        Calendar cal3 = new GregorianCalendar();

        cal3.setTime(rs1.getTimestamp("startdate"));
        String year3 = Integer.toString(cal3.get(Calendar.YEAR));
        String month3 = Integer.toString(cal3.get(Calendar.MONTH) + 1);
        String day3 = Integer.toString(cal3.get(Calendar.DAY_OF_MONTH));
        String hour3 = Integer.toString(cal3.get(Calendar.HOUR_OF_DAY));
        String minute3 = Integer.toString(cal3.get(Calendar.MINUTE));
        if (hour3.length() == 1) {
            hour3 = "0" + hour3;
        }
        if (minute3.length() == 1) {
            minute3 = "0" + minute3;
        }
        if (month3.length() == 1) {
            month3 = "0" + month3;
        }
        if (day3.length() == 1) {
            day3 = "0" + day3;
        }
        String tranid = rs1.getString("tranid");
        String taskfrom = rs1.getString("taskfrom");
        String description = rs1.getString("description");
        String revdate = year1 + "-" + month1 + "-" + day1 + " " + hour1 + ":" + minute1;
        String enddate = year2 + "-" + month2 + "-" + day2 + " " + hour2 + ":" + minute2;
        String taskstat;
        if (rs1.getString("taskstat") == null) {
            taskstat = "Not Started";
        } else {
            taskstat = rs1.getString("taskstat");
        }
        //String taskstat = rs1.getString("taskstat");
        String startdate = year3 + "-" + month3 + "-" + day3 + " " + hour3 + ":" + minute3;
        Tasks task = new Tasks();
        task.setTranid(tranid);
        task.setTaskfrom(taskfrom);
        task.setDescription(description);
        task.setRevdate(revdate);
        task.setEnddate(enddate);
        task.setTaskstat(taskstat);
        task.setStartdate(startdate);
        String color1 = "";
        if (date.after(rs1.getTimestamp("revdate"))) {
            color1 = "red";
        }
        if (color1 == "" && days3.after(rs1.getTimestamp("revdate"))) {
            color1 = "orange";
        }
        if (color1 == "") {
            color1 = "green";
        }
        task.setlinkup1(color1);

        String color2 = "black";
        if ((Username.equals(rs1.getString("taskto1")) && (!"Y".equals(rs1.getString("newt1"))))
                || (Username.equals(rs1.getString("taskto2")) && (!"Y".equals(rs1.getString("newt2"))))
                || (Username.equals(rs1.getString("taskto3")) && (!"Y".equals(rs1.getString("newt3"))))
                || (Username.equals(rs1.getString("taskto4")) && (!"Y".equals(rs1.getString("newt4"))))
                || (Username.equals(rs1.getString("taskto5")) && (!"Y".equals(rs1.getString("newt5"))))
                || (Username.equals(rs1.getString("taskto6")) && (!"Y".equals(rs1.getString("newt6"))))
                || (Username.equals(rs1.getString("taskto7")) && (!"Y".equals(rs1.getString("newt7"))))
                || (Username.equals(rs1.getString("taskto8")) && (!"Y".equals(rs1.getString("newt8"))))
                || (Username.equals(rs1.getString("taskto9")) && (!"Y".equals(rs1.getString("newt9"))))
                || (Username.equals(rs1.getString("taskto10")) && (!"Y".equals(rs1.getString("newt10"))))
                || (Username.equals(rs1.getString("taskto11")) && (!"Y".equals(rs1.getString("newt11"))))
                || (Username.equals(rs1.getString("taskto12")) && (!"Y".equals(rs1.getString("newt12"))))
                || (Username.equals(rs1.getString("taskto13")) && (!"Y".equals(rs1.getString("newt13"))))
                || (Username.equals(rs1.getString("taskto14")) && (!"Y".equals(rs1.getString("newt14"))))
                || (Username.equals(rs1.getString("taskto15")) && (!"Y".equals(rs1.getString("newt15"))))) {
            color2 = "green";
        }
        task.setlinkup2(color2);

        list.add(task);

    }

    return list;
}

From source file:org.redis.shop.test.InitData.java

@Test
public void br_addStockRemoval() {
    List<Category> categories = categoryService.getByProperty(categoryService.getAll(), "level", 3);
    List<Center> centers = centerService.getAll();
    List<Enterprise> enterprises = enterpriseService.getAll();

    GregorianCalendar cal = new GregorianCalendar();

    for (int i = 0; i < categories.size(); i++) {
        cal.setTime(new Date());
        cal.add(Calendar.DATE, 0 - i);
        for (int j = 0; j < centers.size(); j++) {
            for (int k = 0; k < enterprises.size(); k++) {
                StockRemoval stockRemoval = new StockRemoval();
                stockRemoval.setCategory(categories.get(i));
                stockRemoval.setCenter(centers.get(j));
                stockRemoval.setEnterprise(enterprises.get(k));
                stockRemoval.setInTime(cal.getTime());
                stockRemoval.setOutTime(cal.getTime());
                stockRemoval.setPrice(i * j * k + 1);
                stockRemoval.setWeight((i * j * k + 1) * 2);
                stockRemoval.setState(Enum_Transaction.CL);
                stockRemovalService.save(stockRemoval);
            }//from  www  .j  a va 2 s  .com
        }
    }

}

From source file:org.redis.shop.test.InitData.java

@Test
public void bm_addSaleInfo() throws Exception {
    List<Category> categories = categoryService.getByBasicProperty(categoryService.getAll(), "level", 3);
    categories = categoryService.getByPropertyNotNull(categories, "parentCategory");
    User user = userService.get("name", "c1");
    Center center = centerService.get("user.userId", user.getUserId());

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date parse = sdf.parse("2015-11-01");

    Date today = new Date();
    today = sdf.parse(sdf.format(today));

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(parse);//from ww  w. ja v  a2  s.com
    long time1 = calendar.getTimeInMillis();
    calendar.setTime(today);
    long time2 = calendar.getTimeInMillis();
    long betweenDays = (time2 - time1) / (1000 * 3600 * 24);

    GregorianCalendar cal = new GregorianCalendar();
    List<SaleInfo> saleInfos = new ArrayList<SaleInfo>();
    for (int i = 0; i <= betweenDays; i++) {
        cal.setTime(parse);
        cal.add(Calendar.DATE, i);
        Date dateNow = cal.getTime();
        cal.add(Calendar.DAY_OF_MONTH, 7);
        Date endDate = cal.getTime();

        for (Category category : categories) {
            SaleInfo si = new SaleInfo();
            si.setCategory(category);
            si.setCenter(center);
            si.setStartDate(dateNow);
            si.setPerson("cwj");
            si.setPhone("123456789");
            si.setEndDate(endDate);
            si.setTitle("?" + category.getName());
            si.setPrice(DataUtil.getRandm(20, 25));
            si.setWeight((double) DataUtil.getRandm(200, 209));
            System.out.println(si.getPrice());
            System.out.println(si.getWeight());
            si.setUnit("?");
            si.setState(Enum_sale.D);
            si.setOutTime(dateNow);
            //            saleInfoService.save(si);
            saleInfos.add(si);
        }
    }
    saleInfoService.save(saleInfos);
}

From source file:com.lp.server.auftrag.ejbfac.AuftragFacBean.java

/**
 * Methode zum Erzeugen eines neues Auftrags als Kopie eines bestehenden
 * Auftrags. <br>/*  www  .  j  a  v a  2 s  . co m*/
 * Es werden auch die Positionen kopiert.
 * 
 * @param iIdAuftragI
 *            PK des bestehenden Auftrags
 * @param theClientDto
 *            der aktuelle Benutzer
 * @return Integer PK des neuen Auftrags
 * @throws EJBExceptionLP
 *             Ausnahme
 */
public Integer erzeugeAuftragAusAuftrag(Integer iIdAuftragI, TheClientDto theClientDto) throws EJBExceptionLP {
    checkAuftragIId(iIdAuftragI);
    AuftragDto auftragBasisDto = getAuftragFac().auftragFindByPrimaryKey(iIdAuftragI);

    Integer iIdAuftragKopie = null;

    try {
        GregorianCalendar calendar = new GregorianCalendar();
        AuftragDto auftragDto = (AuftragDto) auftragBasisDto.clone();

        auftragDto.setFWechselkursmandantwaehrungzubelegwaehrung(
                new Double(getLocaleFac().getWechselkurs2(theClientDto.getSMandantenwaehrung(),
                        auftragDto.getCAuftragswaehrung(), theClientDto).doubleValue()));

        ParametermandantDto parametermandantLieferzeitDto = getParameterFac().getMandantparameter(
                theClientDto.getMandant(), ParameterFac.KATEGORIE_AUFTRAG,
                ParameterFac.PARAMETER_DEFAULT_LIEFERZEIT_AUFTRAG);
        int defaultLieferzeitAuftrag = ((Integer) parametermandantLieferzeitDto.getCWertAsObject()).intValue();

        calendar = new GregorianCalendar();
        calendar.add(Calendar.DATE, defaultLieferzeitAuftrag);
        Timestamp aktuelleDatumPlusLieferZeit = new Timestamp(calendar.getTimeInMillis());

        ParametermandantDto parametermandantLieferdatumDto = getParameterFac().getMandantparameter(
                theClientDto.getMandant(), ParameterFac.KATEGORIE_AUFTRAG,
                ParameterFac.PARAMETER_AUFTRAG_KOPIEREN_LIEFERDATUM_UEBERNEHMEN);
        if ((Boolean) parametermandantLieferdatumDto.getCWertAsObject()) {
            auftragDto.setDLiefertermin(auftragBasisDto.getDLiefertermin());
            auftragDto.setDFinaltermin(auftragBasisDto.getDLiefertermin());
        } else {
            auftragDto.setDLiefertermin(aktuelleDatumPlusLieferZeit);
            auftragDto.setDFinaltermin(aktuelleDatumPlusLieferZeit);
        }
        auftragDto.setDBestelldatum(new java.sql.Timestamp(System.currentTimeMillis()));

        iIdAuftragKopie = createAuftrag(auftragDto, theClientDto);

        // PJ 15507 Auftragdokumente kopieren
        AuftragauftragdokumentDto[] auftragauftragdokumentDtos = getAuftragServiceFac()
                .auftragauftragdokumentFindByAuftragIId(iIdAuftragI);
        if (auftragauftragdokumentDtos != null && auftragauftragdokumentDtos.length > 0) {
            ArrayList<AuftragdokumentDto> al = new ArrayList<AuftragdokumentDto>();

            for (int i = 0; i < auftragauftragdokumentDtos.length; i++) {
                AuftragdokumentDto dto = new AuftragdokumentDto();
                dto.setIId(auftragauftragdokumentDtos[i].getAuftragdokumentIId());

                al.add(dto);
            }

            getAuftragServiceFac().updateAuftragdokumente(iIdAuftragKopie, al);

        }

        // alle Positionen kopieren
        AuftragpositionDto[] aAuftragpositionBasis = getAuftragpositionFac()
                .auftragpositionFindByAuftrag(iIdAuftragI);
        Integer positionIId = null;
        Integer positionIIdSet = null;
        for (int i = 0; i < aAuftragpositionBasis.length; i++) {
            AuftragpositionDto auftragpositionDto = (AuftragpositionDto) aAuftragpositionBasis[i].clone();

            if (auftragBasisDto.getAuftragartCNr().equals(AuftragServiceFac.AUFTRAGART_ABRUF)) {
                auftragpositionDto.setAuftragpositionIIdRahmenposition(
                        aAuftragpositionBasis[i].getAuftragpositionIIdRahmenposition());
            }

            // Wenn sich sie MWST seither geaendert hat
            if (auftragpositionDto.getMwstsatzIId() != null) {
                MwstsatzDto mwstsatzDto = getMandantFac()
                        .mwstsatzFindByPrimaryKey(auftragpositionDto.getMwstsatzIId(), theClientDto);

                mwstsatzDto = getMandantFac().mwstsatzFindByMwstsatzbezIIdAktuellster(
                        mwstsatzDto.getIIMwstsatzbezId(), theClientDto);
                BigDecimal mwstBetrag = Helper.getProzentWert(auftragpositionDto.getNNettoeinzelpreis(),
                        new BigDecimal(mwstsatzDto.getFMwstsatz()), 4);
                auftragpositionDto.setMwstsatzIId(mwstsatzDto.getIId());
                auftragpositionDto.setNMwstbetrag(mwstBetrag);
                auftragpositionDto
                        .setNBruttoeinzelpreis(auftragpositionDto.getNNettoeinzelpreis().add(mwstBetrag));
            }

            if (aAuftragpositionBasis[i].getPositioniIdArtikelset() != null) {
                auftragpositionDto.setPositioniIdArtikelset(positionIIdSet);
            }
            auftragpositionDto.setBelegIId(iIdAuftragKopie);
            if ((Boolean) parametermandantLieferdatumDto.getCWertAsObject()) {
                auftragpositionDto.setTUebersteuerbarerLiefertermin(auftragBasisDto.getDLiefertermin());
            } else {
                auftragpositionDto.setTUebersteuerbarerLiefertermin(aktuelleDatumPlusLieferZeit);
            }
            if (auftragpositionDto.getTypCNr() != null) {

                if (auftragpositionDto.isPosition()) {
                    if (auftragpositionDto.getCZusatzbez().equals(LocaleFac.POSITIONBEZ_BEGINN)) {
                        positionIId = getAuftragpositionFac().createAuftragposition(auftragpositionDto, false,
                                theClientDto);
                    } else if (auftragpositionDto.getCZusatzbez().equals(LocaleFac.POSITIONBEZ_ENDE)) {
                        getAuftragpositionFac().createAuftragposition(auftragpositionDto, false, theClientDto);
                    }
                } else {
                    auftragpositionDto.setPositioniId(positionIId);
                    getAuftragpositionFac().createAuftragposition(auftragpositionDto, false, theClientDto);
                }
            } else {
                if (aAuftragpositionBasis[i].isIntelligenteZwischensumme()) {
                    Integer von = getAuftragpositionFac()
                            .getPositionNummer(aAuftragpositionBasis[i].getZwsVonPosition());
                    auftragpositionDto.setZwsVonPosition(
                            getAuftragpositionFac().getPositionIIdFromPositionNummer(iIdAuftragKopie, von));
                    Integer bis = getAuftragpositionFac()
                            .getPositionNummer(aAuftragpositionBasis[i].getZwsBisPosition());
                    auftragpositionDto.setZwsBisPosition(
                            getAuftragpositionFac().getPositionIIdFromPositionNummer(iIdAuftragKopie, bis));
                }

                if (auftragpositionDto.getPositioniIdArtikelset() == null) {
                    positionIIdSet = getAuftragpositionFac().createAuftragposition(auftragpositionDto, false,
                            theClientDto);
                } else {
                    getAuftragpositionFac().createAuftragposition(auftragpositionDto, false, theClientDto);
                }
            }
        }
        // kopieren der Auftrageigenschaften
        PaneldatenDto[] aPaneldatenDtoBasis = getPanelFac()
                .paneldatenFindByPanelCNrCKey(PanelFac.PANEL_AUFTRAGSEIGENSCHAFTEN, iIdAuftragI.toString());

        PaneldatenDto[] datenKorrigiert = new PaneldatenDto[aPaneldatenDtoBasis.length];

        for (int y = 0; y < aPaneldatenDtoBasis.length; y++) {
            PaneldatenDto paneldatenDto = (PaneldatenDto) aPaneldatenDtoBasis[y].clone();
            paneldatenDto.setCKey(iIdAuftragKopie.toString());
            datenKorrigiert[y] = paneldatenDto;

        }

        if (datenKorrigiert != null) {
            getPanelFac().createPaneldaten(datenKorrigiert);
        }

        myLogger.exit("Der Auftrag wurde mit " + aAuftragpositionBasis.length + " Positionen erzeugt.");
    } catch (RemoteException ex) {
        throwEJBExceptionLPRespectOld(ex);
    }

    return iIdAuftragKopie;
}

From source file:ucar.unidata.data.storm.AtcfStormDataSource.java

/**
 * _more_/*from   w  ww .  j a  v  a  2  s.  co  m*/
 *
 * @param stormInfo _more_
 * @param tracks _more_
 * @param trackFile _more_
 * @param waysToUse _more_
 * @param throwError _more_
 *
 *
 * @return _more_
 * @throws Exception _more_
 */
private boolean readTracks(StormInfo stormInfo, StormTrackCollection tracks, String trackFile,
        Hashtable<String, Boolean> waysToUse, boolean throwError) throws Exception {

    long t1 = System.currentTimeMillis();
    byte[] bytes = readFile(trackFile, true);
    long t2 = System.currentTimeMillis();
    //        System.err.println("read time:" + (t2 - t1));
    boolean isZip = trackFile.endsWith(".gz");
    if ((bytes == null) && isZip) {
        String withoutGZ = trackFile.substring(0, trackFile.length() - 3);
        bytes = readFile(withoutGZ, true);
        isZip = false;
    }

    if (bytes == null) {
        if (throwError) {
            throw new BadDataException("Unable to read track file:" + trackFile);
        }
        return false;
    }

    if (isZip) {
        GZIPInputStream zin = new GZIPInputStream(new ByteArrayInputStream(bytes));
        bytes = IOUtil.readBytes(zin);
        zin.close();
    }
    GregorianCalendar convertCal = new GregorianCalendar(DateUtil.TIMEZONE_GMT);
    convertCal.clear();

    String trackData = new String(bytes);
    List lines = StringUtil.split(trackData, "\n", true, true);
    SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHH");
    fmt.setTimeZone(TimeZone.getTimeZone("UTC"));
    Hashtable trackMap = new Hashtable();
    Real altReal = new Real(RealType.Altitude, 0);
    //        System.err.println("obs:" + lines.size());
    /*        Hashtable okWays = new Hashtable();
    okWays.put(WAY_CARQ, "");
    okWays.put(WAY_WRNG, "");
    okWays.put(WAY_BEST, "");
    okWays.put("ETA", "");
    okWays.put("NGX", "");
    okWays.put("BAMS", "");*/
    Hashtable seenDate = new Hashtable();
    initParams();
    int xcnt = 0;
    // check if the tech num is included
    // some actf files do not have tech num for some reasom.
    List toks1 = StringUtil.split(lines.get(1), ",", true);
    String techNum = (String) toks1.get(IDX_TECHNUM);
    if (techNum.length() > 0 && !techNum.matches("\\d+")) {
        IDX_TECH = IDX_TECH - 1;
        IDX_TAU = IDX_TAU - 1;
        IDX_LAT = IDX_LAT - 1;
        IDX_LON = IDX_LON - 1;
        IDX_VMAX = IDX_VMAX - 1;
        IDX_MSLP = IDX_MSLP - 1;
        IDX_TY = IDX_TY - 1;
    }
    for (int i = 0; i < lines.size(); i++) {
        String line = (String) lines.get(i);
        if (i == 0) {
            //                System.err.println(line);
        }
        List toks = StringUtil.split(line, ",", true);
        /*            System.err.println(toks.size() + " " + BASEIDX);
        if(toks.size()<BASEIDX-1) {
        System.err.println("bad line:" + line);
        continue;
        } else {
        System.err.println("good line:" + line);
        }
        */

        //BASIN,CY,YYYYMMDDHH,TECHNUM,TECH,TAU,LatN/S,LonE/W,VMAX,MSLP,TY,RAD,WINDCODE,RAD1,RAD2,RAD3,RAD4,RADP,RRP,MRD,GUSTS,EYE,SUBREGION,MAXSEAS,INITIALS,DIR,SPEED,STORMNAME,DEPTH,SEAS,SEASCODE,SEAS1,SEAS2,SEAS3,SEAS4
        //AL, 01, 2007050612,   , BEST,   0, 355N,  740W,  35, 1012, EX,  34, NEQ,    0,    0,    0,  120, 
        //AL, 01, 2007050812, 01, CARQ, -24, 316N,  723W,  55,    0, DB,  34, AAA,    0,    0,    0,    0, 

        String dateString = (String) toks.get(IDX_YYYYMMDDHH);
        String wayString = (String) toks.get(IDX_TECH);
        //            if (okWays.get(wayString) == null) {
        //                continue;
        //            }
        boolean isBest = wayString.equals(WAY_BEST);
        boolean isWarning = wayString.equals(WAY_WRNG);
        boolean isCarq = wayString.equals(WAY_CARQ);

        int category = ((IDX_TY < toks.size()) ? getCategory((String) toks.get(IDX_TY)) : CATEGORY_XX);
        if (category != CATEGORY_XX) {
            //                System.err.println("cat:" + category);
        }

        String fhour = (String) toks.get(IDX_TAU);
        int forecastHour = new Integer(fhour).intValue();
        //A hack - we've seen some atfc files that have a 5 character forecast hour
        //right padded with "00", eg., 01200
        if ((fhour.length() == 5) && (forecastHour > 100)) {
            forecastHour = forecastHour / 100;
        }

        if (isWarning || isCarq) {
            forecastHour = -forecastHour;
        }

        //Check for unique dates for this way
        String dttmkey = wayString + "_" + dateString + "_" + forecastHour;
        if (seenDate.get(dttmkey) != null) {
            continue;
        }
        seenDate.put(dttmkey, dttmkey);

        Date dttm = fmt.parse(dateString);
        convertCal.setTime(dttm);
        String key;
        Way way = getWay(wayString, null);
        if (!isBest && (waysToUse != null) && (waysToUse.size() > 0) && (waysToUse.get(wayString) == null)) {
            continue;
        }

        if (isBest) {
            key = wayString;
        } else {
            key = wayString + "_" + dateString;
            convertCal.add(Calendar.HOUR_OF_DAY, forecastHour);
        }
        dttm = convertCal.getTime();
        StormTrack track = (StormTrack) trackMap.get(key);
        if (track == null) {
            way = (isBest ? Way.OBSERVATION : way);
            track = new StormTrack(stormInfo, addWay(way), new DateTime(dttm), obsParams);
            trackMap.put(key, track);
            tracks.addTrack(track);
        }
        String latString = (String) toks.get(IDX_LAT);
        String lonString = (String) toks.get(IDX_LON);
        String t = latString + " " + lonString;

        boolean south = latString.endsWith("S");
        boolean west = lonString.endsWith("W");
        double latitude = Double.parseDouble(latString.substring(0, latString.length() - 1)) / 10.0;
        double longitude = Double.parseDouble(lonString.substring(0, lonString.length() - 1)) / 10.0;
        if (south) {
            latitude = -latitude;
        }
        if (west) {
            longitude = -longitude;
        }

        EarthLocation elt = new EarthLocationLite(new Real(RealType.Latitude, latitude),
                new Real(RealType.Longitude, longitude), altReal);

        List<Real> attributes = new ArrayList<Real>();

        double windspeed = ((IDX_VMAX < toks.size()) ? getDouble((String) toks.get(IDX_VMAX)) : Double.NaN);
        double pressure = ((IDX_MSLP < toks.size()) ? getDouble((String) toks.get(IDX_MSLP)) : Double.NaN);
        attributes.add(PARAM_STORMCATEGORY.getReal((double) category));
        attributes.add(PARAM_MINPRESSURE.getReal(pressure));
        attributes.add(PARAM_MAXWINDSPEED_KTS.getReal(windspeed));

        StormTrackPoint stp = new StormTrackPoint(elt, new DateTime(dttm), forecastHour, attributes);

        track.addPoint(stp);
    }
    return true;
}

From source file:org.redis.shop.test.InitData.java

@Test
public void ay_addPrice() throws Exception {
    List<Center> centers = centerService.getAll();
    //      List<Center> centers1 = centerService.getByProperty(
    //            centerService.getAll(), "name", "????");

    List<Category> categorys = categoryService.getByBasicProperty(categoryService.getAll(), "level", 2);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    Date parse = sdf.parse("2014-11-01");

    Date today = new Date();
    today = sdf.parse(sdf.format(today));

    Calendar calendar = Calendar.getInstance();
    calendar.setTime(parse);/*from   w  w w.j a  va2 s.c o  m*/
    long time1 = calendar.getTimeInMillis();
    calendar.setTime(today);
    long time2 = calendar.getTimeInMillis();
    long betweenDays = (time2 - time1) / (1000 * 3600 * 24);

    GregorianCalendar cal = new GregorianCalendar();
    List<Price> prices = new ArrayList<Price>();
    for (int i = 0; i <= betweenDays; i++) {
        for (Center center : centers) {

            for (Category category : categorys) {
                cal.setTime(parse);
                cal.add(Calendar.DATE, i);
                Date dateNow = cal.getTime();

                Price price = new Price();
                price.setCreateDate(dateNow);
                price.setUpdateDate(dateNow);
                price.setCreator("jack");
                price.setSite(null);
                price.setUnit("?");
                price.setCenter(center);
                price.setCategory(category);
                price.setIsNewest("0");
                if (i == betweenDays) {

                    price.setIsNewest("1");
                }
                price.setIsGuidencePrice("1");//?
                price.setPrice(DataUtil.getRandm(100, 500));
                prices.add(price);
                //               priceService.save(price);
            }
        }
    }
    priceService.save(prices);

    centers = centerService.getByProperty(centerService.getAll(), "name",
            "????1");
    for (int i = 0; i <= 10; i++) {
        for (Category category : categorys) {
            Price price = new Price();
            price.setCreateDate(new Date());
            price.setUpdateDate(new Date());
            price.setCreator("jack");
            price.setSite(null);
            price.setUnit("?");
            price.setCenter(centers.get(0));
            price.setIsGuidencePrice("1");//?
            price.setCategory(category);
            price.setIsNewest("0");
            price.setPrice(DataUtil.getRandm(100, 500));
            priceService.save(price);
        }
    }

    List<Category> list = categoryService.getByBasicProperty(categoryService.getAll(), "level", 1);
    List<Site> sites = siteService.getAll();
    for (Site site : sites) {
        for (Category category : list) {
            Price price = new Price();
            price.setCreateDate(new Date());
            price.setUpdateDate(new Date());
            price.setCreator("jack");
            price.setSite(site);
            price.setUnit("?");
            price.setCenter(null);
            price.setCategory(category);
            price.setIsNewest("1");
            price.setIsGuidencePrice("1");//?
            price.setPrice(DataUtil.getRandm(100, 500));
            priceService.save(price);
        }
    }

}

From source file:org.eevolution.form.VSCRP.java

public CategoryDataset createDataset(Timestamp start, MResource r) {
    //System.out.println("Create new data set");
    GregorianCalendar gc1 = new GregorianCalendar();
    gc1.setTimeInMillis(start.getTime());
    gc1.clear(Calendar.MILLISECOND);
    gc1.clear(Calendar.SECOND);/*from w  ww .  java2  s .  c o m*/
    gc1.clear(Calendar.MINUTE);
    gc1.clear(Calendar.HOUR_OF_DAY);

    Timestamp date = start;
    String namecapacity = Msg.translate(Env.getCtx(), "Capacity");
    System.out.println("\n Namecapacity :" + namecapacity);
    String nameload = Msg.translate(Env.getCtx(), "Load");
    System.out.println("\n Nameload :" + nameload);
    String namesummary = Msg.translate(Env.getCtx(), "Summary");
    System.out.println("\n Namesummary :" + namesummary);
    MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null);
    System.out.println("\n Resourcetype " + t);
    int days = 1;
    long hours = 0;

    if (t.isTimeSlot()) {

        hours = MMPCMRP.getHoursAvailable(t.getTimeSlotStart(), t.getTimeSlotEnd());

    } else {
        //fjviejo e-evolution MachineQty
        if (r.getDailyCapacity().multiply(r.getMachineQty()).compareTo(Env.ZERO) != 0)
            hours = r.getDailyCapacity().multiply(r.getMachineQty()).longValue();
        else
            //fjviejo e-evolution end
            hours = 24;
    }
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    //      Long Hours = new Long(hours);                            
    int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ",
            r.getS_Resource_ID());
    MUOM uom = new MUOM(Env.getCtx(), C_UOM_ID, null);
    System.out.println("\n uom1 " + uom + "\n");
    //System.out.println("um.isHour()"+ uom.isHour() );
    if (!uom.isHour()) {
        System.out.println("\n uom2 " + uom + "\n");
        return dataset;
    }
    System.out.println("\n Dataset " + dataset + "\n");
    int summary = 0;
    int secondsAcum = 0;
    long hoursAcum = 0;

    while (days < 29) {
        //System.out.println("Day Number" + days);
        String day = new String(new Integer(date.getDate()).toString());
        System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID());
        System.out.println("Date:" + date);
        int seconds = getLoad(r.getS_Resource_ID(), date, date);
        Long Hours = new Long(hours);
        System.out.println("Summary " + summary);
        System.out.println("Capacity " + hours);
        System.out.println("Load " + seconds);

        /*
        **  Realizo la verificacin sobre que da me encuentro
        **  para graficar cada 7 dias el estado de la semana.
        **
        **  secondsAcum y hoursAcum llevan los acumulados para la semana
        **  los reinicio en cada nueva semana.
        **
        **  VIT4B - 07/12/2006
        */

        if (days == 1 || days == 8 || days == 15 || days == 22) {
            secondsAcum = 0;
            hoursAcum = 0;
        }

        secondsAcum += seconds;
        hoursAcum += hours;

        switch (gc1.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.SUNDAY:
            if (t.isOnSunday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600); //+ (Hours.intValue() - ((seconds / 3600)));
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.MONDAY:
            if (t.isOnMonday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.TUESDAY:
            if (t.isOnTuesday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.WEDNESDAY:
            if (t.isOnWednesday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.THURSDAY:
            if (t.isOnThursday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.FRIDAY:
            if (t.isOnFriday()) {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {

                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        case Calendar.SATURDAY:
            if (t.isOnSaturday()) {
                /*
                                                **  Realizo la verificacin sobre que da me encuentro
                                                **  para graficar cada 7 dias el estado de la semana.
                                                **
                                                **  VIT4B - 07/12/2006
                                                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }

                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            } else {
                /*
                **  Realizo la verificacin sobre que da me encuentro
                **  para graficar cada 7 dias el estado de la semana.
                **
                **  VIT4B - 07/12/2006
                */

                if (days == 7 || days == 14 || days == 21 || days == 28) {
                    dataset.addValue(hoursAcum, namecapacity, day);
                    dataset.addValue(secondsAcum / 3600, nameload, day);
                    dataset.addValue(summary, namesummary, day);

                }
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = new Timestamp(gc1.getTimeInMillis());
                break;
            }
        }

        days++;

    }
    return dataset;
}