use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method deleteElementType.
@Override
public void deleteElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException, MetaStoreDependenciesExistsException {
try {
Collection<RowMetaAndData> elementTypeRows = delegate.getElements(new LongObjectId(new StringObjectId(elementType.getId())));
if (!elementTypeRows.isEmpty()) {
List<String> dependencies = new ArrayList<String>();
for (RowMetaAndData elementTypeRow : elementTypeRows) {
Long elementTypeId = elementTypeRow.getInteger(KettleDatabaseRepository.FIELD_ELEMENT_TYPE_ID_ELEMENT_TYPE);
dependencies.add(Long.toString(elementTypeId));
}
throw new MetaStoreDependenciesExistsException(dependencies, "The namespace to delete, '" + namespace + "' is not empty");
}
delegate.deleteElementType(new LongObjectId(new StringObjectId(elementType.getId())));
repository.commit();
} catch (MetaStoreDependenciesExistsException e) {
throw e;
} catch (Exception e) {
repository.rollback();
throw new MetaStoreException(e);
}
}
use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method deleteElement.
@Override
public void deleteElement(String namespace, IMetaStoreElementType elementType, String elementId) throws MetaStoreException {
try {
IMetaStoreElementType type = getElementTypeByName(namespace, elementType.getName());
if (type == null) {
throw new MetaStoreException("Unable to find element type with name '" + elementType.getName() + "'");
}
delegate.deleteElement(new LongObjectId(new StringObjectId(elementId)));
repository.commit();
} catch (Exception e) {
repository.rollback();
throw new MetaStoreException("Unable to delete element with id '" + elementId + "' of type '" + elementType.getName() + "'", e);
}
}
use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method createElementType.
// Handle the element types
public void createElementType(String namespace, IMetaStoreElementType elementType) throws MetaStoreException, MetaStoreElementTypeExistsException {
try {
ObjectId namespaceId = delegate.verifyNamespace(namespace);
// See if the element already exists in this namespace
//
IMetaStoreElementType existingType = getElementTypeByName(namespace, elementType.getName());
if (existingType != null) {
throw new MetaStoreElementTypeExistsException(Arrays.asList(existingType), "Can not create element type with id '" + elementType.getId() + "' because it already exists");
}
KDBRMetaStoreElementType newElementType = new KDBRMetaStoreElementType(delegate, namespace, namespaceId, elementType.getName(), elementType.getDescription());
newElementType.save();
elementType.setId(newElementType.getId());
repository.commit();
} catch (MetaStoreElementTypeExistsException e) {
throw e;
} catch (MetaStoreException e) {
repository.rollback();
throw e;
} catch (Exception e) {
repository.rollback();
throw new MetaStoreException(e);
}
}
use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method getElementTypes.
@Override
public List<IMetaStoreElementType> getElementTypes(String namespace) throws MetaStoreException {
try {
LongObjectId namespaceId = delegate.getNamespaceId(namespace);
if (namespaceId == null) {
return new ArrayList<IMetaStoreElementType>();
}
Collection<RowMetaAndData> elementTypeRows = delegate.getElementTypes(namespaceId);
List<IMetaStoreElementType> list = new ArrayList<IMetaStoreElementType>();
for (RowMetaAndData elementTypeRow : elementTypeRows) {
KDBRMetaStoreElementType elementType = delegate.parseElementType(namespace, namespaceId, elementTypeRow);
list.add(elementType);
}
return list;
} catch (Exception e) {
throw new MetaStoreException("Unable to get list of element types for namespace '" + namespace + "'", e);
}
}
use of org.pentaho.metastore.api.exceptions.MetaStoreException in project pentaho-kettle by pentaho.
the class SharedObjectsMetaStore method createElement.
@Override
public void createElement(String namespace, IMetaStoreElementType elementType, IMetaStoreElement element) throws MetaStoreException, MetaStoreElementExistException {
try {
IMetaStoreElement exists = getElementByName(namespace, elementType, element.getId());
if (exists != null) {
throw new MetaStoreException("The shared objects meta store already contains an element with type name '" + elementType.getName() + "' and element name '" + element.getName());
}
if (elementType.getName().equals(databaseElementType.getName())) {
// convert the element to DatabaseMeta and store it in the shared objects file, then save the file
//
sharedObjects.storeObject(DatabaseMetaStoreUtil.loadDatabaseMetaFromDatabaseElement(this, element));
sharedObjects.saveToFile();
return;
}
throw new MetaStoreException("Storing elements with element type name '" + elementType.getName() + "' is not supported in the shared objects meta store");
} catch (Exception e) {
throw new MetaStoreException("Unexpected error creating an element in the shared objects meta store", e);
}
}
Aggregations