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);
}
}
}
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"));
}
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;
}
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);
}
}
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));
}
}
Aggregations