Пример #1
0
  /**
   * Check for errors and create files before create
   *
   * @param inputData
   * @param outputData
   * @throws IOException
   */
  @Before(only = "create")
  public static void beforeCreate(java.io.File inputData, java.io.File outputData)
      throws IOException {
    params.put("object.creator.id", User.getLoggedUser().getId().toString());
    validation.required(inputData);

    if (!validation.hasErrors()) {
      InputFile inputFile = new InputFile(inputData);
      inputFile.save();
      params.put("object.inputData.id", inputFile.getId().toString());

      if (outputData != null) {
        OutputFile outputFile = new OutputFile(outputData);
        outputFile.save();
        params.put("object.outputData.id", outputFile.getId().toString());
      }
    }
  }
Пример #2
0
  /**
   * Update files before save
   *
   * @param id
   * @param inputData
   * @param outputData
   * @param removeOutputData
   * @throws IOException
   */
  @Before(only = "save")
  public static void beforeSave(
      Long id, java.io.File inputData, java.io.File outputData, boolean removeOutputData)
      throws IOException {
    models.Task task = models.Task.findById(id);
    notFoundIfNull(task);

    if (removeOutputData) {
      task.deleteOutputData();
    }

    if (inputData != null) {
      InputFile inputFile = new InputFile(inputData);
      inputFile.save();
      params.put("object.inputData.id", inputFile.getId().toString());
    }
    if (outputData != null) {
      OutputFile outputFile = new OutputFile(outputData);
      outputFile.save();
      params.put("object.outputData.id", outputFile.getId().toString());
    }
  }