Example usage for org.joda.time LocalDate getWeekOfWeekyear

List of usage examples for org.joda.time LocalDate getWeekOfWeekyear

Introduction

In this page you can find the example usage for org.joda.time LocalDate getWeekOfWeekyear.

Prototype

public int getWeekOfWeekyear() 

Source Link

Document

Get the week of weekyear field value.

Usage

From source file:com.axelor.apps.project.service.ProjectPlanningService.java

License:Open Source License

public void getTasksForUser(ActionRequest request, ActionResponse response) {
    List<Map<String, String>> dataList = new ArrayList<Map<String, String>>();
    try {/*w w w .ja v a2  s  .  co  m*/
        LocalDate todayDate = Beans.get(GeneralService.class).getTodayDate();
        List<ProjectPlanningLine> linesList = Beans.get(ProjectPlanningLineRepository.class).all()
                .filter("self.user.id = ?1 AND self.year >= ?2 AND self.week >= ?3",
                        AuthUtils.getUser().getId(), todayDate.getYear(), todayDate.getWeekOfWeekyear())
                .fetch();

        for (ProjectPlanningLine line : linesList) {
            if (line.getMonday().compareTo(BigDecimal.ZERO) != 0) {
                LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek())
                        .withDayOfWeek(DateTimeConstants.MONDAY);
                if (date.isAfter(todayDate) || date.isEqual(todayDate)) {
                    Map<String, String> map = new HashMap<String, String>();
                    map.put("taskId", line.getProjectTask().getId().toString());
                    map.put("name", line.getProjectTask().getFullName());
                    if (line.getProjectTask().getProject() != null) {
                        map.put("projectName", line.getProjectTask().getProject().getFullName());
                    } else {
                        map.put("projectName", "");
                    }
                    map.put("date", date.toString());
                    map.put("duration", line.getMonday().toString());
                    dataList.add(map);
                }
            }
            if (line.getTuesday().compareTo(BigDecimal.ZERO) != 0) {
                LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek())
                        .withDayOfWeek(DateTimeConstants.TUESDAY);
                if (date.isAfter(todayDate) || date.isEqual(todayDate)) {
                    Map<String, String> map = new HashMap<String, String>();
                    map.put("taskId", line.getProjectTask().getId().toString());
                    map.put("name", line.getProjectTask().getFullName());
                    if (line.getProjectTask().getProject() != null) {
                        map.put("projectName", line.getProjectTask().getProject().getFullName());
                    } else {
                        map.put("projectName", "");
                    }
                    map.put("date", date.toString());
                    map.put("duration", line.getTuesday().toString());
                    dataList.add(map);
                }
            }
            if (line.getWednesday().compareTo(BigDecimal.ZERO) != 0) {
                LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek())
                        .withDayOfWeek(DateTimeConstants.WEDNESDAY);
                if (date.isAfter(todayDate) || date.isEqual(todayDate)) {
                    Map<String, String> map = new HashMap<String, String>();
                    map.put("taskId", line.getProjectTask().getId().toString());
                    map.put("name", line.getProjectTask().getFullName());
                    if (line.getProjectTask().getProject() != null) {
                        map.put("projectName", line.getProjectTask().getProject().getFullName());
                    } else {
                        map.put("projectName", "");
                    }
                    map.put("date", date.toString());
                    map.put("duration", line.getWednesday().toString());
                    dataList.add(map);
                }
            }
            if (line.getThursday().compareTo(BigDecimal.ZERO) != 0) {
                LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek())
                        .withDayOfWeek(DateTimeConstants.THURSDAY);
                if (date.isAfter(todayDate) || date.isEqual(todayDate)) {
                    Map<String, String> map = new HashMap<String, String>();
                    map.put("taskId", line.getProjectTask().getId().toString());
                    map.put("name", line.getProjectTask().getFullName());
                    if (line.getProjectTask().getProject() != null) {
                        map.put("projectName", line.getProjectTask().getProject().getFullName());
                    } else {
                        map.put("projectName", "");
                    }
                    map.put("date", date.toString());
                    map.put("duration", line.getThursday().toString());
                    dataList.add(map);
                }
            }
            if (line.getFriday().compareTo(BigDecimal.ZERO) != 0) {
                LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek())
                        .withDayOfWeek(DateTimeConstants.FRIDAY);
                if (date.isAfter(todayDate) || date.isEqual(todayDate)) {
                    Map<String, String> map = new HashMap<String, String>();
                    map.put("taskId", line.getProjectTask().getId().toString());
                    map.put("name", line.getProjectTask().getFullName());
                    if (line.getProjectTask().getProject() != null) {
                        map.put("projectName", line.getProjectTask().getProject().getFullName());
                    } else {
                        map.put("projectName", "");
                    }
                    map.put("date", date.toString());
                    map.put("duration", line.getFriday().toString());
                    dataList.add(map);
                }
            }
            if (line.getSaturday().compareTo(BigDecimal.ZERO) != 0) {
                LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek())
                        .withDayOfWeek(DateTimeConstants.SATURDAY);
                if (date.isAfter(todayDate) || date.isEqual(todayDate)) {
                    Map<String, String> map = new HashMap<String, String>();
                    map.put("taskId", line.getProjectTask().getId().toString());
                    map.put("name", line.getProjectTask().getFullName());
                    if (line.getProjectTask().getProject() != null) {
                        map.put("projectName", line.getProjectTask().getProject().getFullName());
                    } else {
                        map.put("projectName", "");
                    }
                    map.put("date", date.toString());
                    map.put("duration", line.getSaturday().toString());
                    dataList.add(map);
                }
            }
            if (line.getSunday().compareTo(BigDecimal.ZERO) != 0) {
                LocalDate date = new LocalDate().withYear(line.getYear()).withWeekOfWeekyear(line.getWeek())
                        .withDayOfWeek(DateTimeConstants.SUNDAY);
                if (date.isAfter(todayDate) || date.isEqual(todayDate)) {
                    Map<String, String> map = new HashMap<String, String>();
                    map.put("taskId", line.getProjectTask().getId().toString());
                    map.put("name", line.getProjectTask().getFullName());
                    if (line.getProjectTask().getProject() != null) {
                        map.put("projectName", line.getProjectTask().getProject().getFullName());
                    } else {
                        map.put("projectName", "");
                    }
                    map.put("date", date.toString());
                    map.put("duration", line.getSunday().toString());
                    dataList.add(map);
                }
            }
        }
        response.setData(dataList);
    } catch (Exception e) {
        response.setStatus(-1);
        response.setError(e.getMessage());
    }
}

