Delivery only if there are any non-currency items delivered.

This commit is contained in:
marcins78
2012-12-05 12:21:21 +00:00
parent d16b5192d1
commit 55ace790d0
2 changed files with 19 additions and 16 deletions

View File

@@ -106,8 +106,9 @@ public class DbTransferDAO implements TransferDAO {
}
}
// For now, very naive synchronization
@Override
public Map<String, ? extends CardCollection> consumeUndeliveredPackages(String player) {
public synchronized Map<String, ? extends CardCollection> consumeUndeliveredPackages(String player) {
try {
Connection connection = _dbAccess.getDataSource().getConnection();
try {

View File

@@ -43,23 +43,25 @@ public class DeliveryResource extends AbstractResource {
String collectionType = collectionTypeItems.getKey();
CardCollection items = collectionTypeItems.getValue();
Element collectionTypeElem = doc.createElement("collectionType");
collectionTypeElem.setAttribute("name", collectionType);
for (CardCollection.Item item : items.getAll().values()) {
String blueprintId = item.getBlueprintId();
if (item.getType() == CardCollection.Item.Type.CARD) {
Element card = doc.createElement("card");
card.setAttribute("count", String.valueOf(item.getCount()));
card.setAttribute("blueprintId", blueprintId);
collectionTypeElem.appendChild(card);
} else {
Element pack = doc.createElement("pack");
pack.setAttribute("count", String.valueOf(item.getCount()));
pack.setAttribute("blueprintId", blueprintId);
collectionTypeElem.appendChild(pack);
if (items.getAll().size() > 0) {
Element collectionTypeElem = doc.createElement("collectionType");
collectionTypeElem.setAttribute("name", collectionType);
for (CardCollection.Item item : items.getAll().values()) {
String blueprintId = item.getBlueprintId();
if (item.getType() == CardCollection.Item.Type.CARD) {
Element card = doc.createElement("card");
card.setAttribute("count", String.valueOf(item.getCount()));
card.setAttribute("blueprintId", blueprintId);
collectionTypeElem.appendChild(card);
} else {
Element pack = doc.createElement("pack");
pack.setAttribute("count", String.valueOf(item.getCount()));
pack.setAttribute("blueprintId", blueprintId);
collectionTypeElem.appendChild(pack);
}
}
deliveryElem.appendChild(collectionTypeElem);
}
deliveryElem.appendChild(collectionTypeElem);
}
doc.appendChild(deliveryElem);