Search in sources :

Example 6 with Holiday

use of com.autentia.tnt.businessobject.Holiday in project TNTConcept by autentia.

the class ActivityBean_IT method getMonthTotalHours_GeneralHolidaysInWeekend.

@Test
public void getMonthTotalHours_GeneralHolidaysInWeekend() {
    // create a general holiday day in a weekend
    HolidayManager holidayManager = HolidayManager.getDefault();
    Holiday holiday = new Holiday();
    LocalDate holidayInWeekendDay = LocalDate.of(2017, 8, 13);
    Date holidayDate = Date.from(holidayInWeekendDay.atStartOfDay(ZoneId.systemDefault()).toInstant());
    holiday.setDate(holidayDate);
    holiday.setDescription("Test Holiday");
    holidayManager.insertEntity(holiday);
    // verify total hours for the month where the holiday is in
    ActivityBeanNoJSF sut = new ActivityBeanNoJSF();
    LocalDate august = LocalDate.of(2017, 8, 1);
    Date augustDate = Date.from(august.atStartOfDay(ZoneId.systemDefault()).toInstant());
    sut.setSelectedDate(augustDate);
    double augustHours = sut.getMonthTotalHours();
    assertThat(augustHours, closeTo(184.0, 0.1));
}
Also used : Holiday(com.autentia.tnt.businessobject.Holiday) RequestHoliday(com.autentia.tnt.businessobject.RequestHoliday) RequestHolidayManager(com.autentia.tnt.manager.holiday.RequestHolidayManager) HolidayManager(com.autentia.tnt.manager.holiday.HolidayManager) LocalDate(java.time.LocalDate) Date(java.util.Date) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 7 with Holiday

use of com.autentia.tnt.businessobject.Holiday in project TNTConcept by autentia.

the class UserHolidaysStateManager method isHoliday.

/**
 * @return Indica si un día es festivo
 */
private boolean isHoliday(List<Holiday> fiestas, Date date) {
    // ¿ Es fin de semana ?
    Calendar cActual = Calendar.getInstance();
    cActual.setTime(date);
    if ((cActual.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY) || (cActual.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)) {
        return true;
    }
    Iterator<Holiday> ite = fiestas.iterator();
    Holiday current;
    while (ite.hasNext()) {
        current = ite.next();
        if (DateUtils.isSameDay(current.getDate(), date)) {
            return true;
        }
    }
    return false;
}
Also used : Holiday(com.autentia.tnt.businessobject.Holiday) RequestHoliday(com.autentia.tnt.businessobject.RequestHoliday) Calendar(java.util.Calendar)

Example 8 with Holiday

use of com.autentia.tnt.businessobject.Holiday in project TNTConcept by autentia.

the class ActivityBean method fillHolidays.

private void fillHolidays(SimpleScheduleModel model) {
    Calendar calMin = Calendar.getInstance();
    Calendar calMax = Calendar.getInstance();
    calMin = getMinimumSearchTime(selectedDate);
    calMax = getMaximumSearchTime(selectedDate);
    RequestHolidayManager rhManager = RequestHolidayManager.getDefault();
    RequestHolidaySearch rhSearch = new RequestHolidaySearch();
    rhSearch.setUserRequest(authManager.getCurrentPrincipal().getUser());
    rhSearch.setState(HolidayState.ACCEPT);
    rhSearch.setStartBeginDate(calMin.getTime());
    rhSearch.setEndBeginDate(calMax.getTime());
    rhSearch.setStartFinalDate(calMin.getTime());
    rhSearch.setEndFinalDate(calMax.getTime());
    List<RequestHoliday> listH = rhManager.getAllEntities(rhSearch, null);
    for (RequestHoliday rH : listH) {
        Calendar cActual = Calendar.getInstance();
        cActual.setTime(rH.getBeginDate());
        while (!cActual.getTime().after(rH.getFinalDate())) {
            if (cActual.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY && cActual.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
                model.setHoliday(cActual.getTime(), FacesUtils.getMessage("activity.acceptedHolidays"));
            }
            cActual.add(Calendar.DAY_OF_MONTH, 1);
        }
    }
    HolidaySearch monthSearch = new HolidaySearch();
    monthSearch.setStartDate(calMin.getTime());
    monthSearch.setEndDate(calMax.getTime());
    List<Holiday> allHolidays = holidayManager.getAllEntities(monthSearch, null);
    for (Holiday holiday : allHolidays) {
        model.setHoliday(holiday.getDate(), holiday.getDescription());
    }
}
Also used : RequestHoliday(com.autentia.tnt.businessobject.RequestHoliday) Holiday(com.autentia.tnt.businessobject.Holiday) RequestHoliday(com.autentia.tnt.businessobject.RequestHoliday) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) RequestHolidayManager(com.autentia.tnt.manager.holiday.RequestHolidayManager) HolidaySearch(com.autentia.tnt.dao.search.HolidaySearch) RequestHolidaySearch(com.autentia.tnt.dao.search.RequestHolidaySearch) RequestHolidaySearch(com.autentia.tnt.dao.search.RequestHolidaySearch)