From source file:com.axelor.apps.project.web.ProjectPlanningController.java

License:Open Source License

public void myPlanning(ActionRequest request, ActionResponse response) throws AxelorException {
    LocalDate todayDate = generalService.getTodayDate();
    ProjectPlanning planning = projectPlanningRepo.all()
            .filter("self.year = ?1 AND self.week = ?2", todayDate.getYear(), todayDate.getWeekOfWeekyear())
            .fetchOne();// ww w  . j av  a  2 s .c o m
    if (planning == null) {
        planning = projectPlanningService.createPlanning(todayDate.getYear(), todayDate.getWeekOfWeekyear());
    }
    response.setView(ActionView.define("Week" + planning.getWeek()).model(ProjectPlanning.class.getName())
            .add("form", "project-my-planning-form").param("forceEdit", "true")
            .context("_showRecord", String.valueOf(planning.getId())).context("_type", "user").map());
}

From source file:com.axelor.apps.project.web.ProjectPlanningController.java

License:Open Source License

public void myTeamPlanning(ActionRequest request, ActionResponse response) throws AxelorException {
    LocalDate todayDate = generalService.getTodayDate();
    ProjectPlanning planning = projectPlanningRepo.all()
            .filter("self.year = ?1 AND self.week = ?2", todayDate.getYear(), todayDate.getWeekOfWeekyear())
            .fetchOne();/*w  ww  .j  a v  a 2s.  c  o m*/
    if (planning == null) {
        planning = projectPlanningService.createPlanning(todayDate.getYear(), todayDate.getWeekOfWeekyear());
    }
    response.setView(ActionView.define("Week" + planning.getWeek()).model(ProjectPlanning.class.getName())
            .add("form", "project-my-team-planning-form").param("forceEdit", "true")
            .context("_showRecord", String.valueOf(planning.getId())).context("_type", "team").map());
}

