Search in sources :

Example 16 with MetaverseAnalyzerException

use of org.pentaho.metaverse.api.MetaverseAnalyzerException in project pentaho-metaverse by pentaho.

the class AbstractStepMetaJsonSerializer method writeFieldTransforms.

protected void writeFieldTransforms(T meta, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonGenerationException {
    json.writeArrayFieldStart(JSON_PROPERTY_TRANSFORMS);
    IFieldLineageMetadataProvider mapper = getFieldLineageMetadataProvider(meta);
    try {
        Set<ComponentDerivationRecord> changes = mapper.getChangeRecords(meta);
        if (changes != null) {
            for (ComponentDerivationRecord change : changes) {
                if (change.hasDelta()) {
                    json.writeObject(change);
                }
            }
        }
    } catch (MetaverseAnalyzerException e) {
        LOGGER.warn(Messages.getString("WARNING.Serialization.Step.WriteFieldTransforms", meta.getParentStepMeta().getName()), e);
    }
    json.writeEndArray();
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)

Example 17 with MetaverseAnalyzerException

use of org.pentaho.metaverse.api.MetaverseAnalyzerException in project pentaho-metaverse by pentaho.

the class AbstractStepMetaJsonSerializer method getFieldLineageMetadataProvider.

protected IFieldLineageMetadataProvider getFieldLineageMetadataProvider(T meta) {
    IStepAnalyzerProvider provider = getStepAnalyzerProvider();
    if (provider == null) {
        // try to get it from PentahoSystem
        provider = PentahoSystem.get(IStepAnalyzerProvider.class);
    }
    if (provider != null) {
        Set<Class<?>> types = new HashSet<Class<?>>();
        types.add(meta.getClass());
        List<IStepAnalyzer> analyzers = provider.getAnalyzers(types);
        if (analyzers != null) {
            for (IStepAnalyzer analyzer : analyzers) {
                // try to set up the analyzer with parent step & trans meta
                if (analyzer instanceof StepAnalyzer) {
                    StepAnalyzer bsa = (StepAnalyzer) analyzer;
                    try {
                        bsa.validateState(null, meta);
                        bsa.loadInputAndOutputStreamFields(meta);
                    } catch (MetaverseAnalyzerException e) {
                    // eat it
                    }
                }
                if (analyzer instanceof IFieldLineageMetadataProvider) {
                    return (IFieldLineageMetadataProvider) analyzer;
                }
            }
        }
    }
    return new GenericStepMetaAnalyzer();
}
Also used : IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) StepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.StepAnalyzer) IStepAnalyzer(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzer) IStepAnalyzerProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IStepAnalyzerProvider) HashSet(java.util.HashSet) GenericStepMetaAnalyzer(org.pentaho.metaverse.analyzer.kettle.step.GenericStepMetaAnalyzer)

Example 18 with MetaverseAnalyzerException

use of org.pentaho.metaverse.api.MetaverseAnalyzerException in project pentaho-metaverse by pentaho.

the class AbstractStepMetaJsonSerializer method writeFieldMappings.

protected void writeFieldMappings(T meta, JsonGenerator json, SerializerProvider serializerProvider) throws IOException {
    json.writeArrayFieldStart(JSON_PROPERTY_MAPPINGS);
    IFieldLineageMetadataProvider mapper = getFieldLineageMetadataProvider(meta);
    try {
        Set<IFieldMapping> fieldMappings = mapper.getFieldMappings(meta);
        if (fieldMappings != null) {
            for (IFieldMapping fieldMapping : fieldMappings) {
                json.writeObject(fieldMapping);
            }
        }
    } catch (MetaverseAnalyzerException e) {
        LOGGER.warn(Messages.getString("WARNING.Serialization.Step.WriteFieldMappings", meta.getParentStepMeta().getName()), e);
    }
    json.writeEndArray();
}
Also used : IFieldLineageMetadataProvider(org.pentaho.metaverse.api.analyzer.kettle.step.IFieldLineageMetadataProvider) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) IFieldMapping(org.pentaho.metaverse.api.model.kettle.IFieldMapping)

Example 19 with MetaverseAnalyzerException

use of org.pentaho.metaverse.api.MetaverseAnalyzerException in project pentaho-metaverse by pentaho.

the class JobAnalyzer method analyze.