Example 9 with Holiday

use of com.autentia.tnt.businessobject.Holiday in project TNTConcept by autentia.

the class ActivityBean method calculateHolidays.

private int calculateHolidays(List<Integer> nonWorkingDays, Date date, int daysInMonth) {
    LocalDate selectedDay = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault()).toLocalDate();
    LocalDate firstDaySelectedMonth = selectedDay.withDayOfMonth(1);
    LocalDate lastDaySelectedMonth = selectedDay.with(TemporalAdjusters.lastDayOfMonth());
    Date beginOfMonth = Date.from(firstDaySelectedMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
    Date endOfMonth = Date.from(lastDaySelectedMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
    HolidaySearch monthSearch = new HolidaySearch();
    monthSearch.setStartDate(beginOfMonth);
    monthSearch.setEndDate(endOfMonth);
    List<Holiday> allHolidays = holidayManager.getAllEntities(monthSearch, null);
    Calendar calMin = Calendar.getInstance();
    Calendar calMax = Calendar.getInstance();
    calMin.setTime(beginOfMonth);
    calMax.setTime(endOfMonth);
    int holidays = 0;
    for (Holiday holiday : allHolidays) {
        LocalDateTime holidayValue = LocalDateTime.ofInstant(holiday.getDate().toInstant(), ZoneId.systemDefault());
        int day = holidayValue.getDayOfMonth();
        if (!nonWorkingDays.contains(day) && day <= daysInMonth) {
            holidays++;
            nonWorkingDays.add(day);
        }
    }
    return holidays;
}
Also used : LocalDateTime(java.time.LocalDateTime) Holiday(com.autentia.tnt.businessobject.Holiday) RequestHoliday(com.autentia.tnt.businessobject.RequestHoliday) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) HolidaySearch(com.autentia.tnt.dao.search.HolidaySearch) RequestHolidaySearch(com.autentia.tnt.dao.search.RequestHolidaySearch) LocalDate(java.time.LocalDate) Date(java.util.Date) LocalDate(java.time.LocalDate)

Example 10 with Holiday

use of com.autentia.tnt.businessobject.Holiday in project TNTConcept by autentia.

the class MenuBean method getMenu.

/**
 * Get menu tree
 * @return menu tree
 */
