List of usage examples for org.joda.time LocalDate getYear
public int getYear()
From source file:op.care.supervisor.PnlHandover.java
License:Open Source License
private void reloadDisplay() { /***/*from w ww . ja v a 2 s . c o m*/ * _ _ ____ _ _ * _ __ ___| | ___ __ _ __| | _ \(_)___ _ __ | | __ _ _ _ * | '__/ _ \ |/ _ \ / _` |/ _` | | | | / __| '_ \| |/ _` | | | | * | | | __/ | (_) | (_| | (_| | |_| | \__ \ |_) | | (_| | |_| | * |_| \___|_|\___/ \__,_|\__,_|____/|_|___/ .__/|_|\__,_|\__, | * |_| |___/ */ // synchronized (contentmap) { // SYSTools.clear(contentmap); // } synchronized (cpMap) { SYSTools.clear(cpMap); } // synchronized (linemapHO) { // SYSTools.clear(linemapHO); // } // synchronized (linemapNR) { // SYSTools.clear(linemapNR); // } synchronized (cacheHO) { SYSTools.clear(cacheHO); } synchronized (cacheNR) { SYSTools.clear(cacheNR); } Pair<DateTime, DateTime> minmax = NReportTools.getMinMax(); if (minmax != null) { hollidays = SYSCalendar.getHolidays(minmax.getFirst().getYear(), minmax.getSecond().getYear()); LocalDate start = SYSCalendar.bom(minmax.getFirst()).toLocalDate(); LocalDate end = new LocalDate(); for (int year = end.getYear(); year >= start.getYear(); year--) { createCP4Year(year, start, end); } } expandDay(new LocalDate()); buildPanel(); }
From source file:op.care.supervisor.PnlHandover.java
License:Open Source License
private void expandDay(LocalDate day) { final String keyYear = Integer.toString(day.getYear()) + ".year"; if (cpMap.containsKey(keyYear) && cpMap.get(keyYear).isCollapsed()) { try {//from ww w . ja v a2 s.c o m cpMap.get(keyYear).setCollapsed(false); } catch (PropertyVetoException e) { // bah! } } final String keyMonth = monthFormatter.format(day.toDate()) + ".month"; if (cpMap.containsKey(keyMonth) && cpMap.get(keyMonth).isCollapsed()) { try { cpMap.get(keyMonth).setCollapsed(false); } catch (PropertyVetoException e) { // bah! } } final String keyDay = DateFormat.getDateInstance().format(day.toDate()); if (cpMap.containsKey(keyDay) && cpMap.get(keyDay).isCollapsed()) { try { cpMap.get(keyDay).setCollapsed(false); } catch (PropertyVetoException e) { // bah! } } }
From source file:op.care.supervisor.PnlHandover.java
License:Open Source License
private CollapsiblePane createCP4Day(final LocalDate day) { final String key = DateFormat.getDateInstance().format(day.toDate()); synchronized (cpMap) { if (!cpMap.containsKey(key)) { cpMap.put(key, new CollapsiblePane()); try { cpMap.get(key).setCollapsed(true); } catch (PropertyVetoException e) { e.printStackTrace();/*from www . ja v a 2 s.c o m*/ } } } final CollapsiblePane cpDay = cpMap.get(key); if (hollidays == null) { hollidays = SYSCalendar.getHolidays(day.getYear(), day.getYear()); } String titleDay = "<html><font size=+1>" + dayFormat.format(day.toDate()) + SYSTools.catchNull(hollidays.get(day), " (", ")") + "</font></html>"; final DefaultCPTitle titleCPDay = new DefaultCPTitle(titleDay, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { cpDay.setCollapsed(!cpDay.isCollapsed()); } catch (PropertyVetoException pve) { // BAH! } } }); final JButton btnAcknowledge = new JButton(SYSConst.icon163ledGreenOn); btnAcknowledge.setAlignmentX(Component.RIGHT_ALIGNMENT); btnAcknowledge.setToolTipText(SYSTools.xx("nursingrecords.handover.tooltips.btnAcknowledge")); btnAcknowledge.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { EntityManager em = OPDE.createEM(); try { em.getTransaction().begin(); synchronized (cacheHO) { ArrayList<Handovers> listHO = new ArrayList<Handovers>(cacheHO.get(key)); for (final Handovers ho : listHO) { if (!Handover2UserTools.containsUser(em, ho, OPDE.getLogin().getUser())) { Handovers myHO = em.merge(ho); Handover2User connObj = em .merge(new Handover2User(myHO, em.merge(OPDE.getLogin().getUser()))); myHO.getUsersAcknowledged().add(connObj); } } } synchronized (cacheNR) { ArrayList<NReport> listNR = new ArrayList<NReport>(cacheNR.get(key)); for (final NReport nreport : listNR) { if (!NR2UserTools.containsUser(em, nreport, OPDE.getLogin().getUser())) { NReport myNR = em.merge(nreport); NR2User connObj = em.merge(new NR2User(myNR, em.merge(OPDE.getLogin().getUser()))); myNR.getUsersAcknowledged().add(connObj); } } } em.getTransaction().commit(); createCP4Day(day); buildPanel(); } catch (OptimisticLockException ole) { OPDE.warn(ole); if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } if (ole.getMessage().indexOf("Class> entity.info.Resident") > -1) { OPDE.getMainframe().emptyFrame(); OPDE.getMainframe().afterLogin(); } OPDE.getDisplayManager().addSubMessage(DisplayManager.getLockMessage()); } catch (Exception e) { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } OPDE.fatal(e); } finally { em.close(); } } }); titleCPDay.getRight().add(btnAcknowledge); cpDay.setTitleLabelComponent(titleCPDay.getMain()); cpDay.setSlidingDirection(SwingConstants.SOUTH); if (hollidays.containsKey(day)) { cpDay.setBackground(SYSConst.red1[SYSConst.medium1]); } else if (day.getDayOfWeek() == DateTimeConstants.SATURDAY || day.getDayOfWeek() == DateTimeConstants.SUNDAY) { cpDay.setBackground(SYSConst.red1[SYSConst.light3]); } else { cpDay.setBackground(SYSConst.orange1[SYSConst.light3]); } cpDay.setOpaque(true); cpDay.setHorizontalAlignment(SwingConstants.LEADING); cpDay.setStyle(CollapsiblePane.PLAIN_STYLE); cpDay.addCollapsiblePaneListener(new CollapsiblePaneAdapter() { @Override public void paneExpanded(CollapsiblePaneEvent collapsiblePaneEvent) { createContentPanel4Day(day, cpDay); btnAcknowledge.setEnabled(true); } @Override public void paneCollapsed(CollapsiblePaneEvent collapsiblePaneEvent) { btnAcknowledge.setEnabled(false); } }); btnAcknowledge.setEnabled(!cpDay.isCollapsed()); if (!cpDay.isCollapsed()) { createContentPanel4Day(day, cpDay); } return cpDay; }
From source file:op.care.supervisor.PnlHandover.java
License:Open Source License
private void buildPanel() { cpsHandover.removeAll();/* w ww .jav a 2 s . com*/ cpsHandover.setLayout(new JideBoxLayout(cpsHandover, JideBoxLayout.Y_AXIS)); Pair<DateTime, DateTime> minmax = NReportTools.getMinMax(); if (minmax != null) { LocalDate start = SYSCalendar.bom(minmax.getFirst()).toLocalDate(); LocalDate end = new LocalDate(); for (int year = end.getYear(); year >= start.getYear(); year--) { final String keyYear = Integer.toString(year) + ".year"; cpsHandover.add(cpMap.get(keyYear)); } } cpsHandover.addExpansion(); }
From source file:op.tools.SYSCalendar.java
License:Open Source License
public static LocalDate boy(LocalDate year) { return new LocalDate(year.getYear(), 1, 1); }
From source file:op.tools.SYSCalendar.java
License:Open Source License
public static LocalDate eoy(LocalDate day) { return new LocalDate(day.getYear(), 12, 31); }
From source file:op.tools.SYSCalendar.java
License:Open Source License
public static io.lamma.Date toLammaDate(java.util.Date in) { LocalDate ld = new LocalDate(in); return new io.lamma.Date(ld.getYear(), ld.getMonthOfYear(), ld.getDayOfMonth()); }
From source file:org.agatom.springatom.data.hades.model.appointment.NAppointment.java
License:Open Source License
public NAppointment setBeginDate(final LocalDate localDate) { this.requireBeginDate(); final MutableDateTime mutableDateTime = this.begin.toMutableDateTime(); mutableDateTime.setDate(localDate.getYear(), localDate.getMonthOfYear(), localDate.getDayOfMonth()); this.begin = mutableDateTime.toDateTime(); return this; }
From source file:org.agatom.springatom.data.hades.model.appointment.NAppointment.java
License:Open Source License
public NAppointment setEndDate(final LocalDate localDate) { this.requireEndDate(); final MutableDateTime mutableDateTime = this.end.toMutableDateTime(); mutableDateTime.setDate(localDate.getYear(), localDate.getMonthOfYear(), localDate.getDayOfMonth()); this.end = mutableDateTime.toDateTime(); return this; }
From source file:org.alexlg.bankit.controllers.AccountController.java
License:Open Source License
/** * Build a set of MonthOps for all future ops : "manual" or costs (beyond 2 days of current) * @param day Current day/* www.j a v a2s . c o m*/ * @param futurePlannedOps List of manual future operations * @param costs List of costs * @param balance Start balance * @param nbMonth Number of month to build in addition to the current month. * @return A set of MonthOps for each month planned */ protected Set<MonthOps> buildFutureOps(LocalDate day, List<Operation> futurePlannedOps, List<Cost> costs, BigDecimal balance, int nbMonth) { Set<MonthOps> futureOps = new TreeSet<MonthOps>(); //going through all months for (int i = 0; i < nbMonth + 1; i++) { LocalDate monthDate = day.monthOfYear().addToCopy(i); int lastDayOfMonth = monthDate.dayOfMonth().getMaximumValue(); MonthOps monthOps = new MonthOps(monthDate, balance); futureOps.add(monthOps); //adding "manual" operation of the current month if (futurePlannedOps.size() > 0) { //loop an add all operation of the month for (Operation op : futurePlannedOps) { if (new LocalDate(op.getOperationDate()).getMonthOfYear() == monthDate.getMonthOfYear()) { op.setAuto(false); monthOps.addOp(op); } } } //adding costs of the current month LocalDate costStartDay = day.plusDays(2); for (Cost cost : costs) { int costDay = cost.getDay(); //if the operation is planned after the last day of month //set it to the last day if (costDay > lastDayOfMonth) costDay = lastDayOfMonth; LocalDate opDate = new LocalDate(monthDate.getYear(), monthDate.getMonthOfYear(), costDay); //checking if we add the cost (the date is after current+2) if (opDate.isAfter(costStartDay)) { Operation op = new Operation(); //setting a fake id for comparison (as we put the operation in the set) op.setOperationId(cost.getCostId() + i); op.setOperationDate(opDate.toDate()); op.setPlanned(cost.getAmount()); op.setLabel(cost.getLabel()); op.setCategory(cost.getCategory()); op.setAuto(true); monthOps.addOp(op); } } //saving current balance for next monthOp balance = monthOps.getBalance(); } return futureOps; }