fixed issue where second face was considered a card

This commit is contained in:
North 2013-06-29 12:52:43 +03:00
parent 4c83fd7d6a
commit a43bc8bed6
4 changed files with 15 additions and 4 deletions

View file

@ -236,6 +236,13 @@ public class DownloadPictures extends DefaultBoundedRangeModel implements Runnab
url.setSplitCard(card.isSplitCard());
allCardsUrls.add(url);
if (card.isDoubleFaced()) {
if (card.getSecondSideName() == null || card.getSecondSideName().trim().isEmpty()) {
throw new IllegalStateException("Second side card can't have empty name.");
}
url = new CardDownloadData(card.getSecondSideName(), card.getSetCode(), card.getCardNumber(), usesVariousArt(card), 0, false, card.isDoubleFaced(), true);
allCardsUrls.add(url);
}
if (card.isFlipCard()) {
if (card.getFlipCardName() == null || card.getFlipCardName().trim().isEmpty()) {
throw new IllegalStateException("Flipped card can't have empty name.");

View file

@ -171,7 +171,8 @@ public class CardCriteria {
public void buildQuery(QueryBuilder qb) throws SQLException {
Where where = qb.where();
int clausesCount = 0;
where.eq("nightCard", false);
int clausesCount = 1;
if (name != null) {
where.like("name", new SelectArg('%' + name + '%'));
clausesCount++;

View file

@ -117,7 +117,7 @@ public class CardInfo {
this.flipCard = card.isFlipCard();
this.flipCardName = card.getFlipCardName();
this.doubleFaced = card.canTransform();
this.doubleFaced = card.canTransform() && card.getSecondCardFace() != null;
this.nightCard = card.isNightCard();
Card secondSide = card.getSecondCardFace();
if (secondSide != null) {

View file

@ -54,7 +54,7 @@ public enum CardRepository {
private static final String JDBC_URL = "jdbc:sqlite:db/cards.db";
private static final String VERSION_ENTITY_NAME = "card";
private static final long CARD_DB_VERSION = 7;
private static final long CARD_DB_VERSION = 8;
private Random random = new Random();
private Dao<CardInfo, Object> cardDao;
@ -247,7 +247,10 @@ public enum CardRepository {
public List<CardInfo> getAllCards() {
try {
return cardDao.queryForAll();
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();
queryBuilder.where().eq("nightCard", false);
return cardDao.query(queryBuilder.prepare());
} catch (SQLException ex) {
}
return new ArrayList<CardInfo>();