From source file:com.axelor.apps.project.web.ProjectPlanningController.java

License:Open Source License

public void planningCurrentWeek(ActionRequest request, ActionResponse response) throws AxelorException {
    request.getContext().asType(ProjectPlanning.class);
    LocalDate currentDate = generalService.getTodayDate();
    int year = currentDate.getYear();
    int week = currentDate.getWeekOfWeekyear();
    ProjectPlanning planningCurrentWeek = null;

    planningCurrentWeek = projectPlanningRepo.all().filter("self.year = ?1 AND self.week = ?2", year, week)
            .fetchOne();//from   w ww.  ja va 2s  .  co m

    if (planningCurrentWeek == null) {

        planningCurrentWeek = projectPlanningService.createPlanning(year, week);
    }

    String type = request.getContext().get("_type").toString();
    response.setCanClose(true);
    if (type.contentEquals("user")) {
        response.setView(ActionView.define("Week" + planningCurrentWeek.getWeek())
                .model(ProjectPlanning.class.getName()).add("form", "project-my-planning-form")
                .param("forceEdit", "true").context("_showRecord", String.valueOf(planningCurrentWeek.getId()))
                .context("_type", "user").map());
    } else {
        response.setView(ActionView.define("Week" + planningCurrentWeek.getWeek())
                .model(ProjectPlanning.class.getName()).add("form", "project-my-team-planning-form")
                .param("forceEdit", "true").context("_showRecord", String.valueOf(planningCurrentWeek.getId()))
                .context("_type", "team").map());
    }
}

From source file:com.phloc.datetime.PDTUtils.java

License:Apache License

public static boolean isSameYearAndWeek(@Nonnull final LocalDate x, @Nonnull final LocalDate y) {
    return x.getYear() == y.getYear() && x.getWeekOfWeekyear() == y.getWeekOfWeekyear();
}

From source file:ee.ut.soras.ajavtV2.mudel.ajavaljend.arvutus.TimeMLDateTimePoint.java

License:Open Source License

