Search in sources :

Example 1 with MetaStoreException

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);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) IMetaStore(org.pentaho.metastore.api.IMetaStore)

Example 2 with MetaStoreException

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);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) LongObjectId(org.pentaho.di.repository.LongObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Example 3 with MetaStoreException

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);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) ArrayList(java.util.ArrayList) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Example 4 with MetaStoreException

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);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) LongObjectId(org.pentaho.di.repository.LongObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Example 5 with MetaStoreException

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);
    }
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) LongObjectId(org.pentaho.di.repository.LongObjectId) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException) MetaStoreElementTypeExistsException(org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)

Aggregations

MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)43 MetaStoreDependenciesExistsException (org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException)18 MetaStoreElementTypeExistsException (org.pentaho.metastore.api.exceptions.MetaStoreElementTypeExistsException)18 MetaStoreElementExistException (org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)17 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)17 LongObjectId (org.pentaho.di.repository.LongObjectId)12 IMetaStoreElementType (org.pentaho.metastore.api.IMetaStoreElementType)11 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)9 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)8 StringObjectId (org.pentaho.di.repository.StringObjectId)8 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 ObjectId (org.pentaho.di.repository.ObjectId)5 IMetaStore (org.pentaho.metastore.api.IMetaStore)5 DataServiceMeta (org.pentaho.di.trans.dataservice.DataServiceMeta)4 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)4 List (java.util.List)3 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 KettlePluginException (org.pentaho.di.core.exception.KettlePluginException)2 NamedClusterOsgi (org.pentaho.di.core.osgi.api.NamedClusterOsgi)2