Search in sources :

Example 11 with IDynamicPluginConfiguration

use of org.talend.core.runtime.dynamic.IDynamicPluginConfiguration in project tbd-studio-se by Talend.

the class AbstractDynamicDistributionsGroup method register.

@Override
public void register(IDynamicPlugin dynamicPlugin, IDynamicMonitor monitor) throws Exception {
    boolean registed = false;
    IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
    String templateId = pluginConfiguration.getTemplateId();
    IDynamicDistribution dynamicDistribution = getDynamicDistributionForId(templateId, monitor);
    if (dynamicDistribution != null) {
        dynamicDistribution.register(dynamicPlugin, monitor);
        registed = true;
    }
    if (!registed) {
        throw new Exception("No dynamic distribution serivce found for " + pluginConfiguration.getTemplateId());
    }
}
Also used : IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Example 12 with IDynamicPluginConfiguration

use of org.talend.core.runtime.dynamic.IDynamicPluginConfiguration in project tbd-studio-se by Talend.

the class AbstractDynamicDistributionsGroup method canRegister.

@Override
public boolean canRegister(IDynamicPlugin dynamicPlugin, IDynamicMonitor monitor) throws Exception {
    boolean canRegist = false;
    IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
    String templateId = pluginConfiguration.getTemplateId();
    IDynamicDistribution dynamicDistribution = getDynamicDistributionForId(templateId, monitor);
    canRegist = (dynamicDistribution != null);
    return canRegist;
}
Also used : IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Example 13 with IDynamicPluginConfiguration

use of org.talend.core.runtime.dynamic.IDynamicPluginConfiguration in project tbd-studio-se by Talend.

the class DynamicHDPDistribution method initTemplate.

@Override
protected IDynamicDistributionTemplate initTemplate(DynamicPluginAdapter pluginAdapter, IDynamicMonitor monitor) throws Exception {
    IDynamicDistributionTemplate dynamicDistributionTemplate = null;
    IDynamicPluginConfiguration pluginConfiguration = pluginAdapter.getPluginConfiguration();
    String templateId = pluginConfiguration.getTemplateId();
    switch(templateId) {
        case HDP2xxDistributionTemplate.TEMPLATE_ID:
            dynamicDistributionTemplate = new HDP2xxDistributionTemplate(pluginAdapter);
            break;
        case HDP3xxDistributionTemplate.TEMPLATE_ID:
            dynamicDistributionTemplate = new HDP3xxDistributionTemplate(pluginAdapter);
            break;
        default:
            throw new Exception("Unknown templateId: " + templateId);
    }
    return dynamicDistributionTemplate;
}
Also used : IDynamicDistributionTemplate(org.talend.hadoop.distribution.dynamic.template.IDynamicDistributionTemplate) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Example 14 with IDynamicPluginConfiguration

use of org.talend.core.runtime.dynamic.IDynamicPluginConfiguration in project tbd-studio-se by Talend.

the class DynamicDistributionOptionForm method initExistingConfigurationInfos.

private void initExistingConfigurationInfos() throws Exception {
    existingConfigurationNames = new HashSet<>();
    existingConfigurationIdMap = new HashMap<>();
    IDynamicMonitor monitor = new DummyDynamicMonitor();
    DynamicDistributionManager dynDistrManager = DynamicDistributionManager.getInstance();
    List<IDynamicPlugin> allDynamicPlugins = new LinkedList<>();
    List<IDynamicPlugin> allBuiltinDynamicPlugins = dynDistrManager.getAllBuiltinDynamicPlugins(monitor);
    if (allBuiltinDynamicPlugins != null && !allBuiltinDynamicPlugins.isEmpty()) {
        allDynamicPlugins.addAll(allBuiltinDynamicPlugins);
    }
    List<IDynamicPlugin> allUsesDynamicPlugins = dynDistrManager.getAllUsersDynamicPlugins(monitor);
    if (allUsesDynamicPlugins != null && !allUsesDynamicPlugins.isEmpty()) {
        allDynamicPlugins.addAll(allUsesDynamicPlugins);
    }
    if (allDynamicPlugins != null && !allDynamicPlugins.isEmpty()) {
        Iterator<IDynamicPlugin> iter = allDynamicPlugins.iterator();
        while (iter.hasNext()) {
            IDynamicPlugin dynPlugin = iter.next();
            IDynamicPluginConfiguration pluginConfiguration = dynPlugin.getPluginConfiguration();
            existingConfigurationNames.add(pluginConfiguration.getName());
            existingConfigurationIdMap.put(pluginConfiguration.getId(), dynPlugin);
        }
    }
}
Also used : DynamicDistributionManager(org.talend.hadoop.distribution.dynamic.DynamicDistributionManager) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) LinkedList(java.util.LinkedList)

