Search in sources :

Example 51 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class RepositoryTestBase method testRenameAndUndelete.

@Ignore
@Test
public void testRenameAndUndelete() throws Exception {
    RepositoryDirectoryInterface rootDir = initRepo();
    JobMeta jobMeta = createJobMeta(EXP_JOB_NAME);
    RepositoryDirectoryInterface jobsDir = rootDir.findDirectory(DIR_JOBS);
    repository.save(jobMeta, VERSION_COMMENT_V1, null);
    deleteStack.push(jobMeta);
    repository.deleteJob(jobMeta.getObjectId());
    assertFalse(repository.exists(EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB));
    RepositoryObject robj = new RepositoryObject(jobMeta.getObjectId(), jobMeta.getName(), jobMeta.getRepositoryDirectory(), null, null, jobMeta.getRepositoryElementType(), null, false);
    repository.undeleteObject(robj);
    assertTrue(repository.exists(EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB));
    repository.renameJob(jobMeta.getObjectId(), jobsDir, EXP_JOB_NAME_NEW);
    assertFalse(repository.exists(EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB));
    assertTrue(repository.exists(EXP_JOB_NAME_NEW, jobsDir, RepositoryObjectType.JOB));
    TransMeta transMeta = createTransMeta(EXP_DBMETA_NAME);
    RepositoryDirectoryInterface transDir = rootDir.findDirectory(DIR_TRANSFORMATIONS);
    repository.save(transMeta, VERSION_COMMENT_V1, null);
    deleteStack.push(transMeta);
    repository.renameTransformation(transMeta.getObjectId(), transDir, EXP_TRANS_NAME_NEW);
    assertFalse(repository.exists(EXP_TRANS_NAME.concat(EXP_DBMETA_NAME), transDir, RepositoryObjectType.TRANSFORMATION));
    assertTrue(repository.exists(EXP_TRANS_NAME_NEW, transDir, RepositoryObjectType.TRANSFORMATION));
    DatabaseMeta dbMeta = createDatabaseMeta(EXP_DBMETA2_NAME);
    repository.save(dbMeta, VERSION_COMMENT_V1, null);
    deleteStack.push(dbMeta);
    dbMeta.setName(EXP_DBMETA_NAME_NEW);
    repository.save(dbMeta, VERSION_COMMENT_V2, null);
    assertFalse(repository.exists(EXP_DBMETA2_NAME, null, RepositoryObjectType.DATABASE));
    assertTrue(repository.exists(EXP_DBMETA_NAME_NEW, null, RepositoryObjectType.DATABASE));
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 52 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class RepositoryTestBase method testSetAcl.

@Test
@Ignore
public void testSetAcl() throws Exception {
    RepositoryDirectoryInterface rootDir = initRepo();
    JobMeta jobMeta = createJobMeta(EXP_JOB_NAME);
    RepositoryDirectoryInterface jobsDir = rootDir.findDirectory(DIR_JOBS);
    repository.save(jobMeta, VERSION_COMMENT_V1, null);
    deleteStack.push(jobMeta);
    assertNotNull(jobMeta.getObjectId());
    ObjectRevision version = jobMeta.getObjectRevision();
    assertNotNull(version);
    assertTrue(hasVersionWithComment(jobMeta, VERSION_COMMENT_V1));
    assertTrue(repository.exists(EXP_JOB_NAME, jobsDir, RepositoryObjectType.JOB));
    ObjectAcl acl = ((IAclService) repository).getAcl(jobMeta.getObjectId(), false);
    assertNotNull(acl);
    acl.setEntriesInheriting(false);
    ObjectAce ace = new RepositoryObjectAce(new RepositoryObjectRecipient("suzy", Type.USER), EnumSet.of(RepositoryFilePermission.READ));
    List<ObjectAce> aceList = new ArrayList<ObjectAce>();
    aceList.add(ace);
    acl.setAces(aceList);
    ((IAclService) repository).setAcl(jobMeta.getObjectId(), acl);
    ObjectAcl acl1 = ((IAclService) repository).getAcl(jobMeta.getObjectId(), false);
    assertEquals(Boolean.FALSE, acl1.isEntriesInheriting());
    assertEquals(1, acl1.getAces().size());
    ObjectAce ace1 = acl1.getAces().get(0);
    assertEquals(ace1.getRecipient().getName(), "suzy");
    assertTrue(ace1.getPermissions().contains(RepositoryFilePermission.READ));
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) ObjectAcl(org.pentaho.di.repository.pur.model.ObjectAcl) RepositoryObjectRecipient(org.pentaho.di.repository.pur.model.RepositoryObjectRecipient) ArrayList(java.util.ArrayList) IAclService(org.pentaho.di.ui.repository.pur.services.IAclService) ObjectAce(org.pentaho.di.repository.pur.model.ObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce) RepositoryObjectAce(org.pentaho.di.repository.pur.model.RepositoryObjectAce) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 53 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class DelegatesPrivateDatabasesTest method getData.

@Parameterized.Parameters
public static List<Object[]> getData() {
    Repository repository = mock(Repository.class);
    IUnifiedRepository pur = mock(IUnifiedRepository.class);
    Object[] trans = { new TransDelegate(repository, pur), new TransMeta(), TransDelegate.NODE_TRANS_PRIVATE_DATABASES, TransDelegate.PROP_TRANS_PRIVATE_DATABASE_NAMES };
    Object[] job = { new JobDelegate(repository, pur), new JobMeta(), JobDelegate.NODE_JOB_PRIVATE_DATABASES, JobDelegate.PROP_JOB_PRIVATE_DATABASE_NAMES };
    return Arrays.asList(trans, job);
}
Also used : Repository(org.pentaho.di.repository.Repository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository)

Example 54 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class JobDelegateTest method testElementToDataNodeSavesCopyAttributes.

@Test
public void testElementToDataNodeSavesCopyAttributes() throws KettleException {
    JobMeta mockJobMeta = mock(JobMeta.class);
    IUnifiedRepository mockUnifiedRepository = mock(IUnifiedRepository.class);
    JobDelegate jobDelegate = new JobDelegate(mockPurRepository, mockUnifiedRepository);
    JobLogTable mockJobLogTable = mock(JobLogTable.class);
    JobEntryCopy mockJobEntryCopy = mock(JobEntryCopy.class);
    Map<String, Map<String, String>> attributes = new HashMap<String, Map<String, String>>();
    Map<String, String> group = new HashMap<String, String>();
    final String mockGroup = "MOCK_GROUP";
    final String mockProperty = "MOCK_PROPERTY";
    final String mockValue = "MOCK_VALUE";
    group.put(mockProperty, mockValue);
    attributes.put(mockGroup, group);
    when(mockJobEntryCopy.getAttributesMap()).thenReturn(attributes);
    JobEntryBaseAndInterface mockJobEntry = mock(JobEntryBaseAndInterface.class);
    when(mockJobMeta.listParameters()).thenReturn(new String[] {});
    when(mockJobMeta.getJobLogTable()).thenReturn(mockJobLogTable);
    when(mockJobMeta.nrJobEntries()).thenReturn(1);
    when(mockJobMeta.getJobEntry(0)).thenReturn(mockJobEntryCopy);
    when(mockJobEntryCopy.getName()).thenReturn("MOCK_NAME");
    when(mockJobEntryCopy.getLocation()).thenReturn(new Point(0, 0));
    when(mockJobEntryCopy.getEntry()).thenReturn(mockJobEntry);
    DataNode dataNode = jobDelegate.elementToDataNode(mockJobMeta);
    DataNode groups = dataNode.getNode("entries").getNodes().iterator().next().getNode(AttributesMapUtil.NODE_ATTRIBUTE_GROUPS);
    DataNode mockGroupNode = groups.getNode(mockGroup);
    assertEquals(mockValue, mockGroupNode.getProperty(mockProperty).getString());
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobLogTable(org.pentaho.di.core.logging.JobLogTable) HashMap(java.util.HashMap) Point(org.pentaho.di.core.gui.Point) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) HashMap(java.util.HashMap) Map(java.util.Map) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 55 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class SpoonMenuABSController method updateMenu.

public void updateMenu(Document doc) {
    try {
        Spoon spoon = Spoon.getInstance();
        boolean createPermitted = true;
        boolean executePermitted = true;
        // If we are working with an Enterprise Repository
        if ((spoon != null) && (spoon.getRepository() != null) && (spoon.getRepository() instanceof PurRepository)) {
            Repository repo = spoon.getRepository();
            // Check for ABS Security
            if (repo.hasService(IAbsSecurityProvider.class)) {
                IAbsSecurityProvider securityProvider = (IAbsSecurityProvider) repo.getService(IAbsSecurityProvider.class);
                // Get create & execute permission
                createPermitted = securityProvider.isAllowed(IAbsSecurityProvider.CREATE_CONTENT_ACTION);
                executePermitted = securityProvider.isAllowed(IAbsSecurityProvider.EXECUTE_CONTENT_ACTION);
                EngineMetaInterface meta = spoon.getActiveMeta();
                // If (meta is not null) and (meta is either a Transformation or Job)
                if ((meta != null) && ((meta instanceof JobMeta) || (meta instanceof TransMeta))) {
                    // Main spoon toolbar
                    // $NON-NLS-1$
                    ((XulToolbarbutton) doc.getElementById("toolbar-file-new")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulToolbarbutton) doc.getElementById("toolbar-file-save")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulToolbarbutton) doc.getElementById("toolbar-file-save-as")).setDisabled(!createPermitted);
                    // Popup menus
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("trans-class-new")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("job-class-new")).setDisabled(!createPermitted);
                    // Main spoon menu
                    // $NON-NLS-1$
                    ((XulMenu) doc.getElementById("file-new")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("file-save")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("file-save-as")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("file-close")).setDisabled(!createPermitted);
                }
                // Handle Execute permissions
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("process-run")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-preview")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-debug")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-replay")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-verify")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-impact")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-get-sql")).setDisabled(!executePermitted);
                // Disable Show Last menu under the Action menu. Disable without execute permissions.
                // $NON-NLS-1$
                ((XulMenu) doc.getElementById("trans-last")).setDisabled(!executePermitted);
                boolean exportAllowed = createPermitted && executePermitted;
                // $NON-NLS-1$
                ((XulMenu) doc.getElementById("file-export")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("repository-export-all")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("file-save-as-vfs")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("edit-cut-steps")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("edit-copy-steps")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("edit.copy-file")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("edit-paste-steps")).setDisabled(!exportAllowed);
                // Schedule is a plugin
                if (doc.getElementById("trans-schedule") != null) {
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("trans-schedule")).setDisabled(!executePermitted);
                }
                TransGraph transGraph = Spoon.getInstance().getActiveTransGraph();
                if (transGraph != null) {
                    XulToolbar toolbar = transGraph.getToolbar();
                    XulToolbarbutton runButton = (XulToolbarbutton) toolbar.getElementById("trans-run");
                    XulToolbarbutton debugButton = (XulToolbarbutton) toolbar.getElementById("trans-debug");
                    XulToolbarbutton previewButton = (XulToolbarbutton) toolbar.getElementById("trans-preview");
                    XulToolbarbutton replayButton = (XulToolbarbutton) toolbar.getElementById("trans-replay");
                    XulToolbarbutton verifyButton = (XulToolbarbutton) toolbar.getElementById("trans-verify");
                    XulToolbarbutton impactButton = (XulToolbarbutton) toolbar.getElementById("trans-impact");
                    XulToolbarbutton generateSqlButton = (XulToolbarbutton) toolbar.getElementById("trans-get-sql");
                    if ((runButton != null) && (runButton.isDisabled() ^ !executePermitted)) {
                        runButton.setDisabled(!executePermitted);
                    }
                    if ((debugButton != null) && (debugButton.isDisabled() ^ !executePermitted)) {
                        debugButton.setDisabled(!executePermitted);
                    }
                    if ((previewButton != null) && (previewButton.isDisabled() ^ !executePermitted)) {
                        previewButton.setDisabled(!executePermitted);
                    }
                    if ((replayButton != null) && (replayButton.isDisabled() ^ !executePermitted)) {
                        replayButton.setDisabled(!executePermitted);
                    }
                    if ((verifyButton != null) && (verifyButton.isDisabled() ^ !executePermitted)) {
                        verifyButton.setDisabled(!executePermitted);
                    }
                    if ((impactButton != null) && (impactButton.isDisabled() ^ !executePermitted)) {
                        impactButton.setDisabled(!executePermitted);
                    }
                    if ((generateSqlButton != null) && (generateSqlButton.isDisabled() ^ !executePermitted)) {
                        generateSqlButton.setDisabled(!executePermitted);
                    }
                }
                JobGraph jobGraph = Spoon.getInstance().getActiveJobGraph();
                if (jobGraph != null) {
                    XulToolbar toolbar = jobGraph.getToolbar();
                    XulToolbarbutton runButton = (XulToolbarbutton) toolbar.getElementById("job-run");
                    XulToolbarbutton generateSqlButton = (XulToolbarbutton) toolbar.getElementById("job-get-sql");
                    if ((runButton != null) && (runButton.isDisabled() ^ !executePermitted)) {
                        runButton.setDisabled(!executePermitted);
                    }
                    if ((generateSqlButton != null) && (generateSqlButton.isDisabled() ^ !executePermitted)) {
                        generateSqlButton.setDisabled(!executePermitted);
                    }
                }
            }
        }
        EESpoonPlugin.updateChangedWarningDialog(createPermitted);
    } catch (Exception e) {
        // don't let this bomb all the way out, otherwise we'll get stuck: PDI-4670
        log.logError(e.getMessage(), e);
    }
}
Also used : IAbsSecurityProvider(org.pentaho.di.ui.repository.pur.services.IAbsSecurityProvider) JobMeta(org.pentaho.di.job.JobMeta) XulToolbar(org.pentaho.ui.xul.containers.XulToolbar) PurRepository(org.pentaho.di.repository.pur.PurRepository) TransMeta(org.pentaho.di.trans.TransMeta) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) XulToolbarbutton(org.pentaho.ui.xul.components.XulToolbarbutton) XulMenu(org.pentaho.ui.xul.containers.XulMenu) Repository(org.pentaho.di.repository.Repository) PurRepository(org.pentaho.di.repository.pur.PurRepository) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) Spoon(org.pentaho.di.ui.spoon.Spoon) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface)

Aggregations

JobMeta (org.pentaho.di.job.JobMeta)254 Test (org.junit.Test)88 TransMeta (org.pentaho.di.trans.TransMeta)69 KettleException (org.pentaho.di.core.exception.KettleException)62 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)48 Job (org.pentaho.di.job.Job)45 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)27 Repository (org.pentaho.di.repository.Repository)25 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)25 Point (org.pentaho.di.core.gui.Point)24 ArrayList (java.util.ArrayList)23 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)22 SlaveServer (org.pentaho.di.cluster.SlaveServer)17 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)17 FileObject (org.apache.commons.vfs2.FileObject)16 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)16 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)15 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)15 PrintWriter (java.io.PrintWriter)12 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)12