use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class HopGuiDirectoryOpenSetDefaultFolder method callExtensionPoint.
@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, HopGuiDirectoryDialogExtension ext) throws HopException {
String projectName = HopNamespace.getNamespace();
if (StringUtil.isEmpty(projectName)) {
return;
}
//
if (ext.directoryDialog != null && StringUtils.isNotEmpty(ext.directoryDialog.getFilterPath())) {
return;
}
try {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
ProjectConfig projectConfig = config.findProjectConfig(projectName);
if (projectConfig == null) {
return;
}
String homeFolder = projectConfig.getProjectHome();
if (homeFolder != null) {
IDirectoryDialog dialog = ext.getDirectoryDialog();
dialog.setFilterPath(homeFolder);
}
} catch (Exception e) {
log.logError("Error setting default folder for project " + projectName, e);
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class HopImportCreateProjectIfNotExists method callExtensionPoint.
@Override
public void callExtensionPoint(ILogChannel iLogChannel, IVariables variables, String projectPath) throws HopException {
String projectName = "Hop Import Project";
String envName = "Hop Import Environment";
HopGui hopGui = HopGui.getInstance();
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
// create new project
if (!StringUtil.isEmpty(projectPath)) {
String defaultProjectConfigFilename = variables.resolve(config.getDefaultProjectConfigFile());
ProjectConfig projectConfig = new ProjectConfig(projectName, projectPath, defaultProjectConfigFilename);
Project project = new Project();
project.getDescribedVariables().clear();
project.modifyVariables(variables, projectConfig, Collections.emptyList(), null);
project.setConfigFilename(projectPath + System.getProperty("file.separator") + "project-config.json");
config.addProjectConfig(projectConfig);
HopConfig.getInstance().saveToFile();
project.saveToFile();
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ManageLifecyclesOptionPlugin method createLifecycle.
private void createLifecycle(ILogChannel log) throws Exception {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
validateLifecycleNameSpecified();
log.logBasic("Creating project lifecycle '" + lifecycleName + "'");
ProjectLifecycle lifecycle = config.findLifecycle(lifecycleName);
if (lifecycle != null) {
throw new HopException("Project lifecycle '" + lifecycleName + "' already exists.");
}
lifecycle = new ProjectLifecycle();
lifecycle.setName(lifecycleName);
if (lifecycleEnvironments != null) {
lifecycle.getLifecycleEnvironments().addAll(Arrays.asList(lifecycleEnvironments));
}
if (configFilenames != null) {
lifecycle.getConfigurationFiles().addAll(Arrays.asList(configFilenames));
}
config.addLifecycle(lifecycle);
HopConfig.getInstance().saveToFile();
log.logBasic("Project lifecycle '" + lifecycleName + "' was created.");
log.logBasic("Details after creation:");
logLifecycleDetails(log, lifecycle);
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class Project method verifyProjectsChain.
/**
* Let's check to see if there isn't an infinite loop in the project definition
*
* @throws HopException
*/
public void verifyProjectsChain(String projectName, IVariables variables) throws HopException {
//
if (StringUtils.isEmpty(parentProjectName)) {
return;
}
if (parentProjectName.equals(projectName)) {
throw new HopException("Parent project '" + parentProjectName + "' can not be the same as the project itself");
}
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
String realParentProjectName = variables.resolve(parentProjectName);
List<String> projectsList = new ArrayList<>();
while (StringUtils.isNotEmpty(realParentProjectName)) {
projectsList.add(realParentProjectName);
ProjectConfig projectConfig = config.findProjectConfig(realParentProjectName);
if (projectConfig != null) {
Project parentProject = projectConfig.loadProject(variables);
if (parentProject == null) {
// Can't be loaded, break out of the loop
realParentProjectName = null;
} else {
//
if (StringUtils.isEmpty(parentProject.parentProjectName)) {
// We're done
realParentProjectName = null;
} else {
realParentProjectName = variables.resolve(parentProject.parentProjectName);
if (StringUtils.isNotEmpty(realParentProjectName)) {
//
if (projectsList.contains(realParentProjectName)) {
throw new HopException("There is a loop in the parent projects hierarchy: project " + realParentProjectName + " references itself");
}
}
}
}
} else {
// Project not found: config error, stop looking
realParentProjectName = null;
}
}
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ProjectsGuiPlugin method editEnvironment.
// ////////////////////////////////////////////////////////////////////////////////
// Environment toolbar items...
//
// ////////////////////////////////////////////////////////////////////////////////
@GuiToolbarElement(root = HopGui.ID_MAIN_TOOLBAR, id = ID_TOOLBAR_ENVIRONMENT_LABEL, type = GuiToolbarElementType.LABEL, label = "i18n::HopGui.Toolbar.Environment.Label", toolTip = "i18n::HopGui.Toolbar.Environment.Tooltip", separator = true)
public void editEnvironment() {
HopGui hopGui = HopGui.getInstance();
Combo combo = getEnvironmentsCombo();
if (combo == null) {
return;
}
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
String environmentName = combo.getText();
if (StringUtils.isEmpty(environmentName)) {
return;
}
LifecycleEnvironment environment = config.findEnvironment(environmentName);
if (environment == null) {
return;
}
try {
LifecycleEnvironmentDialog dialog = new LifecycleEnvironmentDialog(hopGui.getShell(), environment, hopGui.getVariables());
if (dialog.open() != null) {
config.addEnvironment(environment);
ProjectsConfigSingleton.saveConfig();
refreshEnvironmentsList();
selectEnvironmentInList(environmentName);
}
//
if (dialog.isNeedingEnvironmentRefresh() && askAboutProjectRefresh(hopGui)) {
// Refresh the loaded environment
//
selectEnvironment();
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "ProjectGuiPlugin.EditEnvironment.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectGuiPlugin.EditEnvironment.Error.Dialog.Message", environmentName), e);
}
}
Aggregations