use of org.apache.hop.core.config.DescribedVariable in project hop by apache.
the class ProjectDialog method getData.
private void getData() {
wName.setText(Const.NVL(projectConfig.getProjectName(), ""));
wHome.setText(Const.NVL(projectConfig.getProjectHome(), ""));
wConfigFile.setText(Const.NVL(projectConfig.getConfigFilename(), ""));
wDescription.setText(Const.NVL(project.getDescription(), ""));
wCompany.setText(Const.NVL(project.getCompany(), ""));
wDepartment.setText(Const.NVL(project.getDepartment(), ""));
wMetadataBaseFolder.setText(Const.NVL(project.getMetadataBaseFolder(), ""));
wUnitTestsBasePath.setText(Const.NVL(project.getUnitTestsBasePath(), ""));
wDataSetCsvFolder.setText(Const.NVL(project.getDataSetsCsvFolder(), ""));
wEnforceHomeExecution.setSelection(project.isEnforcingExecutionInHome());
for (int i = 0; i < project.getDescribedVariables().size(); i++) {
DescribedVariable describedVariable = project.getDescribedVariables().get(i);
TableItem item = wVariables.table.getItem(i);
item.setText(1, Const.NVL(describedVariable.getName(), ""));
item.setText(2, Const.NVL(describedVariable.getValue(), ""));
item.setText(3, Const.NVL(describedVariable.getDescription(), ""));
}
wVariables.setRowNums();
wVariables.optWidth(true);
//
try {
wParentProject.setText(Const.NVL(project.getParentProjectName(), ""));
List<String> names = ProjectsConfigSingleton.getConfig().listProjectConfigNames();
if (projectConfig.getProjectName() != null) {
names.remove(projectConfig.getProjectName());
}
wParentProject.setItems(names.toArray(new String[0]));
} catch (Exception e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "ProjectDialog.ProjectList.Error.Dialog.Header"), BaseMessages.getString(PKG, "ProjectDialog.ProjectList.Error.Dialog.Message"), e);
}
}
use of org.apache.hop.core.config.DescribedVariable in project hop by apache.
the class ManageConfigFileOptionPlugin method handleOption.
@Override
public boolean handleOption(ILogChannel log, IHasHopMetadataProvider hasHopMetadataProvider, IVariables variables) throws HopException {
String realConfigFile = variables.resolve(configFile);
if (StringUtils.isEmpty(realConfigFile)) {
return false;
}
try {
boolean changed = false;
DescribedVariablesConfigFile variablesConfigFile = new DescribedVariablesConfigFile(realConfigFile);
if (HopVfs.fileExists(realConfigFile)) {
variablesConfigFile.readFromFile();
}
//
if (configSetVariables != null && configSetVariables.length > 0) {
for (String varValue : configSetVariables) {
int equalsIndex = varValue.indexOf("=");
if (equalsIndex > 0) {
String variableName = varValue.substring(0, equalsIndex);
String variableValue = varValue.substring(equalsIndex + 1);
DescribedVariable describedVariable = variablesConfigFile.findDescribedVariable(variableName);
if (describedVariable == null) {
describedVariable = new DescribedVariable(variableName, variableValue, "");
} else {
describedVariable.setValue(variableValue);
}
variablesConfigFile.setDescribedVariable(describedVariable);
changed = true;
}
}
}
//
if (configDescribeVariables != null && configDescribeVariables.length > 0) {
for (String varDesc : configDescribeVariables) {
int equalsIndex = varDesc.indexOf("=");
if (equalsIndex > 0) {
String variableName = varDesc.substring(0, equalsIndex);
String variableDescription = varDesc.substring(equalsIndex + 1);
DescribedVariable describedVariable = variablesConfigFile.findDescribedVariable(variableName);
if (describedVariable == null) {
describedVariable = new DescribedVariable(variableName, null, variableDescription);
} else {
describedVariable.setDescription(variableDescription);
}
variablesConfigFile.setDescribedVariable(describedVariable);
changed = true;
}
}
}
if (changed) {
variablesConfigFile.saveToFile();
log.logBasic("Configuration file '" + configFile + "' was modified.");
}
return changed;
} catch (Exception e) {
throw new HopException("Error managing a configuration file", e);
}
}
use of org.apache.hop.core.config.DescribedVariable in project hop by apache.
the class ManageProjectsOptionPlugin method modifyProjectSettings.
private boolean modifyProjectSettings(Project project) {
boolean changed = false;
if (StringUtils.isNotEmpty(projectParent)) {
project.setParentProjectName(projectParent);
changed = true;
}
if (StringUtils.isNotEmpty(projectDescription)) {
project.setDescription(projectDescription);
changed = true;
}
if (StringUtils.isNotEmpty(projectCompany)) {
project.setCompany(projectCompany);
changed = true;
}
if (StringUtils.isNotEmpty(projectDepartment)) {
project.setDepartment(projectDepartment);
changed = true;
}
if (StringUtils.isNotEmpty(projectMetadataBaseFolder)) {
project.setMetadataBaseFolder(projectMetadataBaseFolder);
changed = true;
}
if (StringUtils.isNotEmpty(projectUnitTestsBasePath)) {
project.setUnitTestsBasePath(projectUnitTestsBasePath);
changed = true;
}
if (StringUtils.isNotEmpty(projectDataSetsCsvFolder)) {
project.setDataSetsCsvFolder(projectDataSetsCsvFolder);
changed = true;
}
if (StringUtils.isNotEmpty(projectEnforceExecutionInHome)) {
boolean enabled = "y".equalsIgnoreCase(projectEnforceExecutionInHome) || "true".equalsIgnoreCase(projectEnforceExecutionInHome);
project.setEnforcingExecutionInHome(enabled);
changed = true;
}
if (projectVariables != null) {
for (String projectVariable : projectVariables) {
int equalsIndex = projectVariable.indexOf("=");
if (equalsIndex > 0) {
String varName = projectVariable.substring(0, equalsIndex);
String varValue = projectVariable.substring(equalsIndex + 1);
DescribedVariable describedVariable = new DescribedVariable(varName, varValue, "");
project.setDescribedVariable(describedVariable);
changed = true;
}
}
}
return changed;
}
use of org.apache.hop.core.config.DescribedVariable in project hop by apache.
the class DescribedVariableSearchableAnalyser method search.
@Override
public List<ISearchResult> search(ISearchable<DescribedVariable> searchable, ISearchQuery searchQuery) {
DescribedVariable describedVariable = searchable.getSearchableObject();
List<ISearchResult> results = new ArrayList<>();
matchProperty(searchable, results, searchQuery, "variable name", describedVariable.getName(), describedVariable.getName());
matchProperty(searchable, results, searchQuery, "variable value", describedVariable.getValue(), describedVariable.getName());
matchProperty(searchable, results, searchQuery, "variable description", describedVariable.getDescription(), describedVariable.getName());
return results;
}
use of org.apache.hop.core.config.DescribedVariable in project hop by apache.
the class HopVariablesList method init.
public static void init() throws HopException {
instance = new HopVariablesList();
InputStream inputStream = null;
try {
HopVariablesList variablesList = getInstance();
inputStream = variablesList.getClass().getResourceAsStream(Const.HOP_VARIABLES_FILE);
if (inputStream == null) {
inputStream = variablesList.getClass().getResourceAsStream("/" + Const.HOP_VARIABLES_FILE);
}
if (inputStream == null) {
throw new HopPluginException("Unable to find standard hop variables definition file: " + Const.HOP_VARIABLES_FILE);
}
Document doc = XmlHandler.loadXmlFile(inputStream, null, false, false);
Node varsNode = XmlHandler.getSubNode(doc, "hop-variables");
int nrVars = XmlHandler.countNodes(varsNode, "hop-variable");
for (int i = 0; i < nrVars; i++) {
Node varNode = XmlHandler.getSubNodeByNr(varsNode, "hop-variable", i);
String description = XmlHandler.getTagValue(varNode, "description");
String variable = XmlHandler.getTagValue(varNode, "variable");
String defaultValue = XmlHandler.getTagValue(varNode, "default-value");
instance.defaultVariables.add(new DescribedVariable(variable, defaultValue, description));
}
} catch (Exception e) {
throw new HopException("Unable to read file '" + Const.HOP_VARIABLES_FILE + "'", e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// we do not able to close property file will log it
LogChannel.GENERAL.logDetailed("Unable to close file hop variables definition file", e);
}
}
}
}
Aggregations