use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class UIEETransformation method getRevisions.
public UIRepositoryObjectRevisions getRevisions() throws KettleException {
if (revisions != null) {
return revisions;
}
revisions = new UIRepositoryObjectRevisions();
List<ObjectRevision> or = revisionService.getRevisions(getObjectId());
for (ObjectRevision rev : or) {
revisions.add(new UIRepositoryObjectRevision(rev));
}
return revisions;
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class UnifiedRepositoryRevisionService method getRevisions.
@Override
public List<ObjectRevision> getRevisions(ObjectId fileId) throws KettleException {
String absPath = null;
try {
List<ObjectRevision> versions = new ArrayList<ObjectRevision>();
List<VersionSummary> versionSummaries = unifiedRepository.getVersionSummaries(fileId.getId());
for (VersionSummary versionSummary : versionSummaries) {
versions.add(new PurObjectRevision(versionSummary.getId(), versionSummary.getAuthor(), versionSummary.getDate(), versionSummary.getMessage()));
}
return versions;
} catch (Exception e) {
throw new KettleException("Could not retrieve version history of object with path [" + absPath + "]", e);
}
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class PurRepository method loadTransformation.
@Override
public TransMeta loadTransformation(final String transName, final RepositoryDirectoryInterface parentDir, final ProgressMonitorListener monitor, final boolean setInternalVariables, final String versionId) throws KettleException {
String absPath = null;
try {
// by the user
if (StringUtils.isBlank(transName)) {
throw new KettleFileException(BaseMessages.getString(PKG, "PurRepository.ERROR_0007_TRANSFORMATION_NAME_MISSING"));
}
try {
absPath = getPath(transName, parentDir, RepositoryObjectType.TRANSFORMATION);
} catch (Exception e) {
// ignore and handle null value below
}
// variable that is not available at runtime
if (StringUtils.isBlank(absPath)) {
// Couldn't resolve path, throw an exception
throw new KettleFileException(BaseMessages.getString(PKG, "PurRepository.ERROR_0008_TRANSFORMATION_PATH_INVALID", transName));
}
RepositoryFile file = pur.getFile(absPath);
if (versionId != null) {
// need to go back to server to get versioned info
file = pur.getFileAtVersion(file.getId(), versionId);
}
// valid file
if (file == null) {
throw new KettleException(BaseMessages.getString(PKG, "PurRepository.ERROR_0008_TRANSFORMATION_PATH_INVALID", absPath));
}
NodeRepositoryFileData data = null;
ObjectRevision revision = null;
// Additional obfuscation through obscurity
data = pur.getDataAtVersionForRead(file.getId(), versionId, NodeRepositoryFileData.class);
revision = getObjectRevision(new StringObjectId(file.getId().toString()), versionId);
TransMeta transMeta = buildTransMeta(file, parentDir, data, revision);
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.TransformationMetaLoaded.id, transMeta);
return transMeta;
} catch (final KettleException ke) {
// if we have a KettleException, simply re-throw it
throw ke;
} catch (Exception e) {
throw new KettleException("Unable to load transformation from path [" + absPath + "]", e);
}
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class PurRepository method loadJob.
@Override
public JobMeta loadJob(String jobname, RepositoryDirectoryInterface parentDir, ProgressMonitorListener monitor, String versionId) throws KettleException {
String absPath = null;
try {
absPath = getPath(jobname, parentDir, RepositoryObjectType.JOB);
if (absPath == null) {
// Couldn't resolve path, throw an exception
throw new KettleFileException(BaseMessages.getString(PKG, "PurRepository.ERROR_0003_JOB_NOT_FOUND", jobname));
}
RepositoryFile file = pur.getFile(absPath);
if (versionId != null) {
// need to go back to server to get versioned info
file = pur.getFileAtVersion(file.getId(), versionId);
}
NodeRepositoryFileData data = null;
ObjectRevision revision = null;
data = pur.getDataAtVersionForRead(file.getId(), versionId, NodeRepositoryFileData.class);
revision = getObjectRevision(new StringObjectId(file.getId().toString()), versionId);
JobMeta jobMeta = buildJobMeta(file, parentDir, data, revision);
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.JobMetaLoaded.id, jobMeta);
return jobMeta;
} catch (Exception e) {
throw new KettleException("Unable to load job from path [" + absPath + "]", e);
}
}
use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.
the class TransMetaTest method testCompare.
@Test
public void testCompare() throws Exception {
TransMeta transMeta = new TransMeta("aFile", "aName");
TransMeta transMeta2 = new TransMeta("aFile", "aName");
assertEquals(0, transMeta.compare(transMeta, transMeta2));
transMeta2.setVariable("myVariable", "myValue");
assertEquals(0, transMeta.compare(transMeta, transMeta2));
transMeta2.setFilename(null);
assertEquals(1, transMeta.compare(transMeta, transMeta2));
assertEquals(-1, transMeta.compare(transMeta2, transMeta));
transMeta2.setFilename("aFile");
transMeta2.setName(null);
assertEquals(1, transMeta.compare(transMeta, transMeta2));
assertEquals(-1, transMeta.compare(transMeta2, transMeta));
transMeta2.setFilename("aFile2");
transMeta2.setName("aName");
assertEquals(-1, transMeta.compare(transMeta, transMeta2));
assertEquals(1, transMeta.compare(transMeta2, transMeta));
transMeta2.setFilename("aFile");
transMeta2.setName("aName2");
assertEquals(-1, transMeta.compare(transMeta, transMeta2));
assertEquals(1, transMeta.compare(transMeta2, transMeta));
transMeta.setFilename(null);
transMeta2.setFilename(null);
transMeta2.setName("aName");
assertEquals(0, transMeta.compare(transMeta, transMeta2));
RepositoryDirectoryInterface path1 = mock(RepositoryDirectoryInterface.class);
transMeta.setRepositoryDirectory(path1);
when(path1.getPath()).thenReturn("aPath2");
RepositoryDirectoryInterface path2 = mock(RepositoryDirectoryInterface.class);
when(path2.getPath()).thenReturn("aPath");
transMeta2.setRepositoryDirectory(path2);
assertEquals(1, transMeta.compare(transMeta, transMeta2));
assertEquals(-1, transMeta.compare(transMeta2, transMeta));
when(path1.getPath()).thenReturn("aPath");
assertEquals(0, transMeta.compare(transMeta, transMeta2));
ObjectRevision revision2 = mock(ObjectRevision.class);
transMeta2.setObjectRevision(revision2);
assertEquals(-1, transMeta.compare(transMeta, transMeta2));
assertEquals(1, transMeta.compare(transMeta2, transMeta));
ObjectRevision revision1 = mock(ObjectRevision.class);
transMeta.setObjectRevision(revision1);
when(revision1.getName()).thenReturn("aRevision");
when(revision2.getName()).thenReturn("aRevision");
assertEquals(0, transMeta.compare(transMeta, transMeta2));
when(revision2.getName()).thenReturn("aRevision2");
assertEquals(-1, transMeta.compare(transMeta, transMeta2));
assertEquals(1, transMeta.compare(transMeta2, transMeta));
}
Aggregations