예제 #1
0
 public static void main2(String[] args) {
   Report3 r = new Report3();
   try {
     File f = new File("F:\\\\Formality\\report3.csv");
     FileWriter fw = new FileWriter(f);
     Connection conn = r.getConnection();
     StringBuffer sb = new StringBuffer();
     List<List<String>> rows = r.writeUsers(1508, 1637, conn);
     r.toCSV(rows, sb);
     System.out.println(sb.toString());
     fw.write(sb.toString());
     fw.close();
   } catch (Exception e) {
     e.printStackTrace(); // To change body of catch statement use File | Settings | File
     // Templates.
   }
 }
예제 #2
0
  /**
   * Sample program params for a class 52 with some specified modules Report3 -c:52
   * -f:u:/formality/Greenfield2010/CyczReport3-GeoProbGraph.csv
   * -m:237,246,247,250,252,259,261,265,268
   *
   * @param args
   */
  public static void main(String[] args) {
    Report3 r = new Report3();
    try {
      SimpleJSAP jsap =
          new SimpleJSAP(
              "Report3",
              "Report 3",
              new Parameter[] {
                new QualifiedSwitch(
                    "beginUserId",
                    JSAP.INTEGER_PARSER,
                    JSAP.NO_DEFAULT,
                    JSAP.NOT_REQUIRED,
                    'b',
                    "buid",
                    "Takes a begin Id.  Must be combined with -e --euid"),
                new QualifiedSwitch(
                    "endUserId",
                    JSAP.INTEGER_PARSER,
                    JSAP.NO_DEFAULT,
                    JSAP.NOT_REQUIRED,
                    'e',
                    "euid",
                    "Takes a end Id (must be combined with -b --buid"),
                new QualifiedSwitch(
                    "classId",
                    JSAP.INTEGER_PARSER,
                    JSAP.NO_DEFAULT,
                    JSAP.NOT_REQUIRED,
                    'c',
                    "classId",
                    "Takes the course id."),
                new QualifiedSwitch(
                    "outfile",
                    FileStringParser.getParser(),
                    JSAP.NO_DEFAULT,
                    JSAP.REQUIRED,
                    'f',
                    "file",
                    "The output file (full path) to a comma separated value file."),
                new QualifiedSwitch(
                        "modules",
                        JSAP.INTEGER_PARSER,
                        JSAP.NO_DEFAULT,
                        JSAP.NOT_REQUIRED,
                        'm',
                        "modules",
                        "Module IDs to report on")
                    .setList(true)
                    .setListSeparator(',')
              });
      JSAPResult config = jsap.parse(args);
      if (jsap.messagePrinted()) System.exit(1);

      File f = config.getFile("outfile");
      FileWriter fw = new FileWriter(f);
      Connection conn = null;
      conn = r.getConnection();
      StringBuffer sb = new StringBuffer();
      int beginId = 0, endId = 0, courseId;
      List<List<String>> rows = null;
      int[] modules = config.getIntArray("modules");
      r.modIds = modules;
      if (config.getBoolean("beginUserId") && config.getBoolean("endUserId")) {
        beginId = config.getInt("beginUserId");
        endId = config.getInt("endUserId");
        rows = r.writeUsers(beginId, endId, conn);
      } else if (config.getBoolean("classId")) {
        courseId = config.getInt("classId");
        r.courseName = r.getCourseName(conn, courseId);
        rows = r.writeCourse(courseId, conn);
      }
      r.toCSV(rows, sb);
      System.out.println(sb.toString());
      fw.write(sb.toString());
      fw.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }