org.pentaho.metastore.api.exceptions.MetaStoreException Java Examples
The following examples show how to use
org.pentaho.metastore.api.exceptions.MetaStoreException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KettleDatabaseRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@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 ); } }
Example #2
Source File: NamedClusterEmbedManager.java From pentaho-kettle with Apache License 2.0 | 6 votes |
/** * Clear the embedded metastore of any named clusters */ public void clear() { NamedClusterServiceOsgi ncso = meta.getNamedClusterServiceOsgi(); if ( ncso != null ) { //Don't kill the embedded if we don't have the service to rebuild addedAllClusters = false; addedAnyClusters = false; // The embeddedMetaStoreFactory may be null if creating a brand new job and attempting to run before it ever // saved. if ( embeddedMetaStoreFactory != null ) { try { List<NamedClusterOsgi> list = embeddedMetaStoreFactory.getElements(); for ( NamedClusterOsgi nc : list ) { namedClusterPool.put( nc.getName(), nc ); embeddedMetaStoreFactory.deleteElement( nc.getName() ); } } catch ( MetaStoreException e ) { logMetaStoreException( e ); } } } }
Example #3
Source File: PurRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public void deleteNamespace( String namespace ) throws MetaStoreException { RepositoryFile namespaceFile = getNamespaceRepositoryFile( namespace ); if ( namespaceFile == null ) { return; // already gone. } List<RepositoryFile> children = getChildren( namespaceFile.getId() ); if ( children == null || children.isEmpty() ) { // Delete the file, there are no children. // pur.deleteFile( namespaceFile.getId(), true, "Delete namespace" ); } else { // Dependencies exists, throw an exception. // List<String> elementTypeIds = new ArrayList<String>(); for ( RepositoryFile child : children ) { elementTypeIds.add( child.getId().toString() ); } throw new MetaStoreDependenciesExistsException( elementTypeIds, "Namespace '" + namespace + " can not be deleted because it is not empty" ); } }
Example #4
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 6 votes |
private void editDataSet( Spoon spoon, DataSet dataSet, List<DataSetGroup> groups, MetaStoreFactory<DataSet> setFactory, String setName ) throws MetaStoreException { try { DataSetDialog setDialog = new DataSetDialog( spoon.getShell(), setFactory.getMetaStore(), dataSet, groups, getAvailableDatabases( spoon.getRepository() ) ); while ( setDialog.open() ) { String message = validateDataSet( dataSet, setName, setFactory.getElementNames() ); // Save the data set... // if ( message == null ) { setFactory.saveElement( dataSet ); break; } else { MessageBox box = new MessageBox( spoon.getShell(), SWT.OK ); box.setText( "Error" ); box.setMessage( message ); box.open(); } } } catch ( Exception e ) { new ErrorDialog( spoon.getShell(), "Error", "Unable to edit data set", e ); } }
Example #5
Source File: DataSetHelper.java From pentaho-pdi-dataset with Apache License 2.0 | 6 votes |
private void deleteDataSet( Spoon spoon, DataSet dataSet, List<DataSetGroup> groups, MetaStoreFactory<DataSet> setFactory, String setName ) throws MetaStoreException { MessageBox box = new MessageBox( Spoon.getInstance().getShell(), SWT.YES | SWT.NO ); box.setText( BaseMessages.getString( PKG, "DataSetHelper.YouSureToDeleteDataSet.Title" ) ); box.setMessage( BaseMessages.getString( PKG, "DataSetHelper.YouSureToDeleteDataSet.Message", setName ) ); int answer = box.open(); if ( ( answer & SWT.YES ) != 0 ) { try { FactoriesHierarchy hierarchy = getHierarchy(); hierarchy.getSetFactory().deleteElement( setName ); } catch ( Exception exception ) { new ErrorDialog( Spoon.getInstance().getShell(), BaseMessages.getString( PKG, "DataSetHelper.ErrorDeletingDataSet.Title" ), BaseMessages.getString( PKG, "DataSetHelper.ErrorDeletingDataSet.Message", setName ), exception ); } } }
Example #6
Source File: StarDomainMetaStoreUtil.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public static void saveStarDomain(IMetaStore metaStore, StarDomain starDomain) throws MetaStoreException { IMetaStoreElementType elementType = getStarDomainElementType(metaStore); IMetaStoreElement element = null; if (starDomain.getObjectId()!=null) { // verify the ID! // element = metaStore.getElement(namespace, elementType, starDomain.getObjectId().toString()); } if (element==null) { // Create a new element // element = metaStore.newElement(); populateElementWithStarDomain(metaStore, starDomain, element, elementType); metaStore.createElement(namespace, elementType, element); } else { // Update an existing element // populateElementWithStarDomain(metaStore, starDomain, element, elementType); metaStore.updateElement(namespace, elementType, starDomain.getObjectId().toString(), element); } starDomain.setObjectId(new StringObjectId(element.getId().toString())); }
Example #7
Source File: SharedObjectsMetaStore.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@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 ); } }
Example #8
Source File: NamedClusterEmbedManager.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private void addAllClusters() { NamedClusterServiceOsgi ncso = meta.getNamedClusterServiceOsgi(); if ( ncso != null && meta.getMetaStore() != null ) { try { List<String> list = ncso.listNames( meta.getMetaStore() ); for ( String name : list ) { addClusterToMeta( name ); } for ( NamedClusterOsgi nc : namedClusterPool.values() ) { if ( !list.contains( nc.getName() ) ) { addClusterToMeta( nc ); } } addedAllClusters = true; } catch ( MetaStoreException e ) { logMetaStoreException( e ); } } }
Example #9
Source File: PurRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public IMetaStoreElement getElement( String namespace, IMetaStoreElementType elementType, String elementId ) throws MetaStoreException { NodeRepositoryFileData data = pur.getDataForRead( elementId, NodeRepositoryFileData.class ); if ( data == null ) { return null; } IMetaStoreElement element = newElement(); element.setId( elementId ); element.setElementType( elementType ); DataNode dataNode = data.getNode(); dataNodeToElement( dataNode, element ); return element; }
Example #10
Source File: ModelMetaStoreUtil.java From pentaho-kettle with Apache License 2.0 | 6 votes |
private static IMetaStoreElement populateElement(IMetaStore metaStore, LogicalModel model) throws MetaStoreException { try { IMetaStoreElement element = metaStore.newElement(); element.setName(model.getName(defaultLocale)); element.addChild( metaStore.newAttribute(Attribute.ID_MODEL_DESCRIPTION.id, model.getDescription(defaultLocale)) ); IMetaStoreAttribute logicalTablesAttribute = metaStore.newAttribute(Attribute.ID_LOGICAL_TABLES.id, model.getDescription(defaultLocale)); element.addChild(logicalTablesAttribute); for (LogicalTable logicalTable : model.getLogicalTables()) { IMetaStoreAttribute logicalTableAttribute = metaStore.newAttribute(Attribute.ID_LOGICAL_TABLE.id, model.getDescription(defaultLocale)); logicalTablesAttribute.addChild(logicalTableAttribute); // // Save the ID as well as the name (for safety) // logicalTableAttribute.addChild(metaStore.newAttribute(Attribute.ID_LOGICAL_TABLE_ID.id, logicalTable.getId())); logicalTableAttribute.addChild(metaStore.newAttribute(Attribute.ID_LOGICAL_TABLE_NAME.id, logicalTable.getName())); } return element; } catch(Exception e) { throw new MetaStoreException("Unable to populate metastore element from logical model", e); } }
Example #11
Source File: KettleDatabaseRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public void createNamespace( String namespace ) throws MetaStoreException, MetaStoreNamespaceExistsException { try { ObjectId namespaceId = delegate.getNamespaceId( namespace ); if ( namespaceId != null ) { throw new MetaStoreNamespaceExistsException( "Namespace with name '" + namespace + "' already exists" ); } // insert namespace into R_NAMESPACE // delegate.insertNamespace( namespace ); repository.commit(); } catch ( Exception e ) { repository.rollback(); throw new MetaStoreException( e ); } }
Example #12
Source File: SerializableMetaStore.java From kettle-beam with Apache License 2.0 | 6 votes |
private void readElementType( String namespace, JSONObject jType ) throws MetaStoreException { String name = (String) jType.get("name"); String description = (String) jType.get("description"); IMetaStoreElementType elementType = newElementType( namespace ); elementType.setName( name ); elementType.setDescription( description ); createElementType( namespace, elementType ); JSONArray jElements = (JSONArray) jType.get( "elements" ); for (int e=0;e<jElements.size();e++) { JSONObject jElement = (JSONObject) jElements.get(e); readElement(namespace, elementType, jElement); } }
Example #13
Source File: AbstractMeta.java From pentaho-kettle with Apache License 2.0 | 6 votes |
public void importFromMetaStore() throws MetaStoreException, KettlePluginException { // Read the databases... // if ( metaStore != null ) { IMetaStoreElementType databaseType = metaStore.getElementTypeByName( PentahoDefaults.NAMESPACE, PentahoDefaults.DATABASE_CONNECTION_ELEMENT_TYPE_NAME ); if ( databaseType != null ) { List<IMetaStoreElement> databaseElements = metaStore.getElements( PentahoDefaults.NAMESPACE, databaseType ); for ( IMetaStoreElement databaseElement : databaseElements ) { addDatabase( DatabaseMetaStoreUtil.loadDatabaseMetaFromDatabaseElement( metaStore, databaseElement ), false ); } } // TODO: do the same for slaves, clusters, partition schemas } }
Example #14
Source File: KettleDatabaseRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Override public IMetaStoreElementType getElementType( String namespace, String elementTypeId ) throws MetaStoreException { try { ObjectId namespaceId = delegate.getNamespaceId( namespace ); if ( namespaceId == null ) { return null; } RowMetaAndData elementTypeRow = delegate.getElementType( new LongObjectId( new StringObjectId( elementTypeId ) ) ); return delegate.parseElementType( namespace, namespaceId, elementTypeRow ); } catch ( Exception e ) { throw new MetaStoreException( "Unable to get element type with id '" + elementTypeId + "' in namespace '" + namespace + "'", e ); } }
Example #15
Source File: KettleDatabaseRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@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 ); } }
Example #16
Source File: SerializableMetaStore.java From kettle-beam with Apache License 2.0 | 6 votes |
public String toJson() throws MetaStoreException { JSONObject jStore = new JSONObject(); // Metastore name and description // jStore.put("name", getName()); jStore.put("description", getDescription()); // The namespaces // JSONArray jNamespaces = new JSONArray (); jStore.put("namespaces", jNamespaces); for (String namespace : getNamespaces()) { addNamespace(jNamespaces, namespace); } return jStore.toJSONString(); }
Example #17
Source File: SerializableMetaStore.java From kettle-beam with Apache License 2.0 | 6 votes |
/** * Create a copy of all elements in an existing metastore. * * @param source the source store to copy over */ public SerializableMetaStore(IMetaStore source) throws MetaStoreException { List<String> srcNamespaces = source.getNamespaces(); for (String srcNamespace : srcNamespaces) { createNamespace( srcNamespace ); List<IMetaStoreElementType> srcElementTypes = source.getElementTypes( srcNamespace ); for (IMetaStoreElementType srcElementType : srcElementTypes) { IMetaStoreElementType elementType = newElementType( srcNamespace ); elementType.setName( srcElementType.getName() ); elementType.setDescription( srcElementType.getDescription() ); createElementType(srcNamespace, elementType); List<IMetaStoreElement> srcElements = source.getElements( srcNamespace, elementType ); for (IMetaStoreElement srcElement : srcElements) { IMetaStoreElement element = newElement(); element.setName( srcElement.getName() ); element.setValue( srcElement.getValue() ); copyChildren(srcElement, element); createElement(srcNamespace, elementType, element); } } } }
Example #18
Source File: TransMetaConverterTest.java From pentaho-kettle with Apache License 2.0 | 6 votes |
@Test public void testResolveStepMetaResources() throws KettleException, MetaStoreException { Variables variables = new Variables(); TransMeta transMeta = spy( new TransMeta() ); transMeta.setParentVariableSpace( variables ); doReturn( transMeta ).when( transMeta ).realClone( false ); TestMetaResolvableResource testMetaResolvableResource = spy( new TestMetaResolvableResource() ); TestMetaResolvableResource testMetaResolvableResourceTwo = spy( new TestMetaResolvableResource() ); StepMeta testMeta = new StepMeta( "TestMeta", testMetaResolvableResource ); StepMeta testMetaTwo = new StepMeta( "TestMeta2", testMetaResolvableResourceTwo ); transMeta.addStep( testMeta ); transMeta.addStep( testMetaTwo ); transMeta.addTransHop( new TransHopMeta( testMeta, testMetaTwo ) ); TransMetaConverter.convert( transMeta ); verify( testMetaResolvableResource ).resolve(); verify( testMetaResolvableResourceTwo ).resolve(); }
Example #19
Source File: KettleDatabaseRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public List<String> getElementTypeIds( String namespace ) throws MetaStoreException { List<IMetaStoreElementType> elementTypes = getElementTypes( namespace ); ArrayList<String> ids = new ArrayList<String>(); for ( IMetaStoreElementType elementType : elementTypes ) { ids.add( elementType.getId() ); } return ids; }
Example #20
Source File: PurRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 5 votes |
protected void dataNodeToElement( DataNode dataNode, IMetaStoreElement element ) throws MetaStoreException { DataProperty nameProperty = dataNode.getProperty( PROP_NAME ); if ( nameProperty != null ) { element.setName( nameProperty.getString() ); } DataNode childrenNode = dataNode.getNode( PROP_ELEMENT_CHILDREN ); dataNodeToAttribute( childrenNode, element ); }
Example #21
Source File: PurRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void createNamespace( String namespace ) throws MetaStoreException { if ( namespaceExists( namespace ) ) { throw new MetaStoreNamespaceExistsException( "Namespace '" + namespace + "' can not be created, it already exists" ); } RepositoryFile namespaceFolder = new RepositoryFile.Builder( namespace ).folder( true ).versioned( false ).build(); pur.createFolder( namespacesFolder.getId(), namespaceFolder, "Created namespace" ); }
Example #22
Source File: MetaStoreRunConfigurationFactory.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public List<String> getNames() { try { return getMetaStoreFactory().getElementNames(); } catch ( MetaStoreException me ) { return Collections.emptyList(); } }
Example #23
Source File: SharedObjectsMetaStore.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public IMetaStoreElement getElement( String namespace, IMetaStoreElementType elementType, String elementId ) throws MetaStoreException { for ( IMetaStoreElement element : getElements( namespace, elementType ) ) { if ( element.getId().equals( elementId ) ) { return element; } } return null; }
Example #24
Source File: StarDomainMetaStoreUtil.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public static StarDomain loadStarDomain(DelegatingMetaStore metaStore, String id) throws MetaStoreException { IMetaStoreElementType elementType = getStarDomainElementType(metaStore); IMetaStoreElement element = metaStore.getElement(namespace, elementType, id); if (element==null) { return null; } StarDomain starDomain = new StarDomain(); starDomain.setObjectId(new StringObjectId(id)); starDomain.setName(element.getName()); starDomain.setDescription(getChildString(element, Attribute.ID_STAR_DOMAIN_DESCRIPTION.id)); return starDomain; }
Example #25
Source File: PurRepositoryIT.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Test public void testMetaStoreNamespaces() throws MetaStoreException { IMetaStore metaStore = repository.getMetaStore(); assertNotNull( metaStore ); // We start with a clean slate, only the pentaho namespace // assertEquals( 1, metaStore.getNamespaces().size() ); String ns = PentahoDefaults.NAMESPACE; assertEquals( true, metaStore.namespaceExists( ns ) ); metaStore.deleteNamespace( ns ); assertEquals( false, metaStore.namespaceExists( ns ) ); assertEquals( 0, metaStore.getNamespaces().size() ); metaStore.createNamespace( ns ); assertEquals( true, metaStore.namespaceExists( ns ) ); List<String> namespaces = metaStore.getNamespaces(); assertEquals( 1, namespaces.size() ); assertEquals( ns, namespaces.get( 0 ) ); try { metaStore.createNamespace( ns ); fail( "Exception expected when a namespace already exists and where we try to create it again" ); } catch ( MetaStoreNamespaceExistsException e ) { // OK, we expected this. } metaStore.deleteNamespace( ns ); assertEquals( false, metaStore.namespaceExists( ns ) ); assertEquals( 0, metaStore.getNamespaces().size() ); }
Example #26
Source File: PurRepositoryMetaStore.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public IMetaStoreElement getElementByName( String namespace, IMetaStoreElementType elementType, String name ) throws MetaStoreException { for ( IMetaStoreElement element : getElements( namespace, elementType ) ) { if ( element.getName().equals( name ) ) { return element; } } return null; }
Example #27
Source File: EmbeddedMetaStore.java From pentaho-kettle with Apache License 2.0 | 5 votes |
@Override public void createNamespace( final String namespace ) throws MetaStoreException { // Optional, namespace will be automatically created if not already existing MetaStoreUtil.executeLockedOperation( writeLock(), new Callable<Void>() { @Override public Void call() throws Exception { String groupName = JsonElementType.groupName( namespace ); if ( !attributesInterface.getAttributesMap().containsKey( groupName ) ) { attributesInterface.setAttributes( groupName, Maps.<String, String>newHashMap() ); } return null; } } ); }
Example #28
Source File: JdbcUrlImpl.java From pentaho-hadoop-shims with Apache License 2.0 | 5 votes |
@Override public NamedCluster getNamedCluster() throws MetaStoreException { IMetaStore metaStore = metastoreLocator.getMetastore(); if ( metaStore == null ) { return null; } String queryParam = getQueryParam( PENTAHO_NAMED_CLUSTER ); if ( queryParam == null ) { return null; } return namedClusterService.read( queryParam, metaStore ); }
Example #29
Source File: TransMetaPipelineConverter.java From kettle-beam with Apache License 2.0 | 5 votes |
public TransMetaPipelineConverter( TransMeta transMeta, IMetaStore metaStore, String pluginsToStage, BeamJobConfig beamJobConfig ) throws MetaStoreException, KettleException { this(); this.transMeta = transMeta; this.metaStore = new SerializableMetaStore( metaStore ); this.metaStoreJson = this.metaStore.toJson(); this.beamJobConfig = beamJobConfig; addClassesFromPluginsToStage( pluginsToStage ); addDefaultStepHandlers(); }
Example #30
Source File: JdbcUrlImplTest.java From pentaho-hadoop-shims with Apache License 2.0 | 5 votes |
@Test public void testGetNamedClusterSuccess() throws MetaStoreException, URISyntaxException { String myCluster = "myCluster"; String url = "jdbc:hive2://my.hadoop.cluster:999/default;" + JdbcUrlImpl.PENTAHO_NAMED_CLUSTER + "=" + myCluster; IMetaStore iMetaStore = mock( IMetaStore.class ); NamedCluster namedCluster = mock( NamedCluster.class ); when( namedClusterService.read( myCluster, iMetaStore ) ).thenReturn( namedCluster ); when( metastoreLocator.getMetastore() ).thenReturn( iMetaStore ); JdbcUrlImpl jdbcUrl = new JdbcUrlImpl( url, namedClusterService, metastoreLocator ); assertEquals( myCluster, jdbcUrl.getQueryParam( JdbcUrlImpl.PENTAHO_NAMED_CLUSTER ) ); assertEquals( namedCluster, jdbcUrl.getNamedCluster() ); }