use of org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective 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);
}
}
use of org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective in project hop by apache.
the class PipelineLogEditor method createPipelineFile.
/**
* Create a new pipeline file: ask the user for a name. Add a standard transform and a dummy to
* show how it works.
*
* @param parent
*/
private void createPipelineFile(Composite parent) {
try {
PipelineMeta pipelineMeta = new PipelineMeta();
// Add a Pipeline Logging transform...
//
PipelineLoggingMeta pipelineLoggingMeta = new PipelineLoggingMeta();
pipelineLoggingMeta.setLoggingTransforms(true);
TransformMeta pipelineLogging = new TransformMeta("Pipeline Logging", pipelineLoggingMeta);
pipelineLogging.setLocation(200, 150);
pipelineMeta.addTransform(pipelineLogging);
// Add a dummy
//
DummyMeta dummyMeta = new DummyMeta();
TransformMeta dummy = new TransformMeta("Save logging here", dummyMeta);
dummy.setLocation(500, 150);
pipelineMeta.addTransform(dummy);
// Add a hop between both transforms...
//
pipelineMeta.addPipelineHop(new PipelineHopMeta(pipelineLogging, dummy));
// Save it...
//
HopPipelineFileType<PipelineMeta> type = new HopPipelineFileType<>();
String filename = BaseDialog.presentFileDialog(// save
true, parent.getShell(), wFilename, manager.getVariables(), type.getFilterExtensions(), type.getFilterNames(), true);
if (filename != null) {
// User specified a pipeline filename
//
String realFilename = manager.getVariables().resolve(filename);
pipelineMeta.setFilename(realFilename);
pipelineMeta.clearChanged();
HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
// Switch to the perspective
//
perspective.activate();
// Open it in the Hop GUI
//
HopGui.getDataOrchestrationPerspective().addPipeline(hopGui, pipelineMeta, type);
// Save the file
hopGui.fileDelegate.fileSave();
}
} catch (Exception e) {
new ErrorDialog(parent.getShell(), "Error", "Error creating pipeline", e);
}
}
use of org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective in project hop by apache.
the class PipelineProbeEditor method createPipelineFile.
/**
* Create a new pipeline file: ask the user for a name. Add a standard transform and a dummy to
* show how it works.
*
* @param parent
*/
private void createPipelineFile(Composite parent) {
try {
PipelineMeta pipelineMeta = new PipelineMeta();
// Add a Pipeline Data Probe transform...
//
PipelineDataProbeMeta pipelineDataProbeMeta = new PipelineDataProbeMeta();
pipelineDataProbeMeta.setLoggingTransforms(true);
TransformMeta pipelineLogging = new TransformMeta("Pipeline Data Probe", pipelineDataProbeMeta);
pipelineLogging.setLocation(200, 150);
pipelineMeta.addTransform(pipelineLogging);
// Add a dummy
//
DummyMeta dummyMeta = new DummyMeta();
TransformMeta dummy = new TransformMeta("Process values here", dummyMeta);
dummy.setLocation(500, 150);
pipelineMeta.addTransform(dummy);
// Add a hop between both transforms...
//
pipelineMeta.addPipelineHop(new PipelineHopMeta(pipelineLogging, dummy));
// Save it...
//
HopPipelineFileType<PipelineMeta> type = new HopPipelineFileType<>();
String filename = BaseDialog.presentFileDialog(// save
true, parent.getShell(), wFilename, manager.getVariables(), type.getFilterExtensions(), type.getFilterNames(), true);
if (filename != null) {
// User specified a pipeline filename
//
String realFilename = manager.getVariables().resolve(filename);
pipelineMeta.setFilename(realFilename);
pipelineMeta.clearChanged();
HopDataOrchestrationPerspective perspective = HopGui.getDataOrchestrationPerspective();
// Switch to the perspective
//
perspective.activate();
// Open it in the Hop GUI
//
HopGui.getDataOrchestrationPerspective().addPipeline(hopGui, pipelineMeta, type);
// Save the file
hopGui.fileDelegate.fileSave();
}
} catch (Exception e) {
new ErrorDialog(parent.getShell(), "Error", "Error creating pipeline", e);
}
}
use of org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective in project hop by apache.
the class GitInfoExplorerFileTypeHandler method showPipelineFileDiff.
private void showPipelineFileDiff(String filename, String commitIdNew, String commitIdOld) throws HopException {
GitGuiPlugin guiPlugin = GitGuiPlugin.getInstance();
UIGit git = guiPlugin.getGit();
InputStream xmlStreamOld = null;
InputStream xmlStreamNew = null;
try {
xmlStreamOld = git.open(filename, commitIdOld);
xmlStreamNew = git.open(filename, commitIdNew);
PipelineMeta pipelineMetaOld = new PipelineMeta(xmlStreamOld, hopGui.getMetadataProvider(), true, hopGui.getVariables());
PipelineMeta pipelineMetaNew = new PipelineMeta(xmlStreamNew, hopGui.getMetadataProvider(), true, hopGui.getVariables());
pipelineMetaOld = HopDiff.compareTransforms(pipelineMetaOld, pipelineMetaNew, true);
pipelineMetaOld = HopDiff.comparePipelineHops(pipelineMetaOld, pipelineMetaNew, true);
pipelineMetaNew = HopDiff.compareTransforms(pipelineMetaNew, pipelineMetaOld, false);
pipelineMetaNew = HopDiff.comparePipelineHops(pipelineMetaNew, pipelineMetaOld, false);
pipelineMetaOld.setPipelineVersion("git: " + commitIdOld);
pipelineMetaNew.setPipelineVersion("git: " + commitIdNew);
// Change the name to indicate the git revisions of the file
//
pipelineMetaOld.setName(String.format("%s (%s -> %s)", pipelineMetaOld.getName(), git.getShortenedName(commitIdOld, VCS.TYPE_COMMIT), git.getShortenedName(commitIdNew, VCS.TYPE_COMMIT)));
pipelineMetaOld.setNameSynchronizedWithFilename(false);
pipelineMetaNew.setName(String.format("%s (%s -> %s)", pipelineMetaNew.getName(), git.getShortenedName(commitIdNew, VCS.TYPE_COMMIT), git.getShortenedName(commitIdOld, VCS.TYPE_COMMIT)));
pipelineMetaNew.setNameSynchronizedWithFilename(false);
// Load both in the data orchestration perspective...
//
HopDataOrchestrationPerspective dop = HopGui.getDataOrchestrationPerspective();
dop.addPipeline(hopGui, pipelineMetaOld, dop.getPipelineFileType());
dop.addPipeline(hopGui, pipelineMetaNew, dop.getPipelineFileType());
dop.activate();
} finally {
try {
if (xmlStreamOld != null) {
xmlStreamOld.close();
}
if (xmlStreamNew != null) {
xmlStreamNew.close();
}
} catch (Exception e) {
LogChannel.UI.logError("Error closing XML file after reading", e);
}
}
}
use of org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective in project hop by apache.
the class GitInfoExplorerFileTypeHandler method showHopFileDiff.
public void showHopFileDiff() {
if (wFiles.getSelectionIndices().length == 0) {
return;
}
TableItem fileItem = wFiles.table.getSelection()[0];
String filename = fileItem.getText(1);
if (StringUtils.isEmpty(filename)) {
return;
}
GitGuiPlugin guiPlugin = GitGuiPlugin.getInstance();
UIGit git = guiPlugin.getGit();
try {
// Determine revisions...
//
// A revision/commit was selected...
//
TableItem revisionItem = wRevisions.table.getSelection()[0];
String revisionId = revisionItem.getText(1);
boolean workingTree = VCS.WORKINGTREE.equals(revisionId);
// A file in wFiles was selected...
//
boolean staged = "Y".equalsIgnoreCase(fileItem.getText(3));
String commitIdNew;
String commitIdOld;
if (workingTree) {
commitIdNew = VCS.WORKINGTREE;
commitIdOld = Constants.HEAD;
} else {
commitIdNew = revisionId;
commitIdOld = git.getParentCommitId(revisionId);
if (commitIdOld == null) {
// No parent to compare to
return;
}
}
if (commitIdNew.equals(commitIdOld)) {
// No changes expected
return;
}
HopDataOrchestrationPerspective dop = HopGui.getDataOrchestrationPerspective();
if (dop.getPipelineFileType().isHandledBy(filename, false)) {
// A pipeline
//
showPipelineFileDiff(filename, commitIdNew, commitIdOld);
} else if (dop.getWorkflowFileType().isHandledBy(filename, false)) {
// A workflow
//
showWorkflowFileDiff(filename, commitIdNew, commitIdOld);
}
} catch (Exception e) {
new ErrorDialog(hopGui.getShell(), "Error", "Error while doing visual diff on file : " + filename, e);
}
}
Aggregations