@Override
public synchronized IMetaverseNode analyze(IComponentDescriptor descriptor, IDocument document) throws MetaverseAnalyzerException {
    validateState(document);
    Object repoObject = document.getContent();
    JobMeta jobMeta = null;
    if (repoObject instanceof String) {
        // hydrate the job
        try {
            String content = (String) repoObject;
            ByteArrayInputStream xmlStream = new ByteArrayInputStream(content.getBytes());
            jobMeta = new JobMeta(xmlStream, null, null);
        } catch (KettleXMLException e) {
            throw new MetaverseAnalyzerException(e);
        }
    } else if (repoObject instanceof JobMeta) {
        jobMeta = (JobMeta) repoObject;
    }
    // construct a dummy job based on our JobMeta so we get out VariableSpace set properly
    jobMeta.setFilename(document.getStringID());
    IComponentDescriptor documentDescriptor = new MetaverseComponentDescriptor(document.getStringID(), DictionaryConst.NODE_TYPE_JOB, new Namespace(descriptor.getLogicalId()), descriptor.getContext());
    // Create a metaverse node and start filling in details
    IMetaverseNode jobNode = metaverseObjectFactory.createNodeObject(document.getNamespace(), jobMeta.getName(), DictionaryConst.NODE_TYPE_JOB);
    jobNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
    return analyze(documentDescriptor, jobMeta, jobNode, (String) document.getProperty(DictionaryConst.PROPERTY_PATH));
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) ByteArrayInputStream(java.io.ByteArrayInputStream) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) INamespace(org.pentaho.metaverse.api.INamespace) Namespace(org.pentaho.metaverse.api.Namespace) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Example 20 with MetaverseAnalyzerException

use of org.pentaho.metaverse.api.MetaverseAnalyzerException in project pentaho-metaverse by pentaho.

the class TransformationAnalyzer method analyze.

@Override
public synchronized IMetaverseNode analyze(IComponentDescriptor descriptor, IDocument document) throws MetaverseAnalyzerException {
    validateState(document);
    Object repoObject = document.getContent();
    TransMeta transMeta = null;
    if (repoObject instanceof String) {
        // hydrate the transformation
        try {
            String content = (String) repoObject;
            ByteArrayInputStream xmlStream = new ByteArrayInputStream(content.getBytes());
            transMeta = new TransMeta(xmlStream, null, false, null, null);
            transMeta.setFilename(document.getStringID());
            if (transMeta.hasMissingPlugins()) {
                throw new MetaverseAnalyzerException(Messages.getErrorString("ERROR.MissingPlugin"));
            }
        } catch (KettleException e) {
            throw new MetaverseAnalyzerException(e);
        }
    } else if (repoObject instanceof TransMeta) {
        transMeta = (TransMeta) repoObject;
    }
    IComponentDescriptor documentDescriptor = new MetaverseComponentDescriptor(document.getStringID(), DictionaryConst.NODE_TYPE_TRANS, new Namespace(descriptor.getLogicalId()), descriptor.getContext());
    // Create a metaverse node and start filling in details
    IMetaverseNode transNode = metaverseObjectFactory.createNodeObject(document.getNamespace(), transMeta.getName(), DictionaryConst.NODE_TYPE_TRANS);
    transNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
    return analyze(documentDescriptor, transMeta, transNode, (String) document.getProperty(DictionaryConst.PROPERTY_PATH));
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) ByteArrayInputStream(java.io.ByteArrayInputStream) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) TransMeta(org.pentaho.di.trans.TransMeta) INamespace(org.pentaho.metaverse.api.INamespace) Namespace(org.pentaho.metaverse.api.Namespace) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Aggregations

MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)23 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)13 IComponentDescriptor (org.pentaho.metaverse.api.IComponentDescriptor)9 MetaverseComponentDescriptor (org.pentaho.metaverse.api.MetaverseComponentDescriptor)9 KettleException (org.pentaho.di.core.exception.KettleException)7 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)6 TransMeta (org.pentaho.di.trans.TransMeta)6 JobMeta (org.pentaho.di.job.JobMeta)5 INamespace (org.pentaho.metaverse.api.INamespace)5 Namespace (org.pentaho.metaverse.api.Namespace)5 FileNotFoundException (java.io.FileNotFoundException)4 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)4 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)4 Repository (org.pentaho.di.repository.Repository)4 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)4 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)4 HashSet (java.util.HashSet)3 ProgressNullMonitorListener (org.pentaho.di.core.ProgressNullMonitorListener)3 KettleStepException (org.pentaho.di.core.exception.KettleStepException)3 IDocument (org.pentaho.metaverse.api.IDocument)3