Ejemplo n.º 1
0
 protected void doSetCurrentCalcPeriod(Integer calcPeriodId) {
   CalcPeriod calcPeriod = ServerUtils.getPersistentManager().find(CalcPeriod.class, calcPeriodId);
   if (calcPeriod.getStaffList() == null)
     throw new BusinessException(
         Messages.getInstance().getMessage(Messages.NOT_CHOOSE_STAFFLIST_BY_SEARCHED_CALCPERIOD));
   UIProfile profile = UIProfileManagerLocator.locate().load(CalcPeriodServiceLocal.PROFILE_NAME);
   profile.setProperty(CalcPeriodServiceLocal.PROFILE_PROPERTY, calcPeriodId);
   UIProfileManagerLocator.locate().store(profile);
 }
Ejemplo n.º 2
0
  /**
   * Проверить пересечение даным периодом других периодов
   *
   * @param calcPeriod - расчетный период
   * @return true - если данный период пересекает другие периоды
   */
  protected boolean isPeriodCross(CalcPeriod calcPeriod) {
    Criteria criteria =
        OrmTemplate.createCriteria(CalcPeriod.class)
            .setProjection(Projections.rowCount())
            .add(
                Restrictions.or(
                    Restrictions.and(
                        Restrictions.le("BeginDate", calcPeriod.getBeginDate()),
                        Restrictions.ge(
                            "EndDate", calcPeriod.getBeginDate())), // $NON-NLS-1$ //$NON-NLS-2$
                    Restrictions.and(
                        Restrictions.le("BeginDate", calcPeriod.getEndDate()),
                        Restrictions.ge(
                            "EndDate", calcPeriod.getEndDate())))); // $NON-NLS-1$ //$NON-NLS-2$

    // при редактировании периода исключаем изменяемый период из списка существующих периодов
    if (calcPeriod.getId() != null)
      criteria.add(Restrictions.ne("Id", calcPeriod.getId())); // $NON-NLS-1$

    Integer crossedPeriodsCount = OrmTemplate.getInstance().findUniqueByCriteria(criteria);

    if (crossedPeriodsCount > 0) return true;
    else return false;
  }
Ejemplo n.º 3
0
 /**
  * Проверить корректность диапазона дат
  *
  * @param calcPeriod - расчетный период
  * @return true - если диапазона дат корректен
  */
 protected boolean isPeriodDatesValid(CalcPeriod calcPeriod) {
   Date beginDate = calcPeriod.getBeginDate();
   Date endDate = calcPeriod.getEndDate();
   if (beginDate == null || endDate == null) return true;
   return beginDate.compareTo(endDate) > 0 ? false : true;
 }