public Object getFieldValue(_Fields field) { switch (field) { case NAME: return getName(); case DESCRIPTION: return getDescription(); case LOCATION_URI: return getLocationUri(); case CREATE_TIME: return getCreateTime(); } throw new IllegalStateException(); }
@Override public void alterCatalog(String catName, Catalog cat) throws MetaException, InvalidOperationException { if (!cat.getName().equals(catName)) { throw new InvalidOperationException("You cannot change a catalog's name"); } boolean committed = false; try { MCatalog mCat = getMCatalog(catName); if (org.apache.commons.lang.StringUtils.isNotBlank(cat.getLocationUri())) { mCat.setLocationUri(cat.getLocationUri()); } if (org.apache.commons.lang.StringUtils.isNotBlank(cat.getDescription())) { mCat.setDescription(cat.getDescription()); } openTransaction(); pm.makePersistent(mCat); committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
private MCatalog catToMCat(Catalog cat) { MCatalog mCat = new MCatalog(); mCat.setName(normalizeIdentifier(cat.getName())); if (cat.isSetDescription()) { mCat.setDescription(cat.getDescription()); } mCat.setLocationUri(cat.getLocationUri()); mCat.setCreateTime(cat.getCreateTime()); return mCat; }
Catalog cat = client.getCatalog(catNames[i]); Assert.assertTrue(catNames[i].equalsIgnoreCase(cat.getName())); Assert.assertEquals(description[i], cat.getDescription()); Assert.assertEquals(location[i], cat.getLocationUri()); Assert.assertTrue("Create time of catalog should be set", cat.isSetCreateTime()); Catalog fetchedNewCat = client.getCatalog(catNames[0]); Assert.assertEquals(newLocation, fetchedNewCat.getLocationUri()); Assert.assertEquals(description[0], fetchedNewCat.getDescription()); fetchedNewCat = client.getCatalog(catNames[1]); Assert.assertEquals(location[1], fetchedNewCat.getLocationUri()); Assert.assertEquals(newDescription, fetchedNewCat.getDescription());
@Test public void catalogs() throws MetaException, NoSuchObjectException { final String names[] = {"cat1", "cat2"}; final String locations[] = {"loc1", "loc2"}; final String descriptions[] = {"description 1", "description 2"}; for (int i = 0; i < names.length; i++) { Catalog cat = new CatalogBuilder() .setName(names[i]) .setLocation(locations[i]) .setDescription(descriptions[i]) .build(); objectStore.createCatalog(cat); } List<String> fetchedNames = objectStore.getCatalogs(); Assert.assertEquals(3, fetchedNames.size()); for (int i = 0; i < names.length - 1; i++) { Assert.assertEquals(names[i], fetchedNames.get(i)); Catalog cat = objectStore.getCatalog(fetchedNames.get(i)); Assert.assertEquals(names[i], cat.getName()); Assert.assertEquals(descriptions[i], cat.getDescription()); Assert.assertEquals(locations[i], cat.getLocationUri()); } Catalog cat = objectStore.getCatalog(fetchedNames.get(2)); Assert.assertEquals(DEFAULT_CATALOG_NAME, cat.getName()); Assert.assertEquals(Warehouse.DEFAULT_CATALOG_COMMENT, cat.getDescription()); // Location will vary by system. for (int i = 0; i < names.length; i++) objectStore.dropCatalog(names[i]); fetchedNames = objectStore.getCatalogs(); Assert.assertEquals(1, fetchedNames.size()); }
@Override public void alterCatalog(String catName, Catalog cat) throws MetaException, InvalidOperationException { if (!cat.getName().equals(catName)) { throw new InvalidOperationException("You cannot change a catalog's name"); } boolean committed = false; try { MCatalog mCat = getMCatalog(catName); if (org.apache.commons.lang.StringUtils.isNotBlank(cat.getLocationUri())) { mCat.setLocationUri(cat.getLocationUri()); } if (org.apache.commons.lang.StringUtils.isNotBlank(cat.getDescription())) { mCat.setDescription(cat.getDescription()); } openTransaction(); pm.makePersistent(mCat); committed = commitTransaction(); } finally { if (!committed) { rollbackTransaction(); } } }
private MCatalog catToMCat(Catalog cat) { MCatalog mCat = new MCatalog(); mCat.setName(normalizeIdentifier(cat.getName())); if (cat.isSetDescription()) { mCat.setDescription(cat.getDescription()); } mCat.setLocationUri(cat.getLocationUri()); return mCat; }