예제 #1
0
  public static void init(JPasswordField fpasswd) {
    try {
      String resource = "artemis_sqlmap/chado_iBatis_config.xml";
      Reader reader = Resources.getResourceAsReader(resource);

      Properties properties = null;
      if (System.getProperty("chado") != null) {
        String url = System.getProperty("chado");
        int index = url.indexOf("?");
        int index2 = url.indexOf("user="******"://");
        if (index3 < 0) index3 = 0;
        else index3 = index3 + 3;

        properties.put("chado", url.substring(index3, index));

        if (index2 < 0) properties.put("username", url.substring(index + 1));
        else properties.put("username", url.substring(index2 + 5));

        if (fpasswd != null && fpasswd.getPassword().length > 0)
          properties.put("password", new String(fpasswd.getPassword()));
      }

      sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader, properties);
    } catch (Exception e) {
      // If you get an error at this point, it doesnt matter what it was.  It is going to be
      // unrecoverable and we will want the app to blow up hard so we are aware of the
      // problem.  You should always log such errors and re-throw them in such a way that
      // you can be made immediately aware of the problem.
      e.printStackTrace();
      throw new RuntimeException("Error initializing DbSqlConfig class.  Cause: " + e);
    }
  }
  @SuppressWarnings("unchecked")
  public static void main(String[] args) throws IOException {

    String config = "sqlMapConfig.xml";

    Reader reader = Resources.getResourceAsReader(config);
    SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
    ClusterViewModel cViewModel = new ClusterViewModel();
    cViewModel.setId(Rpid.generate());
    try {
      sqlMap.insert("insertClusterViewModel", cViewModel);
    } catch (SQLException e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    List<ClusterViewModel> list;
    try {
      list = sqlMap.queryForList("checkFromCluster");
      for (ClusterViewModel clusterViewModel : list) {
        System.out.println(clusterViewModel);
      }
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
예제 #3
0
  // 생성자
  public writeAction() throws IOException {

    reader = Resources.getResourceAsReader("sqlMapConfig.xml"); // sqlMapConfig.xml 파일의 설정내용을 가져온다.
    sqlMapper =
        SqlMapClientBuilder.buildSqlMapClient(reader); // sqlMapConfig.xml의 내용을 적용한 sqlMapper 객체 생성.
    reader.close();
  }
예제 #4
0
 public static void main(String[] args) throws IOException, SQLException {
   String resource = "ibatis/sqlmap-config.xml";
   Reader reader = Resources.getResourceAsReader(resource);
   SqlMapClient sqlmap = SqlMapClientBuilder.buildSqlMapClient(reader);
   HashMap<String, String> param = new HashMap<String, String>();
   param.put("a", "1");
   Object obj = sqlmap.queryForObject("testSelectAs", param);
   System.out.println(obj);
 }
 static {
   try {
     Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
     client = SqlMapClientBuilder.buildSqlMapClient(reader);
   } catch (Exception e) {
     System.out.println("在userdao的static里面出错了");
     e.printStackTrace();
   }
 }
예제 #6
0
 static {
   try {
     String resource = "SqlMapConfig.xml";
     Reader reader = Resources.getResourceAsReader(resource);
     sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
   } catch (Exception e) {
     e.printStackTrace();
     throw new RuntimeException("Error initializing IbatisHelper class. Cause : " + e);
   }
 }
예제 #7
0
 /**
  * Singleton SqlMapClient 객체를 리턴
  *
  * @return SqlMapClient
  */
 public static SqlMapClient getSqlMapClient() {
   if (null == sqlMapClient) {
     try {
       Reader reader = Resources.getResourceAsReader("SqlMapConf.xml");
       sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
       reader.close();
     } catch (Exception e) {
       throw new RuntimeException(
           "Something bad happened while building the SqlMapClient instance." + e, e);
     }
   }
   return sqlMapClient;
 }
 /*
  * Required by interface
  *
  * @param properties required by interface
  * @see com.ibatis.dao.engine.transaction.DaoTransactionManager
  */
 public void configure(Properties properties) {
   try {
     Reader reader = null;
     if (properties.containsKey("SqlMapConfigURL")) {
       reader = Resources.getUrlAsReader((String) properties.get("SqlMapConfigURL"));
     } else if (properties.containsKey("SqlMapConfigResource")) {
       reader = Resources.getResourceAsReader((String) properties.get("SqlMapConfigResource"));
     } else {
       throw new DaoException(
           "SQLMAP transaction manager requires either 'SqlMapConfigURL' or 'SqlMapConfigResource' to be specified as a property.");
     }
     client = SqlMapClientBuilder.buildSqlMapClient(reader, properties);
   } catch (IOException e) {
     throw new DaoException("Error configuring SQL Map.  Cause: " + e);
   }
 }
예제 #9
0
  @Before
  public void setUp() throws Exception {

    Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
    SqlMapClient sqlMapClient = SqlMapClientBuilder.buildSqlMapClient(reader);
    reader.close();

    LegacyBankService legacyBankService = new IBatisLegacyBankService(sqlMapClient);

    KnowledgeBase knowledgeBase = DroolsHelper.createKnowledgeBase("etl-iBatis.drl");

    etlBankService = new DataTransformationServiceImpl();
    // etlBankService.setBankingService(new BankingServiceImpl());
    etlBankService.setLegacyBankService(legacyBankService);
    etlBankService.setReportFactory(new DefaultReportFactory());
    etlBankService.setKnowledgeBase(knowledgeBase);
  }
예제 #10
0
  @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;
  }
예제 #11
0
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("/groups")
  public List<AccountGroup> getAccountGroups() {
    List<AccountGroup> objAccountGroupList = null;

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

      objAccountGroupList =
          (List<AccountGroup>) sqlMap.queryForList("Ledger.getAccountGroups", null);

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

    return objAccountGroupList;
  }
예제 #12
0
  @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;
  }
예제 #13
0
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.TEXT_PLAIN)
  public String insertLedger(Ledger objLedger) {
    try {
      Reader reader = Resources.getResourceAsReader("./dao/SqlMapConfig.xml");
      SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
      Ledger temp = (Ledger) sqlMap.queryForObject("Ledger.getDuplicateLedger", objLedger);
      if (temp != null) {
        return "Sorry, Ledger name already exists.! Kindly try some other name.";
      }

      sqlMap.startTransaction();
      sqlMap.insert("Ledger.insertLedger", objLedger);
      sqlMap.commitTransaction();
      sqlMap.endTransaction();

    } catch (Exception e) {
      e.printStackTrace();
      return "Some problem occured while creating New Ledger. Kindly try again!";
    }
    return "New Ledger created successfully";
  }
