Package eu.scape_project.planning.services.taverna.generator

Examples of eu.scape_project.planning.services.taverna.generator.T2FlowExecutablePlanGenerator


     * @param author
     *            the plan author
     */
    public MyExperimentExecutablePlanGenerator(final String name, final String author) {
        this.name = name;
        generator = new T2FlowExecutablePlanGenerator(name, author);
        generator.addSourcePort();
        generator.addTargetPort();
    }
View Full Code Here


    public Future<DigitalObject> generateExecutablePlan(final String planName, final Alternative alternative,
        final List<String> measures, final String sourceMimetype, final String targetMimetype) throws PlanningException {
        DigitalObject workflow = new DigitalObject();

        String name = planName + " - " + alternative.getName();
        T2FlowExecutablePlanGenerator generator = new T2FlowExecutablePlanGenerator(name, user.getFullName());

        // Add ports
        generator.addSourcePort();
        generator.addTargetPort();

        // Migration action
        PreservationActionDefinition action = alternative.getAction();
        if (action != null) {
            try {
                WorkflowDescription wf = MyExperimentRESTClient.getWorkflow(action.getDescriptor());
                HashMap<String, String> parameters = new HashMap<String, String>();
                for (Parameter p : action.getParams()) {
                    parameters.put(p.getName(), p.getValue());
                }
                wf.readMetadata();
                String workflowContent = MyExperimentRESTClient.getWorkflowContent(wf);
                generator.setMigrationComponent(wf, workflowContent, parameters);
            } catch (Exception e) {
                log.warn("An error occured querying myExperiment migration component.", e.getMessage());
                throw new PlanningException("An error occured querying myExperiment migration component", e);
            }
        }

        // Add QA components
        addQaComponents(generator, measures, sourceMimetype, targetMimetype);

        // Create digital object
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        OutputStreamWriter writer = new OutputStreamWriter(out);

        try {
            generator.generate(writer);
        } catch (IOException e) {
            log.warn("An error occured generating the executable plan.", e.getMessage());
            throw new PlanningException("An error occured generating the executable plan.", e);
        } finally {
            if (writer != null) {
View Full Code Here

    }

    @Test
    public void addQaComponent_mimetypePair_sourceRight_targetLeft() throws IOException, ParserConfigurationException,
        SAXException, DocumentException {
        T2FlowExecutablePlanGenerator planGenerator = new T2FlowExecutablePlanGenerator("Name", "Author", "image/tiff",
            "image/jp2");

        planGenerator.addSourcePort();
        planGenerator.addTargetPort();

        addMigrationMock(planGenerator);

        WorkflowDescription wf = mockQa("QA component");
        when(wf.acceptsMimetypes("image/jp2", "image/tiff")).thenReturn(true);
        when(wf.acceptsLeftMimetype("image/jp2")).thenReturn(true);
        when(wf.acceptsRightMimetype("image/tiff")).thenReturn(true);
        planGenerator.addQaComponent(wf, generateQaContent(QA_DATAFLOW_ID, "QA component"), DEFAULT_PARAMETERS,
            DEFAULT_MEASURES);

        Document doc = getDocument(planGenerator);

        assertThat(
View Full Code Here

    }

    @Test
    public void addQaComponent_mimetypePair_sourceBoth_targetBoth() throws IOException, ParserConfigurationException,
        SAXException, DocumentException {
        T2FlowExecutablePlanGenerator planGenerator = new T2FlowExecutablePlanGenerator("Name", "Author", "image/tiff",
            "image/jp2");

        planGenerator.addSourcePort();
        planGenerator.addTargetPort();

        addMigrationMock(planGenerator);

        WorkflowDescription wf = mockQa("QA component");
        when(wf.acceptsMimetypes("image/jp2", "image/tiff")).thenReturn(true);
        when(wf.acceptsMimetypes("image/tiff", "image/jp2")).thenReturn(true);
        when(wf.acceptsLeftMimetype("image/jp2")).thenReturn(true);
        when(wf.acceptsLeftMimetype("image/tiff")).thenReturn(true);
        when(wf.acceptsRightMimetype("image/jp2")).thenReturn(true);
        when(wf.acceptsRightMimetype("image/tiff")).thenReturn(true);
        planGenerator.addQaComponent(wf, generateQaContent(QA_DATAFLOW_ID, "QA component"), DEFAULT_PARAMETERS,
            DEFAULT_MEASURES);

        Document doc = getDocument(planGenerator);

        assertThat(
View Full Code Here

    }

    @Test
    public void addQaComponent_mimetypePair_sourcePair_targetPair() throws IOException, ParserConfigurationException,
        SAXException, DocumentException {
        T2FlowExecutablePlanGenerator planGenerator = new T2FlowExecutablePlanGenerator("Name", "Author", "image/tiff",
            "image/jp2");

        planGenerator.addSourcePort();
        planGenerator.addTargetPort();

        addMigrationMock(planGenerator);
        WorkflowDescription wf = mockQa("QA component");
        when(wf.acceptsMimetypes("image/tiff", "image/tiff")).thenReturn(true);
        when(wf.acceptsMimetypes("image/jp2", "image/jp2")).thenReturn(true);
        when(wf.acceptsLeftMimetype("image/jp2")).thenReturn(true);
        when(wf.acceptsLeftMimetype("image/tiff")).thenReturn(true);
        when(wf.acceptsRightMimetype("image/jp2")).thenReturn(true);
        when(wf.acceptsRightMimetype("image/tiff")).thenReturn(true);
        planGenerator.addQaComponent(wf, generateQaContent(QA_DATAFLOW_ID, "QA component"), DEFAULT_PARAMETERS,
            DEFAULT_MEASURES);

        Document doc = getDocument(planGenerator);

        assertThat(
View Full Code Here

    }

    @Test
    public void addQaComponent_mimetypePair_sourceLeft_targetNone() throws IOException, ParserConfigurationException,
        SAXException, DocumentException {
        T2FlowExecutablePlanGenerator planGenerator = new T2FlowExecutablePlanGenerator("Name", "Author", "image/tiff",
            "image/jp2");

        planGenerator.addSourcePort();
        planGenerator.addTargetPort();

        addMigrationMock(planGenerator);
        WorkflowDescription wf = mockQa("QA component");
        when(wf.acceptsLeftMimetype("image/tiff")).thenReturn(true);
        planGenerator.addQaComponent(wf, generateQaContent(QA_DATAFLOW_ID, "QA component"), DEFAULT_PARAMETERS,
            DEFAULT_MEASURES);

        Document doc = getDocument(planGenerator);

        assertThat(
View Full Code Here

    }

    @Test
    public void addQaComponent_mimetypePair_sourceRight_targetNone() throws IOException, ParserConfigurationException,
        SAXException, DocumentException {
        T2FlowExecutablePlanGenerator planGenerator = new T2FlowExecutablePlanGenerator("Name", "Author", "image/tiff",
            "image/jp2");

        planGenerator.addSourcePort();
        planGenerator.addTargetPort();

        addMigrationMock(planGenerator);
        WorkflowDescription wf = mockQa("QA component");
        when(wf.acceptsRightMimetype("image/tiff")).thenReturn(true);
        planGenerator.addQaComponent(wf, generateQaContent(QA_DATAFLOW_ID, "QA component"), DEFAULT_PARAMETERS,
            DEFAULT_MEASURES);

        Document doc = getDocument(planGenerator);

        assertThat(
View Full Code Here

    }

    @Test
    public void addQaComponent_mimetypePair_sourceNone_targetLeft() throws IOException, ParserConfigurationException,
        SAXException, DocumentException {
        T2FlowExecutablePlanGenerator planGenerator = new T2FlowExecutablePlanGenerator("Name", "Author", "image/tiff",
            "image/jp2");

        planGenerator.addSourcePort();
        planGenerator.addTargetPort();

        addMigrationMock(planGenerator);
        WorkflowDescription wf = mockQa("QA component");
        when(wf.acceptsLeftMimetype("image/jp2")).thenReturn(true);
        planGenerator.addQaComponent(wf, generateQaContent(QA_DATAFLOW_ID, "QA component"), DEFAULT_PARAMETERS,
            DEFAULT_MEASURES);

        Document doc = getDocument(planGenerator);

        assertThat(
View Full Code Here

    }

    @Test
    public void addQaComponent_mimetypePair_sourceNone_targetRight() throws IOException, ParserConfigurationException,
        SAXException, DocumentException {
        T2FlowExecutablePlanGenerator planGenerator = new T2FlowExecutablePlanGenerator("Name", "Author", "image/tiff",
            "image/jp2");

        planGenerator.addSourcePort();
        planGenerator.addTargetPort();

        addMigrationMock(planGenerator);
        WorkflowDescription wf = mockQa("QA component");
        when(wf.acceptsRightMimetype("image/jp2")).thenReturn(true);
        planGenerator.addQaComponent(wf, generateQaContent(QA_DATAFLOW_ID, "QA component"), DEFAULT_PARAMETERS,
            DEFAULT_MEASURES);

        Document doc = getDocument(planGenerator);

        assertThat(
View Full Code Here

    }

    @Test
    public void addQaComponent_twoComponents() throws IOException, ParserConfigurationException, SAXException,
        DocumentException {
        T2FlowExecutablePlanGenerator planGenerator = new T2FlowExecutablePlanGenerator("Name", "Author", "image/tiff",
            "image/jp2");

        planGenerator.addSourcePort();
        planGenerator.addTargetPort();

        addMigrationMock(planGenerator);
        WorkflowDescription wf1 = mockQaAny("QA component 1");
        planGenerator.addQaComponent(wf1, generateQaContent(QA_DATAFLOW_ID, "QA component 1"), DEFAULT_PARAMETERS,
            DEFAULT_MEASURES);
        WorkflowDescription wf2 = mockQaAny("QA component 2");
        planGenerator.addQaComponent(wf2, generateQaContent(QA_DATAFLOW_ID, "QA component 2"), DEFAULT_PARAMETERS,
            DEFAULT_MEASURES);

        Document doc = getDocument(planGenerator);

        assertThat(
View Full Code Here

TOP

Related Classes of eu.scape_project.planning.services.taverna.generator.T2FlowExecutablePlanGenerator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.