Search in sources :

Example 1 with VariableValueDescription

use of org.apache.hop.core.variables.VariableValueDescription in project hop by apache.

the class PipelineEngineFactory method applyVariableDefinitions.

/**
 * Apply all the variables in the pipeline run configuration... //
 *
 * @param pipelineEngine
 * @param configurationVariables
 * @param <T>
 */
private static <T extends PipelineMeta> void applyVariableDefinitions(IPipelineEngine<T> pipelineEngine, List<VariableValueDescription> configurationVariables) {
    for (VariableValueDescription cv : configurationVariables) {
        if (StringUtils.isNotEmpty(cv.getValue()) && StringUtils.isNotEmpty(cv.getName())) {
            String realValue = pipelineEngine.resolve(cv.getValue());
            pipelineEngine.setVariable(cv.getName(), realValue);
        }
    }
}
Also used : VariableValueDescription(org.apache.hop.core.variables.VariableValueDescription)

Example 2 with VariableValueDescription

use of org.apache.hop.core.variables.VariableValueDescription in project hop by apache.

the class BeamDirectPipelineEngineTest method testDirectPipelineEngine.

@Test
public void testDirectPipelineEngine() throws Exception {
    IPipelineEngineRunConfiguration configuration = new BeamDirectPipelineRunConfiguration();
    configuration.setEnginePluginId("BeamDirectPipelineEngine");
    PipelineRunConfiguration pipelineRunConfiguration = new PipelineRunConfiguration("direct", "description", Arrays.asList(new VariableValueDescription("VAR1", "value1", "description1")), configuration);
    metadataProvider.getSerializer(PipelineRunConfiguration.class).save(pipelineRunConfiguration);
    PipelineMeta pipelineMeta = BeamPipelineMetaUtil.generateBeamInputOutputPipelineMeta("input-process-output", "INPUT", "OUTPUT", metadataProvider);
    IPipelineEngine<PipelineMeta> engine = createAndExecutePipeline(pipelineRunConfiguration.getName(), metadataProvider, pipelineMeta);
    validateInputOutputEngineMetrics(engine);
    assertEquals("value1", engine.getVariable("VAR1"));
}
Also used : IPipelineEngineRunConfiguration(org.apache.hop.pipeline.config.IPipelineEngineRunConfiguration) VariableValueDescription(org.apache.hop.core.variables.VariableValueDescription) PipelineRunConfiguration(org.apache.hop.pipeline.config.PipelineRunConfiguration) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) BeamBasePipelineEngineTest(org.apache.hop.beam.engines.BeamBasePipelineEngineTest) Test(org.junit.Test)

Example 3 with VariableValueDescription

use of org.apache.hop.core.variables.VariableValueDescription in project hop by apache.

the class PipelineRunConfigurationSearchableAnalyser method search.

@Override
public List<ISearchResult> search(ISearchable<PipelineRunConfiguration> searchable, ISearchQuery searchQuery) {
    PipelineRunConfiguration runConfig = searchable.getSearchableObject();
    String component = getMetadataComponent();
    List<ISearchResult> results = new ArrayList<>();
    matchProperty(searchable, results, searchQuery, "Pipeline run configuration name", runConfig.getName(), component);
    matchProperty(searchable, results, searchQuery, "Pipeline run configuration description", runConfig.getDescription(), component);
    // 
    for (VariableValueDescription configurationVariable : runConfig.getConfigurationVariables()) {
        matchProperty(searchable, results, searchQuery, "Pipeline run configuration variable name", configurationVariable.getName(), null);
        matchProperty(searchable, results, searchQuery, "Pipeline run configuration variable value", configurationVariable.getValue(), null);
        matchProperty(searchable, results, searchQuery, "Pipeline run configuration variable description", configurationVariable.getDescription(), null);
    }
    // Analyze the configuration plugin fields
    // 
    matchObjectFields(searchable, results, searchQuery, runConfig.getEngineRunConfiguration(), "Pipeline run configuration property", null);
    return results;
}
Also used : VariableValueDescription(org.apache.hop.core.variables.VariableValueDescription) PipelineRunConfiguration(org.apache.hop.pipeline.config.PipelineRunConfiguration) ArrayList(java.util.ArrayList)

Example 4 with VariableValueDescription

use of org.apache.hop.core.variables.VariableValueDescription in project hop by apache.

the class ProjectsGuiPlugin method enableHopGuiProject.

