use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class AbstractStepMetaJsonSerializer method writeExternalResources.
protected void writeExternalResources(T meta, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonGenerationException {
Set<Class<?>> metaClassSet = new HashSet<Class<?>>(1);
metaClassSet.add(meta.getClass());
IStepExternalResourceConsumerProvider stepExternalResourceConsumerProvider = getStepExternalResourceConsumerProvider();
List<IStepExternalResourceConsumer> resourceConsumers = null;
if (stepExternalResourceConsumerProvider != null) {
resourceConsumers = stepExternalResourceConsumerProvider.getExternalResourceConsumers(metaClassSet);
}
json.writeArrayFieldStart(JSON_PROPERTY_EXTERNAL_RESOURCES);
if (resourceConsumers != null) {
for (IStepExternalResourceConsumer resourceConsumer : resourceConsumers) {
Collection<IExternalResourceInfo> infos = resourceConsumer.getResourcesFromMeta(meta);
for (IExternalResourceInfo info : infos) {
json.writeObject(info);
}
}
}
json.writeEndArray();
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class TransMetaJsonDeserializer method deserializeConnections.
protected void deserializeConnections(TransMeta transMeta, JsonNode node, ObjectMapper mapper) {
ArrayNode connectionsArrayNode = (ArrayNode) node.get(TransMetaJsonSerializer.JSON_PROPERTY_CONNECTIONS);
IExternalResourceInfo conn = null;
for (int i = 0; i < connectionsArrayNode.size(); i++) {
JsonNode connNode = connectionsArrayNode.get(i);
String className = connNode.get(IInfo.JSON_PROPERTY_CLASS).asText();
try {
Class clazz = this.getClass().getClassLoader().loadClass(className);
conn = (IExternalResourceInfo) clazz.newInstance();
conn = mapper.readValue(connNode.toString(), conn.getClass());
DatabaseMeta dbMeta = null;
if (conn instanceof JdbcResourceInfo) {
JdbcResourceInfo db = (JdbcResourceInfo) conn;
dbMeta = new DatabaseMeta(db.getName(), db.getPluginId(), DatabaseMeta.getAccessTypeDesc(DatabaseMeta.TYPE_ACCESS_NATIVE), db.getServer(), db.getDatabaseName(), String.valueOf(db.getPort()), db.getUsername(), db.getPassword());
} else if (conn instanceof JndiResourceInfo) {
JndiResourceInfo db = (JndiResourceInfo) conn;
dbMeta = new DatabaseMeta(db.getName(), db.getPluginId(), DatabaseMeta.getAccessTypeDesc(DatabaseMeta.TYPE_ACCESS_JNDI), null, null, null, null, null);
}
transMeta.addDatabase(dbMeta);
} catch (Exception e) {
LOGGER.warn(Messages.getString("WARNING.Deserialization.Trans.Connections", conn.getName(), transMeta.getName()), e);
}
}
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class JobEntryExternalResourceConsumerListener method addExternalResources.
protected void addExternalResources(Collection<IExternalResourceInfo> resources, JobEntryInterface jobEntry) {
if (resources != null) {
// Add the resources to the execution profile
IExecutionProfile executionProfile = JobLineageHolderMap.getInstance().getLineageHolder(jobEntry.getParentJob()).getExecutionProfile();
if (executionProfile != null) {
String jobEntryName = jobEntry.getName();
Map<String, List<IExternalResourceInfo>> resourceMap = executionProfile.getExecutionData().getExternalResources();
List<IExternalResourceInfo> externalResources = resourceMap.get(jobEntryName);
if (externalResources == null) {
externalResources = new LinkedList<IExternalResourceInfo>();
}
externalResources.addAll(resources);
resourceMap.put(jobEntryName, externalResources);
}
}
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class JobEntryExternalResourceConsumerListener method callExtensionPoint.
/**
* This method is called by the Kettle code when a job entry is about to start
*
* @param log the logging channel to log debugging information to
* @param object The subject object that is passed to the plugin code
* @throws org.pentaho.di.core.exception.KettleException In case the plugin decides that an error has occurred
* and the parent process should stop.
*/
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
if (jobEntryConsumerProvider == null) {
jobEntryConsumerProvider = (IJobEntryExternalResourceConsumerProvider) MetaverseBeanUtil.getInstance().get("IJobEntryExternalResourceConsumerProvider");
}
JobExecutionExtension jobExec = (JobExecutionExtension) object;
JobEntryCopy jobEntryCopy = jobExec.jobEntryCopy;
if (jobEntryCopy != null) {
JobEntryInterface meta = jobEntryCopy.getEntry();
if (meta != null) {
Class<?> metaClass = meta.getClass();
if (JobEntryBase.class.isAssignableFrom(metaClass)) {
if (jobEntryConsumerProvider != null) {
// Put the class into a collection and get the consumers that can process this class
Set<Class<?>> metaClassSet = new HashSet<Class<?>>(1);
metaClassSet.add(metaClass);
List<IJobEntryExternalResourceConsumer> jobEntryConsumers = jobEntryConsumerProvider.getExternalResourceConsumers(metaClassSet);
if (jobEntryConsumers != null) {
for (IJobEntryExternalResourceConsumer jobEntryConsumer : jobEntryConsumers) {
// We might know enough at this point, so call the consumer
Collection<IExternalResourceInfo> resources = jobEntryConsumer.getResourcesFromMeta(meta);
addExternalResources(resources, meta);
// Add a JobEntryListener to collect external resource info after a job entry has finished
if (jobExec.job != null && jobEntryConsumer.isDataDriven(meta)) {
// Add the consumer as a resource listener, this is done to override the default impl
if (jobEntryConsumer instanceof JobEntryExternalResourceListener) {
jobExec.job.addJobEntryListener((JobEntryExternalResourceListener) jobEntryConsumer);
} else {
jobExec.job.addJobEntryListener(new JobEntryExternalResourceListener());
}
}
}
} else {
// Add a JobEntryListener to collect external resource info after a job entry has finished
if (jobExec.job != null) {
jobExec.job.addJobEntryListener(new JobEntryExternalResourceListener());
}
}
}
}
}
}
}
use of org.pentaho.metaverse.api.model.IExternalResourceInfo in project pentaho-metaverse by pentaho.
the class StepExternalResourceConsumerListener method callExtensionPoint.
/**
* This method is called by the Kettle code when a step is about to start
*
* @param log the logging channel to log debugging information to
* @param object The subject object that is passed to the plugin code
* @throws org.pentaho.di.core.exception.KettleException In case the plugin decides that an error has occurred
* and the parent process should stop.
*/
@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
if (stepConsumerProvider == null) {
stepConsumerProvider = (IStepExternalResourceConsumerProvider) MetaverseBeanUtil.getInstance().get("IStepExternalResourceConsumerProvider");
}
StepMetaDataCombi stepCombi = (StepMetaDataCombi) object;
if (stepCombi != null) {
StepMetaInterface meta = stepCombi.meta;
StepInterface step = stepCombi.step;
if (meta != null) {
Class<?> metaClass = meta.getClass();
if (BaseStepMeta.class.isAssignableFrom(metaClass)) {
if (stepConsumerProvider != null) {
// Put the class into a collection and get the consumers that can process this class
Set<Class<?>> metaClassSet = new HashSet<Class<?>>(1);
metaClassSet.add(metaClass);
List<IStepExternalResourceConsumer> stepConsumers = stepConsumerProvider.getExternalResourceConsumers(metaClassSet);
if (stepConsumers != null) {
for (IStepExternalResourceConsumer stepConsumer : stepConsumers) {
// We might know enough at this point, so call the consumer
Collection<IExternalResourceInfo> resources = stepConsumer.getResourcesFromMeta(meta);
addExternalResources(resources, step);
// Add a RowListener if the step is data-driven
if (stepConsumer.isDataDriven(meta)) {
stepCombi.step.addRowListener(new StepExternalConsumerRowListener(stepConsumer, step));
}
}
}
}
}
}
}
}
Aggregations