Java Code Examples for org.pentaho.metastore.api.exceptions.MetaStoreException

The following examples show how to use org.pentaho.metastore.api.exceptions.MetaStoreException. These examples are extracted from open source projects. 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 Project: pentaho-kettle   Source File: TransMetaConverterTest.java    License: Apache License 2.0 6 votes vote down vote up
@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 2
Source Project: kettle-beam   Source File: SerializableMetaStore.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 3
Source Project: kettle-beam   Source File: SerializableMetaStore.java    License: Apache License 2.0 6 votes vote down vote up
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 4
Source Project: kettle-beam   Source File: SerializableMetaStore.java    License: Apache License 2.0 6 votes vote down vote up
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 5
Source Project: pentaho-kettle   Source File: StarDomainMetaStoreUtil.java    License: Apache License 2.0 6 votes vote down vote up
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 6
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: Apache License 2.0 6 votes vote down vote up
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 7
Source Project: pentaho-pdi-dataset   Source File: DataSetHelper.java    License: Apache License 2.0 6 votes vote down vote up
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 8
Source Project: pentaho-kettle   Source File: PurRepositoryMetaStore.java    License: Apache License 2.0 6 votes vote down vote up
@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 9
Source Project: pentaho-kettle   Source File: AbstractMeta.java    License: Apache License 2.0 6 votes vote down vote up
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 10
Source Project: pentaho-kettle   Source File: NamedClusterEmbedManager.java    License: Apache License 2.0 6 votes vote down vote up
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 11
Source Project: pentaho-kettle   Source File: NamedClusterEmbedManager.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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 12
Source Project: pentaho-kettle   Source File: SharedObjectsMetaStore.java    License: Apache License 2.0 6 votes vote down vote up
@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 13
Source Project: pentaho-kettle   Source File: PurRepositoryMetaStore.java    License: Apache License 2.0 6 votes vote down vote up
@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 14
Source Project: pentaho-kettle   Source File: ModelMetaStoreUtil.java    License: Apache License 2.0 6 votes vote down vote up
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 15
@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 16
@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 17
@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 18
@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 19
Source Project: kettle-beam   Source File: TransMetaPipelineConverter.java    License: Apache License 2.0 5 votes vote down vote up
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 20
Source Project: kettle-beam   Source File: TransMetaPipelineConverter.java    License: Apache License 2.0 5 votes vote down vote up
public TransMetaPipelineConverter( TransMeta transMeta, IMetaStore metaStore, List<String> stepPluginClasses, List<String> xpPluginClasses, BeamJobConfig beamJobConfig ) throws MetaStoreException {
  this();
  this.transMeta = transMeta;
  this.metaStore = new SerializableMetaStore( metaStore );
  this.metaStoreJson = this.metaStore.toJson();
  this.stepPluginClasses = stepPluginClasses;
  this.xpPluginClasses = xpPluginClasses;
  this.beamJobConfig = beamJobConfig;

  addDefaultStepHandlers();
}
 
Example 21
Source Project: kettle-beam   Source File: SerializableMetaStore.java    License: Apache License 2.0 5 votes vote down vote up
private void copyChildren( IMetaStoreAttribute srcAttribute, IMetaStoreAttribute attribute ) throws MetaStoreException {
  List<IMetaStoreAttribute> srcChildren = srcAttribute.getChildren();
  for (IMetaStoreAttribute srcChild : srcChildren) {
    IMetaStoreAttribute child = newAttribute( srcChild.getId(), srcChild.getValue() );
    copyChildren(srcChild, child);
    attribute.addChild( child );
  }
}
 
Example 22
@Override
public boolean delete( String name ) {
  try {
    getMetaStoreFactory().deleteElement( name );
  } catch ( MetaStoreException me ) {
    return false;
  }

  return true;
}
 
Example 23
Source Project: kettle-beam   Source File: SerializableMetaStore.java    License: Apache License 2.0 5 votes vote down vote up
private void addNamespace( JSONArray jNamespaces, String namespace ) throws MetaStoreException {

    JSONObject jNamespace = new JSONObject();
    jNamespaces.add(jNamespace);

    jNamespace.put("name", namespace);

    JSONArray jElementTypes = new JSONArray();
    jNamespace.put("types", jElementTypes);

    List<IMetaStoreElementType> elementTypes = getElementTypes( namespace );
    for (IMetaStoreElementType elementType : elementTypes) {
      addElementType(jElementTypes, namespace, elementType);
    }
  }
 