예제 #14
0
  @PUT
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.TEXT_PLAIN)
  public String updateLedger(Ledger objLedger) {
    try {
      Reader reader = Resources.getResourceAsReader("./dao/SqlMapConfig.xml");
      SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);

      Ledger temp = (Ledger) sqlMap.queryForObject("Ledger.getLedgerById", objLedger);
      if (temp == null) {
        return "Ledger can not be identified. Try logging in again.!";
      }

      sqlMap.startTransaction();
      sqlMap.update("Ledger.updateByLedgerId", objLedger);
      sqlMap.commitTransaction();
      sqlMap.endTransaction();
    } catch (Exception e) {
      e.printStackTrace();
      return "Some problem occured while updating Ledger information. Kindly try again!";
    }
    return "Information updated successfully";
  }
예제 #15
0
 public MainBean() throws Exception {
   reader = Resources.getResourceAsReader("sqlMapConfig.xml");
   sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
   reader.close();
 }
예제 #16
0
 // DB커넥트 생성자
 public ImprovementCaseEdit() throws IOException {
   reader = Resources.getResourceAsReader("sqlMapConfig.xml");
   sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
   reader.close();
 }
예제 #17
0
 // DB커넥트 생성자
 public TrainingEventView() throws IOException {
   reader = Resources.getResourceAsReader("sqlMapConfig.xml");
   sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
   reader.close();
 }