public boolean removeItemContrat(String itemKey, String contratID) { String publicKey = manager.getUserManager().getCurrentUser().getKeys().getPublicKey().toString(16); if (publicKey == null || publicKey.isEmpty()) return false; for (Contrat d : getDealsCurrentUser()) { if (d.getId().equals(contratID)) { return d.removeItem(itemKey); } } return false; }
public boolean removeSignatoryContrat(String contratID, String publicKey) { String currentPublicKey = manager.getUserManager().getCurrentUser().getKeys().getPublicKey().toString(16); if (publicKey == null || publicKey.isEmpty()) return false; if (currentPublicKey.equals(publicKey)) return false; for (Contrat d : deals.get(publicKey)) { if (d.getId().equals(contratID)) { return d.removeSignatory(publicKey); } } return false; }
public boolean addItem(String contratID, Item item) { Contrat contrat = null; User currentUser = manager.getUserManager().getCurrentUser(); if (currentUser == null) { System.err.println("no user logged"); return false; } String publicKey = currentUser.getKeys().getPublicKey().toString(16); for (Contrat c : deals.get(publicKey)) { if (c.getId().equals(contratID)) { contrat = c; break; } } if (contrat == null) { Printer.printError(this, "addItem", "Contrat doesn't exist !"); return false; } return contrat.addItem(item); }
public void addContrat(Contrat c) { ArrayList<Contrat> contrats = deals.get(c.getKeys().getPublicKey().toString(16)); if (contrats == null) { contrats = new ArrayList<Contrat>(); deals.put(c.getKeys().getPublicKey().toString(16), contrats); } if (contrats.contains(c)) { Contrat local = contrats.get(contrats.indexOf(c)); if (local.getLastUpdated() < c.getLastUpdated()) { contrats.remove(local); contrats.add(c); c.publish(manager.getNetwork()); } } else { contrats.add(c); c.publish(manager.getNetwork()); } }
public Contrat getContract(String contratID) { for (Contrat c : this.getDealsCurrentUser()) { if (c.getId().equals(contratID)) return c; } return null; }
//////////////////////////////////////////////// REMOVERS // \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ public boolean removeContrat(String publicKey, String contratID) { for (Contrat d : deals.get(publicKey)) { if (d.getId().equals(contratID)) return deals.get(publicKey).remove(d); } return false; }