List of usage examples for org.joda.time DateMidnight DateMidnight
public DateMidnight()
ISOChronology
in the default time zone. From source file:org.key2gym.client.actions.CheckOutAction.java
License:Apache License
@Override public void onActionPerformed(ActionEvent e) throws BusinessException, ValidationException, SecurityViolationException { AttendancesService attendancesService = ContextManager.lookup(AttendancesService.class); OrdersService ordersService = ContextManager.lookup(OrdersService.class); /*/*from ww w .jav a 2 s .co m*/ * Presentation */ PickAttendanceDialog pickAttendanceDialog; pickAttendanceDialog = new PickAttendanceDialog(getFrame()); AttendanceDTO attendanceDTO = getFrame().getSelectedAttendance(); if (attendanceDTO != null) { pickAttendanceDialog.setAttendanceId(attendanceDTO.getId()); pickAttendanceDialog.setAttendanceLocked(false); } pickAttendanceDialog.setVisible(true); if (pickAttendanceDialog.getResult().equals(AbstractDialog.Result.CANCEL)) { return; } Integer attendanceId = pickAttendanceDialog.getAttendanceId(); if (pickAttendanceDialog.isEditOrderDialogRequested()) { /* * If the user requested order, * let's recalculate penalties for him. */ attendancesService.recalculatePenalties(attendanceId); Integer orderId; Boolean isCasual; try { isCasual = attendancesService.isCasual(attendanceId); if (isCasual) { orderId = ordersService.findForAttendanceById(attendanceId); } else { orderId = ordersService.findByClientIdAndDate( attendancesService.getAttendanceById(attendanceId).getClientId(), new DateMidnight(), true); } } catch (ValidationException ex) { throw new RuntimeException(ex); } if (orderId != null) { EditOrderDialog editOrderDialog = new EditOrderDialog(getFrame()); editOrderDialog.setOrderId(orderId); editOrderDialog.setFullPaymentForced(isCasual); editOrderDialog.setVisible(true); } } /* * Finally, closes the attendance. */ try { attendancesService.checkOut(attendanceId); } catch (ValidationException ex) { throw new RuntimeException(ex); } }
From source file:org.key2gym.client.actions.EditOrderAction.java
License:Apache License
@Override public void onActionPerformed(ActionEvent e) throws BusinessException, ValidationException, SecurityViolationException { OrdersService ordersService = ContextManager.lookup(OrdersService.class); Integer orderId;// w ww . j a va2s . co m if (e.getActionCommand().equals(ACTION_CONTEXT)) { OrderDTO order = MainFrame.getInstance().getSelectedOrder(); /* * It is possible that the selection has already been discarded. */ if (order == null) { return; } orderId = order.getId(); } else { PickOrderDialog pickOrderDialog = new PickOrderDialog(getFrame()); pickOrderDialog.setVisible(true); if (pickOrderDialog.getResult().equals(AbstractDialog.Result.CANCEL)) { return; } if (pickOrderDialog.isClient()) { PickClientDialog pickClientDialog = new PickClientDialog(getFrame()); pickClientDialog.setVisible(true); if (pickClientDialog.getResult().equals(AbstractDialog.Result.CANCEL)) { return; } try { orderId = ordersService.findByClientIdAndDate(pickClientDialog.getClientId(), new DateMidnight(), true); } catch (ValidationException ex) { throw new RuntimeException(ex); } } else { orderId = pickOrderDialog.getOrderId(); } } EditOrderDialog editOrderDialog = new EditOrderDialog(getFrame()); editOrderDialog.setOrderId(orderId); editOrderDialog.setFullPaymentForced(false); editOrderDialog.setVisible(true); }
From source file:org.key2gym.client.actions.RegisterClientAction.java
License:Apache License
/** * Processes an event.//from w w w . ja v a 2 s. c om * * @param event the event */ @Override public void onActionPerformed(ActionEvent e) throws BusinessException, ValidationException, SecurityViolationException { RegisterClientDialog registerClientDialog; registerClientDialog = new RegisterClientDialog(getFrame()); registerClientDialog.setVisible(true); if (registerClientDialog.getResult().equals(AbstractDialog.Result.CANCEL)) { return; } /* * If requested, creates and launches EditOrderDialog */ if (registerClientDialog.isEditOrderDialogRequested()) { EditOrderDialog editOrderDialog = new EditOrderDialog(getFrame()); try { Integer orderId = ContextManager.lookup(OrdersService.class) .findByClientIdAndDate(registerClientDialog.getClientId(), new DateMidnight(), true); editOrderDialog.setOrderId(orderId); } catch (ValidationException ex) { throw new RuntimeException(ex); } editOrderDialog.setVisible(true); } /* * If requested, creates and lanches CheckInDialog */ if (registerClientDialog.isOpenAttendanceDialogRequested()) { CheckInDialog openAttendanceDialog = new CheckInDialog(getFrame()); openAttendanceDialog.setClientId(registerClientDialog.getClientId()); openAttendanceDialog.setVisible(true); } }
From source file:org.key2gym.client.dialogs.EditClientDialog.java
License:Apache License
private void reloadPurchasesTab() { /*// ww w . j av a2s .c o m * Purchases tab */ List<OrderDTO> ordersDTO; DateMidnight end = new DateMidnight(); DateMidnight begin; if (purchasesFilterComboBox.getSelectedIndex() == 0) { begin = end.minusDays(7); } else if (purchasesFilterComboBox.getSelectedIndex() == 1) { begin = end.minusMonths(1); } else if (purchasesFilterComboBox.getSelectedIndex() == 2) { begin = end.minusMonths(3); } else { begin = client.getRegistrationDate(); } try { ordersDTO = ordersService.findForClientWithinPeriod(clientId, begin, end); } catch (ValidationException | SecurityViolationException ex) { throw new RuntimeException(ex); } DefaultMutableTreeNode topNode = new DefaultMutableTreeNode(); DefaultMutableTreeNode dateNode; DefaultMutableTreeNode itemNode; for (OrderDTO orderDTO : ordersDTO) { String text = MessageFormat.format(getString("Text.Order.withDateAndTotalAndPaid"), new Object[] { orderDTO.getDate().toDate(), //NOI18N orderDTO.getTotal().toPlainString(), orderDTO.getPayment().toPlainString() }); dateNode = new DefaultMutableTreeNode(text); for (OrderLineDTO orderLine : orderDTO.getOrderLines()) { String nodeText = MessageFormat.format( getString("Text.OrderLine(ItemTitle,Quantity,DiscountTitle)"), new Object[] { orderLine.getItemTitle(), orderLine.getQuantity(), orderLine.getDiscountTitle() == null ? getString("Text.None") : orderLine.getDiscountTitle() }); itemNode = new DefaultMutableTreeNode(nodeText); dateNode.add(itemNode); } topNode.add(dateNode); } purchasesTree.setModel(new DefaultTreeModel(topNode)); }
From source file:org.key2gym.client.dialogs.ManageFreezesDialog.java
License:Apache License
private void updateGUI() { List<FreezeDTO> freezes; DateMidnight today = new DateMidnight(); try {//from ww w.j ava 2 s . co m if (periodsComboBox.getSelectedIndex() == 0) { freezes = freezesService.findByDateIssuedRange(today.minusDays(7), today); } else if (periodsComboBox.getSelectedIndex() == 1) { freezes = freezesService.findByDateIssuedRange(today.minusMonths(1), today); } else if (periodsComboBox.getSelectedIndex() == 2) { freezes = freezesService.findByDateIssuedRange(today.minusMonths(3), today); } else { freezes = freezesService.findAll(); } } catch (UserException ex) { UserExceptionHandler.getInstance().processException(ex); return; } freezesTableModel.setFreezes(freezes); }
From source file:org.key2gym.client.dialogs.PickDateDialog.java
License:Apache License
/** * Initializes the dialog's components.//from w ww . ja v a 2s .co m */ private void initComponents() { dateLabel = new JLabel(getString("Label.Date")); dateComboBox = new JComboBox(); dateComboBox.setEditable(true); DateMidnight startDate = new DateMidnight(); String[] dates = new String[10]; for (int i = 0; i < 10; i++) { dates[i] = startDate.toString("dd-MM-yyyy"); startDate = startDate.minusDays(1); } dateComboBox.setModel(new DefaultComboBoxModel(dates)); okButton = new JButton(getOkAction()); cancelButton = new JButton(getCancelAction()); okButton.setPreferredSize(cancelButton.getPreferredSize()); getRootPane().setDefaultButton(okButton); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(getString("Title.PickDate")); // NOI18N }
From source file:org.key2gym.client.dialogs.PickOrderDialog.java
License:Apache License
/** * Processes an OK button click.// ww w. ja v a 2 s .c om * * @param evt the action event, optional */ @Override protected void onOkActionPerformed(ActionEvent evt) { /* * The API requires just to return a valid financial activity's ID upon * a sucessful completion. */ try { if (clientRadioButton.isSelected()) { setResult(Result.OK); setClient(true); dispose(); return; /* * The attendance's key is provided. */ } else if (keyRadioButton.isSelected()) { /* * GUI garantees that there is a key selected, if the * attendanceRadionButton is selected */ KeyDTO key = (KeyDTO) keysComboBox.getSelectedItem(); try { Integer attendanceId = attendancesService.findOpenAttendanceByKey(key.getId()); AttendanceDTO attendanceDTO = attendancesService.getAttendanceById(attendanceId); if (attendanceDTO.getClientId() == null) { /* * The API requires to pass only anonymous attendances * to findForAttendanceById */ orderId = ordersService.findForAttendanceById(attendanceId); } else { orderId = ordersService.findByClientIdAndDate(attendanceDTO.getClientId(), new DateMidnight(), true); } /* * All exceptions are unexpected, and, therefore, are bugs. */ } catch (BusinessException | ValidationException ex) { throw new RuntimeException(ex); } /* * A default financial activity is needed. */ } else { orderId = ordersService.findCurrentDefault(true); } } catch (ValidationException | SecurityViolationException ex) { UserExceptionHandler.getInstance().processException(ex); return; } setClient(false); setOrderId(orderId); super.onOkActionPerformed(evt); }
From source file:org.key2gym.client.panels.forms.DateIntervalReportInputFormPanel.java
License:Apache License
/** * Creates new DateIntervalReportInputFormPanel *//*from w w w . j a va 2 s . co m*/ public DateIntervalReportInputFormPanel() { strings = ResourcesManager.getStrings(); initComponents(); buildForm(); interval = new BindableMutableInterval(new DateMidnight(), new DateMidnight()); formBindingListener = new FormBindingListener(); bindingGroup = new BindingGroup(); bindingGroup.addBindingListener(formBindingListener); /** * Interval start */ Binding binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_ONCE, interval, BeanProperty.create("start"), intervalStartTextField, BeanProperty.create("text"), "start"); binding.setConverter(new DateTimeToStringConverter(getString("Text.Beginning"), "dd-MM-yyyy")); bindingGroup.addBinding(binding); /** * Interval end */ binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_ONCE, interval, BeanProperty.create("end"), intervalEndTextField, BeanProperty.create("text"), "end"); binding.setConverter(new DateTimeToStringConverter(getString("Text.Ending"), "dd-MM-yyyy")); bindingGroup.addBinding(binding); bindingGroup.bind(); }
From source file:org.mifos.application.servicefacade.CenterServiceFacadeWebTier.java
License:Open Source License
@Override public CustomerDetailsDto createNewCenter(CenterCreationDetail createCenterDetail, MeetingDto meetingDto) { MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); UserContext userContext = toUserContext(user); OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId()); userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum()); String centerName = createCenterDetail.getDisplayName(); String externalId = createCenterDetail.getExternalId(); AddressDto addressDto = createCenterDetail.getAddressDto(); Address centerAddress = new Address(addressDto.getLine1(), addressDto.getLine2(), addressDto.getLine3(), addressDto.getCity(), addressDto.getState(), addressDto.getCountry(), addressDto.getZip(), addressDto.getPhoneNumber()); PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(createCenterDetail.getLoanOfficerId()); OfficeBO centerOffice = this.officeDao.findOfficeById(createCenterDetail.getOfficeId()); List<AccountFeesEntity> feesForCustomerAccount = createAccountFeeEntities( createCenterDetail.getFeesToApply()); DateTime mfiJoiningDate = null;/*from w w w. j a v a2 s .com*/ if (createCenterDetail.getMfiJoiningDate() != null) { mfiJoiningDate = createCenterDetail.getMfiJoiningDate().toDateMidnight().toDateTime(); } MeetingBO meeting = new MeetingFactory().create(meetingDto); meeting.setUserContext(userContext); CenterBO center = CenterBO.createNew(userContext, centerName, mfiJoiningDate, meeting, loanOfficer, centerOffice, centerAddress, externalId, new DateMidnight().toDateTime()); try { personnelDao.checkAccessPermission(userContext, center.getOfficeId(), center.getLoanOfficerId()); } catch (AccountException e) { throw new MifosRuntimeException("Access denied!", e); } this.customerService.createCenter(center, meeting, feesForCustomerAccount); return new CustomerDetailsDto(center.getCustomerId(), center.getGlobalCustNum()); }
From source file:org.mifos.customers.business.service.CustomerServiceImpl.java
License:Open Source License
private void changeStatus(CustomerBO customer, CustomerStatus oldStatus, CustomerStatus newStatus) throws CustomerException { Short oldStatusId = oldStatus.getValue(); Short newStatusId = newStatus.getValue(); if (customer.isClient()) { ClientBO client = (ClientBO) customer; if (client.isActiveForFirstTime(oldStatusId, newStatusId)) { if (client.getParentCustomer() != null) { CustomerHierarchyEntity hierarchy = new CustomerHierarchyEntity(client, client.getParentCustomer()); client.addCustomerHierarchy(hierarchy); }/* w w w.j ava 2 s . com*/ CalendarEvent applicableCalendarEvents = holidayDao .findCalendarEventsForThisYearAndNext(customer.getOfficeId()); List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>( customer.getCustomerAccount().getAccountFees()); client.getCustomerAccount().createSchedulesAndFeeSchedulesForFirstTimeActiveCustomer(customer, accountFees, customer.getCustomerMeetingValue(), applicableCalendarEvents, new DateMidnight().toDateTime()); client.setCustomerActivationDate(new DateTimeService().getCurrentJavaDateTime()); if (client.getOfferingsAssociatedInCreate() != null) { for (ClientInitialSavingsOfferingEntity clientOffering : client .getOfferingsAssociatedInCreate()) { try { SavingsOfferingBO savingsOffering = savingsProductDao .findById(clientOffering.getSavingsOffering().getPrdOfferingId().intValue()); if (savingsOffering.isActive()) { List<CustomFieldDto> customerFieldsForSavings = new ArrayList<CustomFieldDto>(); client.addAccount(new SavingsBO(client.getUserContext(), savingsOffering, client, AccountState.SAVINGS_ACTIVE, savingsOffering.getRecommendedAmount(), customerFieldsForSavings)); } } catch (AccountException pe) { throw new CustomerException(pe); } } } new SavingsPersistence().persistSavingAccounts(client); try { if (client.getParentCustomer() != null) { List<SavingsBO> savingsList = new CustomerPersistence() .retrieveSavingsAccountForCustomer(client.getParentCustomer().getCustomerId()); if (client.getParentCustomer().getParentCustomer() != null) { savingsList.addAll(new CustomerPersistence().retrieveSavingsAccountForCustomer( client.getParentCustomer().getParentCustomer().getCustomerId())); } for (SavingsBO savings : savingsList) { savings.setUserContext(client.getUserContext()); if (client.getCustomerMeeting().getMeeting() != null) { if (!(savings.getCustomer().getLevel() == CustomerLevel.GROUP && savings.getRecommendedAmntUnit().getId() .equals(RecommendedAmountUnit.COMPLETE_GROUP.getValue()))) { DateTime today = new DateTime().toDateMidnight().toDateTime(); savings.generateDepositAccountActions(client, client.getCustomerMeeting().getMeeting(), applicableCalendarEvents.getWorkingDays(), applicableCalendarEvents.getHolidays(), today); savings.update(); } } } } } catch (PersistenceException pe) { throw new CustomerException(pe); } catch (AccountException ae) { throw new CustomerException(ae); } } } }