Search in sources :

Example 6 with PurRepositoryMeta

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

the class RepositoryConfigController method ok.

public void ok() {
    if (repositoryMeta instanceof PurRepositoryMeta) {
        repositoryMeta.setName(model.getName());
        repositoryMeta.setDescription(model.getId());
        // remove trailing slash
        String url = model.getUrl();
        String urlTrim = url.endsWith("/") ? url.substring(0, url.length() - 1) : url;
        PurRepositoryLocation location = new PurRepositoryLocation(urlTrim);
        ((PurRepositoryMeta) repositoryMeta).setRepositoryLocation(location);
        ((PurRepositoryMeta) repositoryMeta).setVersionCommentMandatory(model.isModificationComments());
        getCallback().onSuccess(((PurRepositoryMeta) repositoryMeta));
    } else {
        getCallback().onError(new IllegalStateException(BaseMessages.getString(PurRepositoryDialog.class, // $NON-NLS-1$
        "RepositoryConfigDialog.ERROR_0001_NotAnInstanceOfPurRepositoryMeta")));
    }
}
Also used : PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) PurRepositoryLocation(org.pentaho.di.repository.pur.PurRepositoryLocation)

Example 7 with PurRepositoryMeta

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

the class PurRepositoryDialog method open.

public RepositoryMeta open(final MODE mode) {
    try {
        SwtXulLoader swtLoader = new SwtXulLoader();
        swtLoader.setOuterContext(parent);
        swtLoader.registerClassLoader(getClass().getClassLoader());
        container = // $NON-NLS-1$
        swtLoader.loadXul("org/pentaho/di/ui/repository/pur/xul/pur-repository-config-dialog.xul", resourceBundle);
        final XulRunner runner = new SwtXulRunner();
        runner.addContainer(container);
        parent.addDisposeListener(new DisposeListener() {

            public void widgetDisposed(DisposeEvent arg0) {
                hide();
            }
        });
        repositoryConfigController.setMessages(resourceBundle);
        repositoryConfigController.setRepositoryMeta(repositoryMeta);
        repositoryConfigController.setCallback(new IRepositoryConfigDialogCallback() {

            public void onSuccess(PurRepositoryMeta meta) {
                // If repository does not have a name then send back a null repository meta
                if (meta.getName() != null) {
                    // already exist
                    if (mode == MODE.ADD) {
                        if (masterRepositoriesMeta.searchRepository(meta.getName()) == null) {
                            repositoryMeta = meta;
                            hide();
                        } else {
                            displayRepositoryAlreadyExistMessage(meta.getName());
                        }
                    } else {
                        if (masterRepositoryName.equals(meta.getName())) {
                            repositoryMeta = meta;
                            hide();
                        } else if (masterRepositoriesMeta.searchRepository(meta.getName()) == null) {
                            repositoryMeta = meta;
                            hide();
                        } else {
                            displayRepositoryAlreadyExistMessage(meta.getName());
                        }
                    }
                }
            }

            public void onError(Throwable t) {
                SpoonFactory.getInstance().messageBox(t.getLocalizedMessage(), resourceBundle.getString("RepositoryConfigDialog.InitializationFailed"), false, // $NON-NLS-1$
                Const.ERROR);
                // $NON-NLS-1$
                log.error(resourceBundle.getString("RepositoryConfigDialog.ErrorStartingXulApplication"), t);
            }

            public void onCancel() {
                repositoryMeta = null;
                hide();
            }
        });
        container.addEventHandler(repositoryConfigController);
        try {
            runner.initialize();
            show();
        } catch (XulException e) {
            SpoonFactory.getInstance().messageBox(e.getLocalizedMessage(), resourceBundle.getString("RepositoryConfigDialog.InitializationFailed"), false, // $NON-NLS-1$
            Const.ERROR);
            // $NON-NLS-1$
            log.error(resourceBundle.getString("RepositoryConfigDialog.ErrorStartingXulApplication"), e);
        }
    } catch (XulException e) {
        // $NON-NLS-1$
        log.error(resourceBundle.getString("RepositoryConfigDialog.ErrorStartingXulApplication"), e);
    }
    return repositoryMeta;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) XulException(org.pentaho.ui.xul.XulException) PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) SwtXulLoader(org.pentaho.ui.xul.swt.SwtXulLoader) DisposeEvent(org.eclipse.swt.events.DisposeEvent) XulRunner(org.pentaho.ui.xul.XulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner)

Aggregations

PurRepositoryMeta (org.pentaho.di.repository.pur.PurRepositoryMeta)7 PurRepository (org.pentaho.di.repository.pur.PurRepository)3 PurRepositoryLocation (org.pentaho.di.repository.pur.PurRepositoryLocation)3 Before (org.junit.Before)2 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 Serializable (java.io.Serializable)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 Test (org.junit.Test)1 ObjectId (org.pentaho.di.repository.ObjectId)1 Repository (org.pentaho.di.repository.Repository)1 UserInfo (org.pentaho.di.repository.UserInfo)1 PurRepositoryConnector (org.pentaho.di.repository.pur.PurRepositoryConnector)1 UIEETransformation (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEETransformation)1 ILockService (org.pentaho.di.ui.repository.pur.services.ILockService)1 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)1 ITenant (org.pentaho.platform.api.mt.ITenant)1 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)1