use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ManageEnvironmentsOptionPlugin method handleOption.
@Override
public boolean handleOption(ILogChannel log, IHasHopMetadataProvider hasHopMetadataProvider, IVariables variables) throws HopException {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
try {
boolean changed = false;
if (createEnvironment) {
createEnvironment(log, config, variables, hasHopMetadataProvider);
changed = true;
} else if (modifyEnvironment) {
modifyEnvironment(log, config, variables, hasHopMetadataProvider);
changed = true;
} else if (deleteEnvironment) {
deleteEnvironment(log, config, variables);
changed = true;
} else if (listEnvironments) {
listEnvironments(log, config, variables);
changed = true;
}
return changed;
} catch (Exception e) {
throw new HopException("Error handling project lifecycle environments configuration options", e);
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ProjectsGuiPlugin method selectProjectInList.
public static void selectProjectInList(String name) {
GuiToolbarWidgets toolbarWidgets = HopGui.getInstance().getMainToolbarWidgets();
toolbarWidgets.selectComboItem(ID_TOOLBAR_PROJECT_COMBO, name);
Combo combo = getProjectsCombo();
if (combo != null) {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
ProjectConfig projectConfig = config.findProjectConfig(name);
if (projectConfig != null) {
String projectHome = projectConfig.getProjectHome();
if (StringUtils.isNotEmpty(projectHome)) {
combo.setToolTipText(BaseMessages.getString(PKG, "ProjectGuiPlugin.SelectProject.Tooltip", name, projectHome, projectConfig.getConfigFilename()));
}
}
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ProjectsGuiPlugin method addNewProject.
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_PROJECT_ADD, toolTip = "i18n::HopGui.Toolbar.Project.Add.Tooltip", image = "project-add.svg")
public void addNewProject() {
HopGui hopGui = HopGui.getInstance();
IVariables variables = hopGui.getVariables();
try {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
String standardProjectsFolder = variables.resolve(config.getStandardProjectsFolder());
String defaultProjectConfigFilename = variables.resolve(config.getDefaultProjectConfigFile());
ProjectConfig projectConfig = new ProjectConfig("", standardProjectsFolder, defaultProjectConfigFilename);
Project project = new Project();
project.setParentProjectName(config.getStandardParentProject());
ProjectDialog projectDialog = new ProjectDialog(hopGui.getShell(), project, projectConfig, variables, false);
String projectName = projectDialog.open();
if (projectName != null) {
config.addProjectConfig(projectConfig);
HopConfig.getInstance().saveToFile();
// Save the project-config.json file as well in the project itself
//
FileObject configFile = HopVfs.getFileObject(projectConfig.getActualProjectConfigFilename(variables));
if (!configFile.exists()) {
// Create the empty configuration file if it does not exists
project.saveToFile();
} else {
// If projects exists load configuration
MessageBox box = new MessageBox(hopGui.getShell(), SWT.ICON_QUESTION | SWT.OK);
box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.ProjectExists.Dialog.Header"));
box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.ProjectExists.Dialog.Message"));
box.open();
project.readFromFile();
}
refreshProjectsList();
selectProjectInList(projectName);
enableHopGuiProject(projectName, project, null);
// Now see if these project contains any local run configurations.
// If not we can add those automatically
//
// First pipeline
//
IHopMetadataSerializer<PipelineRunConfiguration> prcSerializer = hopGui.getMetadataProvider().getSerializer(PipelineRunConfiguration.class);
List<PipelineRunConfiguration> pipelineRunConfigs = prcSerializer.loadAll();
boolean localFound = false;
for (PipelineRunConfiguration pipelineRunConfig : pipelineRunConfigs) {
if (pipelineRunConfig.getEngineRunConfiguration() instanceof LocalPipelineRunConfiguration) {
localFound = true;
}
}
if (!localFound) {
PipelineExecutionConfigurationDialog.createLocalPipelineConfiguration(hopGui.getShell(), prcSerializer);
}
// Then the local workflow runconfig
//
IHopMetadataSerializer<WorkflowRunConfiguration> wrcSerializer = hopGui.getMetadataProvider().getSerializer(WorkflowRunConfiguration.class);
localFound = false;
List<WorkflowRunConfiguration> workflowRunConfigs = wrcSerializer.loadAll();
for (WorkflowRunConfiguration workflowRunConfig : workflowRunConfigs) {
if (workflowRunConfig.getEngineRunConfiguration() instanceof LocalWorkflowRunConfiguration) {
localFound = true;
}
}
if (!localFound) {
MessageBox box = new MessageBox(HopGui.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.LocalWFRunConfig.Dialog.Header"));
box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.LocalWFRunConfig.Dialog.Message"));
int anwser = box.open();
if ((anwser & SWT.YES) != 0) {
LocalWorkflowRunConfiguration localWorkflowRunConfiguration = new LocalWorkflowRunConfiguration();
localWorkflowRunConfiguration.setEnginePluginId("Local");
WorkflowRunConfiguration local = new WorkflowRunConfiguration("local", BaseMessages.getString(PKG, "ProjectGuiPlugin.LocalWFRunConfigDescription.Text"), localWorkflowRunConfiguration);
wrcSerializer.save(local);
}
}
// Ask to put the project in a lifecycle environment
//
MessageBox box = new MessageBox(HopGui.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.Lifecycle.Dialog.Header"));
box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.Lifecycle.Dialog.Message1") + Const.CR + BaseMessages.getString(PKG, "ProjectGuiPlugin.Lifecycle.Dialog.Message2"));
int anwser = box.open();
if ((anwser & SWT.YES) != 0) {
addNewEnvironment();
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.AddProject.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.AddProject.Error.Dialog.Message"), e);
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ProjectsGuiPlugin method deleteSelectedEnvironment.
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_ENVIRONMENT_DELETE, toolTip = "i18n::HopGui.Toolbar.Environment.Delete.Tooltip", image = "environment-delete.svg", separator = true)
public void deleteSelectedEnvironment() {
Combo combo = getEnvironmentsCombo();
if (combo == null) {
return;
}
String environmentName = combo.getText();
if (StringUtils.isEmpty(environmentName)) {
return;
}
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
LifecycleEnvironment environment = config.findEnvironment(environmentName);
if (environment == null) {
return;
}
MessageBox box = new MessageBox(HopGui.getInstance().getShell(), SWT.YES | SWT.NO | SWT.ICON_QUESTION);
box.setText(BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteEnvironment.Dialog.Header"));
box.setMessage(BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteEnvironment.Dialog.Message1", environmentName) + Const.CR + BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteEnvironment.Dialog.Message2", environment.getProjectName()));
int anwser = box.open();
if ((anwser & SWT.YES) != 0) {
try {
config.removeEnvironment(environmentName);
ProjectsConfigSingleton.saveConfig();
refreshEnvironmentsList();
selectEnvironmentInList(null);
} catch (Exception e) {
new ErrorDialog(HopGui.getInstance().getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteEnvironment.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.DeleteEnvironment.Error.Dialog.Message", environmentName), e);
}
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ProjectsGuiPlugin method addNewEnvironment.
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_ENVIRONMENT_ADD, toolTip = "i18n::HopGui.Toolbar.Environment.Add.Tooltip", image = "environment-add.svg")
public void addNewEnvironment() {
HopGui hopGui = HopGui.getInstance();
try {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
// The default is the active project
String projectName = getProjectsCombo().getText();
LifecycleEnvironment environment = new LifecycleEnvironment(null, "", projectName, new ArrayList<>());
LifecycleEnvironmentDialog dialog = new LifecycleEnvironmentDialog(hopGui.getShell(), environment, hopGui.getVariables());
String environmentName = dialog.open();
if (environmentName != null) {
config.addEnvironment(environment);
ProjectsConfigSingleton.saveConfig();
refreshEnvironmentsList();
selectEnvironmentInList(environmentName);
ProjectConfig projectConfig = config.findProjectConfig(projectName);
if (projectConfig != null) {
Project project = projectConfig.loadProject(hopGui.getVariables());
enableHopGuiProject(projectName, project, environment);
}
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.AddEnvironment.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.AddEnvironment.Error.Dialog.Message"), e);
}
}
Aggregations