Package domain.shedule

Examples of domain.shedule.SheduleIndividualWork


        DetachedCriteria criteria = DetachedCriteria.forClass(SheduleIndividualWork.class)
                .addOrder(Order.asc("timeBegin"))
                .add(Property.forName("collaborator").eq(dto.getCollaborator()));
        for(Object o: dao.getList(criteria, null, null)) {
            SheduleIndividualWork siw = (SheduleIndividualWork) o;
            Calendar cal = GregorianCalendar.getInstance();
            cal.setTime(siw.getTimeBegin());

            int day = cal.get(Calendar.DAY_OF_MONTH);
            List<SheduleIndividualWork> dayList = works.get(day);
            if(dayList == null) {
                dayList = new LinkedList<SheduleIndividualWork>();
View Full Code Here


            DetachedCriteria criteria = DetachedCriteria.forClass(SheduleIndividualWork.class)
                    .add(Property.forName("collaborator").eq(dto.getCollaborator()))
                    .add(Property.forName("timeBegin").ge(begin))
                    .add(Property.forName("timeBegin").le(end));
            for(Object o: dao.getList(criteria, null, null)) {
                SheduleIndividualWork siw = (SheduleIndividualWork) o;
                Day day = new Day(siw.getTimeBegin());
                List<SheduleIndividualWork> dayList = exWorks.get(day);
                if(dayList == null) {
                    dayList = new LinkedList<SheduleIndividualWork>();
                    exWorks.put(day, dayList);
                }
View Full Code Here

            }

        });
        //цикл до предпоследнего элемента - последний объединять не надо (вылетит outofbounds)
        for (int i = 0; i < exWorks.size() - 1; i++) {
            SheduleIndividualWork current = exWorks.get(i);
            if(current == null) {
                continue;
            }
            SheduleIndividualWork next = null;
            Integer nextIndex = null;
            for (int j = i+1; j < exWorks.size(); j++) {
                if (exWorks.get(j) != null) {
                    next = exWorks.get(j);
                    nextIndex = j;
                    break;
                }
            }
            if (next != null) {
                Date currentEnd = current.getTimeEnd();
                Date nextBegin = next.getTimeBegin();
                if (!nextBegin.after(currentEnd)) {
                    //пересекаются либо идут встык
                    if (current.getServiceDuration() == next.getServiceDuration()) {
                        //разбивка совпадает - объединяем
                        current.setTimeEnd(next.getTimeEnd());
                        exWorks.set(nextIndex, null); //убили
                    } else {
                        //разбивка не совпадает - обрезаем
                        current.setTimeEnd(nextBegin);
                    }
                }
            }
        }
        //удаляем убитые
        for (Iterator<SheduleIndividualWork> it = exWorks.iterator(); it.hasNext();) {
            SheduleIndividualWork work = it.next();
            if (work == null) {
                it.remove();
            }
        }
    }
View Full Code Here

TOP

Related Classes of domain.shedule.SheduleIndividualWork

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.