Search in sources :

Example 6 with ObjectRevision

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;
}
Also used : ObjectRevision(org.pentaho.di.repository.ObjectRevision)

Example 7 with ObjectRevision

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);
    }
}
Also used : ObjectRevision(org.pentaho.di.repository.ObjectRevision) KettleException(org.pentaho.di.core.exception.KettleException) ArrayList(java.util.ArrayList) VersionSummary(org.pentaho.platform.api.repository2.unified.VersionSummary) KettleException(org.pentaho.di.core.exception.KettleException)

Example 8 with ObjectRevision

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);
    }
}
Also used : ObjectRevision(org.pentaho.di.repository.ObjectRevision) KettleException(org.pentaho.di.core.exception.KettleException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) TransMeta(org.pentaho.di.trans.TransMeta) EETransMeta(org.pentaho.di.repository.pur.model.EETransMeta) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) StringObjectId(org.pentaho.di.repository.StringObjectId) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) UnifiedRepositoryCreateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException) UnifiedRepositoryUpdateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) KettleException(org.pentaho.di.core.exception.KettleException) IdNotFoundException(org.pentaho.di.core.exception.IdNotFoundException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Example 9 with ObjectRevision

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);
    }
}
Also used : ObjectRevision(org.pentaho.di.repository.ObjectRevision) KettleException(org.pentaho.di.core.exception.KettleException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) EEJobMeta(org.pentaho.di.repository.pur.model.EEJobMeta) JobMeta(org.pentaho.di.job.JobMeta) NodeRepositoryFileData(org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) StringObjectId(org.pentaho.di.repository.StringObjectId) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) UnifiedRepositoryCreateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException) UnifiedRepositoryUpdateFileException(org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) KettleException(org.pentaho.di.core.exception.KettleException) IdNotFoundException(org.pentaho.di.core.exception.IdNotFoundException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Example 10 with ObjectRevision

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));
}
Also used : ObjectRevision(org.pentaho.di.repository.ObjectRevision) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Test(org.junit.Test)

Aggregations

ObjectRevision (org.pentaho.di.repository.ObjectRevision)15 Test (org.junit.Test)6 KettleException (org.pentaho.di.core.exception.KettleException)4 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)4 StringObjectId (org.pentaho.di.repository.StringObjectId)3 ArrayList (java.util.ArrayList)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)2 KettleFileException (org.pentaho.di.core.exception.KettleFileException)2 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)2 JobMeta (org.pentaho.di.job.JobMeta)2 ObjectId (org.pentaho.di.repository.ObjectId)2 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)2 TransMeta (org.pentaho.di.trans.TransMeta)2 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)2 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)2 UnifiedRepositoryCreateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException)2 UnifiedRepositoryUpdateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException)2 NodeRepositoryFileData (org.pentaho.platform.api.repository2.unified.data.node.NodeRepositoryFileData)2 File (java.io.File)1