@Override public void beginLoad() throws DaoException { executeSqlScriptWithSuffix("-drop-indexes.sql"); executeSqlScriptWithSuffix("-create-tables.sql"); if (fields != null) { loader = new FastLoader(wpDs , fields); } }
@Override public void endLoad() throws DaoException { if (labelLoader != null) labelLoader.endLoad(); if (descLoader != null) descLoader.endLoad(); if (aliasLoader != null) aliasLoader.endLoad(); labelLoader = null; descLoader = null; aliasLoader = null; super.endLoad(); if (cache != null) { cache.put("wikidata-properties", properties); } wpDs.optimize(WIKIDATA_ENTITY_LABELS); wpDs.optimize(WIKIDATA_ENTITY_ALIASES); wpDs.optimize(WIKIDATA_ENTITY_DESCRIPTIONS); wpDs.optimize(WIKIDATA_STATEMENT); }
public boolean tableExists() throws DaoException { DSLContext context = getJooq(); try { return JooqUtils.tableExists(context, Tables.META_INFO); } finally { freeJooq(context); } }
public static WpDataSource getWpDataSource(File file) throws IOException, ClassNotFoundException, DaoException { return new WpDataSource(getDataSource(file)); }
/** * Rollback the current transaction. * If a SQLException occurs while rolling back, it logs the error and returns false, * but does not rethrow the exception. * * @param context */ public static boolean rollbackQuietly(DSLContext context) { if (context == null) { return false; } return WpDataSource.rollbackQuietly(getConnection(context)); }
@Override public UniversalPage getByLocalPage(LocalPage localPage) throws DaoException { int conceptId = getUnivPageId(localPage); if (conceptId < 0) { return null; } return getById(conceptId); }
/** * Inserts values into the database. * Call this instead of direct sql inserts because the underlying code may optimize the inserts * by creating batch inserts or a cvs that can be directly loaded by the underlying database. * @param values */ protected void insert(Object ... values) throws DaoException{ loader.load(values); }
public LocalPageSqlDao(WpDataSource dataSource, boolean followRedirects) throws DaoException{ super(dataSource, INSERT_FIELDS, "/db/local-page"); if (followRedirects){ redirectSqlDao = new RedirectSqlDao(wpDs); } }
@Override public void clear() throws DaoException { executeSqlScriptWithSuffix("-drop-indexes.sql"); executeSqlScriptWithSuffix("-drop-tables.sql"); }
@Override public UniversalLink transform(Integer[] item) throws DaoException { return getUniversalLink(item[0], item[1]); } };
/** * Executes a sql resource on the classpath * @param name Resource path - e.g. "/db/local-page.schema.sql" * @throws DaoException */ public void executeSqlResource(String name) throws DaoException { wpDs.executeSqlResource(name); }
/** * Executes the appropriate sql script with a particular suffix (.e.g. "-drop-tables.sql"). * @param suffix * @throws DaoException */ protected void executeSqlScriptWithSuffix(String suffix) throws DaoException { executeSqlResource(sqlScriptPrefix + suffix); }
@Override public UniversalPage transform(int[] item) throws DaoException { return getById(item[0]); } };
public static boolean rollbackQuietly(DSLContext context) { if (context == null) { return false; } return JooqUtils.rollbackQuietly(context); }
public static WpDataSource getWpDataSource() throws IOException, ClassNotFoundException, DaoException { return new WpDataSource(getDataSource()); }
@Override public void setFollowRedirects(boolean followRedirects) throws DaoException { if (followRedirects){ redirectSqlDao = new RedirectSqlDao(wpDs); } else { redirectSqlDao = null; } titlesToIds = null; }