Exemplo n.º 1
0
  @Override
  @Secured
  public void removeTestExecution(TestExecution testExecution) throws ServiceException {
    TestExecution freshTestExecution = testExecutionDAO.get(testExecution.getId());
    if (freshTestExecution == null) {
      throw new ServiceException("serviceException.testExecutionNotFound", testExecution.getName());
    }
    for (TestExecutionParameter testExecutionParameter : freshTestExecution.getParameters()) {
      testExecutionParameterDAO.remove(testExecutionParameter);
    }
    for (Value value : freshTestExecution.getValues()) {
      for (ValueParameter valueParameter : value.getParameters()) {
        valueParameterDAO.remove(valueParameter);
      }
      valueDAO.remove(value);
    }

    Iterator<TestExecutionAttachment> allTestExecutionAttachments =
        freshTestExecution.getAttachments().iterator();
    while (allTestExecutionAttachments.hasNext()) {
      testExecutionAttachmentDAO.remove(allTestExecutionAttachments.next());
      allTestExecutionAttachments.remove();
    }
    testExecutionDAO.remove(freshTestExecution);
  }
Exemplo n.º 2
0
 @Override
 @Secured
 public void removeValue(Value value) throws ServiceException {
   TestExecution exec = testExecutionDAO.get(value.getTestExecution().getId());
   if (exec == null) {
     throw new ServiceException(
         "serviceException.removeValue.testExecutionNotFound", value.getTestExecution().getName());
   }
   Value v = valueDAO.get(value.getId());
   for (ValueParameter vp : v.getParameters()) {
     valueParameterDAO.remove(vp);
   }
   valueDAO.remove(v);
 }
Exemplo n.º 3
0
 @Override
 @Secured
 public Value updateValue(Value value) throws ServiceException {
   TestExecution exec = testExecutionDAO.get(value.getTestExecution().getId());
   if (exec == null) {
     throw new ServiceException(
         "serviceException.updateValue.testExecutionNotFound", value.getTestExecution().getName());
   }
   Value oldValue = valueDAO.get(value.getId());
   if (oldValue == null) {
     throw new ServiceException("serviceException.valueNotFound");
   }
   Value freshValue = valueDAO.update(value);
   Value freshValueClone = freshValue.clone();
   freshValueClone.setMetric(freshValue.getMetric().clone());
   freshValueClone.getMetric().setValues(null);
   UpdateSet<ValueParameter> updateSet =
       EntityUtils.updateSet(oldValue.getParameters(), value.getParameters());
   if (!updateSet.removed.isEmpty()) {
     throw new ServiceException("serviceException.staleCollection");
   }
   List<ValueParameter> newParams = new ArrayList<ValueParameter>();
   for (ValueParameter vp : updateSet.toAdd) {
     vp.setValue(freshValue);
     newParams.add(valueParameterDAO.create(vp).clone());
     newParams.get(newParams.size() - 1).setValue(freshValueClone);
   }
   for (ValueParameter vp : updateSet.toUpdate) {
     newParams.add(valueParameterDAO.update(vp).clone());
     newParams.get(newParams.size() - 1).setValue(freshValueClone);
   }
   for (ValueParameter vp : updateSet.toRemove) {
     valueParameterDAO.remove(vp);
   }
   freshValueClone.setParameters(newParams.isEmpty() ? null : newParams);
   return freshValueClone;
 }