use of org.apache.hop.ui.core.dialog.ErrorDialog in project hop by apache.
the class DataSetEditor method editData.
protected void editData() {
// If the row count is too high, we don't want to load it into memory...
// Too high simply means: above the preview size...
//
int previewSize = PropsUi.getInstance().getDefaultPreviewSize();
try {
verifySettings();
DataSet set = new DataSet();
getWidgetsContent(set);
// get rows from the data set...
//
List<Object[]> rows = set.getAllRows(manager.getVariables(), LogChannel.UI);
IRowMeta fieldsRowMeta = set.getSetRowMeta();
boolean written = false;
while (!written) {
try {
EditRowsDialog editRowsDialog = new EditRowsDialog(getShell(), SWT.NONE, BaseMessages.getString(PKG, "DataSetDialog.EditRows.Title"), BaseMessages.getString(PKG, "DataSetDialog.EditRows.Message", set.getName()), fieldsRowMeta, rows);
List<Object[]> newList = editRowsDialog.open();
if (newList != null) {
FileObject setFolder = HopVfs.getFileObject(set.getActualDataSetFolder(manager.getVariables()));
boolean folderExists = setFolder.exists();
if (!folderExists) {
MessageBox box = new MessageBox(getShell(), SWT.YES | SWT.NO | SWT.CANCEL | SWT.ICON_QUESTION);
box.setText("Create data sets folder?");
box.setMessage("The data sets folder does not exist. Do you want to create it?" + Const.CR + set.getActualDataSetFolder(manager.getVariables()));
int answer = box.open();
if ((answer & SWT.YES) != 0) {
setFolder.createFolder();
folderExists = true;
} else if ((answer & SWT.CANCEL) != 0) {
break;
}
}
//
if (folderExists) {
DataSetCsvUtil.writeDataSetData(manager.getVariables(), set, fieldsRowMeta, newList);
written = true;
}
} else {
// User hit cancel
break;
}
} catch (Exception e) {
new ErrorDialog(getShell(), "Error", "Error writing data to dataset file " + set.getActualDataSetFilename(manager.getVariables()), e);
}
}
} catch (Exception e) {
new ErrorDialog(getShell(), "Error", "Error previewing data from dataset table", e);
}
}
use of org.apache.hop.ui.core.dialog.ErrorDialog in project hop by apache.
the class PipelineUnitTestSetLocationDialog method getData.
public void getData() {
wTransformName.setText(Const.NVL(location.getTransformName(), ""));
try {
wDataset.fillItems();
} catch (Exception e) {
new ErrorDialog(shell, "Error", "Error getting data sets from the metadata", e);
}
wDataset.setText(Const.NVL(location.getDataSetName(), ""));
for (int i = 0; i < location.getFieldMappings().size(); i++) {
PipelineUnitTestFieldMapping fieldMapping = location.getFieldMappings().get(i);
int colnr = 1;
wFieldMappings.setText(Const.NVL(fieldMapping.getTransformFieldName(), ""), colnr++, i);
wFieldMappings.setText(Const.NVL(fieldMapping.getDataSetFieldName(), ""), colnr++, i);
}
wFieldMappings.removeEmptyRows();
wFieldMappings.setRowNums();
wFieldMappings.optWidth(true);
for (int i = 0; i < location.getFieldOrder().size(); i++) {
String field = location.getFieldOrder().get(i);
int colnr = 1;
wFieldOrder.setText(Const.NVL(field, ""), colnr++, i);
}
wFieldOrder.removeEmptyRows();
wFieldOrder.setRowNums();
wFieldOrder.optWidth(true);
wTransformName.setFocus();
}
use of org.apache.hop.ui.core.dialog.ErrorDialog in project hop by apache.
the class PipelineUnitTestSetLocationDialog method getSortFields.
protected void getSortFields() {
try {
String datasetName = wDataset.getText();
if (StringUtils.isEmpty(datasetName)) {
throw new HopException("Please select a data set to get order fields from");
}
DataSet dataSet = findDataSet(datasetName);
IRowMeta setRowMeta = dataSet.getSetRowMeta();
String[] setFieldNames = setRowMeta.getFieldNames();
wFieldOrder.clearAll();
for (String setFieldName : setFieldNames) {
TableItem item = new TableItem(wFieldOrder.table, SWT.NONE);
item.setText(1, setFieldName);
}
wFieldOrder.removeEmptyRows();
wFieldOrder.setRowNums();
wFieldOrder.optWidth(true);
} catch (Exception e) {
new ErrorDialog(shell, "Error", "Error getting sort fields", e);
}
}
use of org.apache.hop.ui.core.dialog.ErrorDialog in project hop by apache.
the class HopNeo4jPerspective method refreshResults.
private void refreshResults() {
// See if logging is enabled
//
ILogChannel log = hopGui.getLog();
String searchName = wExecutions.getText();
int amount = Const.toInt(wAmount.getText(), 50);
boolean onlyRoot = wOnlyRoot.getSelection();
try {
final NeoConnection connection = findLoggingConnection();
if (connection == null) {
wUsedConnection.setText("");
return;
}
wUsedConnection.setText(Const.NVL(connection.getName(), ""));
log.logDetailed("Logging workflow information to Neo4j connection : " + connection.getName());
Map<String, Object> resultsParameters = new HashMap<>();
final StringBuilder resultsCypher = new StringBuilder();
resultsCypher.append("MATCH(e:Execution) ");
resultsCypher.append("WHERE e.type in [ 'PIPELINE', 'WORKFLOW' ] ");
if (StringUtils.isNotEmpty(searchName)) {
resultsCypher.append("AND e.name = $name ");
resultsParameters.put("name", searchName);
}
if (onlyRoot) {
resultsCypher.append("AND e.root = true ");
}
resultsCypher.append("RETURN e.id, e.name, e.type, e.linesRead, e.linesWritten, e.linesInput, e.linesOutput, e.linesRejected, e.errors, e.executionStart, e.durationMs ");
resultsCypher.append("ORDER BY e.executionStart desc ");
resultsCypher.append("LIMIT " + amount);
wResults.clearAll(false);
try (Driver driver = connection.getDriver(log, hopGui.getVariables())) {
try (Session session = connection.getSession(log, driver, hopGui.getVariables())) {
session.readTransaction(tx -> {
Result result = tx.run(resultsCypher.toString(), resultsParameters);
while (result.hasNext()) {
Record record = result.next();
TableItem item = new TableItem(wResults.table, SWT.NONE);
int pos = 0;
Value vId = record.get(pos++);
item.setText(pos, Const.NVL(vId.asString(), ""));
Value vName = record.get(pos++);
item.setText(pos, Const.NVL(vName.asString(), ""));
Value vType = record.get(pos++);
item.setText(pos, Const.NVL(vType.asString(), ""));
Value vLinesRead = record.get(pos++);
item.setText(pos, Long.toString(vLinesRead.asLong(0)));
Value vLinesWritten = record.get(pos++);
item.setText(pos, Long.toString(vLinesWritten.asLong(0)));
Value vLinesInput = record.get(pos++);
item.setText(pos, Long.toString(vLinesInput.asLong(0)));
Value vLinesOutput = record.get(pos++);
item.setText(pos, Long.toString(vLinesOutput.asLong(0)));
Value vLinesRejected = record.get(pos++);
item.setText(pos, Long.toString(vLinesRejected.asLong(0)));
Value vErrors = record.get(pos++);
long errors = vErrors.asLong(0);
item.setText(pos, Long.toString(vErrors.asLong(0)));
Value vExecutionStart = record.get(pos++);
item.setText(pos, Const.NVL(vExecutionStart.asString(), "").replace("T", " "));
Value vDurationMs = record.get(pos++);
String durationHMS = LoggingCore.getFancyDurationFromMs(Long.valueOf(vDurationMs.asLong(0)));
item.setText(pos, durationHMS);
if (errors != 0) {
item.setBackground(errorLineBackground);
}
}
wResults.removeEmptyRows();
wResults.setRowNums();
wResults.optWidth(true);
return null;
});
// Also populate the executions combo box for pipelines and workflows
//
String execCypher = "match(e:Execution) where e.type in ['PIPELINE', 'WORKFLOW'] return distinct e.name order by e.name";
session.readTransaction(tx -> {
List<String> list = new ArrayList<>();
Result result = tx.run(execCypher);
while (result.hasNext()) {
Record record = result.next();
Value value = record.get(0);
list.add(value.asString());
}
wExecutions.setItems(list.toArray(new String[0]));
return null;
});
}
} finally {
wExecutions.setText(Const.NVL(searchName, ""));
}
} catch (Throwable e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.ErrorSearching.Dialog.Header"), BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.ErrorSearching.Dialog.Message"), e);
}
}
use of org.apache.hop.ui.core.dialog.ErrorDialog in project hop by apache.
the class HopNeo4jPerspective method openTransform.
private void openTransform(Session session, String name, String type, String id) {
LogChannel.UI.logDetailed("Open transform : " + id + ", name : " + name + ", type: " + type);
Map<String, Object> params = new HashMap<>();
params.put("subjectName", name);
params.put("subjectType", type);
params.put("subjectId", id);
StringBuilder cypher = new StringBuilder();
cypher.append(// TRANSFORM
"MATCH(e:Execution { name : $subjectName, type : $subjectType, id : $subjectId } )");
cypher.append(// Transform
"-[:EXECUTION_OF_TRANSFORM]->(t:Transform { name : $subjectName } )");
cypher.append("-[:TRANSFORM_OF_PIPELINE]->(p:Pipeline) ");
cypher.append("RETURN p.filename, t.name ");
String[] names = session.readTransaction(tx -> {
Result statementResult = tx.run(cypher.toString(), params);
if (!statementResult.hasNext()) {
statementResult.consume();
// No file found
return null;
}
Record record = statementResult.next();
statementResult.consume();
String filename = LoggingCore.getStringValue(record, 0);
String transformName = LoggingCore.getStringValue(record, 1);
return new String[] { filename, transformName };
});
if (names == null) {
return;
}
String filename = names[0];
String transformName = names[1];
if (StringUtils.isEmpty(filename)) {
return;
}
try {
hopGui.fileDelegate.fileOpen(filename);
if (StringUtils.isEmpty(transformName)) {
return;
}
HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
IHopFileTypeHandler typeHandler = perspective.getActiveFileTypeHandler();
if (typeHandler == null || !(typeHandler instanceof HopGuiPipelineGraph)) {
return;
}
HopGuiPipelineGraph graph = (HopGuiPipelineGraph) typeHandler;
PipelineMeta pipelineMeta = graph.getPipelineMeta();
TransformMeta transformMeta = pipelineMeta.findTransform(transformName);
if (transformMeta == null) {
return;
}
pipelineMeta.unselectAll();
transformMeta.setSelected(true);
graph.editTransform(pipelineMeta, transformMeta);
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.OpeningTransform.Dialog.Header"), BaseMessages.getString(PKG, "Neo4jPerspectiveDialog.OpeningTransform.Dialog.Message"), e);
}
}
Aggregations