Search in sources :

Example 1 with MappingMeta

use of org.pentaho.di.trans.steps.mapping.MappingMeta in project pentaho-kettle by pentaho.

the class RepositoryExporter method convertFromFileRepository.

private void convertFromFileRepository(TransMeta transMeta) {
    Object[] metaInjectObjectArray = new Object[4];
    metaInjectObjectArray[0] = transMeta;
    metaInjectObjectArray[1] = PKG;
    if (repository instanceof KettleFileRepository) {
        KettleFileRepository fileRep = (KettleFileRepository) repository;
        metaInjectObjectArray[2] = fileRep;
        // The id of the transformation is the relative filename.
        // Setting the filename also sets internal variables needed to load the trans/job referenced.
        // 
        String transMetaFilename = fileRep.calcFilename(transMeta.getObjectId());
        transMeta.setFilename(transMetaFilename);
        for (StepMeta stepMeta : transMeta.getSteps()) {
            if (stepMeta.isMapping()) {
                MappingMeta mappingMeta = (MappingMeta) stepMeta.getStepMetaInterface();
                // 
                if (mappingMeta.getSpecificationMethod() == ObjectLocationSpecificationMethod.FILENAME) {
                    try {
                        TransMeta meta = MappingMeta.loadMappingMeta(mappingMeta, fileRep, fileRep.metaStore, transMeta);
                        FileObject fileObject = KettleVFS.getFileObject(meta.getFilename());
                        mappingMeta.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
                        mappingMeta.setFileName(null);
                        mappingMeta.setTransName(meta.getName());
                        mappingMeta.setDirectoryPath(Const.NVL(calcRepositoryDirectory(fileRep, fileObject), "/"));
                    } catch (Exception e) {
                        log.logError(BaseMessages.getString(PKG, "Repository.Exporter.Log.UnableToLoadTransInMap", mappingMeta.getName()), e);
                    }
                }
            }
            metaInjectObjectArray[3] = stepMeta;
            try {
                ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.RepositoryExporterPatchTransStep.id, metaInjectObjectArray);
            } catch (KettleException ke) {
                log.logError(ke.getMessage(), ke);
            }
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) MappingMeta(org.pentaho.di.trans.steps.mapping.MappingMeta) TransMeta(org.pentaho.di.trans.TransMeta) FileObject(org.apache.commons.vfs2.FileObject) FileObject(org.apache.commons.vfs2.FileObject) StepMeta(org.pentaho.di.trans.step.StepMeta) KettleFileRepository(org.pentaho.di.repository.filerep.KettleFileRepository) KettleException(org.pentaho.di.core.exception.KettleException) FileSystemException(org.apache.commons.vfs2.FileSystemException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 2 with MappingMeta

use of org.pentaho.di.trans.steps.mapping.MappingMeta in project pentaho-kettle by pentaho.

the class TransMeta method setRepositoryOnMappingSteps.

/**
 * Set the Repository object on the Mapping step That way the mapping step can determine the output fields for
 * repository hosted mappings... This is the exception to the rule so we don't pass this through the getFields()
 * method. TODO: figure out a way to make this more generic.
 */
private void setRepositoryOnMappingSteps() {
    for (StepMeta step : steps) {
        if (step.getStepMetaInterface() instanceof MappingMeta) {
            ((MappingMeta) step.getStepMetaInterface()).setRepository(repository);
            ((MappingMeta) step.getStepMetaInterface()).setMetaStore(metaStore);
        }
        if (step.getStepMetaInterface() instanceof SingleThreaderMeta) {
            ((SingleThreaderMeta) step.getStepMetaInterface()).setRepository(repository);
            ((SingleThreaderMeta) step.getStepMetaInterface()).setMetaStore(metaStore);
        }
        if (step.getStepMetaInterface() instanceof JobExecutorMeta) {
            ((JobExecutorMeta) step.getStepMetaInterface()).setRepository(repository);
            ((JobExecutorMeta) step.getStepMetaInterface()).setMetaStore(metaStore);
        }
        if (step.getStepMetaInterface() instanceof TransExecutorMeta) {
            ((TransExecutorMeta) step.getStepMetaInterface()).setRepository(repository);
            ((TransExecutorMeta) step.getStepMetaInterface()).setMetaStore(metaStore);
        }
    }
}
Also used : JobExecutorMeta(org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta) TransExecutorMeta(org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta) MappingMeta(org.pentaho.di.trans.steps.mapping.MappingMeta) SingleThreaderMeta(org.pentaho.di.trans.steps.singlethreader.SingleThreaderMeta) StepMeta(org.pentaho.di.trans.step.StepMeta)

Aggregations

StepMeta (org.pentaho.di.trans.step.StepMeta)2 MappingMeta (org.pentaho.di.trans.steps.mapping.MappingMeta)2 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleFileRepository (org.pentaho.di.repository.filerep.KettleFileRepository)1 TransMeta (org.pentaho.di.trans.TransMeta)1 JobExecutorMeta (org.pentaho.di.trans.steps.jobexecutor.JobExecutorMeta)1 SingleThreaderMeta (org.pentaho.di.trans.steps.singlethreader.SingleThreaderMeta)1 TransExecutorMeta (org.pentaho.di.trans.steps.transexecutor.TransExecutorMeta)1