use of org.pentaho.metastore.api.IMetaStoreElement in project pentaho-kettle by pentaho.
the class StarDomainMetaStoreUtil method getStarDomainList.
public static List<IdNameDescription> getStarDomainList(IMetaStore metaStore) throws MetaStoreException {
IMetaStoreElementType elementType = getStarDomainElementType(metaStore);
List<IdNameDescription> list = new ArrayList<IdNameDescription>();
for (IMetaStoreElement element : metaStore.getElements(namespace, elementType)) {
IdNameDescription nameDescription = new IdNameDescription(element.getId(), element.getName(), getChildString(element, Attribute.ID_STAR_DOMAIN_DESCRIPTION.id));
list.add(nameDescription);
}
return list;
}
use of org.pentaho.metastore.api.IMetaStoreElement in project pentaho-kettle by pentaho.
the class PurRepositoryMetaStore method getElements.
@Override
public List<IMetaStoreElement> getElements(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
List<IMetaStoreElement> elements = new ArrayList<IMetaStoreElement>();
RepositoryFile typeFolder = validateElementTypeRepositoryFolder(namespace, elementType);
List<RepositoryFile> children = getChildren(typeFolder.getId());
removeHiddenFilesFromList(children);
for (RepositoryFile child : children) {
IMetaStoreElement element = getElement(namespace, elementType, child.getId().toString());
elements.add(element);
}
return elements;
}
use of org.pentaho.metastore.api.IMetaStoreElement in project pentaho-kettle by pentaho.
the class AbstractMetaTest method testGetSetImportMetaStore.
@Test(expected = KettlePluginException.class)
public void testGetSetImportMetaStore() throws Exception {
assertNull(meta.getMetaStore());
meta.importFromMetaStore();
IMetaStore metastore = mock(IMetaStore.class);
meta.setMetaStore(metastore);
assertEquals(metastore, meta.getMetaStore());
meta.importFromMetaStore();
IMetaStoreElementType elementType = mock(IMetaStoreElementType.class);
when(metastore.getElementTypeByName(PentahoDefaults.NAMESPACE, PentahoDefaults.DATABASE_CONNECTION_ELEMENT_TYPE_NAME)).thenReturn(elementType);
when(metastore.getElements(PentahoDefaults.NAMESPACE, elementType)).thenReturn(new ArrayList<IMetaStoreElement>());
meta.importFromMetaStore();
IMetaStoreElement element = mock(IMetaStoreElement.class);
when(metastore.getElements(PentahoDefaults.NAMESPACE, elementType)).thenReturn(Arrays.asList(element));
meta.importFromMetaStore();
}
use of org.pentaho.metastore.api.IMetaStoreElement in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method createElement.
@Override
public void createElement(String namespace, IMetaStoreElementType elementType, IMetaStoreElement element) throws MetaStoreException, MetaStoreElementExistException {
try {
IMetaStoreElement found = getElementByName(namespace, elementType, element.getName());
if (found != null) {
throw new MetaStoreElementExistException(Arrays.asList(found), "The element with name '" + element.getName() + "' already exists");
}
delegate.insertElement(elementType, element);
repository.commit();
} catch (MetaStoreElementExistException e) {
throw e;
} catch (Exception e) {
repository.rollback();
throw new MetaStoreException("Unable to create element with name '" + element.getName() + "' of type '" + elementType.getName() + "'", e);
}
}
use of org.pentaho.metastore.api.IMetaStoreElement in project pentaho-kettle by pentaho.
the class KettleDatabaseRepositoryMetaStore method getElementIds.
@Override
public List<String> getElementIds(String namespace, IMetaStoreElementType elementType) throws MetaStoreException {
List<String> ids = new ArrayList<String>();
List<IMetaStoreElement> elements = getElements(namespace, elementType);
for (IMetaStoreElement element : elements) {
ids.add(element.getId());
}
return ids;
}
Aggregations