public void seekField(Granulaarsus field, int direction, int soughtValue, boolean excludingCurrent) {
    // ---------------------------------
    //  DAY_OF_MONTH
    // ---------------------------------
    if (field == Granulaarsus.DAY_OF_MONTH && direction != 0 && soughtValue == 0) {
        int dir = (direction > 0) ? (1) : (-1);
        LocalDate ajaFookus = new LocalDate(this.underlyingDate);
        LocalDate nihutatudFookus = ajaFookus.plusDays(1 * dir);
        ajaFookus = nihutatudFookus;//  ww  w .j  a va2s. co m
        this.underlyingDate = ajaFookus;
        updateDateRepresentation(Granulaarsus.DAY_OF_MONTH, null, false, ADD_TYPE_OPERATION);
        functionOtherThanSetUsed = true;
        this.dateModified = true;
    }
    // ---------------------------------
    //  DAY_OF_WEEK
    // ---------------------------------
    if (field == Granulaarsus.DAY_OF_WEEK && soughtValue >= DateTimeConstants.MONDAY
            && soughtValue <= DateTimeConstants.SUNDAY && direction != 0) {
        int dir = (direction > 0) ? (1) : (-1);
        LocalDate ajaFookus = new LocalDate(this.underlyingDate);
        // Algne p2ev ehk p2ev, millest tahame tingimata m66duda
        int algneNadalapaev = (excludingCurrent) ? (ajaFookus.getDayOfWeek()) : (-1);
        if (!excludingCurrent) {
            // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale p2evale            
            ajaFookus = ajaFookus.plusDays(dir * (-1));
        }
        int count = 0;
        while (true) {
            LocalDate nihutatudFookus = ajaFookus.plusDays(1 * dir);
            ajaFookus = nihutatudFookus;
            int uusNadalapaev = ajaFookus.getDayOfWeek();
            if (algneNadalapaev != -1) {
                if (algneNadalapaev == uusNadalapaev) {
                    continue;
                } else {
                    algneNadalapaev = -1;
                }
            }
            if (uusNadalapaev == soughtValue) {
                algneNadalapaev = uusNadalapaev;
                count++;
                if (count == Math.abs(direction)) {
                    break;
                }
            }
        }
        this.underlyingDate = ajaFookus;
        updateDateRepresentation(Granulaarsus.DAY_OF_MONTH, null, false, ADD_TYPE_OPERATION);
        functionOtherThanSetUsed = true;
        this.dateModified = true;
    }
    // ---------------------------------
    //  WEEK OF YEAR
    // ---------------------------------
    if (field == Granulaarsus.WEEK_OF_YEAR && soughtValue == 0 && direction != 0) {
        int dir = (direction > 0) ? (1) : (-1);
        LocalDate ajaFookus = new LocalDate(this.underlyingDate);
        // Algne n2dal ehk n2dal, millest tahame m88duda
        int algneNadal = (excludingCurrent) ? (ajaFookus.getWeekOfWeekyear()) : (-1);
        if (!excludingCurrent) {
            // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale p2evale            
            ajaFookus = ajaFookus.plusDays(dir * (-1));
        }
        int count = 0;
        while (true) {
            LocalDate nihutatudFookus = ajaFookus.plusDays(1 * dir);
            ajaFookus = nihutatudFookus;
            int uusNadal = nihutatudFookus.getWeekOfWeekyear();
            if (algneNadal != -1) {
                if (algneNadal == uusNadal) {
                    continue;
                } else {
                    algneNadal = -1;
                }
            }
            if (soughtValue == 0) {
                algneNadal = uusNadal;
                count++;
                if (count == Math.abs(direction)) {
                    break;
                }
            }
        }
        this.underlyingDate = ajaFookus;
        updateDateRepresentation(Granulaarsus.WEEK_OF_YEAR, null, false, ADD_TYPE_OPERATION);
        functionOtherThanSetUsed = true;
        this.dateModified = true;
    }
    // ---------------------------------
    //  MONTH
    // ---------------------------------
    if (field == Granulaarsus.MONTH
            && (soughtValue == 0
                    || DateTimeConstants.JANUARY <= soughtValue && soughtValue <= DateTimeConstants.DECEMBER)
            && direction != 0) {
        int dir = (direction > 0) ? (1) : (-1);
        LocalDate ajaFookus = new LocalDate(this.underlyingDate);
        // Algne kuu ehk kuu, millest tahame m88duda
        int algneKuu = (excludingCurrent) ? (ajaFookus.getMonthOfYear()) : (-1);
        if (!excludingCurrent) {
            // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale kuule      
            ajaFookus = ajaFookus.plusMonths(dir * (-1));
        }
        int count = 0;
        while (true) {
            LocalDate nihutatudFookus = ajaFookus.plusMonths(1 * dir);
            ajaFookus = nihutatudFookus;
            int uusKuu = nihutatudFookus.getMonthOfYear();
            if (algneKuu != -1) {
                if (algneKuu == uusKuu) {
                    continue;
                } else {
                    algneKuu = -1;
                }
            }
            if (soughtValue == 0 || (soughtValue != 0 && uusKuu == soughtValue)) {
                algneKuu = uusKuu;
                count++;
                if (count == Math.abs(direction)) {
                    break;
                }
            }
        }
        this.underlyingDate = ajaFookus;
        updateDateRepresentation(Granulaarsus.MONTH, null, false, ADD_TYPE_OPERATION);
        functionOtherThanSetUsed = true;
        this.dateModified = true;
    }
    // ---------------------------------
    //   YEAR
    // ---------------------------------
    if (field == Granulaarsus.YEAR && soughtValue == 0 && direction != 0) {
        int dir = (direction > 0) ? (1) : (-1);
        LocalDate ajaFookus = new LocalDate(this.underlyingDate);
        // Algne aasta ehk aasta, millest tahame m88duda
        int algneAasta = (excludingCurrent) ? (ajaFookus.getYear()) : (-1);
        if (!excludingCurrent) {
            // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale kuule      
            ajaFookus = ajaFookus.plusMonths(dir * (-1));
        }
        int count = 0;
        while (true) {
            LocalDate nihutatudFookus = ajaFookus.plusMonths(1 * dir);
            ajaFookus = nihutatudFookus;
            int uusAasta = nihutatudFookus.getYear();
            if (algneAasta != -1) {
                if (algneAasta == uusAasta) {
                    continue;
                } else {
                    algneAasta = -1;
                }
            }
            if (soughtValue == 0) {
                algneAasta = uusAasta;
                count++;
                if (count == Math.abs(direction)) {
                    break;
                }
            }
        }
        this.underlyingDate = ajaFookus;
        updateDateRepresentation(Granulaarsus.YEAR, null, false, ADD_TYPE_OPERATION);
        functionOtherThanSetUsed = true;
        this.dateModified = true;
    }
    // ---------------------------------
    //   YEAR_OF_CENTURY
    // ---------------------------------
    if (field == Granulaarsus.YEAR_OF_CENTURY && direction != 0) {
        int minValue = SemLeidmiseAbimeetodid.getLocalDateTimeFieldExtremum(this.underlyingDate,
                DateTimeFieldType.yearOfCentury(), false);
        int maxValue = SemLeidmiseAbimeetodid.getLocalDateTimeFieldExtremum(this.underlyingDate,
                DateTimeFieldType.yearOfCentury(), true);
        if (minValue <= soughtValue && soughtValue <= maxValue) {
            int dir = (direction > 0) ? (1) : (-1);
            LocalDate ajaFookus = new LocalDate(this.underlyingDate);
            // Algne aasta ehk aasta, millest tahame m88duda
            int algneAasta = (excludingCurrent) ? (ajaFookus.getYearOfCentury()) : (-1);
            if (!excludingCurrent) {
                // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale aastale      
                ajaFookus = ajaFookus.plusYears(dir * (-1));
            }
            int count = 0;
            int cycleCount = 0;
            while (true) {
                LocalDate nihutatudFookus = ajaFookus.plusYears(1 * dir);
                cycleCount++;
                ajaFookus = nihutatudFookus;
                int uusAasta = nihutatudFookus.getYearOfCentury();
                if (algneAasta != -1) {
                    if (algneAasta == uusAasta) {
                        continue;
                    } else {
                        algneAasta = -1;
                    }
                }
                if (uusAasta == soughtValue) {
                    algneAasta = uusAasta;
                    count++;
                    if (count == Math.abs(direction)) {
                        break;
                    }
                }
            }
            this.underlyingDate = ajaFookus;
            updateDateRepresentation(Granulaarsus.YEAR, null, false, ADD_TYPE_OPERATION);
            functionOtherThanSetUsed = true;
            this.dateModified = true;
        }
    }
    // ---------------------------------
    //   CENTURY_OF_ERA
    // ---------------------------------
    if (field == Granulaarsus.CENTURY_OF_ERA && soughtValue == 0 && direction != 0) {
        int dir = (direction > 0) ? (1) : (-1);
        LocalDate ajaFookus = new LocalDate(this.underlyingDate);
        // Algne saj ehk sajand, millest tahame m88duda
        int algneSajand = (excludingCurrent) ? (ajaFookus.getCenturyOfEra()) : (Integer.MIN_VALUE);
        if (!excludingCurrent) {
            // V6tame sammu tagasi, et esimene nihe tooks meid t2pselt k2esolevale aastale      
            ajaFookus = ajaFookus.plusYears(dir * (-10));
        }
        int count = 0;
        while (true) {
            LocalDate nihutatudFookus = ajaFookus.plusYears(10 * dir);
            ajaFookus = nihutatudFookus;
            int uusSajand = nihutatudFookus.getCenturyOfEra();
            if (algneSajand != Integer.MIN_VALUE) {
                if (algneSajand == uusSajand) {
                    continue;
                } else {
                    algneSajand = Integer.MIN_VALUE;
                }
            }
            if (soughtValue == 0) {
                algneSajand = uusSajand;
                count++;
                if (count == Math.abs(direction)) {
                    break;
                }
            }
        }
        this.underlyingDate = ajaFookus;
        updateDateRepresentation(Granulaarsus.CENTURY_OF_ERA, null, false, ADD_TYPE_OPERATION);
        functionOtherThanSetUsed = true;
        this.dateModified = true;
    }

}

