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();
}
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();
}
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();
}
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));
}
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));
}
Aggregations