Adding code that adds cards to collections.
This commit is contained in:
@@ -2,7 +2,6 @@ package com.gempukku.lotro.server;
|
||||
|
||||
import com.gempukku.lotro.DateUtils;
|
||||
import com.gempukku.lotro.cache.CacheManager;
|
||||
import com.gempukku.lotro.collection.CollectionsManager;
|
||||
import com.gempukku.lotro.db.DeckDAO;
|
||||
import com.gempukku.lotro.db.LeagueDAO;
|
||||
import com.gempukku.lotro.db.MerchantDAO;
|
||||
@@ -29,12 +28,11 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
@Path("/admin")
|
||||
public class AdminResource extends AbstractResource {
|
||||
@Context
|
||||
private CollectionsManager _collectionsManager;
|
||||
@Context
|
||||
private LeagueService _leagueService;
|
||||
@Context
|
||||
@@ -285,12 +283,30 @@ public class AdminResource extends AbstractResource {
|
||||
for (String playerName : playerNames) {
|
||||
Player player = _playerDao.getPlayer(playerName);
|
||||
|
||||
_collectionsManager.addItemsToPlayerCollection(true, "Administrator action", player, createCollectionType(collectionType), productItems);
|
||||
_collectionManager.addItemsToPlayerCollection(true, "Administrator action", player, createCollectionType(collectionType), productItems);
|
||||
}
|
||||
|
||||
return "OK";
|
||||
}
|
||||
|
||||
@Path("/addItemsToCollection")
|
||||
@POST
|
||||
public String addItemsToCollection(
|
||||
@FormParam("collectionType") String collectionType,
|
||||
@FormParam("product") String product,
|
||||
@Context HttpServletRequest request) throws Exception {
|
||||
validateAdmin(request);
|
||||
|
||||
Collection<CardCollection.Item> productItems = getProductItems(product);
|
||||
|
||||
Map<Player,CardCollection> playersCollection = _collectionManager.getPlayersCollection(collectionType);
|
||||
|
||||
for (Map.Entry<Player, CardCollection> playerCollection : playersCollection.entrySet())
|
||||
_collectionManager.addItemsToPlayerCollection(true, "Fixing league collection", playerCollection.getKey(), createCollectionType(collectionType), productItems);
|
||||
|
||||
return "OK";
|
||||
}
|
||||
|
||||
private List<String> getItems(String values) {
|
||||
List<String> result = new LinkedList<String>();
|
||||
for (String pack : values.split("\n")) {
|
||||
|
||||
@@ -21,5 +21,13 @@
|
||||
<input type="submit" value="Add items">
|
||||
</form>
|
||||
|
||||
<h2>Add items to collection</h2>
|
||||
|
||||
<form method="POST" action="/gemp-lotr-server/admin/addItemsToCollection">
|
||||
Type: <input type="text" name="collectionType"><br/>
|
||||
Product: <textarea rows="5" cols="20" name="product"></textarea><br/>
|
||||
<input type="submit" value="Add items to collection">
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user