Search in sources :

Example 1 with HopDataOrchestrationPerspective

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);
    }
}
Also used : IHopFileTypeHandler(org.apache.hop.ui.hopgui.file.IHopFileTypeHandler) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopException(org.apache.hop.core.exception.HopException) HopConfigException(org.apache.hop.core.exception.HopConfigException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) HopGuiPipelineGraph(org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph)

Example 2 with HopDataOrchestrationPerspective

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);
    }
}
Also used : DummyMeta(org.apache.hop.pipeline.transforms.dummy.DummyMeta) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) PipelineHopMeta(org.apache.hop.pipeline.PipelineHopMeta) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) PipelineLoggingMeta(org.apache.hop.reflection.pipeline.transform.PipelineLoggingMeta) HopPipelineFileType(org.apache.hop.ui.hopgui.file.pipeline.HopPipelineFileType) PipelineMeta(org.apache.hop.pipeline.PipelineMeta)

Example 3 with HopDataOrchestrationPerspective

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);
    }
}
Also used : PipelineDataProbeMeta(org.apache.hop.reflection.probe.transform.PipelineDataProbeMeta) DummyMeta(org.apache.hop.pipeline.transforms.dummy.DummyMeta) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) PipelineHopMeta(org.apache.hop.pipeline.PipelineHopMeta) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) HopPipelineFileType(org.apache.hop.ui.hopgui.file.pipeline.HopPipelineFileType) PipelineMeta(org.apache.hop.pipeline.PipelineMeta)

Example 4 with HopDataOrchestrationPerspective

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);
        }
    }
}
Also used : GitGuiPlugin(org.apache.hop.git.GitGuiPlugin) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) InputStream(java.io.InputStream) UIGit(org.apache.hop.git.model.UIGit) HopException(org.apache.hop.core.exception.HopException) HopFileException(org.apache.hop.core.exception.HopFileException) FileSystemException(org.apache.commons.vfs2.FileSystemException) PipelineMeta(org.apache.hop.pipeline.PipelineMeta)

Example 5 with HopDataOrchestrationPerspective

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);
    }
}
Also used : GitGuiPlugin(org.apache.hop.git.GitGuiPlugin) HopDataOrchestrationPerspective(org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective) ErrorDialog(org.apache.hop.ui.core.dialog.ErrorDialog) UIGit(org.apache.hop.git.model.UIGit) HopException(org.apache.hop.core.exception.HopException) HopFileException(org.apache.hop.core.exception.HopFileException) FileSystemException(org.apache.commons.vfs2.FileSystemException)

Aggregations

HopDataOrchestrationPerspective (org.apache.hop.ui.hopgui.perspective.dataorch.HopDataOrchestrationPerspective)18 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)10 HopException (org.apache.hop.core.exception.HopException)9 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)9 HopPipelineFileType (org.apache.hop.ui.hopgui.file.pipeline.HopPipelineFileType)5 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)4 IHopFileTypeHandler (org.apache.hop.ui.hopgui.file.IHopFileTypeHandler)4 TabItemHandler (org.apache.hop.ui.hopgui.perspective.TabItemHandler)4 WorkflowMeta (org.apache.hop.workflow.WorkflowMeta)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)3 HopFileException (org.apache.hop.core.exception.HopFileException)3 GitGuiPlugin (org.apache.hop.git.GitGuiPlugin)3 UIGit (org.apache.hop.git.model.UIGit)3 PipelineHopMeta (org.apache.hop.pipeline.PipelineHopMeta)3 DummyMeta (org.apache.hop.pipeline.transforms.dummy.DummyMeta)3 InputStream (java.io.InputStream)2 NotePadMeta (org.apache.hop.core.NotePadMeta)2 IHasFilename (org.apache.hop.core.file.IHasFilename)2 HopGui (org.apache.hop.ui.hopgui.HopGui)2 HopGuiPipelineGraph (org.apache.hop.ui.hopgui.file.pipeline.HopGuiPipelineGraph)2