use of org.pentaho.di.repository.Repository in project pentaho-metaverse by pentaho.
the class TransExecutorStepAnalyzer method customAnalyze.
@Override
protected void customAnalyze(TransExecutorMeta meta, IMetaverseNode node) throws MetaverseAnalyzerException {
String transPath = meta.getFileName();
TransMeta subTransMeta = null;
Repository repo = parentTransMeta.getRepository();
switch(meta.getSpecificationMethod()) {
case FILENAME:
transPath = parentTransMeta.environmentSubstitute(meta.getFileName());
try {
String normalized = KettleAnalyzerUtil.normalizeFilePath(transPath);
subTransMeta = getSubTransMeta(normalized);
transPath = normalized;
} catch (Exception e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found - " + transPath, e);
}
break;
case REPOSITORY_BY_NAME:
if (repo != null) {
String dir = parentTransMeta.environmentSubstitute(meta.getDirectoryPath());
String file = parentTransMeta.environmentSubstitute(meta.getTransName());
try {
RepositoryDirectoryInterface rdi = repo.findDirectory(dir);
subTransMeta = repo.loadTransformation(file, rdi, null, true, null);
transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found in repository - " + file, e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
case REPOSITORY_BY_REFERENCE:
if (repo != null) {
try {
subTransMeta = repo.loadTransformation(meta.getTransObjectId(), null);
transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found by reference - " + meta.getTransObjectId(), e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
}
// analyze the sub trans?
IComponentDescriptor ds = new MetaverseComponentDescriptor(subTransMeta.getName(), DictionaryConst.NODE_TYPE_TRANS, descriptor.getNamespace().getParentNamespace());
IMetaverseNode transformationNode = createNodeFromDescriptor(ds);
transformationNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, ds.getNamespaceId());
transformationNode.setProperty(DictionaryConst.PROPERTY_PATH, transPath);
transformationNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
metaverseBuilder.addLink(node, DictionaryConst.LINK_EXECUTES, transformationNode);
connectToSubTransInputFields(meta, subTransMeta, transformationNode, descriptor);
connectToSubTransOutputFields(meta, subTransMeta, transformationNode, descriptor);
node.setProperty(TRANSFORMATION_TO_EXECUTE, transPath);
if (StringUtils.isNotEmpty(meta.getExecutionResultTargetStep())) {
node.setProperty(EXECUTION_RESULTS_TARGET, meta.getExecutionResultTargetStep());
}
if (StringUtils.isNotEmpty(meta.getOutputRowsSourceStep())) {
node.setProperty(OUTPUT_ROWS_TARGET, meta.getOutputRowsSourceStep());
}
if (StringUtils.isNotEmpty(meta.getResultFilesTargetStep())) {
node.setProperty(RESULT_FILES_TARGET, meta.getResultFilesTargetStep());
}
}
use of org.pentaho.di.repository.Repository in project pentaho-metaverse by pentaho.
the class DIRepositoryLocator method getRootUri.
@Override
public URI getRootUri() {
// Looking for the web service location of the data integration
// server repository. Due to the inaccessible nature of the
// method calls, we use reflection to drill to the location URI.
Repository repo = null;
URI uri = null;
try {
repo = getRepository();
} catch (Exception e) {
LOG.warn(Messages.getString("WARNING.RepositoryNotFoundNoRootURI"));
}
if (repo != null) {
Object repositoryMeta = repo.getRepositoryMeta();
Object repositoryLocation = null;
String location = null;
Class[] parameters = {};
if (repositoryMeta != null) {
Class repositoryMetaClass = repositoryMeta.getClass();
try {
Method m = repositoryMetaClass.getMethod("getRepositoryLocation", parameters);
repositoryLocation = m.invoke(repositoryMeta);
} catch (Exception e) {
LOG.warn(Messages.getString("WARNING.RepositoryUnknownMethodNoRootURI", repo.getClass().getName()));
}
}
if (repositoryLocation != null) {
Class repositoryLocationClass = repositoryLocation.getClass();
try {
Method m = repositoryLocationClass.getMethod("getUrl", parameters);
location = (String) m.invoke(repositoryLocation);
} catch (Exception e) {
LOG.warn(Messages.getString("WARNING.ExceptionFindingLocationNoRootURI"));
}
}
if (location != null) {
uri = URI.create(location);
}
/*
// Here's what we could do if these packages were available to our classloader ...
// but they are not.
if ( repository instanceof PurRepository ) {
PurRepository purRepository = ( PurRepository ) repository;
PurRepositoryMeta meta = ( PurRepositoryMeta ) purRepository.getRepositoryMeta();
uri = URI.create( meta.getRepositoryLocation().getUrl() );
}
*/
}
return uri;
}
use of org.pentaho.di.repository.Repository in project pentaho-metaverse by pentaho.
the class JobJobEntryAnalyzer method customAnalyze.
@Override
protected void customAnalyze(JobEntryJob entry, IMetaverseNode rootNode) throws MetaverseAnalyzerException {
JobMeta subJobMeta = null;
JobMeta parentJobMeta = entry.getParentJob().getJobMeta();
// For some reason the JobMeta's variables have been reset by now, so re-activate them
parentJobMeta.activateParameters();
Repository repo = parentJobMeta.getRepository();
String jobPath = null;
switch(entry.getSpecificationMethod()) {
case FILENAME:
try {
jobPath = parentJobMeta.environmentSubstitute(entry.getFilename());
String normalized = KettleAnalyzerUtil.normalizeFilePath(jobPath);
subJobMeta = getSubJobMeta(normalized);
jobPath = normalized;
} catch (Exception e) {
throw new MetaverseAnalyzerException("Sub job can not be found - " + jobPath, e);
}
break;
case REPOSITORY_BY_NAME:
if (repo != null) {
String dir = parentJobMeta.environmentSubstitute(entry.getDirectory());
String file = parentJobMeta.environmentSubstitute(entry.getJobName());
try {
RepositoryDirectoryInterface rdi = repo.findDirectory(dir);
subJobMeta = repo.loadJob(file, rdi, null, null);
String filename = subJobMeta.getFilename() == null ? subJobMeta.toString() : subJobMeta.getFilename();
jobPath = filename + "." + subJobMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub job can not be found in repository - " + file, e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the job");
}
break;
case REPOSITORY_BY_REFERENCE:
if (repo != null) {
try {
subJobMeta = repo.loadJob(entry.getJobObjectId(), null);
String filename = subJobMeta.getFilename() == null ? subJobMeta.toString() : subJobMeta.getFilename();
jobPath = filename + "." + subJobMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub job can not be found by reference - " + entry.getJobObjectId(), e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the job");
}
break;
}
IComponentDescriptor ds = new MetaverseComponentDescriptor(subJobMeta.getName(), DictionaryConst.NODE_TYPE_JOB, descriptor.getNamespace().getParentNamespace());
IMetaverseNode jobNode = createNodeFromDescriptor(ds);
jobNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, ds.getNamespaceId());
jobNode.setProperty(DictionaryConst.PROPERTY_PATH, jobPath);
jobNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
metaverseBuilder.addLink(rootNode, DictionaryConst.LINK_EXECUTES, jobNode);
}
use of org.pentaho.di.repository.Repository in project pentaho-metaverse by pentaho.
the class TransJobEntryAnalyzer method customAnalyze.
@Override
protected void customAnalyze(JobEntryTrans entry, IMetaverseNode rootNode) throws MetaverseAnalyzerException {
TransMeta subTransMeta = null;
JobMeta parentJobMeta = entry.getParentJob().getJobMeta();
// For some reason the JobMeta's variables have been reset by now, so re-activate them
parentJobMeta.activateParameters();
Repository repo = parentJobMeta.getRepository();
String transPath = null;
switch(entry.getSpecificationMethod()) {
case FILENAME:
try {
transPath = parentJobMeta.environmentSubstitute(entry.getFilename());
String normalized = KettleAnalyzerUtil.normalizeFilePath(transPath);
subTransMeta = getSubTransMeta(normalized);
transPath = normalized;
} catch (Exception e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found - " + transPath, e);
}
break;
case REPOSITORY_BY_NAME:
if (repo != null) {
String dir = parentJobMeta.environmentSubstitute(entry.getDirectory());
String file = parentJobMeta.environmentSubstitute(entry.getTransname());
try {
RepositoryDirectoryInterface rdi = repo.findDirectory(dir);
subTransMeta = repo.loadTransformation(file, rdi, null, true, null);
transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found in repository - " + file, e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
case REPOSITORY_BY_REFERENCE:
if (repo != null) {
try {
subTransMeta = repo.loadTransformation(entry.getTransObjectId(), null);
transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
} catch (KettleException e) {
throw new MetaverseAnalyzerException("Sub transformation can not be found by reference - " + entry.getTransObjectId(), e);
}
} else {
throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
}
break;
}
IComponentDescriptor ds = new MetaverseComponentDescriptor(subTransMeta.getName(), DictionaryConst.NODE_TYPE_TRANS, descriptor.getNamespace().getParentNamespace());
IMetaverseNode transformationNode = createNodeFromDescriptor(ds);
transformationNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, ds.getNamespaceId());
transformationNode.setProperty(DictionaryConst.PROPERTY_PATH, transPath);
transformationNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
metaverseBuilder.addLink(rootNode, DictionaryConst.LINK_EXECUTES, transformationNode);
}
use of org.pentaho.di.repository.Repository in project pentaho-metaverse by pentaho.
the class JobJobEntryAnalyzerTest method testAnalyzeWithRepoByNameThrowsException.
@Test(expected = MetaverseAnalyzerException.class)
public void testAnalyzeWithRepoByNameThrowsException() throws Exception {
Repository repo = mock(Repository.class);
when(mockParentJobMeta.getRepository()).thenReturn(repo);
when(jobEntryJob.getSpecificationMethod()).thenReturn(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
// Test exception
when(repo.findDirectory(anyString())).thenThrow(new KettleException());
spyAnalyzer.analyze(descriptor, jobEntryJob);
}
Aggregations