Search in sources :

Example 1 with LineageRepository

use of org.pentaho.metaverse.impl.model.kettle.LineageRepository in project pentaho-metaverse by pentaho.

the class AbstractJobEntryJsonSerializer method writeRepoAttributes.

protected void writeRepoAttributes(T meta, JsonGenerator json) throws IOException {
    ObjectId jobId = meta.getObjectId() == null ? new StringObjectId(meta.getName()) : meta.getObjectId();
    LineageRepository repo = getLineageRepository();
    if (repo != null) {
        Map<String, Object> attrs = repo.getJobEntryAttributesCache(jobId);
        json.writeObjectField(JSON_PROPERTY_ATTRIBUTES, attrs);
        List<Map<String, Object>> fields = repo.getJobEntryFieldsCache(jobId);
        json.writeObjectField(JSON_PROPERTY_FIELDS, fields);
    }
}
Also used : ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) LineageRepository(org.pentaho.metaverse.impl.model.kettle.LineageRepository) StringObjectId(org.pentaho.di.repository.StringObjectId) Map(java.util.Map)

Example 2 with LineageRepository

use of org.pentaho.metaverse.impl.model.kettle.LineageRepository in project pentaho-metaverse by pentaho.

the class AbstractStepMetaJsonSerializer method writeRepoAttributes.

protected void writeRepoAttributes(T meta, JsonGenerator json) throws IOException {
    StepMeta parentStepMeta = meta.getParentStepMeta();
    if (parentStepMeta != null) {
        String id = meta.getObjectId() == null ? parentStepMeta.getName() : meta.getObjectId().toString();
        ObjectId stepId = new StringObjectId(id);
        LineageRepository repo = getLineageRepository();
        if (repo != null) {
            Map<String, Object> attrs = repo.getStepAttributesCache(stepId);
            json.writeObjectField(JSON_PROPERTY_ATTRIBUTES, attrs);
            List<Map<String, Object>> fields = repo.getStepFieldsCache(stepId);
            json.writeObjectField(JSON_PROPERTY_FIELDS, fields);
        }
    }
}
Also used : StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) LineageRepository(org.pentaho.metaverse.impl.model.kettle.LineageRepository) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) StringObjectId(org.pentaho.di.repository.StringObjectId) Map(java.util.Map)

Example 3 with LineageRepository

use of org.pentaho.metaverse.impl.model.kettle.LineageRepository in project pentaho-metaverse by pentaho.

the class TransMetaJsonSerializer method serializeSteps.

@Override
protected void serializeSteps(TransMeta meta, JsonGenerator json) throws IOException {
    json.writeArrayFieldStart(JSON_PROPERTY_STEPS);
    for (StepMeta stepMeta : meta.getSteps()) {
        BaseStepMeta step = getBaseStepMetaFromStepMeta(stepMeta);
        LineageRepository repo = getLineageRepository();
        String id = stepMeta.getObjectId() == null ? stepMeta.getName() : stepMeta.getObjectId().toString();
        ObjectId stepId = new StringObjectId(id);
        try {
            step.saveRep(repo, null, null, stepId);
        } catch (KettleException e) {
            LOGGER.warn(Messages.getString("INFO.Serialization.Trans.Step", stepMeta.getName()), e);
        }
        json.writeObject(step);
    }
    json.writeEndArray();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) LineageRepository(org.pentaho.metaverse.impl.model.kettle.LineageRepository) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) BaseStepMeta(org.pentaho.di.trans.step.BaseStepMeta) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 4 with LineageRepository

use of org.pentaho.metaverse.impl.model.kettle.LineageRepository in project pentaho-metaverse by pentaho.

the class TransMetaJsonSerializerTest method setUp.

@Before
public void setUp() throws Exception {
    serializer = new TransMetaJsonSerializer(TransMeta.class);
    serializer.setLineageRepository(new LineageRepository());
    when(transMeta.getName()).thenReturn("TestTransName");
    when(transMeta.getDescription()).thenReturn("Trans description");
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) LineageRepository(org.pentaho.metaverse.impl.model.kettle.LineageRepository) Before(org.junit.Before)

Example 5 with LineageRepository

use of org.pentaho.metaverse.impl.model.kettle.LineageRepository in project pentaho-metaverse by pentaho.

the class JobMetaJsonSerializer method serializeSteps.

@Override
protected void serializeSteps(JobMeta meta, JsonGenerator json) throws IOException {
    json.writeArrayFieldStart(JSON_PROPERTY_STEPS);
    int numberOfEntries = meta.nrJobEntries();
    for (int i = 0; i < numberOfEntries; i++) {
        JobEntryCopy jobEntry = meta.getJobEntry(i);
        LineageRepository repo = getLineageRepository();
        ObjectId jobId = meta.getObjectId() == null ? new StringObjectId(meta.getName()) : meta.getObjectId();
        ObjectId entryId = jobEntry.getObjectId() == null ? new StringObjectId(jobEntry.getName()) : jobEntry.getObjectId();
        JobEntryInterface jobEntryInterface = jobEntry.getEntry();
        JobEntryBase jobEntryBase = getJobEntryBase(jobEntryInterface);
        Job job = new Job(null, meta);
        jobEntryBase.setParentJob(job);
        jobEntryInterface.setObjectId(entryId);
        try {
            jobEntryInterface.saveRep(repo, null, jobId);
        } catch (KettleException e) {
            LOGGER.warn(Messages.getString("INFO.Serialization.Trans.Step", jobEntry.getName()), e);
        }
        json.writeObject(jobEntryBase);
    }
    json.writeEndArray();
}
Also used : JobEntryBase(org.pentaho.di.job.entry.JobEntryBase) KettleException(org.pentaho.di.core.exception.KettleException) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) LineageRepository(org.pentaho.metaverse.impl.model.kettle.LineageRepository) Job(org.pentaho.di.job.Job) StringObjectId(org.pentaho.di.repository.StringObjectId)

Aggregations

LineageRepository (org.pentaho.metaverse.impl.model.kettle.LineageRepository)7 ObjectId (org.pentaho.di.repository.ObjectId)4 StringObjectId (org.pentaho.di.repository.StringObjectId)4 Before (org.junit.Before)3 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)3 StepMeta (org.pentaho.di.trans.step.StepMeta)3 Map (java.util.Map)2 KettleException (org.pentaho.di.core.exception.KettleException)2 TransMeta (org.pentaho.di.trans.TransMeta)2 DummyTransMeta (org.pentaho.di.trans.steps.dummytrans.DummyTransMeta)2 Job (org.pentaho.di.job.Job)1 JobEntryBase (org.pentaho.di.job.entry.JobEntryBase)1 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)1 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)1 TableOutputMeta (org.pentaho.di.trans.steps.tableoutput.TableOutputMeta)1