public void process() throws Exception
	{
		WikipediaTemplateInfo info = new WikipediaTemplateInfo(getWiki());
		pageTableExists = info.tableExists(GeneratorConstants.TABLE_TPLID_PAGEID);
		revisionTableExists = info.tableExists(GeneratorConstants.TABLE_TPLID_REVISIONID);

		if(!pageTableExists&&!revisionTableExists&&mode.active_for_pages&&mode.active_for_revisions){
			//TODO see fix-me comment in WikipediaTemplateInfoDumpWriter
			throw new IllegalStateException("Currently, you cannot create revision-tpl index and page-tpl index at the same time. The code is there, but it currently assigns separate tpl-name-ids for page-tpls and revisions-tpls. Please create a revision-tpl index, import the data into the db, create the page-tpl index and import this data.");
		}

		if(mode.useRevisionIterator){
			if (mode.active_for_revisions) {
				processRevisions();
			}
			if (mode.active_for_pages) {
				processPages();
			}
		}else{
			try{
				extractTemplates();
			}catch(WikiApiException e){
				logger.error("Error extracting templates.", e);
			}
		}

		////////////////////

		logger.info("Generating template indices ...");
		boolean tableWithTemplatesExists = false;

		tableWithTemplatesExists = true;

		if (mode.active_for_pages && pageTableExists) {
			generateTemplateIndices(info, TPLNAME_TO_PAGEIDS.keySet());
		}

		if (mode.active_for_revisions && revisionTableExists) {
			generateTemplateIndices(info, TPLNAME_TO_REVISIONIDS.keySet());
		}

		////////////////////


		logger.info("Writing SQL dump ...");

		WikipediaTemplateInfoDumpWriter writer = new WikipediaTemplateInfoDumpWriter(
				this.outputPath, this.charset, this.tplNameToTplId,
				tableWithTemplatesExists);
		mode.templateNameToPageId = TPLNAME_TO_PAGEIDS;
		mode.templateNameToRevId = TPLNAME_TO_REVISIONIDS;
		writer.writeSQL(revisionTableExists, pageTableExists, mode);

		////////////////////
	}
public void process ( ) throws Exception { WikipediaTemplateInfo info = new WikipediaTemplateInfo ( getWiki ( ) ) ; pageTableExists = info . tableExists ( GeneratorConstants . TABLE_TPLID_PAGEID ) ; revisionTableExists = info . tableExists ( GeneratorConstants . TABLE_TPLID_REVISIONID ) ; if ( ! pageTableExists && ! revisionTableExists && mode . active_for_pages && mode . active_for_revisions ) { throw new IllegalStateException ( "Currently, you cannot create revision-tpl index and page-tpl index at the same time. The code is there, but it currently assigns separate tpl-name-ids for page-tpls and revisions-tpls. Please create a revision-tpl index, import the data into the db, create the page-tpl index and import this data." ) ; } if ( mode . useRevisionIterator ) { if ( mode . active_for_revisions ) { processRevisions ( ) ; } if ( mode . active_for_pages ) { processPages ( ) ; } } else { try { extractTemplates ( ) ; } catch ( WikiApiException e ) { logger . error ( "Error extracting templates." , e ) ; } } logger . info ( "Generating template indices ..." ) ; boolean tableWithTemplatesExists = false ; tableWithTemplatesExists = true ; if ( mode . active_for_pages && pageTableExists ) { generateTemplateIndices ( info , TPLNAME_TO_PAGEIDS . keySet ( ) ) ; } if ( mode . active_for_revisions && revisionTableExists ) { generateTemplateIndices ( info , TPLNAME_TO_REVISIONIDS . keySet ( ) ) ; } logger . info ( "Writing SQL dump ..." ) ; WikipediaTemplateInfoDumpWriter writer = new WikipediaTemplateInfoDumpWriter ( this . outputPath , this . charset , this . tplNameToTplId , tableWithTemplatesExists ) ; mode . templateNameToPageId = TPLNAME_TO_PAGEIDS ; mode . templateNameToRevId = TPLNAME_TO_REVISIONIDS ; writer . writeSQL ( revisionTableExists , pageTableExists , mode ) ; }
Start generator