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


Java GeoPackage.getMetadataReferenceDao方法代码示例

本文整理汇总了Java中mil.nga.geopackage.GeoPackage.getMetadataReferenceDao方法的典型用法代码示例。如果您正苦于以下问题:Java GeoPackage.getMetadataReferenceDao方法的具体用法?Java GeoPackage.getMetadataReferenceDao怎么用?Java GeoPackage.getMetadataReferenceDao使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mil.nga.geopackage.GeoPackage的用法示例。


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

示例1: testCreate

import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
 * Test create
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testCreate(GeoPackage geoPackage) throws SQLException {

	MetadataReferenceDao dao = geoPackage.getMetadataReferenceDao();
	MetadataDao metadataDao = geoPackage.getMetadataDao();

	if (dao.isTableExists()) {
		// Get current count
		long count = dao.countOf();

		long fileId = 5555;
		long parentId = 5556;

		// Create new metadata
		Metadata metadata = new Metadata();
		metadata.setId(fileId);
		metadata.setMetadataScope(MetadataScopeType.FEATURE);
		metadata.setStandardUri("https://www.nga.mil");
		metadata.setMimeType("text/xml");
		metadata.setMetadata("Create metadata text");
		metadataDao.create(metadata);

		Metadata metadata2 = new Metadata();
		metadata2.setId(parentId);
		metadata2.setMetadataScope(MetadataScopeType.FEATURE_TYPE);
		metadata2.setStandardUri("https://www.nga.mil");
		metadata2.setMimeType("text/xml");
		metadata2.setMetadata("Create metadata text 2");
		metadataDao.create(metadata2);

		ReferenceScopeType scopeType = ReferenceScopeType.ROW;
		String tableName = "CREATE_TABLE_NAME";
		long rowIdValue = 50;
		Date timestamp = new Date();

		MetadataReference reference = new MetadataReference();
		reference.setReferenceScope(scopeType);
		reference.setTableName(tableName);
		reference.setRowIdValue(rowIdValue);
		reference.setTimestamp(timestamp);
		reference.setMetadata(metadata);
		reference.setParentMetadata(metadata2);
		dao.create(reference);

		// Verify count
		long newCount = dao.countOf();
		TestCase.assertEquals(count + 1, newCount);

		// Verify saved metadata
		List<MetadataReference> queryMetadataReferenceList = dao
				.queryByMetadata(fileId, parentId);
		TestCase.assertNotNull(queryMetadataReferenceList);
		TestCase.assertEquals(1, queryMetadataReferenceList.size());
		MetadataReference queryMetadataReference = queryMetadataReferenceList
				.get(0);
		TestCase.assertEquals(scopeType,
				queryMetadataReference.getReferenceScope());
		TestCase.assertEquals(tableName,
				queryMetadataReference.getTableName());
		TestCase.assertNull(queryMetadataReference.getColumnName());
		TestCase.assertEquals(rowIdValue, queryMetadataReference
				.getRowIdValue().longValue());
		TestCase.assertEquals(timestamp,
				queryMetadataReference.getTimestamp());
		TestCase.assertEquals(fileId, queryMetadataReference.getFileId());
		TestCase.assertEquals(parentId, queryMetadataReference
				.getParentId().longValue());
		TestCase.assertNotNull(queryMetadataReference.getMetadata());
		TestCase.assertNotNull(queryMetadataReference.getParentMetadata());
	}

}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:78,代码来源:MetadataReferenceUtils.java

示例2: testDelete

import mil.nga.geopackage.GeoPackage; //导入方法依赖的package包/类
/**
 * Test delete
 * 
 * @param geoPackage
 * @throws SQLException
 */
public static void testDelete(GeoPackage geoPackage) throws SQLException {

	MetadataReferenceDao dao = geoPackage.getMetadataReferenceDao();

	if (dao.isTableExists()) {
		List<MetadataReference> results = dao.queryForAll();

		if (!results.isEmpty()) {

			// Choose random metadata
			int random = (int) (Math.random() * results.size());
			MetadataReference metadataReference = results.get(random);

			// Delete the metadata reference
			dao.delete(metadataReference);

			// Verify deleted
			List<MetadataReference> queryMetadataReferenceList = dao
					.queryByMetadata(metadataReference.getFileId(),
							metadataReference.getParentId());
			TestCase.assertTrue(queryMetadataReferenceList.isEmpty());

			// Choose prepared deleted
			results = dao.queryForAll();
			if (!results.isEmpty()) {

				// Choose random metadata
				random = (int) (Math.random() * results.size());
				metadataReference = results.get(random);

				// Find which metadata to delete
				QueryBuilder<MetadataReference, Void> qb = dao
						.queryBuilder();
				qb.where().eq(MetadataReference.COLUMN_FILE_ID,
						metadataReference.getFileId());
				PreparedQuery<MetadataReference> query = qb.prepare();
				List<MetadataReference> queryResults = dao.query(query);
				int count = queryResults.size();

				// Delete
				DeleteBuilder<MetadataReference, Void> db = dao
						.deleteBuilder();
				db.where().eq(MetadataReference.COLUMN_FILE_ID,
						metadataReference.getFileId());
				PreparedDelete<MetadataReference> deleteQuery = db
						.prepare();
				int deleted = dao.delete(deleteQuery);

				TestCase.assertEquals(count, deleted);

			}
		}
	}
}
 
开发者ID:ngageoint,项目名称:geopackage-android,代码行数:61,代码来源:MetadataReferenceUtils.java


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