Search in sources :

Example 1 with ObjectRevision

use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.

the class SpoonTest method prepareSetShellTextTests.

private static Shell prepareSetShellTextTests(Spoon spoon, AbstractMeta abstractMeta, boolean versionEnabled, boolean isTransformation, boolean repIsNull, boolean revIsNull, boolean hasChanged, boolean nameIsNull, boolean filenameIsNull, boolean tabNameIsNull) {
    Shell mockShell = mock(Shell.class);
    ObjectRevision mockObjectRevision = revIsNull ? null : mock(ObjectRevision.class);
    RepositoryDirectory mockRepDirectory = mock(RepositoryDirectory.class);
    Repository mockRepository = repIsNull ? null : mock(Repository.class);
    RepositorySecurityProvider mockRepSecurityProvider = mock(RepositorySecurityProvider.class);
    SpoonDelegates mockDelegate = mock(SpoonDelegates.class);
    SpoonTabsDelegate mockDelegateTabs = mock(SpoonTabsDelegate.class);
    spoon.rep = mockRepository;
    spoon.delegates = mockDelegate;
    mockDelegate.tabs = mockDelegateTabs;
    doCallRealMethod().when(spoon).openSpoon();
    doCallRealMethod().when(spoon).setShellText();
    doReturn(mockShell).when(spoon).getShell();
    if (!tabNameIsNull) {
        doReturn("tabName").when(spoon).getActiveTabText();
    }
    doReturn(false).when(mockShell).isDisposed();
    setTransJobValues(abstractMeta, spoon, mockObjectRevision, mockRepDirectory, isTransformation, hasChanged, nameIsNull, filenameIsNull);
    if (!revIsNull) {
        doReturn("1.0").when(mockObjectRevision).getName();
    }
    doReturn("/admin").when(mockRepDirectory).getPath();
    Mockito.doReturn(null).when(abstractMeta).getVersioningEnabled();
    if (!repIsNull) {
        doReturn(mockRepSecurityProvider).when(mockRepository).getSecurityProvider();
        doReturn(versionEnabled).when(mockRepSecurityProvider).isVersioningEnabled(anyString());
    }
    doReturn("RepositoryName").when(spoon).getRepositoryName();
    doReturn(new ArrayList<TabMapEntry>()).when(mockDelegateTabs).getTabs();
    try {
        spoon.openSpoon();
    } catch (NullPointerException e) {
    // ignore work is done
    }
    spoon.setShellText();
    return mockShell;
}
Also used : ObjectRevision(org.pentaho.di.repository.ObjectRevision) RepositorySecurityProvider(org.pentaho.di.repository.RepositorySecurityProvider) Shell(org.eclipse.swt.widgets.Shell) Repository(org.pentaho.di.repository.Repository) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) SpoonDelegates(org.pentaho.di.ui.spoon.delegates.SpoonDelegates) SpoonTabsDelegate(org.pentaho.di.ui.spoon.delegates.SpoonTabsDelegate)

Example 2 with ObjectRevision

use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.

the class SpoonTabsDelegate method makeTabName.

public String makeTabName(EngineMetaInterface transMeta, boolean showLocation) {
    if (Utils.isEmpty(transMeta.getName()) && Utils.isEmpty(transMeta.getFilename())) {
        return Spoon.STRING_TRANS_NO_NAME;
    }
    if (Utils.isEmpty(transMeta.getName()) || spoon.delegates.trans.isDefaultTransformationName(transMeta.getName())) {
        transMeta.nameFromFilename();
    }
    String name = "";
    if (showLocation) {
        if (!Utils.isEmpty(transMeta.getFilename())) {
            // Regular file...
            // 
            name += transMeta.getFilename() + " : ";
        } else {
            // Repository object...
            // 
            name += transMeta.getRepositoryDirectory().getPath() + " : ";
        }
    }
    name += transMeta.getName();
    if (showLocation) {
        ObjectRevision version = transMeta.getObjectRevision();
        if (version != null) {
            name += " : r" + version.getName();
        }
    }
    return name;
}
Also used : ObjectRevision(org.pentaho.di.repository.ObjectRevision)

Example 3 with ObjectRevision

use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.

the class UIEEJobTest method testRevisions.

@Test
public void testRevisions() throws Exception {
    final String revisionName = "revisionName";
    final String commitMessage = "commitMessage";
    ObjectRevision mockObjectRevision = mock(ObjectRevision.class);
    when(mockObjectRevision.getName()).thenReturn(revisionName);
    List<ObjectRevision> mockRevisions = Arrays.asList(new ObjectRevision[] { mockObjectRevision });
    when(mockRevisionService.getRevisions(any(ObjectId.class))).thenReturn(mockRevisions);
    uiJob.refreshRevisions();
    verify(mockRevisionService, times(1)).getRevisions(mockObjectId);
    UIRepositoryObjectRevisions revisions = uiJob.getRevisions();
    assertEquals(1, revisions.size());
    assertEquals("revisionName", revisions.get(0).getName());
    verify(mockRevisionService, times(1)).getRevisions(mockObjectId);
    uiJob.restoreRevision(revisions.get(0), commitMessage);
    verify(mockRevisionService).restoreJob(mockObjectId, revisionName, commitMessage);
    verify(mockParent, times(1)).fireCollectionChanged();
}
Also used : ObjectRevision(org.pentaho.di.repository.ObjectRevision) ObjectId(org.pentaho.di.repository.ObjectId) Test(org.junit.Test)

Example 4 with ObjectRevision

use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.

the class PurRepositoryRevisionBrowserDialog method getData.

/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
    wFields.clearAll(false);
    for (ObjectRevision revision : revisions) {
        wFields.add(revision.getName(), revision.getComment(), XMLHandler.date2string(revision.getCreationDate()), revision.getLogin());
    }
    wFields.removeEmptyRows();
    wFields.setRowNums();
    wFields.optWidth(true);
}
Also used : ObjectRevision(org.pentaho.di.repository.ObjectRevision)

Example 5 with ObjectRevision

use of org.pentaho.di.repository.ObjectRevision in project pentaho-kettle by pentaho.

the class UIEEJob 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)

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