From source file:op.care.reports.PnlReport.java

License:Open Source License

private CollapsiblePane createCP4Week(final LocalDate week) {
    final String key = weekFormater.format(week.toDate()) + ".week";
    synchronized (cpMap) {
        if (!cpMap.containsKey(key)) {
            cpMap.put(key, new CollapsiblePane());
            try {
                cpMap.get(key).setCollapsed(true);
            } catch (PropertyVetoException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }/*from  ww  w . ja va  2 s.c  o  m*/

        }
    }
    final CollapsiblePane cpWeek = cpMap.get(key);

    String title = "<html><font size=+1><b>"
            + DateFormat.getDateInstance(DateFormat.SHORT).format(week.dayOfWeek().withMaximumValue().toDate())
            + " - "
            + DateFormat.getDateInstance(DateFormat.SHORT).format(week.dayOfWeek().withMinimumValue().toDate())
            + " (" + SYSTools.xx("misc.msg.weekinyear") + week.getWeekOfWeekyear() + ")" + "</b>"
            + "</font></html>";

    DefaultCPTitle cptitle = new DefaultCPTitle(title, new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            try {
                cpWeek.setCollapsed(!cpWeek.isCollapsed());
            } catch (PropertyVetoException pve) {
                // BAH!
            }
        }
    });

    GUITools.addExpandCollapseButtons(cpWeek, cptitle.getRight());

    if (OPDE.getAppInfo().isAllowedTo(InternalClassACL.PRINT, internalClassID)) {
        final JButton btnPrintWeek = new JButton(SYSConst.icon22print2);
        btnPrintWeek.setPressedIcon(SYSConst.icon22print2Pressed);
        btnPrintWeek.setAlignmentX(Component.RIGHT_ALIGNMENT);
        btnPrintWeek.setContentAreaFilled(false);
        btnPrintWeek.setBorder(null);
        btnPrintWeek.setToolTipText(SYSTools.xx("misc.tooltips.btnprintweek"));
        btnPrintWeek.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent actionEvent) {
                SYSFilesTools.print(NReportTools.getNReportsAsHTML(
                        NReportTools.getNReports4Week(resident, week), true, null, null), false);
            }
        });
        cptitle.getRight().add(btnPrintWeek);
    }

    cpWeek.setTitleLabelComponent(cptitle.getMain());
    cpWeek.setSlidingDirection(SwingConstants.SOUTH);

    cpWeek.setBackground(SYSConst.orange1[SYSConst.medium1]);
    cpWeek.setOpaque(false);
    cpWeek.setHorizontalAlignment(SwingConstants.LEADING);
    //        cpMonth.setBackground(getColor(vtype, SYSConst.light3));

    /***
     *           _ _      _            _                                       _   _
     *       ___| (_) ___| | _____  __| |   ___  _ __    _ __ ___   ___  _ __ | |_| |__
     *      / __| | |/ __| |/ / _ \/ _` |  / _ \| '_ \  | '_ ` _ \ / _ \| '_ \| __| '_ \
     *     | (__| | | (__|   <  __/ (_| | | (_) | | | | | | | | | | (_) | | | | |_| | | |
     *      \___|_|_|\___|_|\_\___|\__,_|  \___/|_| |_| |_| |_| |_|\___/|_| |_|\__|_| |_|
     *
     */
    cpWeek.addCollapsiblePaneListener(new CollapsiblePaneAdapter() {
        @Override
        public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) {
            cpWeek.setContentPane(createContenPanel4Week(week));
        }
    });

    if (!cpWeek.isCollapsed()) {
        cpWeek.setContentPane(createContenPanel4Week(week));
    }

    return cpWeek;
}

