Search in sources :

Example 1 with RepositoryObjectType

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

the class Spoon method exploreRepository.

public void exploreRepository() {
    if (rep != null) {
        final RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {

            @Override
            public boolean open(UIRepositoryContent element, String revision) throws Exception {
                String objName = element.getName();
                if (objName != null) {
                    RepositoryObjectType objectType = element.getRepositoryElementType();
                    RepositoryDirectory repDir = element.getRepositoryDirectory();
                    if (element.getObjectId() != null) {
                        // new way
                        loadObjectFromRepository(element.getObjectId(), objectType, revision);
                    } else {
                        // old way
                        loadObjectFromRepository(objName, objectType, repDir, revision);
                    }
                }
                // do not close explorer
                return false;
            }

            @Override
            public boolean error(String message) throws Exception {
                closeRepository();
                return true;
            }
        };
        try {
            final KettleWaitBox box = (KettleWaitBox) this.mainSpoonContainer.getDocumentRoot().createElement("iconwaitbox");
            box.setIndeterminate(true);
            box.setCanCancel(false);
            box.setIcon("ui/images/kettle_logo_small.svg");
            box.setTitle(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Connection.Wait.Title"));
            box.setMessage(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Explorer.Wait.Message"));
            box.setDialogParent(shell);
            box.setRunnable(new WaitBoxRunnable(box) {

                @Override
                public void run() {
                    shell.getDisplay().syncExec(new Runnable() {

                        @Override
                        public void run() {
                            RepositoryExplorer explorer;
                            try {
                                try {
                                    explorer = new RepositoryExplorer(shell, rep, cb, Variables.getADefaultVariableSpace(), sharedObjectSyncUtil);
                                } catch (final KettleRepositoryLostException krle) {
                                    handleRepositoryLost(krle);
                                    closeRepository();
                                    return;
                                } finally {
                                    box.stop();
                                }
                                if (explorer.isInitialized()) {
                                    explorer.show();
                                } else {
                                    return;
                                }
                                explorer.dispose();
                            } catch (final Throwable e) {
                                shell.getDisplay().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
                                    }
                                });
                            }
                        }
                    });
                }

                @Override
                public void cancel() {
                }
            });
            box.start();
        } catch (Throwable e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
        }
    }
}
Also used : RepositoryExplorer(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorer) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RepositoryExplorerCallback(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) RepositoryDialogInterface(org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface) KettleWaitBox(org.pentaho.di.ui.xul.KettleWaitBox)

Example 2 with RepositoryObjectType

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

the class JobMeta method lookupRepositoryReferences.

/**
 * Look up the references after import
 *
 * @param repository the repository to reference.
 */
public void lookupRepositoryReferences(Repository repository) throws KettleException {
    KettleException lastThrownException = null;
    Map<String, RepositoryObjectType> notFoundedReferences = new HashMap<>();
    for (JobEntryCopy copy : jobcopies) {
        if (copy.getEntry().hasRepositoryReferences()) {
            try {
                copy.getEntry().lookupRepositoryReferences(repository);
            } catch (IdNotFoundException e) {
                lastThrownException = e;
                String path = e.getPathToObject();
                String name = e.getObjectName();
                String key = StringUtils.isEmpty(path) || path.equals("null") ? name : path + "/" + name;
                notFoundedReferences.put(key, e.getObjectType());
            }
        }
    }
    if (lastThrownException != null && !notFoundedReferences.isEmpty()) {
        throw new LookupReferencesException(lastThrownException, notFoundedReferences);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) LookupReferencesException(org.pentaho.di.core.exception.LookupReferencesException) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) HashMap(java.util.HashMap) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) IdNotFoundException(org.pentaho.di.core.exception.IdNotFoundException)

Example 3 with RepositoryObjectType

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

the class PurRepository_SharedObjects_IT method loadAllShared.

@Test
public void loadAllShared() throws Exception {
    ClusterSchema cluster = cluster();
    DatabaseMeta database = database();
    SlaveServer slaveServer = slaveServer();
    PartitionSchema partition = partition();
    purRepository.save(cluster, null, null);
    purRepository.save(database, null, null);
    purRepository.save(slaveServer, null, null);
    purRepository.save(partition, null, null);
    Map<RepositoryObjectType, List<? extends SharedObjectInterface>> map = map();
    purRepository.readSharedObjects(map, RepositoryObjectType.CLUSTER_SCHEMA, RepositoryObjectType.DATABASE, RepositoryObjectType.SLAVE_SERVER, RepositoryObjectType.PARTITION_SCHEMA);
    RepositoryElementInterface[] saved = new RepositoryElementInterface[] { cluster, database, slaveServer, partition };
    assertEquals(saved.length, map.size());
    for (RepositoryElementInterface sharedObject : saved) {
        List<? extends SharedObjectInterface> list = map.get(sharedObject.getRepositoryElementType());
        assertEquals(1, list.size());
        assertEquals(sharedObject, list.get(0));
    }
}
Also used : RepositoryElementInterface(org.pentaho.di.repository.RepositoryElementInterface) PartitionSchema(org.pentaho.di.partition.PartitionSchema) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) List(java.util.List) SharedObjectInterface(org.pentaho.di.shared.SharedObjectInterface) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) Test(org.junit.Test)