public TreeNode getMenu() {
    // Create menu only the first time
    if (menu == null) {
        Principal creds = SpringUtils.getPrincipal();
        Stack<TreeNode> path = new Stack<TreeNode>();
        menu = new TreeNodeBase("menu", "Menu", false);
        path.push(menu);
        if (openNode(path, creds, null, "admin")) {
            addLeaf(path, creds, Permission.Entity_Menu(User.class), "users");
            addLeaf(path, creds, Permission.Entity_Menu(UserCategory.class), "userCategorys");
            addLeaf(path, creds, null, "changePassword");
            addLeaf(path, creds, Permission.Entity_Menu(Department.class), "departments");
            // addLeaf( path, creds, Permission.Entity_Menu(Setting.class),      "settings" );
            closeNode(path);
        }
        if (openNode(path, creds, null, "masterTables")) {
            addLeaf(path, creds, Permission.Entity_Menu(AccountEntryType.class), "accountEntryTypes");
            addLeaf(path, creds, Permission.Entity_Menu(OrganizationType.class), "organizationTypes");
            addLeaf(path, creds, Permission.Entity_Menu(InteractionType.class), "interactionTypes");
            addLeaf(path, creds, Permission.Entity_Menu(OrganizationISOCategory.class), "organizationISOCategorys");
            addLeaf(path, creds, Permission.Entity_Menu(ContractType.class), "contractTypes");
            addLeaf(path, creds, Permission.Entity_Menu(Magazine.class), "magazines");
            addLeaf(path, creds, Permission.Entity_Menu(OfferRejectReason.class), "offerRejectReasons");
            closeNode(path);
        }
        if (openNode(path, creds, null, "billing")) {
            addLeaf(path, creds, Permission.Entity_Menu(Bill.class), "bills");
            addLeaf(path, creds, Permission.Entity_Menu(Account.class), "accounts");
            addLeaf(path, creds, Permission.Entity_Menu(AccountEntry.class), "accountEntrys");
            addLeaf(path, creds, Permission.Entity_Menu(PeriodicalAccountEntry.class), "periodicalAccountEntrys");
            addLeaf(path, creds, Permission.Action_NOF, "nof");
            addLeaf(path, creds, Permission.Entity_Menu(FinancialRatio.class), "financialRatios");
            closeNode(path);
        }
        if (openNode(path, creds, null, "contacts")) {
            addLeaf(path, creds, Permission.Entity_Menu(Organization.class), "organizations");
            addLeaf(path, creds, Permission.Entity_Menu(Interaction.class), "interactions");
            addLeaf(path, creds, Permission.Entity_Menu(Contact.class), "contacts");
            addLeaf(path, creds, Permission.Entity_Menu(Offer.class), "offers");
            addLeaf(path, creds, Permission.Entity_Menu(Project.class), "projects");
            closeNode(path);
        }
        if (openNode(path, creds, null, "quality")) {
            addLeaf(path, creds, Permission.Action_ListQualityDocuments, "qualityDocuments");
            closeNode(path);
        }
        if (openNode(path, creds, null, "bulletin")) {
            addLeaf(path, creds, Permission.Entity_Menu(BulletinBoard.class), "bulletinBoards");
            addLeaf(path, creds, Permission.Entity_Menu(CompanyState.class), "companyStates");
            addLeaf(path, creds, Permission.Entity_Menu(BulletinBoardCategory.class), "bulletinBoardCategorys");
            addLeaf(path, creds, Permission.Entity_Menu(Idea.class), "ideas");
            closeNode(path);
        }
        if (openNode(path, creds, null, "activity")) {
            addLeaf(path, creds, Permission.Entity_Menu(Activity.class), "activitys");
            addLeaf(path, creds, Permission.Entity_Menu(Objective.class), "objectives");
            closeNode(path);
        }
        if (openNode(path, creds, null, "reports")) {
            addLeaf(path, creds, Permission.Action_GeneralReports, "generalReports");
            addLeaf(path, creds, Permission.Action_BitacoreReports, "bitacoreReports");
            addLeaf(path, creds, Permission.Action_BillReports, "billReports");
            addLeaf(path, creds, Permission.Action_ProjectReports, "projectReports");
            addLeaf(path, creds, Permission.Action_InteractionReports, "interactionReports");
            addLeaf(path, creds, Permission.Action_OrganizationReports, "organizationReports");
            addLeaf(path, creds, Permission.Action_OfferReports, "offerReports");
            addLeaf(path, creds, Permission.Action_OwnReports, "ownReports");
            addLeaf(path, creds, Permission.Action_PersonalReports, "personalReports");
            closeNode(path);
        }
        if (openNode(path, creds, null, "publish")) {
            addLeaf(path, creds, Permission.Entity_Menu(Tutorial.class), "tutorials");
            addLeaf(path, creds, Permission.Entity_Menu(Publication.class), "publications");
            closeNode(path);
        }
        if (openNode(path, creds, null, "holiday")) {
            addLeaf(path, creds, Permission.Entity_Menu(Holiday.class), "holidays");
            addLeaf(path, creds, Permission.Entity_Menu(RequestHoliday.class), "requestHolidays");
            addLeaf(path, creds, Permission.Entity_Menu(AdminHoliday.class), "adminHolidays");
            closeNode(path);
        }
        if (openNode(path, creds, null, "utils")) {
            addLeaf(path, creds, Permission.Entity_Menu(Book.class), "books");
            addLeaf(path, creds, Permission.Entity_Menu(Inventary.class), "inventarys");
            closeNode(path);
        }
    }
    return menu;
}
Also used : InteractionType(com.autentia.tnt.businessobject.InteractionType) UserCategory(com.autentia.tnt.businessobject.UserCategory) Account(com.autentia.tnt.businessobject.Account) User(com.autentia.tnt.businessobject.User) Organization(com.autentia.tnt.businessobject.Organization) BulletinBoardCategory(com.autentia.tnt.businessobject.BulletinBoardCategory) Activity(com.autentia.tnt.businessobject.Activity) PeriodicalAccountEntry(com.autentia.tnt.businessobject.PeriodicalAccountEntry) AccountEntry(com.autentia.tnt.businessobject.AccountEntry) TreeNodeBase(org.apache.myfaces.custom.tree2.TreeNodeBase) RequestHoliday(com.autentia.tnt.businessobject.RequestHoliday) Department(com.autentia.tnt.businessobject.Department) PeriodicalAccountEntry(com.autentia.tnt.businessobject.PeriodicalAccountEntry) TreeNode(org.apache.myfaces.custom.tree2.TreeNode) Book(com.autentia.tnt.businessobject.Book) OrganizationISOCategory(com.autentia.tnt.businessobject.OrganizationISOCategory) FinancialRatio(com.autentia.tnt.businessobject.FinancialRatio) Tutorial(com.autentia.tnt.businessobject.Tutorial) Interaction(com.autentia.tnt.businessobject.Interaction) Publication(com.autentia.tnt.businessobject.Publication) AccountEntryType(com.autentia.tnt.businessobject.AccountEntryType) CompanyState(com.autentia.tnt.businessobject.CompanyState) OrganizationType(com.autentia.tnt.businessobject.OrganizationType) Inventary(com.autentia.tnt.businessobject.Inventary) Stack(java.util.Stack) Contact(com.autentia.tnt.businessobject.Contact) BulletinBoard(com.autentia.tnt.businessobject.BulletinBoard) Project(com.autentia.tnt.businessobject.Project) Objective(com.autentia.tnt.businessobject.Objective) OfferRejectReason(com.autentia.tnt.businessobject.OfferRejectReason) Offer(com.autentia.tnt.businessobject.Offer) Idea(com.autentia.tnt.businessobject.Idea) Holiday(com.autentia.tnt.businessobject.Holiday) AdminHoliday(com.autentia.tnt.businessobject.AdminHoliday) RequestHoliday(com.autentia.tnt.businessobject.RequestHoliday) Bill(com.autentia.tnt.businessobject.Bill) ContractType(com.autentia.tnt.businessobject.ContractType) Principal(com.autentia.tnt.manager.security.Principal) Magazine(com.autentia.tnt.businessobject.Magazine) AdminHoliday(com.autentia.tnt.businessobject.AdminHoliday)