From source file:org.libreplan.web.montecarlo.MonteCarloGraphController.java

License:Open Source License

private String weekLabelFor(LocalDate date) {
    return "W" + date.getWeekOfWeekyear();
}

From source file:org.libreplan.web.montecarlo.MonteCarloGraphController.java

License:Open Source License

private String weekAndYearLabelFor(LocalDate date) {
    return "W" + date.getWeekOfWeekyear() + "-" + date.getYear();
}

From source file:supply.CapacityHarvester.java

License:Apache License

public static int getCalculatedRemainingHours(String username) {
    // Find start and end date for current sprint
    // --> Lookup sprint setup

    // Business days To Sprint End
    DateTime sprintStartDate = new DateTime(2014, 02, 1, 0, 0, 0, 0);
    DateTime sprintEndDate = new DateTime(2014, 02, 28, 17, 0);
    logger.info("sprintEndDate WeekOfWeekyear=" + sprintEndDate.getWeekOfWeekyear());
    logger.info("sprintEndDate WeekOfWeekyear=" + sprintEndDate.getWeekOfWeekyear());
    LocalDate today = new LocalDate();

    // business days left in current week
    logger.info("Current week=" + today.getWeekOfWeekyear());
    if (today.getDayOfWeek() > 5) {
        logger.info("Not a business day. 0 hours left of availability as this is weekend.");
    }/*from www  .ja  va 2s  . com*/
    SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy");
    Period weekPeriod = new Period().withWeeks(1);
    Interval i = new Interval(sprintStartDate, weekPeriod);
    int hours = 0;
    while (i.getEnd().isBefore(sprintEndDate)) {
        logger.info("week: " + i.getStart().getWeekOfWeekyear() + " start: " + df.format(i.getStart().toDate())
                + " end: " + df.format(i.getEnd().minusMillis(1).toDate()));
        i = new Interval(i.getStart().plus(weekPeriod), weekPeriod);
        int availabilityHours = Availability.getAvailability(i.getStart().toCalendar(Locale.US), username);
        logger.info("Reported availability hours for [" + username + "]: " + availabilityHours);
        hours += availabilityHours;
    }

    Days days = Days.daysBetween(today.toDateTimeAtStartOfDay(), sprintEndDate);

    int hoursRemaining = Hours.hoursBetween(today.toDateTimeAtCurrentTime(), sprintEndDate).getHours();
    if (hoursRemaining < 0)
        hoursRemaining = 0;
    logger.info("HoursToSprintEnd=" + hoursRemaining);
    logger.info("DayOfWeek=" + today.getDayOfWeek());
    logger.info("WeekOfWeekyear=" + today.getWeekOfWeekyear());
    logger.info("Hours from DB=" + hours);

    // --> Find week numbers
    // --> Check that current date is between start/end date of sprint

    // Lookup how many hours this user has for the sprint
    // --> lookup in HBase
    // --> 

    return hoursRemaining;
}