private void performMatching() { QueryDataSet sks = null, pok = null; Int2 run = new Int2(); String lastcpar = ""; total.clear(); for (int row = 0; row < model.getRowCount(); row++) if (model.isRowSelected(row)) { MatchableCollection mc = (MatchableCollection) model.getValueAt(row, 0); String mkey = mc.getRow(0).getMasterKey(); String cpar = mkey.substring(0, mkey.indexOf('$')); if (!cpar.equals(lastcpar)) { if (sks != null && raTransaction.saveChangesInTransaction(new QueryDataSet[] {sks, pok})) total = total.add(run); run.clear(); sks = dM.getDataModule().getSkstavke(); Skstavke.getDataModule() .setFilter( Aus.getKnjigCond() .and(Aus.getFreeYearCond()) .and(Condition.equal("CPAR", Aus.getNumber(lastcpar = cpar)))); sks.open(); pok = Pokriveni.getDataModule().getFilteredDataSet("1=0"); pok.open(); } PotentialMatch pm = new PotentialMatch(); for (int i = 0; i < mc.getRowCount(); i++) pm.addStavka(mc.getRow(i)); for (int i = 0; i < mc.getMatch().getRowCount(); i++) pm.addStavka(mc.getMatch().getRow(i)); run = run.add(pm.realize(sks, pok)); } if (sks != null && R2Handler.saveChangesInTransaction(new QueryDataSet[] {sks, pok})) total = total.add(run); dM.getDataModule().getSynchronizer().markAsDirty("pokriveni"); }
public void updateValues() { if (mc != null) { saldo = mc.getSaldoFormatted(); act = act || (mc.getMatch() != null && mc.getMatchedFactor() > raOptimisticMatch.getFactor()); act = act && mc.getMatch() != null; } else { saldo = ""; act = false; } }
public Object getElement(int col) { if (mc == null) return ""; switch (col) { case 2: return saldo; case 0: return mc; case 1: return mc.getMatch() != null ? mc.getMatch() : MatchableCollection.none; default: return ""; } }
public Object[] getMatchOptions(int row) { RowData rd = (RowData) rows.get(row); SaldoSlot ss = rd.mc.getOwner(); ArrayList ret = new ArrayList(); ret.add(MatchableCollection.none); for (int i = 0; i < ss.getCollectionCount(); i++) { MatchableCollection mc = ss.getCollection(i); if (rd.mc.isRacunTip() != mc.isRacunTip() && (mc.getMaxMatchStrength() <= 0 || mc.getMatch() == rd.mc)) ret.add(mc); } return ret.toArray(); }
public void fillData(final HashMap master) { // javax.swing.plaf.basic.BasicTableUI tui; rows.clear(); ArrayList keys = new ArrayList(master.keySet()); Collections.sort( keys, new Comparator() { public int compare(Object o1, Object o2) { SaldoGroup s1 = (SaldoGroup) master.get(o1); SaldoGroup s2 = (SaldoGroup) master.get(o2); if (s1.countMarkedCollections() != s2.countMarkedCollections()) return s2.countMarkedCollections() - s1.countMarkedCollections(); else if (s1.countTotalCollections() != s2.countTotalCollections()) return s1.countTotalCollections() - s2.countTotalCollections(); return Aus.getAnyNumber((String) o1) - Aus.getAnyNumber((String) o2); } }); for (Iterator it = keys.iterator(); it.hasNext(); ) { String key = (String) it.next(); String desc = analyzeKey(key); SaldoGroup salda = (SaldoGroup) master.get(key); rows.add(new RowData(desc, null)); rows.add(new RowData(desc, null)); for (Iterator s = salda.slotIterator(); s.hasNext(); ) { SaldoSlot ss = (SaldoSlot) s.next(); for (int c = 0; c < ss.getCollectionCount(); c++) { MatchableCollection mc = ss.getCollection(c); if ((mc.getMatch() != null || mc.getMaxMatchStrength() <= raOptimisticMatch.getFactor()) && mc.isRacunTip() == (ss.getNumRac() <= ss.getNumUpl())) rows.add(new RowData(desc, mc)); } } } rows.add(new RowData("", null)); this.fireTableDataChanged(); }
public boolean canSelect() { return mc != null && mc.getMatch() != null; }