Aggregations

Holiday (com.autentia.tnt.businessobject.Holiday)10 RequestHoliday (com.autentia.tnt.businessobject.RequestHoliday)10 Calendar (java.util.Calendar)6 Date (java.util.Date)6 HolidaySearch (com.autentia.tnt.dao.search.HolidaySearch)5 RequestHolidaySearch (com.autentia.tnt.dao.search.RequestHolidaySearch)5 RequestHolidayManager (com.autentia.tnt.manager.holiday.RequestHolidayManager)4 HolidayManager (com.autentia.tnt.manager.holiday.HolidayManager)3 LocalDate (java.time.LocalDate)3 AccountEntry (com.autentia.tnt.businessobject.AccountEntry)2 AccountEntryType (com.autentia.tnt.businessobject.AccountEntryType)2 Activity (com.autentia.tnt.businessobject.Activity)2 AdminHoliday (com.autentia.tnt.businessobject.AdminHoliday)2 Bill (com.autentia.tnt.businessobject.Bill)2 Book (com.autentia.tnt.businessobject.Book)2 BulletinBoard (com.autentia.tnt.businessobject.BulletinBoard)2 BulletinBoardCategory (com.autentia.tnt.businessobject.BulletinBoardCategory)2 CompanyState (com.autentia.tnt.businessobject.CompanyState)2 Contact (com.autentia.tnt.businessobject.Contact)2 ContractType (com.autentia.tnt.businessobject.ContractType)2