public Collection<Short> getRankOrdinals() { if (ranks == null) { return null; } Set<Short> ordinals = new HashSet<Short>(); for (WikidataStatement.Rank rank : ranks) { ordinals.add((short)rank.ordinal()); } return ordinals; }
protected WikidataStatement buildStatement(Record record) throws DaoException { if (record == null) { return null; } WikidataEntity item = new WikidataEntity( WikidataEntity.Type.getByCode(record.getValue(Tables.WIKIDATA_STATEMENT.ENTITY_TYPE).charAt(0)), record.getValue(Tables.WIKIDATA_STATEMENT.ENTITY_ID) ); WikidataEntity prop = getProperty(record.getValue(Tables.WIKIDATA_STATEMENT.PROP_ID)); Short rankOrdinal = record.getValue(Tables.WIKIDATA_STATEMENT.RANK); JsonElement json = new JsonParser().parse(record.getValue(Tables.WIKIDATA_STATEMENT.VAL_STR)); WikidataValue val; try { val = parser.jsonToValue( record.getValue(Tables.WIKIDATA_STATEMENT.VAL_TYPE), json); } catch (WpParseException e) { throw new DaoException(e); } WikidataStatement stmt = new WikidataStatement( record.getValue(Tables.WIKIDATA_STATEMENT.ID), item, prop, val, WikidataStatement.Rank.values()[rankOrdinal] ); return stmt; }
protected WikidataStatement buildStatement(Record record) throws DaoException { if (record == null) { return null; } WikidataEntity item = new WikidataEntity( WikidataEntity.Type.getByCode(record.getValue(Tables.WIKIDATA_STATEMENT.ENTITY_TYPE).charAt(0)), record.getValue(Tables.WIKIDATA_STATEMENT.ENTITY_ID) ); WikidataEntity prop = getProperty(record.getValue(Tables.WIKIDATA_STATEMENT.PROP_ID)); Short rankOrdinal = record.getValue(Tables.WIKIDATA_STATEMENT.RANK); JsonElement json = new JsonParser().parse(record.getValue(Tables.WIKIDATA_STATEMENT.VAL_STR)); WikidataValue val; try { val = parser.jsonToValue( record.getValue(Tables.WIKIDATA_STATEMENT.VAL_TYPE), json); } catch (WpParseException e) { throw new DaoException(e); } WikidataStatement stmt = new WikidataStatement( record.getValue(Tables.WIKIDATA_STATEMENT.ID), item, prop, val, WikidataStatement.Rank.values()[rankOrdinal] ); return stmt; }
@Override public void save(WikidataStatement item) throws DaoException { insert( item.getId(), item.getItem().getType().code, item.getItem().getId(), item.getProperty().getId(), item.getValue().getTypeName().toLowerCase(), encodeValue(item.getValue()), item.getRank().ordinal() ); }
@Override public void save(WikidataStatement item) throws DaoException { insert( item.getId(), item.getItem().getType().code, item.getItem().getId(), item.getProperty().getId(), item.getValue().getTypeName().toLowerCase(), encodeValue(item.getValue()), item.getRank().ordinal() ); }
public Collection<Short> getRankOrdinals() { if (ranks == null) { return null; } Set<Short> ordinals = new HashSet<Short>(); for (WikidataStatement.Rank rank : ranks) { ordinals.add((short)rank.ordinal()); } return ordinals; }