Java Code Examples for org.pentaho.di.repository.ObjectId#getId()

The following examples show how to use org.pentaho.di.repository.ObjectId#getId() . 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: KettleDatabaseRepositoryMetaStoreDelegate.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public Collection<RowMetaAndData> getElementAttributes( ObjectId elementId, ObjectId parentAttributeId ) throws KettleDatabaseException, KettleValueException {
  List<RowMetaAndData> attrs = new ArrayList<RowMetaAndData>();

  String sql =
    "SELECT * FROM "
      + quoteTable( KettleDatabaseRepository.TABLE_R_ELEMENT_ATTRIBUTE ) + " WHERE "
      + quote( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT ) + " = " + elementId.getId();
  if ( parentAttributeId != null ) {
    sql +=
      " AND "
        + quote( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE_PARENT ) + " = "
        + parentAttributeId.getId();
  }

  List<Object[]> rows = repository.connectionDelegate.getRows( sql, 0 );
  for ( Object[] row : rows ) {
    RowMetaAndData rowWithMeta = new RowMetaAndData( repository.connectionDelegate.getReturnRowMeta(), row );
    long id =
      rowWithMeta.getInteger(
        quote( KettleDatabaseRepository.FIELD_ELEMENT_ATTRIBUTE_ID_ELEMENT_ATTRIBUTE ), 0 );
    if ( id > 0 ) {
      attrs.add( rowWithMeta );
    }
  }
  return attrs;
}
 
Example 2
Source File: KettleFileRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public Node loadNodeFromXML( ObjectId id, String tag ) throws KettleException {
  try {
    // The object ID is the base name of the file in the Base directory folder
    //
    String filename = calcDirectoryName( null ) + id.getId();
    FileObject fileObject = KettleVFS.getFileObject( filename );
    Document document = XMLHandler.loadXMLFile( fileObject );
    Node node = XMLHandler.getSubNode( document, tag );

    return node;
  } catch ( Exception e ) {
    throw new KettleException( "Unable to load XML object from object with ID ["
      + id + "] and tag [" + tag + "]", e );
  }
}
 
Example 3
Source File: KettleFileRepository.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
@Override
public RepositoryObject getObjectInformation( ObjectId objectId, RepositoryObjectType objectType ) throws KettleException {
  try {
    String filename = calcDirectoryName( null );
    if ( objectId.getId().startsWith( "/" ) ) {
      filename += objectId.getId().substring( 1 );
    } else {
      filename += objectId.getId();
    }
    FileObject fileObject = KettleVFS.getFileObject( filename );
    if ( !fileObject.exists() ) {
      return null;
    }
    FileName fname = fileObject.getName();
    String name = fname.getBaseName();
    if ( !Utils.isEmpty( fname.getExtension() ) && name.length() > fname.getExtension().length() ) {
      name = name.substring( 0, name.length() - fname.getExtension().length() - 1 );
    }

    String filePath = fileObject.getParent().getName().getPath();
    final FileObject baseDirObject = KettleVFS.getFileObject( repositoryMeta.getBaseDirectory() );
    final int baseDirObjectPathLength = baseDirObject.getName().getPath().length();
    final String dirPath =
      baseDirObjectPathLength <= filePath.length() ? filePath.substring( baseDirObjectPathLength ) : "/";
    RepositoryDirectoryInterface directory = loadRepositoryDirectoryTree().findDirectory( dirPath );
    Date lastModified = new Date( fileObject.getContent().getLastModifiedTime() );

    return new RepositoryObject( objectId, name, directory, "-", lastModified, objectType, "", false );

  } catch ( Exception e ) {
    throw new KettleException( "Unable to get object information for object with id=" + objectId, e );
  }
}
 
Example 4
Source File: RepositoryProxy.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void insertJobEntryDatabase( ObjectId idJob, ObjectId idJobentry, ObjectId idDatabase ) throws KettleException {
  DataNodeRef ref = new DataNodeRef( idDatabase.getId() );
  node.setProperty( idDatabase.getId(), ref );
}
 
Example 5
Source File: RepositoryProxy.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void insertStepDatabase( ObjectId idTransformation, ObjectId idStep, ObjectId idDatabase )
  throws KettleException {
  DataNodeRef ref = new DataNodeRef( idDatabase.getId() );
  node.setProperty( idDatabase.getId(), ref );
}