Example 15 with IDynamicPluginConfiguration

use of org.talend.core.runtime.dynamic.IDynamicPluginConfiguration in project tbd-studio-se by Talend.

the class DynamicDistributionOptionForm method checkImportConfigText.

private boolean checkImportConfigText() {
    try {
        if (!importConfigBtn.getSelection()) {
            return true;
        }
        StringBuffer messageBuffer = new StringBuffer();
        importConfigText.setBackground(null);
        importConfigText.setToolTipText(importConfigText.getText());
        String importConfig = importConfigText.getText();
        if (StringUtils.isEmpty(importConfig)) {
            // $NON-NLS-1$
            String errorMessage = Messages.getString("DynamicDistributionOptionForm.importConfigText.check.empty");
            showMessage(errorMessage, WizardPage.ERROR);
            importConfigText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
            importConfigText.setToolTipText(errorMessage);
            return false;
        }
        if (importedDynamicPlugin == null) {
            // $NON-NLS-1$
            String errorMessage = Messages.getString("DynamicDistributionOptionForm.importConfigText.check.empty");
            importConfigText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
            importConfigText.setToolTipText(errorMessage);
            showMessage(errorMessage, WizardPage.ERROR);
            return false;
        }
        // 1. check plugin configuration
        IDynamicPluginConfiguration pluginConfiguration = importedDynamicPlugin.getPluginConfiguration();
        if (pluginConfiguration == null) {
            // $NON-NLS-1$
            String errorMessage = Messages.getString("DynamicDistributionOptionForm.importConfigText.check.noConfiguration");
            importConfigText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
            importConfigText.setToolTipText(errorMessage);
            showMessage(errorMessage, WizardPage.ERROR);
            return false;
        }
        DynamicDistributionSetupData dynamicBuildConfigurationData = getDynamicDistributionSetupData();
        // 2. check distribution
        IDynamicDistributionsGroup dynamicDistributionsGroup = dynamicBuildConfigurationData.getDynamicDistributionsGroup();
        if (!dynamicDistributionsGroup.getDistribution().equalsIgnoreCase(pluginConfiguration.getDistribution())) {
            String errorMessage = // $NON-NLS-1$
            Messages.getString(// $NON-NLS-1$
            "DynamicDistributionOptionForm.importConfigText.check.wrongDistribution", pluginConfiguration.getDistribution(), dynamicDistributionsGroup.getDistribution());
            importConfigText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
            importConfigText.setToolTipText(errorMessage);
            showMessage(errorMessage, WizardPage.ERROR);
            return false;
        }
        // 3. check id
        boolean isIdSame = false;
        String id = pluginConfiguration.getId();
        if (StringUtils.isEmpty(id)) {
            // $NON-NLS-1$
            String errorMessage = Messages.getString("DynamicDistributionOptionForm.importConfigText.check.badId.empty");
            importConfigText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
            importConfigText.setToolTipText(errorMessage);
            showMessage(errorMessage, WizardPage.ERROR);
            return false;
        }
        if (id.contains(".")) {
            // $NON-NLS-1$
            String errorMessage = // $NON-NLS-1$
            Messages.getString(// $NON-NLS-1$
            "DynamicDistributionOptionForm.importConfigText.check.badId.invalid", id);
            importConfigText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
            importConfigText.setToolTipText(errorMessage);
            showMessage(errorMessage, WizardPage.ERROR);
            return false;
        }
        IDynamicPlugin existingDynamicPlugin = getDynamicPluginById(id);
        if (existingDynamicPlugin != null) {
            IDynamicPluginConfiguration existingPluginConfig = existingDynamicPlugin.getPluginConfiguration();
            String distribution = existingPluginConfig.getDistribution();
            if (!dynamicDistributionsGroup.getDistribution().equalsIgnoreCase(distribution)) {
                String errorMessage = Messages.getString(// $NON-NLS-1$
                "DynamicDistributionOptionForm.importConfigText.check.badId.exist.diffDistribution", // $NON-NLS-1$
                id, dynamicDistributionsGroup.getDistribution(), // $NON-NLS-1$
                distribution);
                importConfigText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
                importConfigText.setToolTipText(errorMessage);
                showMessage(errorMessage, WizardPage.ERROR);
                return false;
            }
            String errorMessage = Messages.getString(// $NON-NLS-1$
            "DynamicDistributionOptionForm.importConfigText.check.badId.exist.sameDistribution", id);
            // $NON-NLS-1$
            messageBuffer.append(errorMessage).append("\n");
            isIdSame = true;
        }
        // 4. check name
        String name = pluginConfiguration.getName();
        if (!isIdSame && isConfigurationNameExist(name)) {
            Calendar cal = Calendar.getInstance();
            Date date = cal.getTime();
            String newName = name + // $NON-NLS-1$
            Messages.getString(// $NON-NLS-1$
            "DynamicDistributionOptionForm.importConfigText.check.badName.exist.desc", date.toString());
            pluginConfiguration.setName(newName);
            String errorMessage = // $NON-NLS-1$
            Messages.getString(// $NON-NLS-1$
            "DynamicDistributionOptionForm.importConfigText.check.badName.exist", name, newName);
            // $NON-NLS-1$
            messageBuffer.append(errorMessage).append("\n");
        }
        if (0 < messageBuffer.length()) {
            String warnMessage = messageBuffer.toString();
            importConfigText.setBackground(LoginDialogV2.YELLOW_COLOR);
            importConfigText.setToolTipText(warnMessage);
            showMessage(warnMessage, WizardPage.WARNING);
        }
        pluginConfiguration.setAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME, ProjectManager.getInstance().getCurrentProject().getTechnicalLabel());
        getDynamicDistributionSetupData().setDynamicPlugin(importedDynamicPlugin);
        return true;
    } catch (Exception e) {
        importConfigText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
        importConfigText.setToolTipText(e.getMessage());
        return false;
    }
}
Also used : IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) Calendar(java.util.Calendar) DynamicDistributionSetupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) Date(java.util.Date) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)38 IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)16 DynamicPluginAdapter (org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter)10 Set (java.util.Set)6 NodeComponentTypeBean (org.talend.hadoop.distribution.NodeComponentTypeBean)6 File (java.io.File)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 DummyDynamicMonitor (org.talend.designer.maven.aether.DummyDynamicMonitor)5 IDynamicMonitor (org.talend.designer.maven.aether.IDynamicMonitor)5 IDynamicDistributionTemplate (org.talend.hadoop.distribution.dynamic.template.IDynamicDistributionTemplate)4 ArrayList (java.util.ArrayList)3 Project (org.talend.core.model.general.Project)3 DynamicConfiguration (org.talend.hadoop.distribution.dynamic.DynamicConfiguration)3 DynamicDistributionSetupData (org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData)3 IFolder (org.eclipse.core.resources.IFolder)2 IProject (org.eclipse.core.resources.IProject)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Bundle (org.osgi.framework.Bundle)2 LoginException (org.talend.commons.exception.LoginException)2 PersistenceException (org.talend.commons.exception.PersistenceException)2