private void printComponent(String component, List<MetaInfo> metaInfos) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (MetaInfo mi : metaInfos) { printRow( "" + component, "" + mi.getLanguage(), "" + mi.getNumRecords(), "" + mi.getNumErrors(), "" + df.format(mi.getLastUpdated()) ); } }
public int incrementNumRecords() { return incrementNumRecords(1); }
DSLContext context = getJooq(); try { Condition langCondition = (info.getLanguage() == null) ? Tables.META_INFO.LANG_ID.isNull() : Tables.META_INFO.LANG_ID.eq(info.getLanguage().getId()); .set(Tables.META_INFO.NUM_ERRORS, info.getNumErrors()) .set(Tables.META_INFO.NUM_RECORDS, info.getNumRecords()) .set(Tables.META_INFO.LAST_UPDATED, new Timestamp(info.getLastUpdated().getTime())) .where(Tables.META_INFO.COMPONENT.eq(info.getComponent().getSimpleName())) .and(langCondition) .execute(); if (n == 0) { Short langId = (info.getLanguage() == null) ? null : info.getLanguage().getId(); context.insertInto(Tables.META_INFO, Tables.META_INFO.COMPONENT, Tables.META_INFO.LANG_ID, Tables.META_INFO.NUM_RECORDS, Tables.META_INFO.NUM_ERRORS, Tables.META_INFO.LAST_UPDATED) .values(info.getComponent().getSimpleName(), langId, info.getNumRecords(), info.getNumErrors(), new Timestamp(info.getLastUpdated().getTime())) .execute(); info.markAsWritten(); JooqUtils.commit(context); } catch (RuntimeException e) {
public boolean isNeeded(boolean forceRerun) { if (hasBeenRun()) { // if run this execution cycle, skip return false; } else if (shouldRun != null && !shouldRun) { // if user said not to run, skip return false; } else if (forceRerun) { // if we should rerun everything, rerun return true; } else { // check to see if the class is loaded return loadedInfo == null || loadedInfo.getNumRecords() == 0; } }
@Override public MetaInfo getInfo(Class component) throws DaoException { sync(component); MetaInfo accumulated = new MetaInfo(component); DSLContext context = getJooq(); try { if (!tableExists(context)) { return accumulated; } Result<Record3<Integer, Integer, Timestamp>> records = context.select(Tables.META_INFO.NUM_RECORDS, Tables.META_INFO.NUM_ERRORS, Tables.META_INFO.LAST_UPDATED) .from(Tables.META_INFO) .where(Tables.META_INFO.COMPONENT.eq(component.getSimpleName())) .fetch(); for (Record3<Integer, Integer, Timestamp> record : records) { MetaInfo info = new MetaInfo(component, null, record.value1(), record.value2(), record.value3()); accumulated.merge(info); } return accumulated; } finally { freeJooq(context); } }
metaDao.endLoad(); System.out.println("encountered " + metaDao.getInfo(LocalLink.class).getNumErrors() + " parse errors");
throw new DaoException("when looking for " + name + ", no info about class " + klass); Date tableTstamp = info.getLastUpdated(); if (tableTstamp == null || tableTstamp.after(cacheTstamp)) { return null;
@Override public int incrementErrors(Class component, Language lang) throws DaoException { MetaInfo info = getInfo(component, lang); int n = info.incrementNumErrors(); maybeFlush(info); return n; }
public boolean isNeeded(boolean forceRerun) { if (hasBeenRun()) { // if run this execution cycle, skip return false; } else if (shouldRun != null && !shouldRun) { // if user said not to run, skip return false; } else if (forceRerun) { // if we should rerun everything, rerun return true; } else { // check to see if the class is loaded return loadedInfo == null || loadedInfo.getNumRecords() == 0; } }
metaDao.endLoad(); System.out.println("encountered " + metaDao.getInfo(LocalLink.class).getNumErrors() + " parse errors");
new MetaInfo(null, (langId == null) ? null : Language.getById(langId), record.getValue(Tables.META_INFO.ID),
private void printComponent(String component, List<MetaInfo> metaInfos) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (MetaInfo mi : metaInfos) { printRow( "" + component, "" + mi.getLanguage(), "" + mi.getNumRecords(), "" + mi.getNumErrors(), "" + df.format(mi.getLastUpdated()) ); } }
@Override public boolean isLoaded(Class component) throws DaoException { MetaInfo info = getInfo(component); return (info != null && info.getNumRecords() > 0); }
@Override public int incrementRecords(Class component, Language lang, int n) throws DaoException { MetaInfo info = getInfo(component, lang); n = info.incrementNumRecords(n); maybeFlush(info); return n; }