Switch to unified view

a/src/net/timbusproject/extractors/TavernaExtractor.java b/src/net/timbusproject/extractors/TavernaExtractor.java
...
...
18
18
19
package net.timbusproject.extractors;
19
package net.timbusproject.extractors;
20
20
21
import java.awt.Dimension;
21
import java.awt.Dimension;
22
import java.awt.Point;
22
import java.awt.Point;
23
import java.io.BufferedReader;
24
import java.io.File;
23
import java.io.*;
25
import java.io.FileWriter;
26
import java.io.IOException;
27
import java.io.InputStream;
28
import java.io.InputStreamReader;
29
import java.io.StringWriter;
30
import java.net.URL;
24
import java.net.URL;
31
import java.nio.file.Files;
25
import java.nio.file.Files;
26
import java.nio.file.InvalidPathException;
32
import java.nio.file.Path;
27
import java.nio.file.Path;
33
import java.nio.file.Paths;
28
import java.nio.file.Paths;
34
import java.util.ArrayList;
29
import java.util.ArrayList;
35
import java.util.Collections;
30
import java.util.Collections;
36
import java.util.HashMap;
31
import java.util.HashMap;
...
...
47
import javax.xml.xpath.XPathConstants;
42
import javax.xml.xpath.XPathConstants;
48
import javax.xml.xpath.XPathExpression;
43
import javax.xml.xpath.XPathExpression;
49
import javax.xml.xpath.XPathExpressionException;
44
import javax.xml.xpath.XPathExpressionException;
50
import javax.xml.xpath.XPathFactory;
45
import javax.xml.xpath.XPathFactory;
51
46
47
import edu.emory.mathcs.backport.java.util.Arrays;
52
import net.sf.taverna.t2.activities.beanshell.BeanshellActivity;
48
import net.sf.taverna.t2.activities.beanshell.BeanshellActivity;
53
import net.sf.taverna.t2.activities.beanshell.BeanshellActivityConfigurationBean;
49
import net.sf.taverna.t2.activities.beanshell.BeanshellActivityConfigurationBean;
54
import net.sf.taverna.t2.activities.dataflow.DataflowActivity;
50
import net.sf.taverna.t2.activities.dataflow.DataflowActivity;
55
import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
51
import net.sf.taverna.t2.activities.externaltool.ExternalToolActivity;
56
import net.sf.taverna.t2.activities.externaltool.ExternalToolActivityConfigurationBean;
52
import net.sf.taverna.t2.activities.externaltool.ExternalToolActivityConfigurationBean;
...
...
338
            npe.printStackTrace();
334
            npe.printStackTrace();
339
            LOGGER.error("ERROR reading workflow from [" + inputFileName + "]." + npe.getMessage());
335
            LOGGER.error("ERROR reading workflow from [" + inputFileName + "]." + npe.getMessage());
340
            return;
336
            return;
341
        }
337
        }
342
338
339
340
        // current classpath
341
        String classpath = System.getProperty("java.class.path");
342
        String[] classpathEntries = classpath.split(File.pathSeparator);
343
        List<String> cleanClasspathEntries = cleanedClasspath(Arrays.asList(classpathEntries));
344
343
        factory = IArchimateFactory.eINSTANCE;
345
        factory = IArchimateFactory.eINSTANCE;
344
346
345
        IArchimateModel model = factory.createArchimateModel();
347
        IArchimateModel model = factory.createArchimateModel();
346
        model.setDefaults();
348
        model.setDefaults();
347
        model.setName("Converted Taverna Workflow " + inputFileName);
349
        model.setName("Converted Taverna Workflow " + inputFileName);
...
...
352
        infrastructureFolder = model.getFolder(FolderType.TECHNOLOGY);
354
        infrastructureFolder = model.getFolder(FolderType.TECHNOLOGY);
353
        motivationFolder = model.getFolder(FolderType.MOTIVATION);
355
        motivationFolder = model.getFolder(FolderType.MOTIVATION);
354
        applicationFolder = model.getFolder(FolderType.APPLICATION);
356
        applicationFolder = model.getFolder(FolderType.APPLICATION);
355
        relationsFolder = model.getFolder(FolderType.RELATIONS);
357
        relationsFolder = model.getFolder(FolderType.RELATIONS);
356
358
357
        // LAYERD VIEWS
359
        // LAYERED VIEWS
358
        layeredView = factory.createArchimateDiagramModel();
360
        layeredView = factory.createArchimateDiagramModel();
359
        layeredView.setName("Layered View");
361
        layeredView.setName("Layered View");
360
        layeredView.setViewpoint(IViewpoint.LAYERED_VIEWPOINT);
362
        layeredView.setViewpoint(IViewpoint.LAYERED_VIEWPOINT);
361
        diagramFolder.getElements().add(layeredView);
363
        diagramFolder.getElements().add(layeredView);
362
364
...
...
969
                beanshellScriptDep.getProperties().add(jarLocation);
971
                beanshellScriptDep.getProperties().add(jarLocation);
970
972
971
                // do proper checking whether the file exists !
973
                // do proper checking whether the file exists !
972
                Path pathToDep = Paths.get(fileName);
974
                Path pathToDep = Paths.get(fileName);
973
                if (Files.exists(pathToDep)) {
975
                if (Files.exists(pathToDep)) {
974
                    String license = null;
975
976
                    license = licenseCheck.extract(pathToDep.toAbsolutePath().toString());
976
                    String license = licenseCheck.extract(pathToDep.toAbsolutePath().toString());
977
977
978
                    if (license.equals("Unknown license")) {
978
                    if (license.equals("Unknown license")) {
979
                        LOGGER.debug("\t Unknown license for dependency [" + item + "].");
979
                        LOGGER.debug("\t Unknown license for dependency [" + item + "].");
980
                    }
980
                    }
981
981
...
...
1786
        return inputsNumber;
1786
        return inputsNumber;
1787
    }
1787
    }
1788
1788
1789
    private boolean isDotAvailable() {
1789
    private boolean isDotAvailable() {
1790
1790
1791
        // TODO improve checking if DOT is available on system.
1792
        if (dotLocation != null && !dotLocation.isEmpty()) {
1791
        if (dotLocation != null && !dotLocation.isEmpty()) {
1792
1793
            try {
1794
                Paths.get(dotLocation);
1795
            }catch(InvalidPathException ipe){
1796
                return false;
1797
            }
1793
            return true;
1798
            return true;
1794
        }
1799
        }
1795
        return false;
1800
        return false;
1796
    }
1801
    }
1797
1802
...
...
1878
                }
1883
                }
1879
            }
1884
            }
1880
        }
1885
        }
1881
    }
1886
    }
1882
1887
1888
1889
    private List<String> cleanedClasspath(List<String> classpathEntries){
1890
1891
        List<String> cleanedClasspathEntries = new ArrayList<String>();
1892
1893
        for(String entry : classpathEntries)
1894
            if(entry.contains("taverna-2."))
1895
                cleanedClasspathEntries.add(entry);
1896
1897
1898
        return cleanedClasspathEntries;
1899
    }
1900
1883
    private URL getJarLocationOfClass(Class clazz) {
1901
    private URL getJarLocationOfClass(Class clazz) {
1884
        return clazz.getProtectionDomain().getCodeSource().getLocation();
1902
        return clazz.getProtectionDomain().getCodeSource().getLocation();
1885
    }
1903
    }
1886
1904
1887
    public void treatProcessors(List<? extends Processor> processors) {
1905
    public void treatProcessors(List<? extends Processor> processors) {