コード例 #1
0
ファイル: LedgerService.java プロジェクト: ashishswami22/b
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("{ledger_id}")
  public Ledger getUser(@PathParam("ledger_id") long ledger_id) {
    Ledger objLedger = new Ledger();
    objLedger.setLedger_id(ledger_id);
    try {
      Reader reader = Resources.getResourceAsReader("./dao/SqlMapConfig.xml");
      SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

      objLedger = (Ledger) sqlMap.queryForObject("Ledger.getLedgerById", objLedger);

    } catch (Exception e) {
      e.printStackTrace();
    }

    return objLedger;
  }
コード例 #2
0
ファイル: LedgerService.java プロジェクト: ashishswami22/b
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("/list/{company_id}/{type}")
  public List<Ledger> getLedgers(
      @PathParam("company_id") long company_id, @PathParam("type") String type) {
    List<Ledger> objLedgerList = null;
    Ledger objLedger = new Ledger();
    objLedger.setCompany_id(company_id);

    try {
      Reader reader = Resources.getResourceAsReader("./dao/SqlMapConfig.xml");
      SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

      if (type.equals("all")) {
        objLedgerList =
            (List<Ledger>) sqlMap.queryForList("Ledger.getLedgersByCompanyId", objLedger);
      } else if (type.equals("as")) {
        objLedgerList =
            (List<Ledger>) sqlMap.queryForList("Ledger.getAssetsByCompanyId", objLedger);
      } else if (type.equals("li")) {
        objLedgerList =
            (List<Ledger>) sqlMap.queryForList("Ledger.getLiabilitiesByCompanyId", objLedger);
      } else if (type.equals("de")) {
        objLedgerList =
            (List<Ledger>) sqlMap.queryForList("Ledger.getDirectExpensesByCompanyId", objLedger);
      } else if (type.equals("di")) {
        objLedgerList =
            (List<Ledger>) sqlMap.queryForList("Ledger.getDirectIncomeByCompanyId", objLedger);
      } else if (type.equals("ie")) {
        objLedgerList =
            (List<Ledger>) sqlMap.queryForList("Ledger.getIndirectExpensesByCompanyId", objLedger);
      } else if (type.equals("ii")) {
        objLedgerList =
            (List<Ledger>) sqlMap.queryForList("Ledger.getIndirectIncomeByCompanyId", objLedger);
      }

    } catch (Exception e) {
      e.printStackTrace();
    }

    return objLedgerList;
  }