コード例 #1
0
ファイル: ApiCreator.java プロジェクト: tghass/AppFactory
  ///////////
  // Methods//
  ///////////
  public void createServerFile(
      HashMap<String, DataObj> dataObjsMap, HashMap<String, PageObj> pageObjsMap) {
    // Copy files over
    try {
      FileUtils.copyFile(sourceConfig, new File("Output/config.js"));
    } catch (IOException e) {
      System.out.println("Error copying over config file for");
      System.out.println(e);
    }
    out.write(genDbConnection());
    // For each data object, get object by ID
    Iterator it = dataObjsMap.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry one = (Map.Entry) it.next();
      DataObj curDataObj = (DataObj) one.getValue();
      String name = curDataObj.getName();
      out.write("\n /* " + name + ": CRUD GET, DELETE, UPDATE, POST BY ID*/\n");
      out.write(genGetById(curDataObj));
      out.write(genDelById(curDataObj));
      out.write(genUpdateById(curDataObj));
      out.write(genAdd(curDataObj));
    }
    // Hack to get a necessary API call for OAuth stuff
    out.write(
        genGetByPageParam(
            null,
            new Section(
                "View",
                new ArrayList<String>(Arrays.asList(new String[] {"OAuthID"})),
                new ArrayList<String>(Arrays.asList(new String[] {"User"}))),
            dataObjsMap));

    // For each page, generate the calls necessery to make
    // the view/create params work
    it = pageObjsMap.entrySet().iterator();
    while (it.hasNext()) {
      Map.Entry one = (Map.Entry) it.next();
      PageObj curPageObj = (PageObj) one.getValue();
      String name = curPageObj.getName();
      out.write("\n /* " + name + ": CRUD GET,DELETE,UPDATE,POST *NOT* BY ID */\n");
      List<Section> sections = curPageObj.getSections();
      for (Section section : sections) {
        switch ((Section.Type) section.getType()) {
          case VIEW:
            out.write(genGetByPageParam(curPageObj, section, dataObjsMap));
            break;
          case CREATE:
            // out.write(genPostByPageParam(curPageObj, section));
            break;
          case MODIFY:
            break;
          case DELETE:
            break;
        }
      }
    }
    out.write(genServerListen());
  }
コード例 #2
0
ファイル: Elf.java プロジェクト: patronuliviu/Flashtool
  /**
   * @param type
   * @return
   * @throws IOException
   */
  public Section[] getSections(final int type) throws IOException {
    final ArrayList<Section> result = new ArrayList<Section>();

    final Section[] secs = getSections();
    for (Section section : secs) {
      if (type == section.getType()) {
        result.add(section);
      }
    }

    return result.toArray(new Section[result.size()]);
  }