public void deleteTaskQualityForm(TaskQualityForm taskQualityForm) {
     try {
         assignedTaskQualityFormsToOrderElementModel
                 .removeAdvanceAssignmentIfNeeded(taskQualityForm);
     } catch (ValidationException e) {
         showInformativeMessage(e.getMessage());
         return;
     }
     assignedTaskQualityFormsToOrderElementModel
             .deleteTaskQualityForm(taskQualityForm);
     reloadTaskQualityForms();
 }
    /**
     * Method called when the onUpload event happens.
     *
     * @param Media
     *            Media to be imported.
     */
    public void importProject(Media media) {

        String file = media.getName();

        if (checkFileFormat(file)) {

            if (importCalendars.isChecked()) {

                try {
                    importCalendar(media.getStreamData(), file);
                    messages.showMessage(Level.INFO, _(file
                            + ": Calendar import successfully!"));
                } catch (InstanceNotFoundException e) {
                    messages.showMessage(Level.ERROR, _("Instance not found."));
                } catch (ValidationException e) {
                    messages.showMessage(Level.ERROR, e.getMessage());
                }

            } else if (importTasks.isChecked()) {
                importProject(media.getStreamData(), file);

                messages.showMessage(Level.INFO, _(file
                        + ": Task import successfully!"));

            } else if (importAll.isChecked()) {

                try {
                    importAll(media.getStreamData(), file);
                    messages.showMessage(Level.INFO, _(file
                            + ": Import successfully!"));
                } catch (InstanceNotFoundException e) {
                    messages.showMessage(Level.ERROR, _("Instance not found."));
                } catch (ValidationException e) {
                    messages.showMessage(Level.ERROR, e.getMessage());
                }

            } else {
                messages.showMessage(Level.WARNING,
                        _("Select one of the options."));
            }

        } else {
            messages.showMessage(Level.ERROR,
                    _("The only current supported formats are mpp and planner."));
        }

    }
示例#3
0
 private void checkIsPersonalTimesheetsTypeOfWorkHours(TypeOfWorkHours type) {
   Configuration configuration = configurationDAO.getConfiguration();
   if (configuration.getPersonalTimesheetsTypeOfWorkHours().getId().equals(type.getId())) {
     throw ValidationException.invalidValueException(
         "Cannot delete the type of work hours. It is configured as type of work hours for personal timesheets.",
         type);
   }
 }
 /**
  * Shows invalid values for {@link TaskQualityForm} entities
  * @param e
  */
 private void showInvalidValues(ValidationException e) {
     for (InvalidValue invalidValue : e.getInvalidValues()) {
         Object value = invalidValue.getRootBean();
         if (value instanceof TaskQualityForm) {
             showInvalidValue(invalidValue, (TaskQualityForm) value);
         }
     }
 }
示例#5
0
 private void checkHasHourCost(TypeOfWorkHours type) {
   List hoursCost =
       getSession().createCriteria(HourCost.class).add(Restrictions.eq("type", type)).list();
   if (!hoursCost.isEmpty()) {
     throw ValidationException.invalidValueException(
         "Cannot delete type of work hours. It is being used at this moment in some cost category.",
         type);
   }
 }
示例#6
0
 private void checkIsJiraConnectorTypeOfWorkHours(TypeOfWorkHours type) {
   Connector connector = connectorDAO.findUniqueByName(PredefinedConnectors.JIRA.getName());
   if (connector != null) {
     String name =
         connector.getPropertiesAsMap().get(PredefinedConnectorProperties.JIRA_HOURS_TYPE);
     if (name.equals(type.getName())) {
       throw ValidationException.invalidValueException(
           "Cannot delete the type of work hours. It is configured as type of work hours for JIRA connector.",
           type);
     }
   }
 }
示例#7
0
 private void checkHasWorkReportLine(TypeOfWorkHours type) {
   List workReportLines =
       getSession()
           .createCriteria(WorkReportLine.class)
           .add(Restrictions.eq("typeOfWorkHours", type))
           .list();
   if (!workReportLines.isEmpty()) {
     throw ValidationException.invalidValueException(
         "Cannot delete type of work hours. It is being used at this moment in some timesheet line.",
         type);
   }
 }
示例#8
0
 @Override
 public void checkHasTasks(QualityForm qualityForm) throws ValidationException {
   Query query =
       getSession()
           .createQuery(
               "FROM TaskQualityForm taskQualityForm JOIN taskQualityForm.qualityForm tq WHERE tq IN (:qualityForms)");
   query.setParameterList("qualityForms", Collections.singleton(qualityForm));
   if (!query.list().isEmpty()) {
     throw ValidationException.invalidValue(
         "Cannot delete quality form. It is being used at this moment by some task.", qualityForm);
   }
 }