Search in sources :

Example 11 with ProjectsConfig

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;
}
Also used : ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig)

Example 12 with ProjectsConfig

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);
}
Also used : ProjectConfig(org.apache.hop.projects.project.ProjectConfig) HopException(org.apache.hop.core.exception.HopException) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig)

Example 13 with ProjectsConfig

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;
}
Also used : ProjectConfig(org.apache.hop.projects.project.ProjectConfig) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig)

Example 14 with ProjectsConfig

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.");
}
Also used : HopException(org.apache.hop.core.exception.HopException) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig)

Example 15 with ProjectsConfig

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);
    }
}
Also used : HopException(org.apache.hop.core.exception.HopException) ProjectsConfig(org.apache.hop.projects.config.ProjectsConfig) HopException(org.apache.hop.core.exception.HopException)

Aggregations

ProjectsConfig (org.apache.hop.projects.config.ProjectsConfig)33 HopException (org.apache.hop.core.exception.HopException)22 ProjectConfig (org.apache.hop.projects.project.ProjectConfig)20 HopGui (org.apache.hop.ui.hopgui.HopGui)12 IOException (java.io.IOException)11 Project (org.apache.hop.projects.project.Project)11 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)11 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 GuiToolbarElement (org.apache.hop.core.gui.plugin.toolbar.GuiToolbarElement)10 LifecycleEnvironment (org.apache.hop.projects.environment.LifecycleEnvironment)9 Combo (org.eclipse.swt.widgets.Combo)9 FileObject (org.apache.commons.vfs2.FileObject)4 MessageBox (org.eclipse.swt.widgets.MessageBox)4 HopExtensionPoint (org.apache.hop.core.extension.HopExtensionPoint)3 AuditEvent (org.apache.hop.history.AuditEvent)3 LifecycleEnvironmentDialog (org.apache.hop.projects.environment.LifecycleEnvironmentDialog)3 ProjectDialog (org.apache.hop.projects.project.ProjectDialog)3 GuiToolbarWidgets (org.apache.hop.ui.core.gui.GuiToolbarWidgets)3 OutputStream (java.io.OutputStream)2 ArrayList (java.util.ArrayList)2