use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.
the class MetaStoreExplorerDialog method removeElement.
private void removeElement(String metaStoreName, String namespace, String elementTypeName, String elementName) {
try {
IMetaStore metaStore = findMetaStore(metaStoreName);
if (metaStore == null) {
throw new MetaStoreException("Unable to find metastore '" + metaStoreName + "'");
}
IMetaStoreElementType elementType = metaStore.getElementTypeByName(namespace, elementTypeName);
if (elementType == null) {
throw new MetaStoreException("Unable to find element type '" + elementTypeName + "' from metastore '" + metaStoreName + "' in namespace '" + namespace + "'");
}
IMetaStoreElement element = metaStore.getElementByName(namespace, elementType, elementName);
if (element == null) {
throw new MetaStoreException("Unable to find element '" + elementName + "' of type '" + elementTypeName + "' from metastore '" + metaStoreName + "' in namespace '" + namespace + "'");
}
metaStore.deleteElement(namespace, elementType, element.getId());
refreshTree();
} catch (MetaStoreException e) {
new ErrorDialog(shell, "Error removing element", "There was an error removing the element '" + elementName + "' of type '" + elementTypeName + "' from metastore '" + metaStoreName + "' in namespace '" + namespace + "'", e);
}
}
use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method getElements.
@Override
public List<IMetaStoreElement> getElements(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
try {
IMetaStoreElementType type = getElementTypeByName(namespace, elementType.getName());
if (type == null) {
return new ArrayList<IMetaStoreElement>();
}
Collection<RowMetaAndData> elementRows = delegate.getElements(new LongObjectId(new StringObjectId(type.getId())));
List<IMetaStoreElement> elements = new ArrayList<IMetaStoreElement>();
for (RowMetaAndData elementRow : elementRows) {
IMetaStoreElement element = delegate.parseElement(elementType, elementRow);
elements.add(element);
}
return elements;
} catch (Exception e) {
throw new MetaStoreException("Unable to get list of elements from namespace '" + namespace + "' and for element type '" + elementType.getName() + "'", e);
}
}
use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method getNamespaces.
// Handle namespaces...
@Override
public List<String> getNamespaces() throws MetaStoreException {
try {
List<String> namespaces = new ArrayList<String>();
Collection<RowMetaAndData> namespaceRows = delegate.getNamespaces();
for (RowMetaAndData namespaceRow : namespaceRows) {
String namespace = namespaceRow.getString(KettleDatabaseRepository.FIELD_NAMESPACE_NAME, null);
if (!Utils.isEmpty(namespace)) {
namespaces.add(namespace);
}
}
return namespaces;
} catch (Exception e) {
throw new MetaStoreException(e);
}
}
use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method updateElementType.
@Override
public void updateElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
try {
ObjectId namespaceId = delegate.verifyNamespace(namespace);
String elementTypeId = elementType.getId();
if (elementTypeId == null) {
IMetaStoreElementType type = getElementTypeByName(namespace, elementType.getName());
if (type != null) {
elementTypeId = type.getId();
}
}
if (elementTypeId != null) {
delegate.updateElementType(namespaceId, new LongObjectId(new StringObjectId(elementType.getId())), elementType);
repository.commit();
} else {
throw new MetaStoreException("Unable to update element type: no id was provided and the name '" + elementType.getName() + "' didn't match");
}
} catch (MetaStoreException e) {
throw e;
} catch (Exception e) {
repository.rollback();
throw new MetaStoreException("Unable to update element type", e);
}
}
use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method getElementByName.
@Override
public IMetaStoreElement getElementByName(String namespace, IMetaStoreElementType elementType, String name) throws MetaStoreException {
try {
LongObjectId namespaceId = delegate.getNamespaceId(namespace);
if (namespaceId == null) {
return null;
}
LongObjectId elementTypeId = delegate.getElementTypeId(namespaceId, elementType.getName());
if (elementTypeId == null) {
return null;
}
LongObjectId elementId = delegate.getElementId(elementTypeId, name);
if (elementId == null) {
return null;
}
RowMetaAndData elementRow = delegate.getElement(elementId);
if (elementRow == null) {
return null;
}
return delegate.parseElement(elementType, elementRow);
} catch (Exception e) {
throw new MetaStoreException("Unable to get element by name '" + name + "' from namespace '" + namespace + "'", e);
}
}
Aggregations