Package net.sf.pmr.keopsframework.domain.validation

Examples of net.sf.pmr.keopsframework.domain.validation.Errors


  /* (non-Javadoc)
   * @see net.sf.pmr.agilePlanning.domain.release.ReleaseValidator#validateForDelete(net.sf.pmr.agilePlanning.domain.release.Release)
   */
  public Errors validateForDelete(Release release) {
   
        Errors errors = AgilePlanningObjectFactory.getErrors();
   
    if (release.getStories() == null || release.getStories().isEmpty() ) {
     
      return errors;
     
    } else {
     
      errors.reject("release.IsNotDeletableBecauseOfStories");
     
      return errors;
    }

  }
View Full Code Here


     */
    public Errors validate(final Object object) {

        Iteration iteration = (Iteration) object;

        Errors errors = AgilePlanningObjectFactory.getErrors();

        // la date de d�but est obligatoire
        if (iteration.getStartDate() == null) {

            errors.rejectValue(IterationValidator.FIELD_START,
                    "iteration.startMandatory");

        }

        // la date de fin est obligatoire
        if (iteration.getEndDate() == null) {

            errors.rejectValue(IterationValidator.FIELD_END,
                    "iteration.endMandatory");

        }

        if (iteration.getStartDate() != null && iteration.getEndDate() != null) {

            Calendar start = Calendar.getInstance();
            start.setTime(iteration.getStartDate());
            Calendar end = Calendar.getInstance();
            end.setTime(iteration.getEndDate());

            if (end.compareTo(start) < 0) {

                errors.reject("iteration.incoherentDate");

            }

        }

View Full Code Here

        // buid the story
        Story story = this.buildStory(projectPersistanceId, shortDescription, description, daysEstimated,
                businessValueId, riskLevelId);

        // validate
        Errors errors = storyValidator.validate(story);

        // no errors
        if (!errors.hasErrors()) {
            // persist
            storyRepository.addOrUpdate(story);
        }

        return errors;
View Full Code Here

        // find the story
        Story story = storyRepository.findByPersistanceId(storyPersistanceId);
       
    // if the story is not found, return a global error
    if (story == null) {
      Errors errros = AgilePlanningObjectFactory.getErrors();
      errros.reject("story.doesntExistsInDatabase");
      return errros;
    }

        // else build the object to persist
        Task task = AgilePlanningObjectFactory.getTask();
        User user = CoreObjectFactory.getUser();
        user.setPersistanceId(developperPersistanceId);

        task.setOwner(user);
        task.setDaysEstimated(numberOfIdealDays);
        task.setShortDescription(shortDescription);

        // validate
        Errors errors = taskValidator.validate(task);

        // persist
        if (!errors.hasErrors()) {
                story.getTasks().add(task);
                storyRepository.addOrUpdate(story);

        }
View Full Code Here

         // find the story to delete in the repository
         Story story = storyRepository.findByPersistanceId(persistanceId);

     // if the story is not found, return a global error
     if (story == null) {
       Errors errors = AgilePlanningObjectFactory.getErrors();
       errors.reject("story.doesntExistsInDatabase");
       return errors;
     }
        
         // if the story is found, update the persistanceVersion for concurrency management
         story.setPersistanceVersion(persistanceVersion);
 
         // validate
         Errors errors = storyValidator.validateForDelete(story);

         // delete if validation is ok
         if (!errors.hasErrors()) {
             storyRepository.delete(story);
         }
        
         return errors;
      
View Full Code Here

        // find the story to update in the repository
        Story story = storyRepository.findByPersistanceId(persistanceId);

    // if the story is not found, return a global error
    if (story == null) {
      Errors errros = AgilePlanningObjectFactory.getErrors();
      errros.reject("story.doesntExistsInDatabase");
      return errros;
    }

       
        // update the story
        story.setShortDescription(shortDescription);
        story.setDescription(description);
        story.setDaysEstimated(daysEstimated);
        story.setPersistanceId(persistanceId);
        story.setPersistanceVersion(persistanceVersion);

        // find the riskLevel and business value
        BusinessValue businessValue = businessValueRepository.findById(businessValueId);
        story.setBusinessValue(businessValue);

        RiskLevel riskLevel = riskLevelRepository.findById(riskLevelId);
        story.setRiskLevel(riskLevel);

        // validate
        Errors errors = storyValidator.validate(story);

        // persist
        if (!errors.hasErrors()) {
            storyRepository.addOrUpdate(story);
        }

        // return an empty error object (no validations are made)
        return AgilePlanningObjectFactory.getErrors();
View Full Code Here

    // find the story
    Story story = storyRepository.findByPersistanceId(storyPersistanceId);

    // if the story is not found, return a global error
    if (story == null) {
      Errors errros = AgilePlanningObjectFactory.getErrors();
      errros.reject("story.doesntExistsInDatabase");
      return errros;
    }

    // else, build the object to persist
    Task task = AgilePlanningObjectFactory.getTask();
    User user = CoreObjectFactory.getUser();
    user.setPersistanceId(developperPersistanceId);

    task.setOwner(user);
    task.setPersistanceId(persistanceId);
    task.setPersistanceVersion(persistanceVersion);
    task.setDaysEstimated(numberOfIdealDays);
    task.setShortDescription(shortDescription);

    // validate
    Errors errors = taskValidator.validate(task);

    if (!errors.hasErrors()) {

      // find the task to update
      for (Iterator iterator = story.getTasks().iterator(); iterator
          .hasNext();) {
        Task taskToUpdate = (Task) iterator.next();
View Full Code Here

    // find the story
    Story story = storyRepository.findByPersistanceId(storyPersistanceId);

    // if the story is not found, return a global error
    if (story == null) {
      Errors errros = AgilePlanningObjectFactory.getErrors();
      errros.reject("story.doesntExistsInDatabase");
      return errros;
    }
   
    Task taskToDelete = null;
   
    // find the task to delete
    for (Task task : story.getTasks()) {
      if (task.getPersistanceId() == persistanceId) {
        taskToDelete = task;
      }
    }
   
    // if the task is not found, return a global error
    if (taskToDelete == null) {
      Errors errros = AgilePlanningObjectFactory.getErrors();
      errros.reject("task.doesntExistsInDatabase");
      return errros;
    }
   
    // else check if the task can be deleted
    Errors errors = taskValidator.validateForDelete(taskToDelete);
   
    // else, remove the task from the set
    if (!errors.hasErrors()) {

      // update the persistanceVersion
      taskToDelete.setPersistanceVersion(persistanceVersion);

      // remove from the set
View Full Code Here


        // finding story
        Story story = storyRepository.findByPersistanceId(storyPersistanceId);

    Errors errors = AgilePlanningObjectFactory.getErrors();
       
    // if the story is not found, return a global error
    if (story == null) {
      errors.reject("story.doesntExistsInDatabase");
      return errors;
    }

     
        // building object charge
View Full Code Here

            final long chargePersistanceVersion) {

        // find the charge
        Story story = storyRepository.findByPersistanceId(storyPersistanceId);
       
    Errors errors = AgilePlanningObjectFactory.getErrors();
       
    // if the story is not found, return a global error
    if (story == null) {
      errors.reject("story.doesntExistsInDatabase");
      return errors;
    }


        for (Task task : story.getTasks()) {
View Full Code Here

TOP

Related Classes of net.sf.pmr.keopsframework.domain.validation.Errors

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.