public static void enableHopGuiProject(String projectName, Project project, LifecycleEnvironment environment) throws HopException {
    try {
        HopGui hopGui = HopGui.getInstance();
        // Before we switch the namespace in HopGui, save the state of the perspectives
        // 
        hopGui.auditDelegate.writeLastOpenFiles();
        // 
        if (!hopGui.fileDelegate.saveGuardAllFiles()) {
            // Abort the project change
            return;
        }
        // Close 'm all
        // 
        hopGui.fileDelegate.closeAllFiles();
        // This is called only in HopGui so we want to start with a new set of variables
        // It avoids variables from one project showing up in another
        // 
        IVariables variables = Variables.getADefaultVariableSpace();
        // See if there's an environment associated with the current project
        // In that case, apply the variables in those files
        // 
        List<String> configurationFiles = new ArrayList<>();
        if (environment != null) {
            configurationFiles.addAll(environment.getConfigurationFiles());
        }
        // Set the variables and give HopGui the new metadata provider(s) for the project.
        // 
        String environmentName = environment == null ? null : environment.getName();
        ProjectsUtil.enableProject(hopGui.getLog(), projectName, project, variables, configurationFiles, environmentName, hopGui);
        // HopGui now has a new metadata provider set.
        // Only now we can get the variables from the defined run configs.
        // Set them with default values just to make them show up.
        // 
        IHopMetadataSerializer<PipelineRunConfiguration> runConfigSerializer = hopGui.getMetadataProvider().getSerializer(PipelineRunConfiguration.class);
        for (PipelineRunConfiguration runConfig : runConfigSerializer.loadAll()) {
            for (VariableValueDescription variableValueDescription : runConfig.getConfigurationVariables()) {
                variables.setVariable(variableValueDescription.getName(), "");
            }
        }
        // We need to change the currently set variables in the newly loaded files
        // 
        hopGui.setVariables(variables);
        // Re-open last open files for the namespace
        // 
        hopGui.auditDelegate.openLastFiles();
        // Clear last used, fill it with something useful.
        // 
        IVariables hopGuiVariables = Variables.getADefaultVariableSpace();
        hopGui.setVariables(hopGuiVariables);
        for (String variable : variables.getVariableNames()) {
            String value = variables.getVariable(variable);
            if (!variable.startsWith(Const.INTERNAL_VARIABLE_PREFIX)) {
                hopGuiVariables.setVariable(variable, value);
            }
        }
        // Refresh the currently active file
        // 
        hopGui.getActivePerspective().getActiveFileTypeHandler().updateGui();
        // Update the toolbar combos
        // 
        ProjectsGuiPlugin.selectProjectInList(projectName);
        ProjectsGuiPlugin.selectEnvironmentInList(environment == null ? null : environment.getName());
        // Also add this as an event so we know what the project usage history is
        // 
        AuditEvent prjUsedEvent = new AuditEvent(ProjectsUtil.STRING_PROJECTS_AUDIT_GROUP, ProjectsUtil.STRING_PROJECT_AUDIT_TYPE, projectName, "open", new Date());
        AuditManager.getActive().storeEvent(prjUsedEvent);
        // Now use that event to refresh the list...
        // 
        refreshProjectsList();
        ProjectsGuiPlugin.selectProjectInList(projectName);
        if (environment != null) {
            // Also add this as an event so we know what the project usage history is
            // 
            AuditEvent envUsedEvent = new AuditEvent(ProjectsUtil.STRING_PROJECTS_AUDIT_GROUP, ProjectsUtil.STRING_ENVIRONMENT_AUDIT_TYPE, environment.getName(), "open", new Date());
            AuditManager.getActive().storeEvent(envUsedEvent);
        }
        // Send out an event notifying that a new project is activated...
        // The metadata has changed so fire those events as well
        // 
        hopGui.getEventsHandler().fire(projectName, HopGuiEvents.ProjectActivated.name());
        hopGui.getEventsHandler().fire(projectName, HopGuiEvents.MetadataChanged.name());
        // Inform the outside world that we're enabled an other project
        // 
        ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, hopGuiVariables, HopExtensionPoint.HopGuiProjectAfterEnabled.name(), project);
    } catch (Exception e) {
        throw new HopException("Error enabling project '" + projectName + "' in HopGui", e);
    }
}
Also used : VariableValueDescription(org.apache.hop.core.variables.VariableValueDescription) HopException(org.apache.hop.core.exception.HopException) IVariables(org.apache.hop.core.variables.IVariables) LocalPipelineRunConfiguration(org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration) PipelineRunConfiguration(org.apache.hop.pipeline.config.PipelineRunConfiguration) AuditEvent(org.apache.hop.history.AuditEvent) HopException(org.apache.hop.core.exception.HopException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) HopGui(org.apache.hop.ui.hopgui.HopGui)

Example 5 with VariableValueDescription

use of org.apache.hop.core.variables.VariableValueDescription in project hop by apache.

the class PipelineRunConfigurationEditor method getWidgetsContent.

@Override
public void getWidgetsContent(PipelineRunConfiguration meta) {
    meta.setName(wName.getText());
    meta.setDescription(wDescription.getText());
    // 
    if (meta.getEngineRunConfiguration() != null && guiCompositeWidgets != null && !guiCompositeWidgets.getWidgetsMap().isEmpty()) {
        guiCompositeWidgets.getWidgetsContents(meta.getEngineRunConfiguration(), PipelineRunConfiguration.GUI_PLUGIN_ELEMENT_PARENT_ID);
    }
    // The variables
    // 
    meta.getConfigurationVariables().clear();
    for (int i = 0; i < wVariables.nrNonEmpty(); i++) {
        TableItem item = wVariables.getNonEmpty(i);
        String name = item.getText(1);
        String value = item.getText(2);
        String description = item.getText(3);
        meta.getConfigurationVariables().add(new VariableValueDescription(name, value, description));
    }
}
Also used : VariableValueDescription(org.apache.hop.core.variables.VariableValueDescription)

Aggregations

VariableValueDescription (org.apache.hop.core.variables.VariableValueDescription)8 PipelineRunConfiguration (org.apache.hop.pipeline.config.PipelineRunConfiguration)5 BeamBasePipelineEngineTest (org.apache.hop.beam.engines.BeamBasePipelineEngineTest)3 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)3 Test (org.junit.Test)3 IPipelineEngineRunConfiguration (org.apache.hop.pipeline.config.IPipelineEngineRunConfiguration)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 HopException (org.apache.hop.core.exception.HopException)1 IVariables (org.apache.hop.core.variables.IVariables)1 AuditEvent (org.apache.hop.history.AuditEvent)1 LocalPipelineRunConfiguration (org.apache.hop.pipeline.engines.local.LocalPipelineRunConfiguration)1 HopGui (org.apache.hop.ui.hopgui.HopGui)1 Ignore (org.junit.Ignore)1