use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ProjectsUtil method projectExists.
/**
* Returns true if given project exists
*
* @param projectName
* @return
*/
public static boolean projectExists(String projectName) {
boolean prjFound = false;
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
List<String> prjs = config.listProjectConfigNames();
Iterator<String> iPrj = prjs.iterator();
while (!prjFound && iPrj.hasNext()) {
String p = iPrj.next();
prjFound = p.equals(projectName);
}
return prjFound;
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ProjectsUtil method enableProject.
/**
* Enable the specified project Force reload of a number of settings
*
* @param log the log channel to log to
* @param projectName
* @param project
* @param variables
* @param configurationFiles
* @throws HopException
* @throws HopException
*/
public static void enableProject(ILogChannel log, String projectName, Project project, IVariables variables, List<String> configurationFiles, String environmentName, IHasHopMetadataProvider hasHopMetadataProvider) throws HopException {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
ProjectConfig projectConfig = config.findProjectConfig(projectName);
if (projectConfig == null) {
throw new HopException("Error enabling project " + projectName + ": it is not configured.");
}
// Variable system variables but also apply them to variables
// We'll use those to change the loaded variables in HopGui
//
project.modifyVariables(variables, projectConfig, configurationFiles, environmentName);
//
if (hasHopMetadataProvider != null) {
hasHopMetadataProvider.setMetadataProvider(HopMetadataUtil.getStandardHopMetadataProvider(variables));
}
// We store the project in the namespace singleton (used mainly in the GUI)
//
HopNamespace.setNamespace(projectName);
// Save some history concerning the usage of the project...
//
AuditManager.registerEvent(HopGui.DEFAULT_HOP_GUI_NAMESPACE, STRING_PROJECT_AUDIT_TYPE, projectName, "open");
// Signal others that we have a new active project
//
ExtensionPointHandler.callExtensionPoint(log, variables, Defaults.EXTENSION_POINT_PROJECT_ACTIVATED, projectName);
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ExplorerPerspectiveRoot method callExtensionPoint.
@Override
public void callExtensionPoint(ILogChannel log, IVariables variables, ExplorerPerspective.DetermineRootFolderExtension ext) throws HopException {
// Get the current project...
//
String projectName = HopNamespace.getNamespace();
if (StringUtil.isEmpty(projectName)) {
return;
}
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
ProjectConfig projectConfig = config.findProjectConfig(projectName);
if (projectConfig == null) {
return;
}
ext.rootFolder = variables.resolve(projectConfig.getProjectHome());
ext.rootName = projectName;
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ManageLifecyclesOptionPlugin method deleteLifecycle.
private void deleteLifecycle(ILogChannel log) throws Exception {
validateLifecycleNameSpecified();
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
validateLifecycleNameSpecified();
ProjectLifecycle lifecycle = config.findLifecycle(lifecycleName);
if (lifecycle == null) {
throw new HopException("Project lifecycle '" + lifecycleName + "' doesn't exists, it can't be deleted");
}
config.removeLifecycle(lifecycleName);
HopConfig.getInstance().saveToFile();
log.logBasic("Project lifecycle '" + lifecycleName + "' was delete.");
}
use of org.apache.hop.projects.config.ProjectsConfig in project hop by apache.
the class ManageProjectsOptionPlugin method handleOption.
@Override
public boolean handleOption(ILogChannel log, IHasHopMetadataProvider hasHopMetadataProvider, IVariables variables) throws HopException {
ProjectsConfig config = ProjectsConfigSingleton.getConfig();
try {
boolean changed = false;
if (createProject) {
createProject(log, config, variables);
changed = true;
} else if (modifyProject) {
modifyProject(log, config, variables);
changed = true;
} else if (deleteProject) {
deleteProject(log, config, variables);
changed = true;
} else if (listProjects) {
listProjects(log, config, variables);
changed = true;
} else if (StringUtils.isNotEmpty(metadataJsonFilename)) {
exportMetadataToJson(log, config, variables, hasHopMetadataProvider);
changed = true;
}
return changed;
} catch (Exception e) {
throw new HopException("Error handling environment configuration options", e);
}
}
Aggregations