예제 #1
0
파일: MapperDiff.java 프로젝트: atcrew/a13
  // пока касается только навигаций...
  public void getElementFromDB2(String query, String conn, String login, String pass) {
    if (OnConnection(conn, login, pass)) {
      el01 = new Element();
      Statement stmt = null;

      try {
        stmt = connection.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while (rs.next()) {
          // el.setArrBody(rs.getString("NAVCODE"));
          NavStroke stroke = new NavStroke();
          stroke.setFLD(rs.getString("PUREFLD"));
          stroke.setEVENT(rs.getString("PUREEVENT"));
          stroke.setCOND(rs.getString("PURECOND"));
          stroke.setACTION(rs.getString("PUREACTION"));
          stroke.setOP(rs.getString("PURECODE"));
          stroke.setCOMM(rs.getString("COMM"));
          stroke.setNAVN(rs.getString("NAVN"));
          stroke.setFrom(rs.getString("OWNER"));
          stroke.setCuser(rs.getString("MODNAME"));
          stroke.setCdate(rs.getString("MODDATE"));
          stroke.prepareData();
          el01.setData(stroke);
        }
      } catch (SQLException e) {
        System.out.println("Ошибка соединения\n" + e.getSQLState() + "\n" + e.toString());
        System.out.println(e.toString());
      } finally {
        if (stmt != null) {
          try {
            stmt.close();
          } catch (SQLException ex) {
            System.out.println(
                "Ошибка соединения Statement.close\n" + ex.getSQLState() + "\n" + ex.toString());
            System.out.println(ex.toString());
          }
        }
      }
    }
  }
예제 #2
0
파일: MapperDiff.java 프로젝트: atcrew/a13
  public void diff() {
    outDiff = new Element();
    outDiff01 = new Element();
    outDiff02 = new Element();
    ArrayList<NavStroke> identity = new ArrayList();

    //
    ArrayList<NavStroke> il01 = new ArrayList();
    ArrayList<NavStroke> il02 = new ArrayList();
    ArrayList<NavStroke> result01 = new ArrayList();
    ArrayList<NavStroke> result02 = new ArrayList();
    //

    ArrayList<NavStroke> result = new ArrayList();
    ArrayList<NavStroke> l01 = new ArrayList(el01.getData());
    ArrayList<NavStroke> l02 = new ArrayList(el02.getData());
    Collections.sort(l01);
    Collections.sort(l02);

    diff_match_patch dmp = new diff_match_patch();
    LinkedList<diff_match_patch.Diff> diffs;
    //////// l1.retainAll(l2) )
    for (NavStroke ns01 : l01) {
      for (NavStroke ns02 : l02) {
        // NavStroke ns01 = (NavStroke) str01;
        // NavStroke ns02 = (NavStroke) str02;
        if (ns01.getNAVN().equals(ns02.getNAVN())) {
          ns01.setStatus("identity");
          ns02.setStatus("identity");

          if (ns01.getEVENT().equals(ns02.getEVENT())) {
          } else {
            ns01.setStatus("diff");
            ns02.setStatus("diff");
            // находим различия
            // diffs = dmp.diff_main(ns01.getEVENT(), ns02.getEVENT());
            // ns02.setEVENT(dmp.diff_prettyHtml(diffs));
          }
          if (ns01.getFLD().equals(ns02.getFLD())) {
          } else {
            ns01.setStatus("diff");
            ns02.setStatus("diff");
            // находим различия
            // diffs = dmp.diff_main(ns01.getFLD(), ns02.getFLD());
            // ns02.setFLD(dmp.diff_prettyHtml(diffs));
          }
          if (ns01.getACTION().equals(ns02.getACTION())) {
          } else {
            ns01.setStatus("diff");
            ns02.setStatus("diff");
            // находим различия
            // diffs = dmp.diff_main(ns01.getACTION(), ns02.getACTION());
            // ns02.setACTION(dmp.diff_prettyHtml(diffs));
          }
          if (ns01.getCOND().equals(ns02.getCOND())) {
          } else {
            ns01.setStatus("diff");
            ns02.setStatus("diff");
            // находим различия
            // diffs = dmp.diff_main(ns01.getCOND(), ns02.getCOND());
            // ns02.setCOND(dmp.diff_prettyHtml(diffs));
          }
          if (ns01.getOP().equals(ns02.getOP())) {
          } else {
            ns01.setStatus("diff");
            ns02.setStatus("diff");
            // находим различия
            // diffs = dmp.diff_main(ns01.getOP(), ns02.getOP());
            // ns02.setOP(dmp.diff_prettyHtml(diffs));
          }
          if (ns01.getCOMM().equals(ns02.getCOMM())) {
          } else {
            ns01.setStatus("diff");
            ns02.setStatus("diff");
            // находим различия
            //  diffs = dmp.diff_main(ns01.getCOMM(), ns02.getCOMM());
            //  ns02.setCOMM(dmp.diff_prettyHtml(diffs));
          }
          identity.add(ns01);
          il01.add(ns01);
          identity.add(ns02);
          il02.add(ns02);
        }
      }
    }

    l01.removeAll(identity);
    for (NavStroke str : l01) {
      str.setStatus("deleted");
    }
    l02.removeAll(identity);
    for (NavStroke str : l02) {
      str.setStatus("added");
    }
    result.addAll(l01);
    result.addAll(l02);
    result.addAll(identity);
    Collections.sort(result);

    /*Collections.sort(list);
    for (Iterator<NavStroke> it = list.iterator(); it.hasNext();) {
    NavStroke str = it.next();
    if (str.getStatus().equals("identity")) {
    it.remove();
    }
    }*/
    for (NavStroke _str : result) {
      outDiff.setData(_str);
    }

    /*mlist = new ArrayList<List<NavStroke>>();
    mlist.add(l02);
    mlist.add(l01);
    mlist.add(identity);  */
    result01.addAll(l01);
    result01.addAll(il01);
    Collections.sort(result01);
    for (NavStroke _str : result01) {
      outDiff01.setData(_str);
    }

    result02.addAll(l02);
    result02.addAll(il02);
    Collections.sort(result02);
    for (NavStroke _str : result02) {
      outDiff02.setData(_str);
    }
  }