Example 4 with RepositoryObjectType

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

the class PurRepository_SharedObjects_IT method testLoadSharedObjects.

private void testLoadSharedObjects(RepositoryElementInterface sharedObject) throws Exception {
    purRepository.save(sharedObject, null, null);
    Map<RepositoryObjectType, List<? extends SharedObjectInterface>> map = map();
    purRepository.readSharedObjects(map, sharedObject.getRepositoryElementType());
    List<? extends SharedObjectInterface> objects = map.get(sharedObject.getRepositoryElementType());
    assertNotNull(objects);
    assertEquals(1, objects.size());
    SharedObjectInterface object = objects.get(0);
    assertEquals(sharedObject, object);
}
Also used : RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) List(java.util.List) SharedObjectInterface(org.pentaho.di.shared.SharedObjectInterface)

Example 5 with RepositoryObjectType

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

the class PurRepositoryIT method testNewNonAmbiguousNaming.

@Test
public void testNewNonAmbiguousNaming() throws Exception {
    PurRepository repo = (PurRepository) repository;
    System.setProperty("KETTLE_COMPATIBILITY_PUR_OLD_NAMING_MODE", "N");
    // $NON-NLS-1$
    PartitionSchema partSchema1 = createPartitionSchema("find.me");
    // $NON-NLS-1$
    PartitionSchema partSchema2 = createPartitionSchema("find|me");
    repository.save(partSchema1, VERSION_COMMENT_V1, null);
    repository.save(partSchema2, VERSION_COMMENT_V1, null);
    Map<RepositoryObjectType, List<? extends SharedObjectInterface>> sharedObjectsByType = new HashMap<RepositoryObjectType, List<? extends SharedObjectInterface>>();
    repo.readSharedObjects(sharedObjectsByType, RepositoryObjectType.PARTITION_SCHEMA);
    List<PartitionSchema> partitionSchemas = (List<PartitionSchema>) sharedObjectsByType.get(RepositoryObjectType.PARTITION_SCHEMA);
    assertEquals(2, partitionSchemas.size());
    System.setProperty("KETTLE_COMPATIBILITY_PUR_OLD_NAMING_MODE", "Y");
    // $NON-NLS-1$
    PartitionSchema partSchema3 = createPartitionSchema("another.one");
    // $NON-NLS-1$
    PartitionSchema partSchema4 = createPartitionSchema("another|one");
    repository.save(partSchema3, VERSION_COMMENT_V1, null);
    repository.save(partSchema4, VERSION_COMMENT_V1, null);
    sharedObjectsByType = new HashMap<RepositoryObjectType, List<? extends SharedObjectInterface>>();
    repo.readSharedObjects(sharedObjectsByType, RepositoryObjectType.PARTITION_SCHEMA);
    partitionSchemas = (List<PartitionSchema>) sharedObjectsByType.get(RepositoryObjectType.PARTITION_SCHEMA);
    assertEquals(3, partitionSchemas.size());
}
Also used : PartitionSchema(org.pentaho.di.partition.PartitionSchema) HashMap(java.util.HashMap) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) ArrayList(java.util.ArrayList) AbstractList(java.util.AbstractList) List(java.util.List) SharedObjectInterface(org.pentaho.di.shared.SharedObjectInterface) Test(org.junit.Test)

Aggregations

RepositoryObjectType (org.pentaho.di.repository.RepositoryObjectType)25 ArrayList (java.util.ArrayList)13 KettleException (org.pentaho.di.core.exception.KettleException)13 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)10 List (java.util.List)7 SharedObjectInterface (org.pentaho.di.shared.SharedObjectInterface)7 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)6 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)6 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)5 Test (org.junit.Test)5 KettleFileException (org.pentaho.di.core.exception.KettleFileException)5 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)5 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)5 StringObjectId (org.pentaho.di.repository.StringObjectId)5 EERepositoryObject (org.pentaho.di.repository.pur.model.EERepositoryObject)5 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)5 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)5 RepositoryFileTree (org.pentaho.platform.api.repository2.unified.RepositoryFileTree)5 UnifiedRepositoryCreateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException)5 UnifiedRepositoryUpdateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException)5