use of org.talend.core.runtime.dynamic.IDynamicConfiguration in project tbd-studio-se by Talend.
the class DynamicModuleGroupAdapter method adapt.
public IDynamicConfiguration adapt(IDynamicMonitor monitor) throws Exception {
DynamicDistributionUtils.checkCancelOrNot(monitor);
resolve();
if (monitor != null) {
monitor.setTaskName(// $NON-NLS-1$
Messages.getString("DynamicModuleGroupAdapter.monitor.buildModuleGroup", moduleGroupBean.getId()));
}
DynamicConfiguration configuration = getConfiguration();
String distribution = configuration.getDistribution();
String version = configuration.getVersion();
String id = configuration.getId();
String moduleGroupId = moduleGroupBean.getId();
String description = moduleGroupBean.getDescription();
List<ESparkVersion> selectedSparkVersions = configuration.getSelectedSparkVersions();
List<String> sparkVersions = moduleGroupBean.getSupportedSparkVersions();
if (sparkVersions != null && !sparkVersions.isEmpty()) {
boolean isSupport = false;
for (String sparkVersion : sparkVersions) {
try {
ESparkVersion eSparkVersion = ESparkVersion.valueOf(sparkVersion);
if (selectedSparkVersions.contains(eSparkVersion)) {
isSupport = true;
break;
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
if (!isSupport) {
return null;
}
}
runtimeId = DynamicDistributionUtils.getPluginKey(distribution, version, id, moduleGroupId);
IDynamicConfiguration dynamicModuleGroup = DynamicFactory.getInstance().createDynamicConfiguration();
dynamicModuleGroup.setConfigurationName(TAG_NAME);
dynamicModuleGroup.setAttribute(ATTR_ID, runtimeId);
dynamicModuleGroup.setAttribute(ATTR_GROUP_TEMPLATE_ID, moduleGroupId);
dynamicModuleGroup.setAttribute(ATTR_DESCRIPTION, description);
List<String> modules = moduleGroupBean.getModules();
Set<String> runtimeModulesSet = new HashSet<>();
if (modules != null) {
for (String module : modules) {
DynamicModuleAdapter moduleAdapter = moduleBeanAdapterMap.get(module);
if (moduleAdapter == null) {
throw new Exception(// $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"DynamicModuleGroupAdapter.exception.noModuleAdapterFound", // $NON-NLS-1$
module, DynamicModuleAdapter.class.getName()));
}
if (moduleAdapter.isSkipped()) {
continue;
}
List<String> runtimeIds = moduleAdapter.getRuntimeIds();
if (runtimeIds == null || runtimeIds.isEmpty()) {
// means it is using existing modules of studio
runtimeModulesSet.add(module);
} else {
runtimeModulesSet.addAll(runtimeIds);
}
}
if (runtimeModulesSet != null) {
for (String runtimeModule : runtimeModulesSet) {
IDynamicConfiguration createDynamicLibrary = createDynamicLibrary(runtimeModule);
dynamicModuleGroup.addChildConfiguration(createDynamicLibrary);
}
}
}
this.runtimeModules.addAll(runtimeModulesSet);
return dynamicModuleGroup;
}
use of org.talend.core.runtime.dynamic.IDynamicConfiguration in project tbd-studio-se by Talend.
the class DynamicClassloaderAdapter method adapt.
public IDynamicConfiguration adapt(IDynamicMonitor monitor) throws Exception {
DynamicDistributionUtils.checkCancelOrNot(monitor);
resolve();
if (monitor != null) {
monitor.setTaskName(// $NON-NLS-1$
Messages.getString("DynamicClassloaderAdapter.monitor.buildClassLoader", classLoaderBean.getId()));
}
IDynamicConfiguration classLoader = DynamicFactory.getInstance().createDynamicConfiguration();
classLoader.setConfigurationName(TAG_NAME);
classLoader.setAttribute(ATTR_INDEX, classLoaderBean.getIndex());
String moduleGroupId = classLoaderBean.getModuleGroup();
DynamicModuleGroupAdapter dynamicModuleGroupAdapter = moduleGroupBeanAdapterMap.get(moduleGroupId);
if (dynamicModuleGroupAdapter == null) {
throw new Exception(// $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"DynamicClassloaderAdapter.exception.noModuleAdapterFound", // $NON-NLS-1$
moduleGroupId, DynamicModuleGroupAdapter.class.getName()));
}
classLoader.setAttribute(ATTR_MODULE_GROUP_TEMPLATE_ID, moduleGroupId);
List<String> runtimeModules = dynamicModuleGroupAdapter.getRuntimeModules();
if (runtimeModules != null) {
String libraries = buildLibrariesString(runtimeModules);
classLoader.setAttribute(ATTR_LIBRARIES, libraries);
}
return classLoader;
}
use of org.talend.core.runtime.dynamic.IDynamicConfiguration in project tbd-studio-se by Talend.
the class ModuleGroupDetailsForm method initData.
protected void initData() {
try {
DynamicModuleGroupData moduleGroupData = getModuleGroupData();
String groupTemplateId = moduleGroupData.getGroupTemplateId();
groupTemplateIdLabel.setText(// $NON-NLS-1$
Messages.getString("ModuleGroupDetailsForm.groupDetails.label.groupTemplateId", groupTemplateId));
DynamicPluginAdapter pluginAdapter = moduleGroupData.getPluginAdapter();
IDynamicConfiguration moduleGroup = pluginAdapter.getModuleGroupByTemplateId(groupTemplateId);
List<IDynamicConfiguration> childConfigurations = moduleGroup.getChildConfigurations();
if (childConfigurations != null) {
Collections.sort(childConfigurations, new DynamicAttributeComparator());
}
groupDetailsViewer.setInput(childConfigurations);
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.runtime.dynamic.IDynamicConfiguration in project tbd-studio-se by Talend.
the class ModuleGroupDetailsForm method checkLibraries.
private boolean checkLibraries() {
List<IDynamicConfiguration> childConfigurations = (List<IDynamicConfiguration>) groupDetailsViewer.getInput();
List<String> errorLines = new ArrayList<>();
for (int i = 0; i < childConfigurations.size(); ++i) {
IDynamicConfiguration library = childConfigurations.get(i);
if (checkLibrary(library) != null) {
errorLines.add(String.valueOf(i + 1));
}
}
if (errorLines.isEmpty()) {
return true;
} else {
// $NON-NLS-1$
String seperator = ", ";
StringBuffer errorLinesBuf = new StringBuffer();
for (String errorLine : errorLines) {
if (0 < errorLinesBuf.length()) {
errorLinesBuf.append(seperator);
}
groupDetailsViewer.refresh(childConfigurations.get(Integer.valueOf(errorLine) - 1));
errorLinesBuf.append(errorLine);
}
String errorLinesStr = errorLinesBuf.toString();
// $NON-NLS-1$
String message = Messages.getString("ModuleGroupDetailsForm.groupDetails.check.errorLines", errorLinesStr);
showMessage(message, WizardPage.ERROR);
return false;
}
}
use of org.talend.core.runtime.dynamic.IDynamicConfiguration in project tbd-studio-se by Talend.
the class ModuleGroupDetailsForm method onDeleteBtnSelected.
protected void onDeleteBtnSelected() {
IStructuredSelection selection = (IStructuredSelection) groupDetailsViewer.getSelection();
IDynamicConfiguration firstElement = (IDynamicConfiguration) selection.getFirstElement();
DynamicModuleGroupData moduleGroupData = getModuleGroupData();
String groupTemplateId = moduleGroupData.getGroupTemplateId();
DynamicPluginAdapter pluginAdapter = moduleGroupData.getPluginAdapter();
IDynamicConfiguration moduleGroup = pluginAdapter.getModuleGroupByTemplateId(groupTemplateId);
List<IDynamicConfiguration> childConfigurations = moduleGroup.getChildConfigurations();
childConfigurations.remove(firstElement);
groupDetailsViewer.refresh();
}
Aggregations