forked from External/mage
This commit is contained in:
parent
8926bcf5c2
commit
d73dbfba11
3 changed files with 24 additions and 23 deletions
|
|
@ -46,7 +46,12 @@ public class TaggerModel extends AbstractTableModel {
|
||||||
placeholder.id = "";
|
placeholder.id = "";
|
||||||
placeholder.description = "Please download Scryfall tags from the 'download' tab & reopen";
|
placeholder.description = "Please download Scryfall tags from the 'download' tab & reopen";
|
||||||
placeholder.label = "Data missing!";
|
placeholder.label = "Data missing!";
|
||||||
view.add(placeholder);
|
|
||||||
|
Tag placeholder2 = new Tag();
|
||||||
|
placeholder2.id = "";
|
||||||
|
placeholder2.description = "You may need do a Scryfall download to associate IDs";
|
||||||
|
placeholder2.label = "Also!";
|
||||||
|
view.add(placeholder2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ public class TagRelation {
|
||||||
@DatabaseField(indexName = "tags_oracle_id_index", uniqueCombo = true)
|
@DatabaseField(indexName = "tags_oracle_id_index", uniqueCombo = true)
|
||||||
protected String oracle_id;
|
protected String oracle_id;
|
||||||
|
|
||||||
@DatabaseField(indexName = "tags_tag_id_index", foreign = true, columnName = "tag_id")
|
@DatabaseField(indexName = "tags_tag_id_index", foreign = true, columnName = "tag_id", uniqueCombo = true)
|
||||||
protected Tag tag;
|
protected Tag tag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,7 @@ public enum TagRepository {
|
||||||
private static final int MAX_DATABASE_FIXES = 10;
|
private static final int MAX_DATABASE_FIXES = 10;
|
||||||
|
|
||||||
private static final String VERSION_ENTITY_NAME = "tags";
|
private static final String VERSION_ENTITY_NAME = "tags";
|
||||||
private static final long TAG_VERSION = 2; // raise this if db structure was changed
|
private static final long TAG_VERSION = 3; // raise this if db structure was changed
|
||||||
private static final long TAG_RELATION_VERSION = 2; // raise this if new cards were added to the server
|
|
||||||
|
|
||||||
private Dao<Tag, Object> tagsDao;
|
private Dao<Tag, Object> tagsDao;
|
||||||
private Dao<TagRelation, Object> tagRelationDao;
|
private Dao<TagRelation, Object> tagRelationDao;
|
||||||
|
|
@ -99,34 +98,31 @@ public enum TagRepository {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
tagsDao.createOrUpdate(tag);
|
tagsDao.createOrUpdate(tag);
|
||||||
|
// clear out old ones
|
||||||
|
DeleteBuilder<TagRelation, Object> cleanser = tagRelationDao.deleteBuilder();
|
||||||
|
cleanser.where().eq("tag_id", tag);
|
||||||
|
cleanser.delete();
|
||||||
|
|
||||||
tagRelationDao.callBatchTasks(() -> {
|
tagRelationDao.callBatchTasks(() -> {
|
||||||
// only add new cards (no updates)
|
// only add new cards (no updates)
|
||||||
logger.info("DB: refreshing tag " + tag.label);
|
logger.info("DB: refreshing tag " + tag.label);
|
||||||
// clear out old ones
|
|
||||||
DeleteBuilder<TagRelation, Object> cleanser = tagRelationDao.deleteBuilder();
|
|
||||||
cleanser.where().eq("tag_id", tag.id);
|
|
||||||
cleanser.delete();
|
|
||||||
try {
|
|
||||||
for (String oracleId : oracleIds) {
|
for (String oracleId : oracleIds) {
|
||||||
TagRelation relation = new TagRelation();
|
TagRelation relation = new TagRelation();
|
||||||
relation.oracle_id = oracleId;
|
relation.oracle_id = oracleId;
|
||||||
relation.tag = tag;
|
relation.tag = tag;
|
||||||
|
try {
|
||||||
tagRelationDao.create(relation);
|
tagRelationDao.create(relation);
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Logger.getLogger(TagRepository.class).error("Error adding tags to DB - " + e, e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
} catch (Exception ex) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue