当前位置: 首页>>代码示例>>Java>>正文


Java DumpContentType类代码示例

本文整理汇总了Java中org.wikidata.wdtk.dumpfiles.DumpContentType的典型用法代码示例。如果您正苦于以下问题:Java DumpContentType类的具体用法?Java DumpContentType怎么用?Java DumpContentType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DumpContentType类属于org.wikidata.wdtk.dumpfiles包,在下文中一共展示了DumpContentType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WmfLocalDumpFile

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param dateStamp
 *            dump date in format YYYYMMDD
 * @param projectName
 *            project name string
 * @param dumpfileDirectoryManager
 *            the directory manager for the directory where dumps should be
 *            downloaded to
 * @param dumpContentType
 *            the type of dump this represents
 */
public WmfLocalDumpFile(String dateStamp, String projectName,
		DirectoryManager dumpfileDirectoryManager,
		DumpContentType dumpContentType) {
	super(dateStamp, projectName);

	String subdirectoryName = WmfDumpFile.getDumpFileDirectoryName(
			dumpContentType, dateStamp);
	if (!dumpfileDirectoryManager.hasSubdirectory(subdirectoryName)) {
		throw new IllegalArgumentException(
				"There is no local dump file directory at the specified location.");
	}
	try {
		this.localDumpfileDirectoryManager = dumpfileDirectoryManager
				.getSubdirectoryManager(subdirectoryName);
	} catch (IOException e) {
		throw new IllegalArgumentException(
				"Could not change to dump file directory", e);
	}

	this.dumpContentType = dumpContentType;
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:35,代码来源:WmfLocalDumpFile.java

示例2: findDumpsOnline

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
/**
 * Finds out which dump files of the given type are available for download.
 * The result is a list of objects that describe the available dump files,
 * in descending order by their date. Not all of the dumps included might be
 * actually available.
 *
 * @return list of objects that provide information on available full dumps
 */
List<MwDumpFile> findDumpsOnline(DumpContentType dumpContentType) {
	List<String> dumpFileDates = findDumpDatesOnline(dumpContentType);

	List<MwDumpFile> result = new ArrayList<MwDumpFile>();

	for (String dateStamp : dumpFileDates) {
		if (dumpContentType == DumpContentType.DAILY) {
			result.add(new WmfOnlineDailyDumpFile(dateStamp,
					this.projectName, this.webResourceFetcher,
					this.dumpfileDirectoryManager));
		} else if (dumpContentType == DumpContentType.JSON) {
			result.add(new JsonOnlineDumpFile(dateStamp, this.projectName,
					this.webResourceFetcher, this.dumpfileDirectoryManager));
		} else {
			result.add(new WmfOnlineStandardDumpFile(dateStamp,
					this.projectName, this.webResourceFetcher,
					this.dumpfileDirectoryManager, dumpContentType));
		}
	}

	logger.info("Found " + result.size() + " online dumps of type "
			+ dumpContentType + ": " + result);

	return result;
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:34,代码来源:WmfDumpFileManager.java

示例3: getDumpFileWebDirectory

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
/**
 * Returns the absolute directory on the Web site where dumpfiles of the
 * given type can be found.
 *
 * @param dumpContentType
 *            the type of dump
 * @return relative web directory for the current dumpfiles
 * @throws IllegalArgumentException
 *             if the given dump file type is not known
 */
public static String getDumpFileWebDirectory(
		DumpContentType dumpContentType, String projectName) {
	if (dumpContentType == DumpContentType.JSON) {
		if ("wikidatawiki".equals(projectName)) {
			return WmfDumpFile.DUMP_SITE_BASE_URL
					+ WmfDumpFile.WEB_DIRECTORY.get(dumpContentType)
					+ "wikidata" + "/";
		} else {
			throw new RuntimeException(
					"Wikimedia Foundation uses non-systematic directory names for this type of dump file."
							+ " I don't know where to find dumps of project "
							+ projectName);
		}
	} else if (WmfDumpFile.WEB_DIRECTORY.containsKey(dumpContentType)) {
		return WmfDumpFile.DUMP_SITE_BASE_URL
				+ WmfDumpFile.WEB_DIRECTORY.get(dumpContentType)
				+ projectName + "/";
	} else {
		throw new IllegalArgumentException("Unsupported dump type "
				+ dumpContentType);
	}
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:33,代码来源:WmfDumpFile.java

示例4: validDumpProperties

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
@Test
public void validDumpProperties() throws IOException {
	String dateStamp = "20140220";
	wrf.setWebResourceContents(
			"https://dumps.wikimedia.org/other/incr/wikidatawiki/"
					+ dateStamp + "/status.txt", "done");
	wrf.setWebResourceContents(
			"https://dumps.wikimedia.org/other/incr/wikidatawiki/"
					+ dateStamp + "/wikidatawiki-" + dateStamp
					+ "-pages-meta-hist-incr.xml.bz2", "Line1",
			CompressionType.BZ2);
	WmfOnlineDailyDumpFile dump = new WmfOnlineDailyDumpFile(dateStamp,
			"wikidatawiki", wrf, dm);

	BufferedReader br = dump.getDumpFileReader();

	assertEquals(br.readLine(), "Line1");
	assertEquals(br.readLine(), null);
	assertTrue(dump.isAvailable());
	assertTrue(dump.isAvailable()); // second time should use cached entry
	assertEquals(dateStamp, dump.getDateStamp());
	assertEquals("wikidatawiki", dump.getProjectName());
	assertEquals("wikidatawiki-daily-" + dateStamp, dump.toString());
	assertEquals(DumpContentType.DAILY, dump.getDumpContentType());
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:26,代码来源:WmfOnlineDailyDumpFileTest.java

示例5: validCurrentDumpPropertiesOldFormat

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
@Test
public void validCurrentDumpPropertiesOldFormat() throws IOException {
	wrf.setWebResourceContentsFromResource(
			"https://dumps.wikimedia.org/wikidatawiki/20140210/",
			"/wikidatawiki-20140210-index.html", this.getClass());
	wrf.setWebResourceContents(
			"https://dumps.wikimedia.org/wikidatawiki/20140210/wikidatawiki-20140210-pages-meta-current.xml.bz2",
			"Line1", CompressionType.BZ2);
	wrf.setWebResourceContentsFromResource(
			"https://dumps.wikimedia.org/wikidatawiki/20140210/wikidatawiki-20140210-md5sums.txt",
			"/wikidatawiki-20140210-md5sums.txt", this.getClass());
	MwDumpFile dump = new WmfOnlineStandardDumpFile("20140210",
			"wikidatawiki", wrf, dm, DumpContentType.CURRENT);

	BufferedReader br = dump.getDumpFileReader();

	assertEquals(br.readLine(), "Line1");
	assertEquals(br.readLine(), null);
	assertTrue(dump.isAvailable());
	assertEquals("20140210", dump.getDateStamp());
	assertEquals(DumpContentType.CURRENT, dump.getDumpContentType());
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:23,代码来源:WmfOnlineStandardDumpFileTest.java

示例6: validCurrentDumpPropertiesNewFormat

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
@Test
public void validCurrentDumpPropertiesNewFormat() throws IOException {
	wrf.setWebResourceContentsFromResource(
			"https://dumps.wikimedia.org/wikidatawiki/20140210/",
			"/wikidatawiki-20140508-index.html", this.getClass());
	wrf.setWebResourceContents(
			"https://dumps.wikimedia.org/wikidatawiki/20140210/wikidatawiki-20140210-pages-meta-current.xml.bz2",
			"Line1", CompressionType.BZ2);
	wrf.setWebResourceContentsFromResource(
			"https://dumps.wikimedia.org/wikidatawiki/20140210/wikidatawiki-20140210-md5sums.txt",
			"/wikidatawiki-20140210-md5sums.txt", this.getClass());
	MwDumpFile dump = new WmfOnlineStandardDumpFile("20140210",
			"wikidatawiki", wrf, dm, DumpContentType.CURRENT);

	BufferedReader br = dump.getDumpFileReader();

	assertEquals(br.readLine(), "Line1");
	assertEquals(br.readLine(), null);
	assertTrue(dump.isAvailable());
	assertEquals("20140210", dump.getDateStamp());
	assertEquals(DumpContentType.CURRENT, dump.getDumpContentType());
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:23,代码来源:WmfOnlineStandardDumpFileTest.java

示例7: inaccessibleCurrentDumpProperties

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
@Test
public void inaccessibleCurrentDumpProperties() throws IOException {
	wrf.setWebResourceContentsFromResource(
			"http://dumps.wikimedia.org/wikidatawiki/20140210/",
			"/wikidatawiki-20140210-index.html", this.getClass());
	wrf.setWebResourceContents(
			"http://dumps.wikimedia.org/wikidatawiki/20140210/wikidatawiki-20140210-pages-meta-current.xml.bz2",
			"Line1");
	wrf.setWebResourceContentsFromResource(
			"http://dumps.wikimedia.org/wikidatawiki/20140210/wikidatawiki-20140210-md5sums.txt",
			"/wikidatawiki-20140210-md5sums.txt", this.getClass());
	wrf.setReturnFailingReaders(true);

	MwDumpFile dump = new WmfOnlineStandardDumpFile("20140210",
			"wikidatawiki", wrf, dm, DumpContentType.CURRENT);

	assertFalse(dump.isAvailable());
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:19,代码来源:WmfOnlineStandardDumpFileTest.java

示例8: setLocalDump

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
/**
 * Helper method to create mocked local dump files.
 *
 * @param dateStamp
 * @param dumpContentType
 * @param isDone
 * @throws IOException
 */
void setLocalDump(String dateStamp, DumpContentType dumpContentType,
		boolean isDone) throws IOException {

	Path dumpFilePath = this.dmPath.resolve("dumpfiles").resolve(
			"wikidatawiki");
	Path thisDumpPath = dumpFilePath.resolve(dumpContentType.toString()
			.toLowerCase() + "-" + dateStamp);
	dm.setDirectory(thisDumpPath);
	if (isDone) {
		Path filePath = thisDumpPath.resolve(WmfDumpFile.getDumpFileName(
				dumpContentType, "wikidatawiki", dateStamp));
		dm.setFileContents(filePath,
				"Contents of " + dumpContentType.toString().toLowerCase() + " " + dateStamp,
				WmfDumpFile.getDumpFileCompressionType(filePath.toString()));
	}
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:25,代码来源:WmfDumpFileManagerTest.java

示例9: getAllDailyDumpsOffline

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
@Test
public void getAllDailyDumpsOffline() throws IOException {
	setLocalDump("20140220", DumpContentType.DAILY, true);
	setLocalDump("20140205", DumpContentType.DAILY, true);

	WmfDumpFileManager dumpFileManager = new WmfDumpFileManager(
			"wikidatawiki", dm, null);

	List<? extends MwDumpFile> dumpFiles = dumpFileManager
			.findAllDumps(DumpContentType.DAILY);

	String[] dumpDates = { "20140220", "20140205" };

	assertEquals(dumpFiles.size(), dumpDates.length);
	for (int i = 0; i < dumpFiles.size(); i++) {
		assertEquals(dumpFiles.get(i).getDumpContentType(),
				DumpContentType.DAILY);
		assertEquals(dumpFiles.get(i).getDateStamp(), dumpDates[i]);
		assertTrue(dumpFiles.get(i) instanceof WmfLocalDumpFile);
	}
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:22,代码来源:WmfDumpFileManagerTest.java

示例10: getAllCurrentDumpsOffline

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
@Test
public void getAllCurrentDumpsOffline() throws IOException {
	setLocalDump("20140220", DumpContentType.CURRENT, true);
	setLocalDump("20140205", DumpContentType.CURRENT, true);

	WmfDumpFileManager dumpFileManager = new WmfDumpFileManager(
			"wikidatawiki", dm, null);

	List<? extends MwDumpFile> dumpFiles = dumpFileManager
			.findAllDumps(DumpContentType.CURRENT);

	String[] dumpDates = { "20140220", "20140205" };

	assertEquals(dumpFiles.size(), dumpDates.length);
	for (int i = 0; i < dumpFiles.size(); i++) {
		assertEquals(dumpFiles.get(i).getDumpContentType(),
				DumpContentType.CURRENT);
		assertEquals(dumpFiles.get(i).getDateStamp(), dumpDates[i]);
		assertTrue(dumpFiles.get(i) instanceof WmfLocalDumpFile);
	}
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:22,代码来源:WmfDumpFileManagerTest.java

示例11: getAllFullDumpsOffline

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
@Test
public void getAllFullDumpsOffline() throws IOException {
	setLocalDump("20140220", DumpContentType.FULL, true);
	setLocalDump("20140205", DumpContentType.FULL, true);

	WmfDumpFileManager dumpFileManager = new WmfDumpFileManager(
			"wikidatawiki", dm, null);

	List<? extends MwDumpFile> dumpFiles = dumpFileManager
			.findAllDumps(DumpContentType.FULL);

	String[] dumpDates = { "20140220", "20140205" };

	assertEquals(dumpFiles.size(), dumpDates.length);
	for (int i = 0; i < dumpFiles.size(); i++) {
		assertEquals(dumpFiles.get(i).getDumpContentType(),
				DumpContentType.FULL);
		assertEquals(dumpFiles.get(i).getDateStamp(), dumpDates[i]);
		assertTrue(dumpFiles.get(i) instanceof WmfLocalDumpFile);
	}
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:22,代码来源:WmfDumpFileManagerTest.java

示例12: getAllRelevantDumpsMainDumpMissing

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
@Test
public void getAllRelevantDumpsMainDumpMissing() throws IOException {
	setLocalDump("20140220", DumpContentType.DAILY, true);
	setLocalDump("20140210", DumpContentType.CURRENT, true);

	WmfDumpFileManager dumpFileManager = new WmfDumpFileManager(
			"wikidatawiki", dm, wrf);

	List<? extends MwDumpFile> dumpFiles = dumpFileManager
			.findAllRelevantRevisionDumps(false);

	assertEquals(dumpFiles.size(), 1);
	assertEquals(dumpFiles.get(0).getDumpContentType(),
			DumpContentType.DAILY);
	assertEquals(dumpFiles.get(0).getDateStamp(), "20140220");
	assertTrue(dumpFiles.get(0) instanceof WmfLocalDumpFile);
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:18,代码来源:WmfDumpFileManagerTest.java

示例13: processAllRelevantDumps

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
@Test
public void processAllRelevantDumps() throws IOException {

	setLocalDump("20140221", DumpContentType.DAILY, true);
	setLocalDump("20140220", DumpContentType.DAILY, true);
	setLocalDump("20140219", DumpContentType.CURRENT, true);

	WmfDumpFileManager dumpFileManager = new WmfDumpFileManager(
			"wikidatawiki", dm, null);

	TestDumpfileProcessor dfp = new TestDumpfileProcessor();

	for (MwDumpFile dumpFile : dumpFileManager
			.findAllRelevantRevisionDumps(true)) {
		dfp.processDumpFileContents(dumpFile.getDumpFileStream(), dumpFile);
	}

	assertEquals(
			dfp.result,
			"Contents of daily 20140221\nContents of daily 20140220\nContents of current 20140219\n");
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:22,代码来源:WmfDumpFileManagerTest.java

示例14: getPossibleDumpsToProcess

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
private static Stream<MwDumpFile> getPossibleDumpsToProcess(WmfDumpFileManager dumpFileManager) {
    MwDumpFile jsonDump = dumpFileManager.findMostRecentDump(DumpContentType.JSON);
    return Stream.concat(
            Stream.of(jsonDump),
            dumpFileManager.findAllRelevantRevisionDumps(true).stream()
                    .filter(dump -> Integer.parseInt(dump.getDateStamp()) > Integer.parseInt(jsonDump.getDateStamp()))
    ).sorted(new MwDumpFile.DateComparator());
}
 
开发者ID:askplatypus,项目名称:platypus-kb-lucene,代码行数:9,代码来源:WikidataLuceneIndexFactory.java

示例15: getDumpFileStream

import org.wikidata.wdtk.dumpfiles.DumpContentType; //导入依赖的package包/类
@Override
public InputStream getDumpFileStream() throws IOException {
	prepareDumpFile();

	String fileName = WmfDumpFile.getDumpFileName(DumpContentType.DAILY,
			this.projectName, this.dateStamp);
	DirectoryManager dailyDirectoryManager = this.dumpfileDirectoryManager
			.getSubdirectoryManager(WmfDumpFile.getDumpFileDirectoryName(
					DumpContentType.DAILY, this.dateStamp));

	return dailyDirectoryManager.getInputStreamForFile(fileName,
			WmfDumpFile.getDumpFileCompressionType(fileName));
}
 
开发者ID:Wikidata,项目名称:Wikidata-Toolkit,代码行数:14,代码来源:WmfOnlineDailyDumpFile.java


注:本文中的org.wikidata.wdtk.dumpfiles.DumpContentType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。