Package org.projectforge.timesheet

Examples of org.projectforge.timesheet.TimesheetDO


    return null;
  }

  private TimesheetDO getRecentSheet(final TimesheetPrefEntry entry)
  {
    final TimesheetDO sheet = new TimesheetDO();
    final TaskDO task = taskTree.getTaskById(entry.getTaskId());
    sheet.setTask(task);
    final Kost2DO kost2 = kostCache.getKost2(entry.getKost2Id());
    sheet.setKost2(kost2);
    sheet.setDescription(entry.getDescription());
    sheet.setLocation(entry.getLocation());
    final PFUserDO user = userGroupCache.getUser(entry.getUserId());
    sheet.setUser(user);
    return sheet;
  }
View Full Code Here


   */
  @Override
  protected void cloneData()
  {
    super.cloneData();
    final TimesheetDO timesheet = getData();
    getBaseDao().setUser(timesheet, getUser().getId());
    form.userSelectPanel.markTextFieldModelAsChanged();
  }
View Full Code Here

    if(form != null && form.getFilter() != null && getData() != null) {
      form.getFilter().removeIgnoredLocation(getData().getLocation());
    }
    // Save time sheet as recent time sheet
    final TimesheetPrefData pref = getTimesheetPrefData();
    final TimesheetDO timesheet = getData();
    pref.appendRecentEntry(timesheet);
    pref.appendRecentTask(timesheet.getTaskId());
    if (StringUtils.isNotBlank(timesheet.getLocation()) == true) {
      pref.appendRecentLocation(timesheet.getLocation());
    }
    // Does the user want to store this time sheet as template?
    if (BooleanUtils.isTrue(form.saveAsTemplate) == true) {
      final UserPrefEditPage userPrefEditPage = new UserPrefEditPage(UserPrefArea.TIMESHEET_TEMPLATE, getData());
      userPrefEditPage.setReturnToPage(this.returnToPage);
View Full Code Here

  }

  public TimesheetDO addTimesheet(final PFUserDO user, final TaskDO task, final Timestamp startTime, final Timestamp stopTime,
      final String description)
  {
    final TimesheetDO timesheet = new TimesheetDO();
    timesheet.setDescription(description);
    timesheet.setStartTime(startTime);
    timesheet.setStopTime(stopTime);
    timesheet.setTask(task);
    timesheet.setUser(user);
    timesheetDao.internalSave(timesheet);
    return timesheet;
  }
