/** * 构造子查询sql * * @param table * @param refKey * @param ids * @param ordersMap * @param fieldName * @return */ private String buildChildQuerySql( String table, String refKey, StringBuffer ids, Map<String, Orders> ordersMap, String fieldName) { StringBuffer childSql = new StringBuffer(); childSql .append("select * from ") .append(NameConverter.toTableName(Constants.DEFAULT_TABLE_PREFIX, table)) .append(" where ") .append(NameConverter.toColumnName(Constants.DEFAULT_COLUMN_PREFIX, refKey)) .append(" in ("); childSql.append(ids); childSql.append(")"); Orders orders = ordersMap.get(fieldName); if (orders != null && orders.value().length > 0) { childSql.append(" order by "); for (Order order : orders.value()) { childSql .append(NameConverter.toColumnName(Constants.DEFAULT_COLUMN_PREFIX, order.key())) .append(" ") .append(order.order()) .append(","); } childSql.deleteCharAt(childSql.length() - 1); } return childSql.toString(); }
public Orders getMostRecentOrder() { Orders mostRecent = null; for (Orders order : getOrders()) { if (mostRecent == null) { mostRecent = order; } else if (order.isMoreRecentThan(mostRecent)) { mostRecent = order; } } return mostRecent; }
public void generateOrders() { int counter = 1; int clientsCounter = 1; int workshopsCounter = 1; for (String cdw : capacityDateWorkshop) { Orders o = new Orders(counter, clientsCounter, workshopsCounter, cdw); counter++; clientsCounter = o.getClientsCounter(); workshopsCounter = o.getWorkshopsCounter(); orders.add(o.toString()); } }
// Update the argument Map, adding the amounts for each book that this client ever ordered public void updateQuantityOfBooksOrdered(Map<Book, Integer> quantities) { for (Orders order : getOrders()) { for (OrderLine orderLine : order.getOrderLines()) { Book book = orderLine.getBook(); Integer quantity = quantities.get(book); if (quantity == null) { quantity = orderLine.getQty(); } else { quantity += orderLine.getQty(); } quantities.put(book, quantity); } } }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((idDaysOfWeek == null) ? 0 : idDaysOfWeek.hashCode()); result = prime * result + ((openTime == null) ? 0 : openTime.hashCode()); result = prime * result + ((user == null) ? 0 : user.hashCode()); result = prime * result + ((userSchedulePK == null) ? 0 : userSchedulePK.hashCode()); return result; }
// @Test public void create() throws Exception { Contact contact = ContactFactory.createContact("*****@*****.**", "7550"); Address_location address_location = AddressFactory.createAddress("1 Hens rd", "7945"); CorporateClient corporateClient = CorporateClientFactory.createCorpClient( "Groote schuur", "Riyaaz", "Rawoot", address_location, contact); IndividualClient individualClient = IndividualClientFactory.createIndividualClient( "Rawoot", "Riyaaz", address_location, contact); Machine machine = MachineFactory.createMachine("Washing machine"); corpClients.add(corporateClient); indivClients.add(individualClient); machines.add(machine); Orders orders = OrderFactory.createOrder( (long) 23434, new Date(), true, 32.00, corpClients, indivClients, machines); repository.save(orders); id = orders.getOrderID(); Assert.assertNotNull(orders.getOrderID()); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; UserSchedule other = (UserSchedule) obj; if (idDaysOfWeek == null) { if (other.idDaysOfWeek != null) return false; } else if (!idDaysOfWeek.equals(other.idDaysOfWeek)) return false; if (openTime == null) { if (other.openTime != null) return false; } else if (!openTime.equals(other.openTime)) return false; if (user == null) { if (other.user != null) return false; } else if (!user.equals(other.user)) return false; if (userSchedulePK == null) { if (other.userSchedulePK != null) return false; } else if (!userSchedulePK.equals(other.userSchedulePK)) return false; return true; }