Search in sources :

Example 36 with ResourceReference

use of org.pentaho.di.resource.ResourceReference in project pentaho-metaverse by pentaho.

the class JobEntryBaseJsonSerializerTest method testWriteExternalResources.

@Test
public void testWriteExternalResources() throws Exception {
    Job parentJob = mock(Job.class);
    JobMeta jobMeta = mock(JobMeta.class);
    List<ResourceReference> dependencies = new ArrayList<ResourceReference>();
    ResourceReference resRef = mock(ResourceReference.class);
    dependencies.add(resRef);
    List<ResourceEntry> resources = new ArrayList<ResourceEntry>();
    ResourceEntry resEntry = mock(ResourceEntry.class);
    resources.add(resEntry);
    when(resRef.getEntries()).thenReturn(resources);
    when(resEntry.getResource()).thenReturn("path/to/my/resource");
    when(resEntry.getResourcetype()).thenReturn(ResourceEntry.ResourceType.FILE);
    when(meta.getParentJob()).thenReturn(parentJob);
    when(parentJob.getJobMeta()).thenReturn(jobMeta);
    when(meta.getResourceDependencies(jobMeta)).thenReturn(dependencies);
    serializer.writeExternalResources(meta, json, provider);
    verify(json).writeArrayFieldStart(JobEntryBaseJsonSerializer.JSON_PROPERTY_EXTERNAL_RESOURCES);
    verify(json).writeObject(any(IExternalResourceInfo.class));
    verify(json).writeEndArray();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) ResourceEntry(org.pentaho.di.resource.ResourceEntry) ArrayList(java.util.ArrayList) ResourceReference(org.pentaho.di.resource.ResourceReference) Job(org.pentaho.di.job.Job) Test(org.junit.Test)

Example 37 with ResourceReference

use of org.pentaho.di.resource.ResourceReference in project pentaho-metaverse by pentaho.

the class AbstractJobEntryJsonSerializer method writeExternalResources.

protected void writeExternalResources(T meta, JsonGenerator json, SerializerProvider serializerProvider) throws IOException, JsonGenerationException {
    json.writeArrayFieldStart(JSON_PROPERTY_EXTERNAL_RESOURCES);
    JobMeta jobMeta = new JobMeta();
    if (meta.getParentJob() != null && meta.getParentJob().getJobMeta() != null) {
        jobMeta = meta.getParentJob().getJobMeta();
    }
    List<ResourceReference> dependencies = meta.getResourceDependencies(jobMeta);
    for (ResourceReference dependency : dependencies) {
        for (ResourceEntry resourceEntry : dependency.getEntries()) {
            IExternalResourceInfo resourceInfo = ExternalResourceInfoFactory.createResource(resourceEntry);
            json.writeObject(resourceInfo);
        }
    }
    json.writeEndArray();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) IExternalResourceInfo(org.pentaho.metaverse.api.model.IExternalResourceInfo) ResourceEntry(org.pentaho.di.resource.ResourceEntry) ResourceReference(org.pentaho.di.resource.ResourceReference)

Example 38 with ResourceReference

use of org.pentaho.di.resource.ResourceReference in project pentaho-kettle by pentaho.

the class BaseFileInputFiles method getResourceDependencies.

public List<ResourceReference> getResourceDependencies(TransMeta transMeta, StepMeta stepInfo) {
    List<ResourceReference> references = new ArrayList<ResourceReference>(5);
    ResourceReference reference = new ResourceReference(stepInfo);
    references.add(reference);
    String[] textFiles = FileInputList.createFilePathList(transMeta, fileName, fileMask, excludeFileMask, fileRequired, includeSubFolderBoolean());
    if (textFiles != null) {
        for (int i = 0; i < textFiles.length; i++) {
            reference.getEntries().add(new ResourceEntry(textFiles[i], ResourceType.FILE));
        }
    }
    return references;
}
Also used : ResourceEntry(org.pentaho.di.resource.ResourceEntry) ArrayList(java.util.ArrayList) ResourceReference(org.pentaho.di.resource.ResourceReference)

Example 39 with ResourceReference

use of org.pentaho.di.resource.ResourceReference in project pentaho-kettle by pentaho.

the class FixedInputMeta method getResourceDependencies.

@Override
public List<ResourceReference> getResourceDependencies(TransMeta transMeta, StepMeta stepInfo) {
    List<ResourceReference> references = new ArrayList<ResourceReference>(5);
    ResourceReference reference = new ResourceReference(stepInfo);
    references.add(reference);
    if (!Utils.isEmpty(filename)) {
        // Add the filename to the references, including a reference to this step meta data.
        // 
        reference.getEntries().add(new ResourceEntry(transMeta.environmentSubstitute(filename), ResourceType.FILE));
    }
    return references;
}
Also used : ResourceEntry(org.pentaho.di.resource.ResourceEntry) ArrayList(java.util.ArrayList) ResourceReference(org.pentaho.di.resource.ResourceReference)

Example 40 with ResourceReference

use of org.pentaho.di.resource.ResourceReference in project pentaho-kettle by pentaho.

the class JobExecutorMeta method getResourceDependencies.

@Override
public List<ResourceReference> getResourceDependencies(TransMeta transMeta, StepMeta stepInfo) {
    List<ResourceReference> references = new ArrayList<ResourceReference>(5);
    String realFilename = transMeta.environmentSubstitute(fileName);
    String realTransname = transMeta.environmentSubstitute(jobName);
    ResourceReference reference = new ResourceReference(stepInfo);
    references.add(reference);
    if (!Utils.isEmpty(realFilename)) {
        // Add the filename to the references, including a reference to this step
        // meta data.
        // 
        reference.getEntries().add(new ResourceEntry(realFilename, ResourceType.ACTIONFILE));
    } else if (!Utils.isEmpty(realTransname)) {
        // Add the filename to the references, including a reference to this step
        // meta data.
        // 
        reference.getEntries().add(new ResourceEntry(realTransname, ResourceType.ACTIONFILE));
        references.add(reference);
    }
    return references;
}
Also used : ResourceEntry(org.pentaho.di.resource.ResourceEntry) ArrayList(java.util.ArrayList) ResourceReference(org.pentaho.di.resource.ResourceReference) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Aggregations

ResourceReference (org.pentaho.di.resource.ResourceReference)66 ResourceEntry (org.pentaho.di.resource.ResourceEntry)61 ArrayList (java.util.ArrayList)18 Test (org.junit.Test)6 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 JobMeta (org.pentaho.di.job.JobMeta)4 TransMeta (org.pentaho.di.trans.TransMeta)4 StepMeta (org.pentaho.di.trans.step.StepMeta)4 ResultFile (org.pentaho.di.core.ResultFile)2 Job (org.pentaho.di.job.Job)2 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)2 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)2 IExecutionData (org.pentaho.metaverse.api.model.IExecutionData)2 IExecutionProfile (org.pentaho.metaverse.api.model.IExecutionProfile)2 IExternalResourceInfo (org.pentaho.metaverse.api.model.IExternalResourceInfo)2 FileName (org.apache.commons.vfs2.FileName)1 FileObject (org.apache.commons.vfs2.FileObject)1 Result (org.pentaho.di.core.Result)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)1