Example 24
Source Project: kettle-beam   Source File: SerializableMetaStore.java    License: Apache License 2.0 5 votes vote down vote up
private void readNamespace( JSONObject jNamespace ) throws MetaStoreException {

    String namespace = (String) jNamespace.get( "name" );
    createNamespace( namespace );

    JSONArray jTypes = (JSONArray) jNamespace.get( "types" );
    for (int t=0;t<jTypes.size();t++) {
      JSONObject jType = (JSONObject) jTypes.get(t);
      readElementType(namespace, jType);
    }
  }
 
Example 25
Source Project: pentaho-kettle   Source File: ModelMetaStoreUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Inflate a logical model from a metastore element.
 *
 * @param metaStore The metastore to read from
 * @param element The element to read from
 * @return The Logical Model
 * @throws MetaStoreException in case something goes wrong
 */
public static LogicalModel buildLogicalModel(IMetaStore metaStore, IMetaStoreElement element) throws MetaStoreException {
  try {
    LogicalModel model = new LogicalModel();

    model.setName(new LocalizedString(defaultLocale, element.getName()));
    model.setDescription(new LocalizedString(defaultLocale, getChildString(element, Attribute.ID_MODEL_DESCRIPTION.id)));



    return model;
  } catch(Exception e) {
    throw new MetaStoreException("Unable to inflate logical model from metastore element", e);
  }
}
 
Example 26
Source Project: pentaho-kettle   Source File: StarDomainMetaStoreUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static IMetaStoreElementType getStarDomainElementType(IMetaStore metaStore) throws MetaStoreException {
  verifyNamespaceCreated(metaStore, namespace);

  IMetaStoreElementType elementType = metaStore.getElementTypeByName(namespace, METASTORE_STAR_DOMAIN_TYPE_NAME);
  if (elementType==null) {
    // create the type
    //
    elementType = createStarDomainElementType(metaStore);
  }
  return elementType;
}
 
Example 27
Source Project: pentaho-kettle   Source File: EmbeddedMetaStore.java    License: Apache License 2.0 5 votes vote down vote up
private void update( final AttributesInterfaceEntry entry ) throws MetaStoreException {
  MetaStoreUtil.executeLockedOperation( writeLock(), new Callable<Void>() {
    @Override public Void call() throws Exception {
      attributesInterface.setAttribute( entry.groupName(), entry.key(), entry.jsonValue() );
      return null;
    }
  } );
}
 
Example 28
Source Project: kettle-beam   Source File: SerializableMetaStoreTest.java    License: Apache License 2.0 5 votes vote down vote up
private void assertEqualMetastores( IMetaStore store1, IMetaStore store2 ) throws MetaStoreException {
  List<String> namespaces1 = store1.getNamespaces();
  List<String> namespaces2 = store2.getNamespaces();
  assertEquals( namespaces1.size(), namespaces2.size());

  for (int n=0;n<namespaces1.size();n++) {
    String namespace1 = namespaces1.get( n );
    String namespace2 = namespaces2.get( n );
    assertEquals( namespace1, namespace2 );

    List<IMetaStoreElementType> elementTypes1 = store1.getElementTypes( namespace1 );
    List<IMetaStoreElementType> elementTypes2 = store2.getElementTypes( namespace2 );
    assertEquals( elementTypes1.size(), elementTypes2.size() );
    for (int t=0;t<elementTypes1.size();t++) {
      IMetaStoreElementType elementType1 = elementTypes1.get(t);
      IMetaStoreElementType elementType2 = elementTypes2.get(t);
      assertEquals(elementType1.getName(), elementType2.getName());
      assertEquals(elementType1.getDescription(), elementType2.getDescription());

      List<IMetaStoreElement> elements1 = store1.getElements( namespace1, elementType1 );
      List<IMetaStoreElement> elements2 = store2.getElements( namespace2, elementType2 );
      assertEquals( elements1.size(), elements2.size() );
      for (int e=0;e<elements1.size();e++) {

        IMetaStoreElement element1 = elements1.get(e);
        IMetaStoreElement element2 = elements2.get(e);

        assertEquals( element1.getName(), element2.getName() );

        assertEqualAttributes(element1, element2);
      }
    }
  }
}
 
Example 29
Source Project: pentaho-kettle   Source File: MetaStoreExplorerDialog.java    License: Apache License 2.0 5 votes vote down vote up
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 );
    }

  }
 
Example 30
Source Project: pentaho-kettle   Source File: PurRepositoryMetaStore.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<String> getElementIds( String namespace, IMetaStoreElementType elementType ) throws MetaStoreException {
  RepositoryFile folder = validateElementTypeRepositoryFolder( namespace, elementType );
  List<RepositoryFile> children = getChildren( folder.getId() );
  removeHiddenFilesFromList( children );
  List<String> ids = new ArrayList<String>();
  for ( RepositoryFile child : children ) {
    ids.add( child.getId().toString() );
  }
  return ids;
}