@Override public void save(LocalPage category, LocalPage article) throws DaoException, WikiBrainException { if (!graphs.isEmpty()) { graphs.clear(); } save(new LocalCategoryMember(category, article)); }
@Override public void save(LocalCategoryMember member) throws DaoException { insert( member.getLanguage().getId(), member.getCategoryId(), member.getArticleId() ); }
int catIndex1 = graph.catIdToIndex(lcm.getArticleId()); // cat index for page (probably -1) int catIndex2 = graph.catIdToIndex(lcm.getCategoryId()); // cat index for cat if (catIndex1 >= 0 && catIndex2 >= 0) { numCatChildren[catIndex2]++; int catIndex1 = graph.catIdToIndex(lcm.getArticleId()); // cat index for page (probably -1) int catIndex2 = graph.catIdToIndex(lcm.getCategoryId()); // cat index for cat if (catIndex1 >= 0 && catIndex2 >= 0) { graph.catChildren[catIndex2][--numCatChildren[catIndex2]] = catIndex1; graph.catParents[catIndex1][--numCatParents[catIndex1]] = catIndex2; } else if (catIndex2 >= 0) { graph.catPages[catIndex2][--numCatPages[catIndex2]] = lcm.getArticleId();
private LocalCategoryMember buildLocalCategoryMember(Record r) { return new LocalCategoryMember( r.getValue(Tables.CATEGORY_MEMBERS.CATEGORY_ID), r.getValue(Tables.CATEGORY_MEMBERS.ARTICLE_ID), Language.getById(r.getValue(Tables.CATEGORY_MEMBERS.LANG_ID)) ); }
@Override public void category(ParsedCategory cat) throws WikiBrainException { Language lang = cat.category.getLanguage(); try{ LanguageInfo langInfo = LanguageInfo.getByLanguage(lang); int c = counter.getAndIncrement(); if(c % 100000 == 0) LOG.info("Visited category #" + c); String catText = cat.category.getCanonicalTitle().split("\\|")[0]; //piped cat link catText = catText.split("#")[0]; //cat subsection Title catTitle = new Title(catText, langInfo); if(!isCategory(catText, langInfo) && !catTitle.getNamespace().equals(NameSpace.CATEGORY)) { throw new WikiBrainException("Thought it was a category, was not a category."); } int catId = pageDao.getIdByTitle(catTitle.getCanonicalTitle(), lang, NameSpace.CATEGORY); catMemDao.save( new LocalCategoryMember( catId, cat.location.getXml().getLocalId(), lang )); metaDao.incrementRecords(LocalCategoryMember.class, lang); } catch (DaoException e) { metaDao.incrementErrorsQuietly(LocalCategoryMember.class, lang); throw new WikiBrainException(e); } }