Example #1
0
  public Data[] execute() {
    File inData, outData;
    Data[] dm = null;
    ValidateNETFile validator;
    // System.out.println("Executing PajeknetToPajekMat");
    Object inFile = data[0].getData();

    if (inFile instanceof File) {
      inData = (File) inFile;

      validator = new ValidateNETFile();
      // System.out.println("Before try");
      try {
        // System.out.println("Trying");
        validator.validateNETFormat(inData);
        if (validator.getValidationResult()) {
          outData = convertNetToMat(validator);
          if (outData != null) {
            dm = new Data[] {new BasicData(outData, MATFileProperty.MAT_MIME_TYPE)};
            return dm;
          } else {
            logger.log(
                LogService.LOG_ERROR,
                "Problem executing conversion from Pajek .net to .mat. Output file was not created");
            return null;
          }
        } else {
          logger.log(
              LogService.LOG_ERROR,
              "Problem executing conversion from Pajek .net to .mat "
                  + validator.getErrorMessages());
          return null;
        }
      } catch (FileNotFoundException fnf) {
        logger.log(LogService.LOG_ERROR, "Could not find the specified Pajek .net file.", fnf);
        return null;
      } catch (IOException ioe) {
        logger.log(LogService.LOG_ERROR, "IO Error while converting from Pajek .net to .mat.", ioe);
        ioe.printStackTrace();
        return null;
      } catch (Exception ex) {
        logger.log(
            LogService.LOG_ERROR,
            "Error while converting from Pajek .net to .mat." + validator.getErrorMessages(),
            ex);
        ex.printStackTrace();
        return null;
      }
    } else
      logger.log(
          LogService.LOG_ERROR,
          "Unable to convert the file. "
              + "Unable to convert from Pajek .net to .mat because input data is not a file");
    return null;
  }