View Full Code Here

            log.debug("Selected region: " + range.getStart() + " - " + range.getEnd() + " / allDay: " + range.isAllDay());
          }
          if (accessChecker.isRestrictedUser() == true) {
            return;
          }
          final TimesheetDO timesheet = new TimesheetDO();
          if (range.isAllDay() == true) {
            // Start with the first hour displayed (combo-box) or if any time sheets already exists for this date with a time sheet starts
            // with the stop date of the last time sheet of the current day.
            final TimesheetDO latest = timesheetEventsProvider.getLatestTimesheetOfDay(range.getEnd());
            if (latest != null) {
              timesheet.setStartDate(latest.getStopTime()).setStopTime(latest.getStopTime());
            } else {
              final Integer firstHourOfDay = filter.getFirstHour();
              final DateTime start = range.getStart().withHourOfDay(firstHourOfDay != null ? firstHourOfDay : 8);
              final long millis = DateHelper.getDateTimeAsMillis(start);
              timesheet.setStartDate(millis).setStopTime(millis);
            }
          } else {
            timesheet.setStartDate(DateHelper.getDateTimeAsMillis(range.getStart()))//
            .setStopTime(DateHelper.getDateTimeAsMillis(range.getEnd()));
          }
          if (filter.getTimesheetUserId() != null) {
            timesheetDao.setUser(timesheet, filter.getTimesheetUserId());
          }
          final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(timesheet);
          timesheetEditPage.setReturnToPage((WebPage) getPage());
          setResponsePage(timesheetEditPage);
        } else {
          onDateRangeSelectedHook(filter.getSelectedCalendar(), range, response);
        }
      }

      /**
       * Event was moved, a new start time was chosen.
       * @see net.ftlines.wicket.fullcalendar.FullCalendar#onEventDropped(net.ftlines.wicket.fullcalendar.callback.DroppedEvent,
       *      net.ftlines.wicket.fullcalendar.CalendarResponse)
       */
      @Override
      protected boolean onEventDropped(final DroppedEvent event, final CalendarResponse response)
      {
        // default mode is move and edit
        CalendarDropMode dropMode = CalendarDropMode.MOVE_EDIT;
        final StringValue parameterValue = RequestCycle.get().getRequest().getQueryParameters().getParameterValue("which");
        if (parameterValue != null) {
          try {
            dropMode = CalendarDropMode.fromAjaxTarget(parameterValue.toString());
          } catch (final Exception ex) {
            log.warn("Unable to get calendar drop mode for given value, using default mode. Given mode: " + parameterValue.toString());
          }
        }
        if (log.isDebugEnabled() == true) {
          log.debug("Event drop. eventId: "
              + event.getEvent().getId()
              + " eventClass"
              + event.getEvent().getClassName()
              + " sourceId: "
              + event.getSource().getUuid()
              + " dayDelta: "
              + event.getDaysDelta()
              + " minuteDelta: "
              + event.getMinutesDelta()
              + " allDay: "
              + event.isAllDay());
          log.debug("Original start time: " + event.getEvent().getStart() + ", original end time: " + event.getEvent().getEnd());
          log.debug("New start time: " + event.getNewStartTime() + ", new end time: " + event.getNewEndTime());
        }
        modifyEvent(event.getEvent(), event.getNewStartTime(), event.getNewEndTime(), dropMode, response);
        return false;
      }

      @Override
      protected boolean onEventResized(final ResizedEvent event, final CalendarResponse response)
      {
        if (log.isDebugEnabled() == true) {
          log.debug("Event resized. eventId: "
              + event.getEvent().getId()
              + " eventClass"
              + event.getEvent().getClassName()
              + " sourceId: "
              + event.getSource().getUuid()
              + " dayDelta: "
              + event.getDaysDelta()
              + " minuteDelta: "
              + event.getMinutesDelta());
        }
        modifyEvent(event.getEvent(), null, event.getNewEndTime(), CalendarDropMode.MOVE_EDIT, response);
        return false;
      }

      @Override
      protected void onEventClicked(final ClickedEvent clickedEvent, final CalendarResponse response)
      {
        final Event event = clickedEvent.getEvent();
        final String eventId = event != null ? event.getId() : null;
        final String eventClassName = event != null ? event.getClassName() : null;
        if (log.isDebugEnabled() == true) {
          log.debug("Event clicked. eventId: "
              + eventId
              + " eventClass"
              + event.getClassName()
              + ", sourceId: "
              + clickedEvent.getSource().getUuid());
        }
        if (eventId != null && eventClassName != null) {
          if (TimesheetEventsProvider.EVENT_CLASS_NAME.startsWith(eventClassName) == true) {
            // User clicked on a time sheet, show the time sheet:
            final Integer id = NumberHelper.parseInteger(eventId);
            final PageParameters parameters = new PageParameters();
            parameters.add(AbstractEditPage.PARAMETER_KEY_ID, id);
            final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(parameters);
            timesheetEditPage.setReturnToPage((WebPage) getPage());
            setResponsePage(timesheetEditPage);
            return;
          } else if (TimesheetEventsProvider.BREAK_EVENT_CLASS_NAME.startsWith(eventClassName) == true) {
            // User clicked on a break (between time sheets), create new time sheet with times of the break:
            final TimesheetDO breaksTimesheet = timesheetEventsProvider.getBreakTimesheet(eventId);
            final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(breaksTimesheet);
            timesheetEditPage.setReturnToPage((WebPage) getPage());
            setResponsePage(timesheetEditPage);
            return;
          } else if (BirthdayEventsProvider.EVENT_CLASS_NAME.startsWith(eventClassName) == true) {
View Full Code Here

    final String eventId = event != null ? event.getId() : null;
    final String eventClassName = event != null ? event.getClassName() : null;
    if (eventId != null && TimesheetEventsProvider.EVENT_CLASS_NAME.equals(eventClassName) == true) {
      // User clicked on a time sheet, show the time sheet:
      final Integer id = NumberHelper.parseInteger(eventId);
      final TimesheetDO dbTimesheet = timesheetDao.internalGetById(id);
      if (dbTimesheet == null) {
        return;
      }
      final TimesheetDO timesheet = new TimesheetDO();
      timesheet.copyValuesFrom(dbTimesheet);
      final Long newStartTimeMillis = newStartTime != null ? DateHelper.getDateTimeAsMillis(newStartTime) : null;
      final Long newEndTimeMillis = newEndTime != null ? DateHelper.getDateTimeAsMillis(newEndTime) : null;
      if (newStartTimeMillis != null) {
        timesheet.setStartDate(newStartTimeMillis);
      }
      if (newEndTimeMillis != null) {
        timesheet.setStopTime(new Timestamp(newEndTimeMillis));
      }
      final PFUserDO loggedInUser = PFUserContext.getUser();
      if (CalendarDropMode.MOVE_SAVE.equals(dropMode) == true || CalendarDropMode.MOVE_EDIT.equals(dropMode) == true) {
        if (timesheetDao.hasUpdateAccess(loggedInUser, timesheet, dbTimesheet, false) == false) {
          // User has no update access, therefore ignore this request...
          return;
        }
        if (CalendarDropMode.MOVE_SAVE.equals(dropMode) == true) {
          timesheetDao.update(timesheet);
          setResponsePage(getPage());
        } else {
          setResponsePage(new TimesheetEditPage(timesheet).setReturnToPage((WebPage) getPage()));
        }
        return;
      }
      // Copy this time sheet:
      timesheet.setId(null);
      timesheet.setDeleted(false);
      timesheetDao.setUser(timesheet, loggedInUser.getId()); // Copy for own user.
      if (CalendarDropMode.COPY_SAVE.equals(dropMode) == true) {
        if (timesheetDao.hasInsertAccess(loggedInUser, timesheet, false) == false) {
          // User has no insert access, therefore ignore this request...
          return;
View Full Code Here

      final ContentMenuEntryPanel menu = new ContentMenuEntryPanel(getNewContentMenuChildId(),
          new Link<Void>(ContentMenuEntryPanel.LINK_ID) {
        @Override
        public void onClick()
        {
          final TimesheetDO timesheet = new TimesheetDO();
          timesheet.setStartDate(getData().getStartDate())//
          .setStopTime(getData().getEndDate()) //
          .setLocation(getData().getLocation());
          final StringBuffer buf = new StringBuffer();
          buf.append(getData().getSubject());
          final String note = getData().getNote();
          if (StringUtils.isNotBlank(note) == true) {
            buf.append("\n").append(note);
          }
          timesheet.setDescription(buf.toString());
          final TimesheetDao timesheetDao = Registry.instance().getDao(TimesheetDao.class);
          timesheetDao.setUser(timesheet, getUserId());
          final TimesheetEditPage timesheetEditPage = new TimesheetEditPage(timesheet);
          timesheetEditPage.setReturnToPage(getReturnToPage());
          setResponsePage(timesheetEditPage);
        };
      }, getString("plugins.teamcal.event.convert2Timesheet"));
      addContentMenuEntry(menu);
    }
    if (isNew() == true) {
      @SuppressWarnings("serial")
      final ContentMenuEntryPanel menu = new ContentMenuEntryPanel(getNewContentMenuChildId(), new SubmitLink(
          ContentMenuEntryPanel.LINK_ID, form) {
        @Override
        public void onSubmit()
        {
          final TeamEventDO event = getData();
          final TimesheetDO timesheet = new TimesheetDO();
          if (event != null) {
            timesheet.setStartDate(event.getStartDate());
            timesheet.setStopTime(event.getEndDate());
          }
          if (returnToPage == null) {
            returnToPage = new TeamCalCalendarPage(new PageParameters());
          }
          setResponsePage(new TimesheetEditPage(timesheet).setReturnToPage(returnToPage));
View Full Code Here

    if (userPrefDO == null) {
      return null;
    }
    final TimesheetTemplateObject template = new TimesheetTemplateObject();
    final UserPrefDao userPrefDao = Registry.instance().getDao(UserPrefDao.class);
    final TimesheetDO timesheet = new TimesheetDO();
    userPrefDao.fillFromUserPrefParameters(userPrefDO, timesheet);
    template.setName(userPrefDO.getName());
    template.setDescription(timesheet.getDescription());
    template.setLocation(timesheet.getLocation());
    final UserObject user = PFUserDOConverter.getUserObject(timesheet.getUser());
    if (user != null) {
      template.setUser(user);
    }
    final TaskObject task = TaskDOConverter.getTaskObject(timesheet.getTask());
    if (task != null) {
      template.setTask(task);
    }
    final Cost2Object cost2 = Kost2DOConverter.getCost2Object(timesheet.getKost2());
    if (cost2 != null) {
      template.setCost2(cost2);
    }
    return template;
  }
View Full Code Here

    final PFUserDO user = getUser(TEST_USER);
    logon(user);
    final PFUserDO user2 = getUser(TEST_USER2);
    final TaskDO task = initTestDB.addTask("UserPrefTest", "root");
    UserPrefDO userPref = createUserPref(user, UserPrefArea.TIMESHEET_TEMPLATE, "test");
    TimesheetDO timesheet = createTimesheet(user2, task, "Micromata", "Wrote a test case...");
    userPrefDao.addUserPrefParameters(userPref, timesheet);
    assertFalse(userPrefDao.doesParameterNameAlreadyExist(null, user, UserPrefArea.TIMESHEET_TEMPLATE, "test"));
    final Serializable id = userPrefDao.save(userPref);
    assertTrue(userPrefDao.doesParameterNameAlreadyExist(null, user, UserPrefArea.TIMESHEET_TEMPLATE, "test"));
    assertFalse(userPrefDao.doesParameterNameAlreadyExist((Integer)id, user, UserPrefArea.TIMESHEET_TEMPLATE, "test"));
    userPref = userPrefDao.getById(id);
    assertEquals(5, userPref.getUserPrefEntries().size()); // user, task, kost2, location, description.
    {
      final Iterator<UserPrefEntryDO> it = userPref.getSortedUserPrefEntries().iterator();
      UserPrefEntryDO entry = it.next();
      assertUserPrefEntry(entry, "user", PFUserDO.class, user2.getId().toString(), "user", null, "1");
      userPrefDao.updateParameterValueObject(entry);
      assertEquals(user2.getId(), ((PFUserDO)entry.getValueAsObject()).getId());
      entry = it.next();
      assertUserPrefEntry(entry, "task", TaskDO.class, task.getId().toString(), "task", null, "2");
      userPrefDao.updateParameterValueObject(entry);
      assertEquals(task.getId(), ((TaskDO)entry.getValueAsObject()).getId());
      entry = it.next();
      assertUserPrefEntry(entry, "kost2", Kost2DO.class, null, "fibu.kost2", null, "3");
      entry = it.next();
      assertUserPrefEntry(entry, "location", String.class, "Micromata", "timesheet.location", 100, "ZZZ00");
      entry = it.next();
      assertUserPrefEntry(entry, "description", String.class, "Wrote a test case...", "description", 4000, "ZZZ01");
    }
    timesheet = new TimesheetDO();
    userPrefDao.fillFromUserPrefParameters(userPref, timesheet);
    assertEquals(user2.getId(), timesheet.getUserId());
    assertEquals(task.getId(), timesheet.getTaskId());
    assertNull(timesheet.getKost2Id());
    assertEquals("Micromata", timesheet.getLocation());
    assertEquals("Wrote a test case...", timesheet.getDescription());
    userPref.getUserPrefEntry("location").setValue("At home");
    userPrefDao.update(userPref);
    String[] names = userPrefDao.getPrefNames(UserPrefArea.TIMESHEET_TEMPLATE);
    assertEquals(1, names.length);
    assertEquals("test", names[0]);
View Full Code Here

    assertEquals(valueAsString, userPrefEntry.getValue());
  }

  private TimesheetDO createTimesheet(final PFUserDO user, final TaskDO task, final String location, final String description)
  {
    TimesheetDO timesheet = new TimesheetDO();
    timesheet.setUser(user);
    timesheet.setTask(task);
    timesheet.setLocation(location);
    timesheet.setDescription(description);
    return timesheet;
  }
View Full Code Here

TOP

Related Classes of org.projectforge.timesheet.TimesheetDO

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.