http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-prov/example/test.sparql ---------------------------------------------------------------------- diff --git a/taverna-prov/example/test.sparql b/taverna-prov/example/test.sparql deleted file mode 100644 index 834e332..0000000 --- a/taverna-prov/example/test.sparql +++ /dev/null @@ -1,25 +0,0 @@ -PREFIX prov: <http://www.w3.org/ns/prov#> -PREFIX wfdesc: <http://purl.org/wf4ever/wfdesc#> -PREFIX wfprov: <http://purl.org/wf4ever/wfprov#> -PREFIX tavernaprov: <http://ns.taverna.org.uk/2012/tavernaprov/> -PREFIX cnt: <http://www.w3.org/2011/content#> -PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> -PREFIX wf4ever: <http://purl.org/wf4ever/wf4ever#> - - -SELECT DISTINCT ?paramName ?name ?value ?ended ?script -WHERE { - ?greeting tavernaprov:content <outputs/greeting.txt> . - ?greeting prov:wasGeneratedBy ?concatenate . - ?concatenate prov:endedAtTime ?ended ; - wfprov:wasPartOfWorkflowRun ?run ; - wfprov:describedByProcess ?plan . - ?concatenate wfprov:usedInput ?input . - ?input tavernaprov:content ?name . - OPTIONAL { ?name cnt:chars ?value } . - OPTIONAL { ?plan wf4ever:script ?script } . - ?input wfprov:describedByParameter ?param . - ?plan wfdesc:hasInput ?param . - OPTIONAL { ?param rdfs:label ?paramName } . -} -
http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-prov/pom.xml ---------------------------------------------------------------------- diff --git a/taverna-prov/pom.xml b/taverna-prov/pom.xml deleted file mode 100644 index 2eebd56..0000000 --- a/taverna-prov/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.taverna.engine</groupId> - <artifactId>taverna-engine</artifactId> - <version>3.1.0-incubating-SNAPSHOT</version> - </parent> - <artifactId>taverna-prov</artifactId> - <name>Apache Taverna PROV support</name> - <dependencies> - <dependency> - <groupId>${project.parent.groupId}</groupId> - <artifactId>taverna-database-configuration-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - -<!-- - <dependency> - <groupId>net.sf.taverna.t2.results</groupId> - <artifactId>results</artifactId> - <version>${t2.results.version}</version> - <exclusions> - <exclusion> - <groupId>com.sun</groupId> - <artifactId>tools</artifactId> - </exclusion> - </exclusions> - </dependency> - --> - <dependency> - <groupId>${project.parent.groupId}</groupId> - <artifactId>taverna-provenanceconnector</artifactId> - <version>${project.parent.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.taverna.language</groupId> - <artifactId>taverna-scufl2-api</artifactId> - <version>${taverna.language.version}</version> - </dependency> - <dependency> - <groupId>org.apache.taverna.language</groupId> - <artifactId>taverna-scufl2-rdfxml</artifactId> - <version>${taverna.language.version}</version> - </dependency> - <dependency> - <groupId>org.apache.taverna.language</groupId> - <artifactId>taverna-scufl2-wfdesc</artifactId> - <version>${taverna.language.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.taverna.language</groupId> - <artifactId>taverna-databundle</artifactId> - <version>${taverna.language.version}</version> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>${project.parent.groupId}</groupId> - <artifactId>taverna-prov-owl-bindings</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.apache.tika</groupId> - <artifactId>tika-core</artifactId> - <version>1.4</version> - </dependency> - <dependency> - <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils-core</artifactId> - <version>1.8.3</version> - </dependency> - - </dependencies> - -</project> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/SafeFileOutputStream.java ---------------------------------------------------------------------- diff --git a/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/SafeFileOutputStream.java b/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/SafeFileOutputStream.java deleted file mode 100644 index 3731c76..0000000 --- a/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/SafeFileOutputStream.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.purl.wf4ever.provtaverna.export; - -/** - * Copied out from net.sf.taverna.t2.workbench.file.impl.SafeFileOutputStream - * to avoid dependency on file-impl. - * - * TODO: Move to taverna utils! - * - */ - -import java.io.FileNotFoundException; -import java.io.FilterOutputStream; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.StandardCopyOption; - -public class SafeFileOutputStream extends FilterOutputStream { - - private final Path desiredFile; - private Path tempFile; - boolean desiredAlreadyExisted; - - public SafeFileOutputStream(Path file) throws IOException { - this(file, tempFile(file)); - } - - public SafeFileOutputStream(Path desiredFile, Path tempFile) - throws IOException { - - super(Files.newOutputStream(tempFile)); - this.desiredFile = desiredFile; - this.tempFile = tempFile; - // Some useful things to check that we preferably don't want to fail on - // close() - desiredAlreadyExisted = Files.exists(desiredFile); - Path desiredFolder = this.desiredFile.getParent(); - if (desiredAlreadyExisted) { - if (!Files.isWritable(desiredFile)) { - throw new FileNotFoundException("Can't write to " + desiredFile); - } - } else { - if (!Files.exists(desiredFolder)) { - throw new FileNotFoundException("Folder does not exist: " - + desiredFolder); - } - if (!Files.isDirectory(desiredFolder)) { - throw new FileNotFoundException("Not a directory: " - + desiredFolder); - } - } - if (!Files.isWritable(desiredFolder)) { - throw new FileNotFoundException("Can't modify folder " - + desiredFolder); - } - } - - private static Path tempFile(Path file) throws IOException { - return Files.createTempFile(file.getParent(), file.getFileName() - .toString(), ".tmp"); - } - - @Override - public void close() throws IOException { - // If super.close fails - we leave the tempfiles behind - super.close(); - if (!Files.exists(tempFile)) { - // Probably something went wrong before close called, - // like rollback() - return; - } - Path beforeDeletion = null; - try { - if (desiredAlreadyExisted) { - // In case renaming goes wrong, we don't want to have already - // deleted the - // desired file. So we'll rename it to another temporary file - // instead which - // we can delete on successful rename. - beforeDeletion = tempFile(desiredFile); - if (!Files.deleteIfExists(beforeDeletion)) { - // Should not happen, we just made it! - throw new IOException("Can't delete temporary file " - + beforeDeletion); - } - Files.move(desiredFile, beforeDeletion, - StandardCopyOption.ATOMIC_MOVE); - } - try { - Files.move(tempFile, desiredFile, - StandardCopyOption.ATOMIC_MOVE); - } catch (IOException e) { - // We'll leave our tempFiles for recovery. - tempFile = null; - beforeDeletion = null; - - if (Files.exists(desiredFile)) { - // Someone else added or replaced the file afterwards, - // kind-a OK - return; - } - throw e; - } - } finally { - if (beforeDeletion != null) { - Files.deleteIfExists(beforeDeletion); - } - if (tempFile != null) { - Files.deleteIfExists(tempFile); - } - } - } - - public void rollback() throws IOException { - super.close(); - Files.deleteIfExists(tempFile); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/Saver.java ---------------------------------------------------------------------- diff --git a/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/Saver.java b/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/Saver.java deleted file mode 100644 index c903e98..0000000 --- a/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/Saver.java +++ /dev/null @@ -1,388 +0,0 @@ -package org.purl.wf4ever.provtaverna.export; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.ProtocolException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.DigestOutputStream; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.sf.taverna.t2.invocation.InvocationContext; -import net.sf.taverna.t2.provenance.api.ProvenanceAccess; -import net.sf.taverna.t2.reference.ExternalReferenceSPI; -import net.sf.taverna.t2.reference.ReferenceService; -import net.sf.taverna.t2.reference.ReferenceSet; -import net.sf.taverna.t2.reference.ReferenceSetService; -import net.sf.taverna.t2.reference.T2Reference; -import net.sf.taverna.t2.reference.ValueCarryingExternalReference; -import net.sf.taverna.t2.spi.SPIRegistry; -import net.sf.taverna.t2.workbench.reference.config.DataManagementConfiguration; - -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.io.IOUtils; -import org.apache.log4j.Logger; -import org.apache.tika.Tika; -import org.apache.tika.mime.MimeTypeException; -import org.apache.tika.mime.MimeTypes; -import org.openrdf.rio.RDFParserFactory; -import org.openrdf.rio.RDFParserRegistry; -import org.openrdf.rio.RDFWriterFactory; -import org.openrdf.rio.RDFWriterRegistry; -import org.purl.wf4ever.robundle.Bundle; - -import uk.org.taverna.databundle.DataBundles; - -public class Saver { - - private static final String APPLICATION_OCTET_STREAM = "application/octet-stream"; - - private static Logger logger = Logger.getLogger(Saver.class); - - /** - * @param saveProvAction - */ - public Saver(ReferenceService referenceService, InvocationContext context, - String runId, Map<String, T2Reference> chosenReferences) { - this.setReferenceService(referenceService); - this.setContext(context); - this.setRunId(runId); - this.setChosenReferences(chosenReferences); - prepareSesame(); - } - - /** - * Load - */ - protected void prepareSesame() { - RDFParserRegistry parserReg = RDFParserRegistry.getInstance(); - SPIRegistry<RDFParserFactory> parserSPI = new SPIRegistry<>( - RDFParserFactory.class); - for (RDFParserFactory service : parserSPI.getInstances()) { - parserReg.add(service); - } - - RDFWriterRegistry writerReg = RDFWriterRegistry.getInstance(); - SPIRegistry<RDFWriterFactory> writerSPI = new SPIRegistry<>( - RDFWriterFactory.class); - for (RDFWriterFactory service : writerSPI.getInstances()) { - writerReg.add(service); - } - - } - - private Map<Path, T2Reference> fileToId = new HashMap<>(); - - private Map<Path, String> sha1sums = new HashMap<>(); - private Map<Path, String> sha512sums = new HashMap<>(); - - private ReferenceService referenceService; - - private InvocationContext context; - - private String runId; - - private Map<String, T2Reference> chosenReferences; - - private Bundle bundle; - - private Map<T2Reference, String> mediaTypes = new HashMap<>(); - - /** - * @return the bundle - */ - public Bundle getBundle() { - return bundle; - } - - public void saveData(Path bundlePath) throws FileNotFoundException, - IOException { - Bundle bundle = DataBundles.createBundle(); - // String folderName = bundlePath.getFileName().toString(); - // if (folderName.endsWith(".")) { - // bundlePath = bundlePath.resolveSibling(folderName.substring(0, - // folderName.length() - 1)); - // } - setBundle(bundle); - saveToFolder(bundle.getRoot(), getChosenReferences(), - getReferenceService()); - DataBundles.closeAndSaveBundle(bundle, bundlePath); - } - - private void setBundle(Bundle bundle) { - this.bundle = bundle; - } - - protected static Tika tika = new Tika(); - - public Path saveReference(T2Reference t2Ref, Path file) throws IOException { - ReferenceSetService refSet = getReferenceService() - .getReferenceSetService(); - ReferenceSet referenceSet = refSet.getReferenceSet(t2Ref); - List<ExternalReferenceSPI> externalReferences = new ArrayList<ExternalReferenceSPI>( - referenceSet.getExternalReferences()); - Collections.sort(externalReferences, - new Comparator<ExternalReferenceSPI>() { - public int compare(ExternalReferenceSPI o1, - ExternalReferenceSPI o2) { - return (int) (o1.getResolutionCost() - o2 - .getResolutionCost()); - } - }); - String mimeType = findMimeType(externalReferences); - getMediaTypes().put(t2Ref, mimeType); - - Path targetFile = writeIfLocal(externalReferences, file, mimeType); - if (targetFile == null) { - URI uri = referenceAsURI(externalReferences); - if (uri != null) { - targetFile = DataBundles.setReference(file, uri); - } - } - - if (targetFile != null) { - getFileToId().put(targetFile, t2Ref); - } else { - logger.warn("Could not write out reference " + t2Ref); - } - - return targetFile; - - } - - private Path writeIfLocal(List<ExternalReferenceSPI> externalReferences, - Path file, String mimeType) throws IOException { - - ValueCarryingExternalReference<?> valRef = null; - for (ExternalReferenceSPI ref : externalReferences) { - if (ref instanceof ValueCarryingExternalReference) { - valRef = (ValueCarryingExternalReference<?>) ref; - break; - } - } - - if (valRef == null) { - return null; - } - - String fileExtension; - try { - fileExtension = MimeTypes.getDefaultMimeTypes().forName(mimeType) - .getExtension(); - } catch (MimeTypeException e1) { - fileExtension = ""; - } - Path targetFile = file.resolveSibling(file.getFileName() - + fileExtension); - - MessageDigest sha = null; - MessageDigest sha512 = null; - OutputStream output = Files.newOutputStream(targetFile); - try { - try { - sha = MessageDigest.getInstance("SHA"); - output = new DigestOutputStream(output, sha); - - sha512 = MessageDigest.getInstance("SHA-512"); - output = new DigestOutputStream(output, sha512); - } catch (NoSuchAlgorithmException e) { - logger.info("Could not find digest", e); - } - - IOUtils.copyLarge(valRef.openStream(getContext()), output); - } finally { - output.close(); - } - - if (sha != null) { - getSha1sums().put(targetFile.toRealPath(), hexOfDigest(sha)); - } - if (sha512 != null) { - sha512.digest(); - getSha512sums().put(targetFile.toRealPath(), hexOfDigest(sha512)); - } - - return targetFile; - } - - private URI referenceAsURI(List<ExternalReferenceSPI> externalReferences) { - for (ExternalReferenceSPI ref : externalReferences) { - String className = ref.getClass().getName(); - if (className - .equals("net.sf.taverna.t2.reference.impl.external.http.HttpReference")) { - URL url = (URL) getProperty(ref, "httpUrl"); - try { - return url.toURI(); - } catch (URISyntaxException e) { - logger.warn("Can't convert HttpReference to URI: " + url, e); - continue; - } - } else if (className - .equals("net.sf.taverna.t2.reference.impl.external.file.FileReference")) { - File file = (File) getProperty(ref, "file"); - return file.toURI(); - } else if (className - .equals("de.uni_luebeck.inb.knowarc.usecases.invocation.ssh.SshReference")) { - String host = (String) getProperty(ref, "host"); - int port = (int) getProperty(ref, "port"); - String path = (String) getProperty(ref, "fullPath"); - try { - return new URI("sftp", null, host, port, path, null, null); - } catch (URISyntaxException e) { - logger.warn("Can't convert SshReference to URI: sftp://" - + host + ":" + port + path, e); - continue; - } - } - } - return null; - } - - protected Object getProperty(ExternalReferenceSPI ref, String propertyName) { - try { - return PropertyUtils.getSimpleProperty(ref, propertyName); - } catch (Exception ex) { - throw new IllegalArgumentException("Can't look up " + propertyName - + " in bean " + ref, ex); - } - } - - private String findMimeType(List<ExternalReferenceSPI> externalReferences) - throws IOException, ProtocolException { - String mimeType = null; - for (ExternalReferenceSPI externalReference : externalReferences) { - String className = externalReference.getClass().getName(); - if (className - .equals("net.sf.taverna.t2.reference.impl.external.http.HttpReference")) { - URL url = (URL) getProperty(externalReference, "httpUrl"); - mimeType = tika.detect(url); - } else if (className - .equals("net.sf.taverna.t2.reference.impl.external.file.FileReference")) { - File file = (File) getProperty(externalReference, "file"); - mimeType = tika.detect(file); - } else if (className - .equals("de.uni_luebeck.inb.knowarc.usecases.invocation.ssh.SshReference")) { - String filename = (String) getProperty(externalReference, - "fileName"); - try (InputStream instream = externalReference - .openStream(context)) { - mimeType = tika.detect(instream, filename); - } - } else if (className - .equals("net.sf.taverna.t2.reference.impl.external.object.VMObjectReference")) { - mimeType = "application/x-java-serialized-object"; - } else { - try (InputStream instream = externalReference - .openStream(context)) { - mimeType = tika.detect(instream); - } - } - if (mimeType != null && !mimeType.equals(APPLICATION_OCTET_STREAM)) { - break; - } - } - if (mimeType == null || mimeType.isEmpty()) { - return APPLICATION_OCTET_STREAM; - } - return mimeType; - } - - protected void saveToFolder(Path folder, - Map<String, T2Reference> chosenReferences, - ReferenceService referenceService) throws IOException, - FileNotFoundException { - logger.info("Saving provenance and outputs to " + folder.toRealPath()); - Files.createDirectories(folder); - String connectorType = DataManagementConfiguration.getInstance() - .getConnectorType(); - ProvenanceAccess provenanceAccess = new ProvenanceAccess(connectorType, - getContext()); - W3ProvenanceExport export = new W3ProvenanceExport(provenanceAccess, - getRunId(), this); - export.setFileToT2Reference(getFileToId()); - export.setBundle(bundle); - - try { - logger.debug("Saving provenance"); - export.exportAsW3Prov(); - logger.info("Saved provenance"); - } catch (Exception e) { - logger.error("Failed to save the provenance graph", e); - } - } - - private String hexOfDigest(MessageDigest sha) { - return new String(Hex.encodeHex(sha.digest())); - } - - public ReferenceService getReferenceService() { - return referenceService; - } - - public void setReferenceService(ReferenceService referenceService) { - this.referenceService = referenceService; - } - - public InvocationContext getContext() { - return context; - } - - public void setContext(InvocationContext context) { - this.context = context; - } - - public String getRunId() { - return runId; - } - - public void setRunId(String runId) { - this.runId = runId; - } - - public Map<String, T2Reference> getChosenReferences() { - return chosenReferences; - } - - public void setChosenReferences(Map<String, T2Reference> chosenReferences) { - this.chosenReferences = chosenReferences; - } - - public Map<Path, T2Reference> getFileToId() { - return fileToId; - } - - public void setFileToId(Map<Path, T2Reference> fileToId) { - this.fileToId = fileToId; - } - - public Map<Path, String> getSha1sums() { - return sha1sums; - } - - public Map<T2Reference, String> getMediaTypes() { - return mediaTypes; - } - - public Map<Path, String> getSha512sums() { - return sha512sums; - } - - public void setMediaTypes(Map<T2Reference, String> mediaTypes) { - this.mediaTypes = mediaTypes; - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/W3ProvenanceExport.java ---------------------------------------------------------------------- diff --git a/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/W3ProvenanceExport.java b/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/W3ProvenanceExport.java deleted file mode 100644 index 110ff72..0000000 --- a/taverna-prov/src/main/java/org/purl/wf4ever/provtaverna/export/W3ProvenanceExport.java +++ /dev/null @@ -1,1008 +0,0 @@ -package org.purl.wf4ever.provtaverna.export; - -import static uk.org.taverna.scufl2.translator.t2flow.T2FlowParser.ravenURI; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.lang.reflect.InvocationTargetException; -import java.math.BigDecimal; -import java.net.URI; -import java.nio.charset.Charset; -import java.nio.file.Files; -import java.nio.file.Path; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.GregorianCalendar; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.UUID; - -import javax.xml.datatype.DatatypeConfigurationException; -import javax.xml.datatype.DatatypeFactory; -import javax.xml.datatype.XMLGregorianCalendar; - -import net.sf.taverna.raven.appconfig.ApplicationConfig; -import net.sf.taverna.t2.provenance.api.ProvenanceAccess; -import net.sf.taverna.t2.provenance.lineageservice.URIGenerator; -import net.sf.taverna.t2.provenance.lineageservice.utils.DataflowInvocation; -import net.sf.taverna.t2.provenance.lineageservice.utils.Port; -import net.sf.taverna.t2.provenance.lineageservice.utils.ProcessorEnactment; -import net.sf.taverna.t2.provenance.lineageservice.utils.ProvenanceProcessor; -import net.sf.taverna.t2.provenance.lineageservice.utils.WorkflowRun; -import net.sf.taverna.t2.reference.ErrorDocument; -import net.sf.taverna.t2.reference.IdentifiedList; -import net.sf.taverna.t2.reference.StackTraceElementBean; -import net.sf.taverna.t2.reference.T2Reference; -import net.sf.taverna.t2.reference.T2ReferenceType; -import net.sf.taverna.t2.spi.SPIRegistry; - -import org.apache.commons.beanutils.BeanUtils; -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.jena.riot.RDFDataMgr; -import org.apache.jena.riot.RDFFormat; -import org.apache.jena.riot.WriterGraphRIOT; -import org.apache.jena.riot.system.RiotLib; -import org.apache.log4j.Logger; -import org.purl.wf4ever.provtaverna.owl.TavernaProvModel; -import org.purl.wf4ever.robundle.Bundle; -import org.purl.wf4ever.robundle.manifest.Agent; -import org.purl.wf4ever.robundle.manifest.Manifest; -import org.purl.wf4ever.robundle.manifest.PathAnnotation; -import org.purl.wf4ever.robundle.manifest.PathMetadata; - -import uk.org.taverna.databundle.DataBundles; -import uk.org.taverna.scufl2.api.common.URITools; -import uk.org.taverna.scufl2.api.container.WorkflowBundle; -import uk.org.taverna.scufl2.api.io.ReaderException; -import uk.org.taverna.scufl2.api.io.WorkflowBundleIO; -import uk.org.taverna.scufl2.api.io.WorkflowBundleReader; -import uk.org.taverna.scufl2.api.io.WorkflowBundleWriter; -import uk.org.taverna.scufl2.translator.t2flow.T2FlowReader; - -import com.hp.hpl.jena.datatypes.xsd.XSDDatatype; -import com.hp.hpl.jena.ontology.Individual; -import com.hp.hpl.jena.ontology.OntModel; -import com.hp.hpl.jena.rdf.model.Literal; -import com.hp.hpl.jena.rdf.model.Model; -import com.hp.hpl.jena.rdf.model.ModelFactory; -import com.hp.hpl.jena.sparql.util.Context; -import com.hp.hpl.jena.sparql.vocabulary.FOAF; - -public class W3ProvenanceExport { - - private static URITools uriTools = new URITools(); - - private static final URI osgiURI = URI.create("http://ns.taverna.org.uk/2013/osgibundle/"); - private static final String TEXT = "text/"; - private static final String WORKFLOW_BUNDLE = "application/vnd.taverna.scufl2.workflow-bundle"; - // TODO: Avoid this Taverna 2 dependency - private static SPIRegistry<WorkflowBundleReader> readerSpi = new SPIRegistry<>( - WorkflowBundleReader.class); - private static SPIRegistry<WorkflowBundleWriter> writerSpi = new SPIRegistry<>( - WorkflowBundleWriter.class); - - private static final String EN = "en"; - - private static final int EMBEDDED_MAX_FILESIZE = 1024; - - private static final Charset UTF8 = Charset.forName("UTF-8"); - - private static ApplicationConfig applicationConfig = ApplicationConfig - .getInstance(); - - private static Logger logger = Logger.getLogger(W3ProvenanceExport.class); - - protected Map<T2Reference, Path> seenReferences = new HashMap<>(); - - private static final int NANOSCALE = 9; - - private ProvenanceAccess provenanceAccess; - - private DatatypeFactory datatypeFactory; - - private ProvenanceURIGenerator uriGenerator = new ProvenanceURIGenerator(); - - private String workflowRunId; - - private Map<Path, T2Reference> fileToT2Reference = Collections.emptyMap(); - - private Saver saver; - - private Map<URI, Individual> describedEntities = new HashMap<URI, Individual>(); - - private TavernaProvModel provModel = new TavernaProvModel(); - - public Path getBaseFolder() { - return bundle.getRoot(); - } - - public Map<Path, T2Reference> getFileToT2Reference() { - return fileToT2Reference; - } - - // protected <I> void repopulateRegistry(ServiceRegistry<?, I> registry, - // Class<I> spi) { - // ClassLoader cl = classLoaderForServiceLoader(spi); - // logger.info("Selected classloader " + cl + " for registry of " + spi); - // for (I service : ServiceLoader.load(spi, cl)) { - // registry.add(service); - // } - // } - - // private ClassLoader classLoaderForServiceLoader(Class<?> mustHave) { - // List<ClassLoader> possibles = Arrays.asList(Thread.currentThread() - // .getContextClassLoader(), getClass().getClassLoader(), mustHave - // .getClassLoader()); - // - // for (ClassLoader cl : possibles) { - // if (cl == null) { - // continue; - // } - // try { - // if (cl.loadClass(mustHave.getCanonicalName()) == mustHave) { - // return cl; - // } - // } catch (ClassNotFoundException e) { - // } - // } - // // Final fall-back, the old.. - // return ClassLoader.getSystemClassLoader(); - // } - - public W3ProvenanceExport(ProvenanceAccess provenanceAccess, - String workflowRunId, Saver saver) { - this.saver = saver; - this.setWorkflowRunId(workflowRunId); - this.setProvenanceAccess(provenanceAccess); - - try { - datatypeFactory = DatatypeFactory.newInstance(); - } catch (DatatypeConfigurationException e) { - throw new IllegalStateException( - "Can't find a DatatypeFactory implementation", e); - } - prepareScufl2(); - - } - - protected void prepareScufl2() { - Thread.currentThread().setContextClassLoader( - getClass().getClassLoader()); - wfBundleIO = new WorkflowBundleIO(); - DataBundles.setWfBundleIO(wfBundleIO); - wfBundleIO.setReaders(readerSpi.getInstances()); - wfBundleIO.setWriters(writerSpi.getInstances()); - } - - private final class ProvenanceURIGenerator extends URIGenerator { - - // Make URIs match with Scufl2 - @Override - public String makeWorkflowURI(String workflowID) { - return makeWorkflowBundleURI(workflowRunId) + "workflow/" - + provenanceAccess.getWorkflowNameByWorkflowID(workflowID) - + "/"; - } - - public String makeWorkflowBundleURI(String workflowRunId) { - - return "http://ns.taverna.org.uk/2010/workflowBundle/" - + provenanceAccess.getTopLevelWorkflowID(workflowRunId) - + "/"; - } - - public String makePortURI(String wfId, String pName, String vName, - boolean inputPort) { - String base; - if (pName == null) { - base = makeWorkflowURI(wfId); - } else { - base = makeProcessorURI(pName, wfId); - } - return base + (inputPort ? "in/" : "out/") + escape(vName); - } - - // public String makeDataflowInvocationURI(String workflowRunId, - // String dataflowInvocationId) { - // return makeWFInstanceURI(workflowRunId) + "workflow/" - // + dataflowInvocationId + "/"; - // } - - public String makeProcessExecution(String workflowRunId, - String processEnactmentId) { - return makeWFInstanceURI(workflowRunId) + "process/" - + processEnactmentId + "/"; - } - } - - enum Direction { - INPUTS("in"), OUTPUTS("out"); - private final String path; - - Direction(String path) { - this.path = path; - - } - - public String getPath() { - return path; - } - } - - public void exportAsW3Prov() throws IOException { - - Path provFile = DataBundles.getWorkflowRunProvenance(bundle); - - // TODO: Make this thread safe using contexts? - - GregorianCalendar startedProvExportAt = new GregorianCalendar(); - - runURI = URI.create(uriGenerator.makeWFInstanceURI(getWorkflowRunId())); - - URI provFileUri = toURI(provFile); - Individual bundle = provModel.createBundle(provFileUri); - - // Mini-provenance about this provenance trace. Unkown URI for - // agent/activity - - Individual storeProvenance = provModel.createActivity(provFileUri - .resolve("#taverna-prov-export")); - storeProvenance.setLabel( - "taverna-prov export of workflow run provenance", EN); - - provModel.setStartedAtTime(storeProvenance, startedProvExportAt); - - // The agent is an execution of the Taverna software (e.g. also an - // Activity) - Individual tavernaAgent = provModel.createTavernaEngine(provFileUri - .resolve("#taverna-engine")); - - Individual plan = provModel - .createPlan(getTavernaVersion()); - plan.setLabel(applicationConfig.getTitle(), EN); - - provModel.setWasAssociatedWith(storeProvenance, tavernaAgent, plan); - provModel.setWasGeneratedBy(bundle, storeProvenance); - - Individual wfProcess = provModel.createWorkflowRun(runURI); - - bundle.setPropertyValue(FOAF.primaryTopic, wfProcess); - - DataflowInvocation dataflowInvocation = provenanceAccess - .getDataflowInvocation(getWorkflowRunId()); - - // TODO: Should we go through all of getDataflowInvocations() in order - // to find - // the plans etc. for the nested workflow executions and also cover - // empty - // nested workflow runs? - - String workflowName = provenanceAccess - .getWorkflowNameByWorkflowID(dataflowInvocation.getWorkflowId()); - label(wfProcess, "Workflow run of " + workflowName); - - provModel.setWasInformedBy(storeProvenance, wfProcess); - String wfUri = uriGenerator.makeWorkflowURI(dataflowInvocation - .getWorkflowId()); - Individual wfPlan = provModel.createWorkflow(URI.create(wfUri)); - provModel.setWasEnactedBy(wfProcess, tavernaAgent, wfPlan); - provModel.setDescribedByWorkflow(wfProcess, wfPlan); - - provModel.setStartedAtTime(wfProcess, - timestampToLiteral(dataflowInvocation.getInvocationStarted())); - provModel.setEndedAtTime(wfProcess, - timestampToLiteral(dataflowInvocation.getInvocationEnded())); - - // Workflow inputs and outputs - storeEntitities(dataflowInvocation.getInputsDataBindingId(), wfProcess, - Direction.INPUTS, true); - // FIXME: These entities come out as "generated" by multiple processes - storeEntitities(dataflowInvocation.getOutputsDataBindingId(), - wfProcess, Direction.OUTPUTS, true); - List<ProcessorEnactment> processorEnactments = provenanceAccess - .getProcessorEnactments(getWorkflowRunId()); - // This will also include processor enactments in nested workflows - for (ProcessorEnactment pe : processorEnactments) { - String parentId = pe.getParentProcessorEnactmentId(); - URI parentURI; - if (parentId == null) { - // Top-level workflow - parentURI = runURI; - } else { - // inside nested wf - this will be parent processenactment - parentURI = URI.create(uriGenerator.makeProcessExecution( - pe.getWorkflowRunId(), - pe.getParentProcessorEnactmentId())); - - // TODO: Find plan for nested workflow! - // String wfUri = uriGenerator.makeWorkflowURI(nestedWfId); - // Individual wfPlan = - // provModel.createWorkflow(URI.create(wfUri)); - // provModel.setDescribedByWorkflow(wfProcess, wfPlan); - // provModel.setWasEnactedBy(wfProcess, tavernaAgent, wfPlan); - } - - URI processURI = URI.create(uriGenerator.makeProcessExecution( - pe.getWorkflowRunId(), pe.getProcessEnactmentId())); - - Individual process = provModel.createProcessRun(processURI); - Individual parentProcess = provModel.createWorkflowRun(parentURI); - provModel.setWasPartOfWorkflowRun(process, parentProcess); - - provModel.setStartedAtTime(process, - timestampToLiteral(pe.getEnactmentStarted())); - provModel.setEndedAtTime(process, - timestampToLiteral(pe.getEnactmentEnded())); - - ProvenanceProcessor provenanceProcessor = provenanceAccess - .getProvenanceProcessor(pe.getProcessorId()); - - URI processorURI = URI.create(uriGenerator.makeProcessorURI( - provenanceProcessor.getProcessorName(), - provenanceProcessor.getWorkflowId())); - - label(process, - "Processor execution " - + provenanceProcessor.getProcessorName()); - // The facade identifier is a bit too techie! - // + " (" - // + pe.getProcessIdentifier() + ")"); - Individual procPlan = provModel.createProcess(processorURI); - label(procPlan, - "Processor " + provenanceProcessor.getProcessorName()); - provModel.setWasEnactedBy(process, tavernaAgent, procPlan); - provModel.setDescribedByProcess(process, procPlan); - - URI parentWfUri = URI.create(uriGenerator - .makeWorkflowURI(provenanceProcessor.getWorkflowId())); - - Individual parentWf = provModel.createWorkflow(parentWfUri); - provModel.addSubProcess(parentWf, procPlan); - - // TODO: How to link together iterations on a single processor and - // the collections - // they are iterating over and creating? - // Need 'virtual' ProcessExecution for iteration? - - // TODO: Activity/service details from definition? - - // Inputs and outputs - storeEntitities(pe.getInitialInputsDataBindingId(), process, - Direction.INPUTS, false); - storeEntitities(pe.getFinalOutputsDataBindingId(), process, - Direction.OUTPUTS, false); - } - - storeFileReferences(); - - provModel.setEndedAtTime(storeProvenance, new GregorianCalendar()); - - // provModel.model.write(outStream, "TURTLE", - // provFileUri.toASCIIString()); - - OntModel model = provModel.model; - try (OutputStream outStream = Files.newOutputStream(provFile)) { - WriterGraphRIOT writer = RDFDataMgr - .createGraphWriter(RDFFormat.TURTLE_BLOCKS); - writer.write(outStream, model.getBaseModel().getGraph(), - RiotLib.prefixMap(model.getGraph()), - provFileUri.toString(), new Context()); - } finally { - // Avoid registering the RIOT readers/writers from ARQ, as that - // won't - // work within Raven or OSGi - provModel.resetJena(); - logger.warn("Reset Jena readers and writers"); - } - - byte[] dataflow = getDataflow(dataflowInvocation); - try { - WorkflowBundle wfBundle = wfBundleIO.readBundle( - new ByteArrayInputStream(dataflow), - T2FlowReader.APPLICATION_VND_TAVERNA_T2FLOW_XML); - writeBundle(wfBundle); - } catch (ReaderException e) { - logger.warn("Could not write bundle", e); - } - - } - - private URI getTavernaVersion() { - String versionName = applicationConfig.getName(); - URI tavernaVersion = URI - .create("http://ns.taverna.org.uk/2011/software/" + versionName); - return tavernaVersion; - } - - private byte[] getDataflow(DataflowInvocation dataflowInvocation) { - // you are not going to believe this...! - for (final WorkflowRun run : provenanceAccess.listRuns( - dataflowInvocation.getWorkflowId(), null)) { - if (getWorkflowRunId().equals(run.getWorkflowRunId())) { - return run.getDataflowBlob(); - } - } - throw new IllegalStateException("Can't find dataflow blob for run " - + getWorkflowRunId()); - } - - protected void label(Individual obj, String label) { - obj.setLabel(label, EN); - } - - protected Literal timestampToLiteral(Timestamp timestamp) { - if (timestamp == null) { - return null; - } - GregorianCalendar cal = new GregorianCalendar(); - cal.setTime(timestamp); - XMLGregorianCalendar xmlCal = datatypeFactory - .newXMLGregorianCalendar(cal); - // Chop of the trailing 0-s of non-precission - xmlCal.setFractionalSecond(BigDecimal.valueOf( - timestamp.getNanos() / 1000000, NANOSCALE - 6)); - return provModel.model.createTypedLiteral(xmlCal.toXMLFormat(), - XSDDatatype.XSDdateTime); - } - - private static Map<URI, String> mediaTypes = new HashMap<>(); - - protected void storeFileReferences() { - - for (Entry<Path, T2Reference> entry : getFileToT2Reference().entrySet()) { - Path file = entry.getKey(); - - try { - T2Reference t2Ref = entry.getValue(); - URI dataURI = URI.create(uriGenerator.makeT2ReferenceURI(t2Ref - .toUri().toASCIIString())); - - Individual entity = provModel.createArtifact(dataURI); - - String mediaType = saver.getMediaTypes().get(t2Ref); - - if (!Files.exists(file)) { - continue; - } - URI contentUri; - if (DataBundles.isReference(file)) { - // TODO: Do we really need to read this back again from the - // file? - contentUri = DataBundles.getReference(file); - } else { - contentUri = toURI(file); - } - - Individual content = provModel.setContent(entity, contentUri); - if (mediaType != null) { - mediaTypes.put(contentUri, mediaType); - } - if (!DataBundles.isValue(file)) { - // Don't capture the checksum and content of references and - // lists - continue; - } - - // Add checksums - String sha1 = saver.getSha1sums().get(file.toRealPath()); - if (sha1 != null) { - content.addLiteral(provModel.sha1, sha1); - } - String sha512 = saver.getSha512sums().get(file.toRealPath()); - if (sha512 != null) { - content.addLiteral(provModel.sha512, sha512); - } - long byteCount = Files.size(file); - content.addLiteral(provModel.byteCount, byteCount); - - if (byteCount < EMBEDDED_MAX_FILESIZE) { - // Add content if it's "tiny" - byte[] bytes = Files.readAllBytes(file); - if (mediaType != null && mediaType.startsWith(TEXT)) { - // as string - assuming UTF8 (and declaring so) - String str = new String(bytes, UTF8); - content.addLiteral(provModel.chars, str); - content.addLiteral(provModel.characterEncoding, - UTF8.name()); - content.addRDFType(provModel.ContentAsText); - } else { - // Or base64-encoded bytes - content.addRDFType(provModel.ContentAsBase64); - content.addLiteral(provModel.bytes, bytes); - } - } - } catch (IOException e) { - logger.warn("Could not read " + file + " as " + UTF8, e); - } - } - } - - protected URI toURI(Path file) { - return file.toUri(); - } - - protected void storeEntitities(String dataBindingId, Individual activity, - Direction direction, boolean isTopLevel) throws IOException { - - Map<Port, T2Reference> bindings = provenanceAccess - .getDataBindings(dataBindingId); - - for (Entry<Port, T2Reference> binding : bindings.entrySet()) { - Port port = binding.getKey(); - T2Reference t2Ref = binding.getValue(); - - Individual entity = describeEntity(t2Ref); - - if (isTopLevel) { - Path ports; - if (direction == Direction.INPUTS) { - ports = DataBundles.getInputs(bundle); - } else { - ports = DataBundles.getOutputs(bundle); - } - Path portPath = DataBundles.getPort(ports, port.getPortName()); - saveValue(t2Ref, portPath); - } else if (!seenReference(t2Ref)) { - saveIntermediate(t2Ref); - } - - // String id = t2Ref.getLocalPart(); - // String prefix = id.substring(0, 2); - Individual involvement; - if (direction == Direction.INPUTS) { - involvement = provModel.setUsedInput(activity, entity); - } else { - involvement = provModel.setWasOutputFrom(entity, activity); - } - - String processorName = null; - if (port.getProcessorId() != null) { - // Not a workflow port - ProvenanceProcessor p = provenanceAccess - .getProvenanceProcessor(port.getProcessorId()); - processorName = p.getProcessorName(); - } - URI portURI = URI.create(uriGenerator.makePortURI( - port.getWorkflowId(), processorName, port.getPortName(), - port.isInputPort())); - - Individual portRole; - if (port.isInputPort()) { - portRole = provModel.createInputParameter(portURI); - } else { - portRole = provModel.createOutputParameter(portURI); - } - - portRole.setLabel(port.getPortName(), ""); - if (processorName == null) { - portRole.setComment( - "Workflow" - + (port.isInputPort() ? " input " : " output ") - + port.getPortName(), EN); - } else { - portRole.setComment( - processorName - + (port.isInputPort() ? " input " : " output ") - + port.getPortName(), EN); - } - provModel.setDescribedByParameter(entity, portRole, involvement); - - } - - } - - protected Individual describeEntity(T2Reference t2Ref) throws IOException { - URI dataURI = URI.create(uriGenerator.makeT2ReferenceURI(t2Ref.toUri() - .toASCIIString())); - - Individual artifact = describedEntities.get(dataURI); - if (artifact != null) { - return artifact; - } - artifact = provModel.createArtifact(dataURI); - describedEntities.put(dataURI, artifact); - - if (t2Ref.getReferenceType() == T2ReferenceType.ErrorDocument) { - Individual error = provModel.createError(dataURI); - ErrorDocument errorDoc = saver.getReferenceService() - .getErrorDocumentService().getError(t2Ref); - addMessageIfNonEmpty(error, errorDoc.getMessage()); - // getExceptionMEssage added by addStackTrace - addStackTrace(error, errorDoc); - } else if (t2Ref.getReferenceType() == T2ReferenceType.IdentifiedList) { - IdentifiedList<T2Reference> list = saver.getReferenceService() - .getListService().getList(t2Ref); - Individual dictionary = provModel.createDictionary(dataURI); - - int pos = 0; - for (T2Reference ref : list) { - URI itemURI = URI.create(uriGenerator.makeT2ReferenceURI(ref - .toUri().toASCIIString())); - Individual listItem = provModel.createArtifact(itemURI); - provModel.addKeyPair(dictionary, pos++, listItem); - describeEntity(ref); - } - if (list.isEmpty()) { - artifact.addRDFType(provModel.EmptyCollection); - artifact.addRDFType(provModel.EmptyDictionary); - } - } - - return artifact; - } - - private boolean seenReference(T2Reference t2Ref) { - return seenReferences.containsKey(t2Ref); - } - - private Path saveIntermediate(T2Reference t2Ref) throws IOException { - // Avoid double-saving - Path f = seenReferences.get(t2Ref); - if (f != null) { - return f; - } - Path file = referencePath(t2Ref); - - if (t2Ref.getReferenceType() == T2ReferenceType.IdentifiedList) { - IdentifiedList<T2Reference> list = saver.getReferenceService() - .getListService().getList(t2Ref); - for (T2Reference ref : list) { - saveIntermediate(ref); - } - seenReference(t2Ref, file); - return file; - } else { - return saveValue(t2Ref, file); - } - - } - - private Path saveValue(T2Reference t2Ref, Path file) throws IOException { - Path parent = file.getParent(); - - switch (t2Ref.getReferenceType()) { - - case IdentifiedList: - DataBundles.createList(file); - IdentifiedList<T2Reference> list = saver.getReferenceService() - .getListService().getList(t2Ref); - long position = 0; - for (T2Reference ref : list) { - saveValue(ref, DataBundles.getListItem(file, position++)); - } - break; - case ErrorDocument: - Files.createDirectories(parent); - file = saveError(t2Ref, file); - break; - case ReferenceSet: - Files.createDirectories(parent); - file = saver.saveReference(t2Ref, file); - } - seenReference(t2Ref, file); - return file; - } - - private Path saveError(T2Reference t2Ref, Path file) throws IOException { - ErrorDocument errorDoc = saver.getReferenceService() - .getErrorDocumentService().getError(t2Ref); - - StringBuilder trace = new StringBuilder(); - addStackTrace(trace, errorDoc); - - List<Path> causes = new ArrayList<>(); - for (T2Reference cause : errorDoc.getErrorReferences()) { - causes.add(saveIntermediate(cause)); - } - file = DataBundles.setError(file, errorDoc.getMessage(), - trace.toString(), causes.toArray(new Path[causes.size()])); - return file; - } - - protected void addStackTrace(Individual error, ErrorDocument errorDoc) - throws IOException { - StringBuilder sb = new StringBuilder(); - addStackTrace(sb, errorDoc); - if (sb.length() > 0) { - error.addLiteral(provModel.stackTrace, sb.toString()); - } - - for (T2Reference errRef : errorDoc.getErrorReferences()) { - URI errorURI = URI.create(uriGenerator.makeT2ReferenceURI(errRef - .toUri().toASCIIString())); - Individual nestedErr = provModel.createError(errorURI); - provModel.setWasDerivedFrom(error, nestedErr); - describeEntity(errRef); - } - } - - protected void addStackTrace(StringBuilder sb, ErrorDocument errorDoc) { - if (errorDoc.getExceptionMessage() != null - && !errorDoc.getExceptionMessage().isEmpty()) { - sb.append(errorDoc.getExceptionMessage()); - sb.append("\n"); - } - if (errorDoc.getStackTraceStrings() == null) { - return; - } - if (sb.length() == 0) { - sb.append("Stack trace:\n"); - } - // Attempt to recreate Java stacktrace style - for (StackTraceElementBean trace : errorDoc.getStackTraceStrings()) { - sb.append(" at "); - sb.append(trace.getClassName()); - sb.append("."); - sb.append(trace.getMethodName()); - sb.append("("); - sb.append(trace.getFileName()); - sb.append(":"); - sb.append(trace.getLineNumber()); - sb.append(")"); - sb.append("\n"); - } - } - - protected void addMessageIfNonEmpty(Individual error, String message) { - if (message == null || message.isEmpty()) { - return; - } - error.addLiteral(provModel.errorMessage, message); - } - - private Path referencePath(T2Reference t2Ref) throws IOException { - String local = t2Ref.getLocalPart(); - try { - return DataBundles.getIntermediate(bundle, UUID.fromString(local)); - } catch (IllegalArgumentException ex) { - return DataBundles.getIntermediates(bundle) - .resolve(t2Ref.getNamespacePart()) - .resolve(t2Ref.getLocalPart()); - } - - } - - private boolean seenReference(T2Reference t2Ref, Path file) { - getFileToT2Reference().put(file, t2Ref); - if (seenReference(t2Ref)) { - return true; - } - return seenReferences.put(t2Ref, file) != null; - } - - public ProvenanceAccess getProvenanceAccess() { - return provenanceAccess; - } - - public void setProvenanceAccess(ProvenanceAccess provenanceAccess) { - this.provenanceAccess = provenanceAccess; - } - - public String getWorkflowRunId() { - return workflowRunId; - } - - public void setWorkflowRunId(String workflowRunId) { - this.workflowRunId = workflowRunId; - } - - public void setFileToT2Reference(Map<Path, T2Reference> fileToT2Reference) { - this.fileToT2Reference = new HashMap<>(); - for (Entry<Path, T2Reference> entry : fileToT2Reference.entrySet()) { - seenReference(entry.getValue(), entry.getKey()); - } - } - - private static final String WFDESC = "http://purl.org/wf4ever/wfdesc#"; - private static WorkflowBundleIO wfBundleIO; - private Bundle bundle; - private URI runURI; - - /** - * @return the bundle - */ - public Bundle getBundle() { - return bundle; - } - - public void writeBundle(WorkflowBundle wfBundle) throws IOException { - - Bundle dataBundle = getBundle(); - - // Workflow - DataBundles.setWorkflowBundle(dataBundle, wfBundle); - - // Generate Manifest - // TODO: This should be done automatically on close/save - Manifest manifest = new Manifest(dataBundle); - manifest.populateFromBundle(); - - Path workflowRunProvenance = DataBundles - .getWorkflowRunProvenance(dataBundle); - // Additional metadata - manifest.getAggregation(workflowRunProvenance).setMediatype( - "text/turtle"); - - Agent provPlugin = new Agent(); - provPlugin.setName("Taverna-PROV plugin, " + applicationConfig.getTitle() + " " + applicationConfig.getName()); - provPlugin.setUri(getPluginIdentifier(getClass())); - manifest.getAggregation(workflowRunProvenance).setCreatedBy( - provPlugin); - manifest.setCreatedBy(provPlugin); - - - // Media types: - for (Entry<URI, String> e : mediaTypes.entrySet()) { - URI uri = e.getKey(); - String mediatype = e.getValue(); - PathMetadata aggregation = manifest.getAggregation(uri); - if (aggregation == null) { - // An external reference? Add it. - aggregation = manifest.getAggregation(uri); - //aggregation = new PathMetadata(); - //aggregation.setUri(uri); - //manifest.getAggregates().add(aggregation); - } - aggregation.setMediatype(mediatype); - } - - // Add annotations - - // This RO Bundle is about a run - PathAnnotation bundleAboutRun = new PathAnnotation(); - bundleAboutRun.setAbout(runURI); - bundleAboutRun.setContent(URI.create("/")); - manifest.getAnnotations().add(bundleAboutRun); - - // Also aggregate the run by ID, and that it was done by taverna - Agent taverna = new Agent(); - taverna.setName(applicationConfig.getTitle()); - taverna.setUri(getTavernaVersion()); - manifest.getAggregation(runURI).setCreatedBy(taverna); - - // TODO: Do we need both the "history" link and the annotation below? - manifest.setHistory(Arrays.asList(workflowRunProvenance)); - - // This RO Bundle is described in the provenance file - PathAnnotation provenanceAboutBundle = new PathAnnotation(); - provenanceAboutBundle.setAbout(URI.create("/")); - provenanceAboutBundle.setContent(URI.create(workflowRunProvenance - .toUri().getPath())); - manifest.getAnnotations().add(provenanceAboutBundle); - - // The wfdesc is about the workflow definition - Path workflow = DataBundles.getWorkflow(dataBundle); - // String workflowType = Files.probeContentType(workflow); - manifest.getAggregation(workflow).setMediatype(WORKFLOW_BUNDLE); - Path wfdesc = DataBundles.getWorkflowDescription(dataBundle); - if (Files.exists(wfdesc)) { - PathAnnotation wfdescAboutWfBundle = new PathAnnotation(); - wfdescAboutWfBundle - .setAbout(URI.create(workflow.toUri().getPath())); - wfdescAboutWfBundle - .setContent(URI.create(wfdesc.toUri().getPath())); - manifest.getAnnotations().add(wfdescAboutWfBundle); - } - - // And the workflow definition is about the workflow - PathAnnotation wfBundleAboutWf = new PathAnnotation(); - URITools uriTools = new URITools(); - URI mainWorkflow = uriTools.uriForBean(wfBundle.getMainWorkflow()); - wfBundleAboutWf.setAbout(mainWorkflow); - URI wfBundlePath = URI.create(workflow.toUri().getPath()); - wfBundleAboutWf.setContent(wfBundlePath); - manifest.getAnnotations().add(wfBundleAboutWf); - manifest.getAggregation(mainWorkflow); - - // hasWorkflowDefinition - PathAnnotation hasWorkflowDefinition = new PathAnnotation(); - hasWorkflowDefinition.setAbout(wfBundlePath); - UUID uuid = UUID.randomUUID(); - hasWorkflowDefinition.setUri(URI.create("urn:uuid:" + uuid)); - Path annotationBody = DataBundles.getAnnotations(dataBundle).resolve( - uuid + ".ttl"); - hasWorkflowDefinition.setContent(URI.create(annotationBody.toUri() - .getPath())); - Model model = ModelFactory.createDefaultModel(); - URI relPathToWfBundle = uriTools.relativePath(annotationBody.toUri(), - workflow.toUri()); - model.setNsPrefix("wfdesc", WFDESC); - model.add(model.createResource(mainWorkflow.toASCIIString()), - model.createProperty(WFDESC + "hasWorkflowDefinition"), - model.createResource(relPathToWfBundle.toASCIIString())); - try (OutputStream out = Files.newOutputStream(annotationBody)) { - model.write(out, "TURTLE", annotationBody.toUri().toASCIIString()); - } - manifest.getAnnotations().add(hasWorkflowDefinition); - - PathAnnotation wfBundleAboutWfB = new PathAnnotation(); - wfBundleAboutWfB.setAbout(wfBundle.getGlobalBaseURI()); - wfBundleAboutWfB.setContent(URI.create(workflow.toUri().getPath())); - manifest.getAnnotations().add(wfBundleAboutWfB); - - manifest.writeAsJsonLD(); - - // // Saving a data bundle: - // Path bundleFile = runPath.getParent().resolve(runPath.getFileName() + - // ".bundle.zip"); - // DataBundles.closeAndSaveBundle(dataBundle, bundleFile); - // NOTE: From now dataBundle and its Path's are CLOSED - // and can no longer be accessed - - } - - /** Extract our own plugin version - if running within Raven */ - protected static URI getPluginIdentifier(Class<?> pluginClass) { - ClassLoader classLoader = pluginClass.getClassLoader(); - String className = pluginClass.getCanonicalName(); - - try { -// org.osgi.framework.Bundle osgiBundle = FrameworkUtil -// .getBundle(pluginClass); -// if (osgiBundle != null) { -// String symbolicName = osgiBundle.getSymbolicName(); -// Version version = osgiBundle.getVersion(); -// } - - // equivalent as above without OSGi dependency: - Object bundle = PropertyUtils.getProperty(classLoader, "bundle"); - String symbolicName = BeanUtils.getProperty(bundle, "symbolicName"); - String version = BeanUtils.getProperty(bundle, "version") - .toString(); - - // NOTE: The above code has not been tested within OSGi as of 2013-12-18 - - return osgiURI.resolve(uriTools.validFilename(symbolicName) + "/" - + uriTools.validFilename(version)); - } catch (IllegalAccessException | InvocationTargetException - | NullPointerException | NoSuchMethodException e) { - // Assume it's not OSGi - } - - // Not OSGi, try as Raven: - try { - -// Artifact artifact = ((LocalArtifactClassLoader) classLoader) -// .getArtifact(); -// String groupId = artifact.getGroupId(); -// String artifactId = artifact.getArtifactId(); -// String version = artifact.getVersion(); - - // Equivalent as above, but without Raven dependency: - - Object artifact = PropertyUtils - .getProperty(classLoader, "artifact"); - if (artifact == null) { - return null; - } - // If it worked, then we assume it is a - // net.sf.taverna.raven.repository.Artifact - // implementation - String groupId = BeanUtils.getProperty(artifact, "groupId"); - String artifactId = BeanUtils.getProperty(artifact, "artifactId"); - String version = BeanUtils.getProperty(artifact, "version"); - // mimic scufl2-t2flow - return ravenURI.resolve(uriTools.validFilename(groupId) + "/" - + uriTools.validFilename(artifactId) + "/" - + uriTools.validFilename(version) + "/" - + uriTools.validFilename(className)); - } catch (IllegalAccessException | InvocationTargetException - | NullPointerException | NoSuchMethodException e) { - // Assume it's not Raven - } - - // Fallback based on the classname - mimic scufl2-t2flow - return ravenURI.resolve("undefined/" + uriTools.validFilename(className)); - - } - - public void setBundle(Bundle bundle) { - this.bundle = bundle; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-provenanceconnector/javadoc.xml ---------------------------------------------------------------------- diff --git a/taverna-provenanceconnector/javadoc.xml b/taverna-provenanceconnector/javadoc.xml deleted file mode 100644 index 3d863c6..0000000 --- a/taverna-provenanceconnector/javadoc.xml +++ /dev/null @@ -1,6 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project default="javadoc"> -<target name="javadoc"> -<javadoc access="public" author="true" classpath="/Users/paolo/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar:/Users/paolo/.m2/repository/net/sf/taverna/t2/core/reference-api/0.9-SNAPSHOT/reference-api-0.9-SNAPSHOT.jar:/Users/paolo/.m2/repository/net/sf/taverna/t2/infrastructure/launcher-api/1.12-SNAPSHOT/launcher-api-1.12-SNAPSHOT.jar:/Users/paolo/.m2/repository/net/sf/taverna/t2/infrastructure/raven/1.12-SNAPSHOT/raven-1.12-SNAPSHOT.jar:/Users/paolo/.m2/repository/geronimo-spec/geronimo-spec-jta/1.0-M1/geronimo-spec-jta-1.0-M1.jar:/Users/paolo/.m2/repository/org/aspectj/aspectjweaver/1.6.0/aspectjweaver-1.6.0.jar:/Users/paolo/.m2/repository/org/springframework/spring-orm/2.5.4/spring-orm-2.5.4.jar:/Users/paolo/.m2/repository/org/jvnet/jaxb2_commons/runtime/0.2.RC1/runtime-0.2.RC1.jar:/Users/paolo/.m2/repository/asm/asm/1.5.3/asm-1.5.3.jar:/Users/paolo/.m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar:/Users/paolo/.m2/repository/net/sf/t averna/t2/infrastructure/raven-log4j/1.12-SNAPSHOT/raven-log4j-1.12-SNAPSHOT.jar:/Users/paolo/.m2/repository/org/springframework/spring-aop/2.5.4/spring-aop-2.5.4.jar:/Users/paolo/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar:/Users/paolo/.m2/repository/org/openprovenance/tupelo/1.0.3/tupelo-1.0.3.jar:/Users/paolo/.m2/repository/org/springframework/spring-tx/2.5.4/spring-tx-2.5.4.jar:/Users/paolo/.m2/repository/commons-codec/commons-codec/1.2/commons-codec-1.2.jar:/Users/paolo/.m2/repository/org/openprovenance/opm/1.0.3/opm-1.0.3.jar:/Users/paolo/.m2/repository/junit/junit/4.4/junit-4.4.jar:/Users/paolo/.m2/repository/cglib/cglib/2.1_3/cglib-2.1_3.jar:/Users/paolo/.m2/repository/org/springframework/spring-beans/2.5.4/spring-beans-2.5.4.jar:/Users/paolo/.m2/repository/net/sf/taverna/t2/core/reference-core-extensions/0.7-SNAPSHOT/reference-core-extensions-0.7-SNAPSHOT.jar:/Users/paolo/.m2/repository/log4j/log4j/1.2.13/log4j-1.2.13.jar:/Users/paolo/.m2/repository/net/sf/t averna/t2/infrastructure/spi-discovery-api/1.12-SNAPSHOT/spi-discovery-api-1.12-SNAPSHOT.jar:/Users/paolo/.m2/repository/commons-lang/commons-lang/2.2/commons-lang-2.2.jar:/Users/paolo/.m2/repository/org/openprovenance/toolbox/1.0.3/toolbox-1.0.3.jar:/Users/paolo/.m2/repository/commons-jxpath/commons-jxpath/1.2/commons-jxpath-1.2.jar:/Users/paolo/.m2/repository/org/tupeloproject/tupelo-kernel/2.4.3/tupelo-kernel-2.4.3.jar:target/test-classes:/Users/paolo/.m2/repository/commons-collections/commons-collections/2.1.1/commons-collections-2.1.1.jar:/Users/paolo/.m2/repository/net/sf/taverna/t2/core/workflowmodel-api/0.9-SNAPSHOT/workflowmodel-api-0.9-SNAPSHOT.jar:/Users/paolo/.m2/repository/commons-io/commons-io/1.3/commons-io-1.3.jar:/Users/paolo/.m2/repository/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar:/Users/paolo/.m2/repository/org/aspectj/aspectjrt/1.6.0/aspectjrt-1.6.0.jar:/Users/paolo/.m2/repository/org/tupeloproject/tupelo-cet/2.4.3/tupelo-cet-2.4.3.jar:/Users/paolo/.m2/reposit ory/org/tupeloproject/tupelo-util/2.4.3/tupelo-util-2.4.3.jar:/Users/paolo/.m2/repository/org/hibernate/hibernate/3.2.5.ga.raven/hibernate-3.2.5.ga.raven.jar:/Users/paolo/.m2/repository/net/sf/taverna/t2/infrastructure/appconfig/1.12-SNAPSHOT/appconfig-1.12-SNAPSHOT.jar:/Users/paolo/.m2/repository/commons-pool/commons-pool/1.3/commons-pool-1.3.jar:/Users/paolo/.m2/repository/net/sf/taverna/t2/infrastructure/prelauncher/1.12-SNAPSHOT/prelauncher-1.12-SNAPSHOT.jar:/Users/paolo/.m2/repository/commons-beanutils/commons-beanutils/1.4/commons-beanutils-1.4.jar:/Users/paolo/.m2/repository/jdom/jdom/1.0/jdom-1.0.jar:/Users/paolo/.m2/repository/net/sf/taverna/t2/core/reference-impl/0.9-SNAPSHOT/reference-impl-0.9-SNAPSHOT.jar:/Users/paolo/.m2/repository/net/sf/taverna/t2/lang/observer/0.6-SNAPSHOT/observer-0.6-SNAPSHOT.jar:/Users/paolo/.m2/repository/simple-jndi/simple-jndi/0.11.1/simple-jndi-0.11.1.jar:/Users/paolo/.m2/repository/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar:/Users/pao lo/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.3/jaxb-impl-2.1.3.jar:/Users/paolo/.m2/repository/commons-dbcp/commons-dbcp/1.2.2/commons-dbcp-1.2.2.jar:/Users/paolo/.m2/repository/org/springframework/spring-core/2.5.4/spring-core-2.5.4.jar:/Users/paolo/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar:/Users/paolo/.m2/repository/org/springframework/spring-context/2.5.4/spring-context-2.5.4.jar:/Users/paolo/.m2/repository/org/springframework/spring-jdbc/2.5.4/spring-jdbc-2.5.4.jar:/Users/paolo/.m2/repository/javax/activation/activation/1.1/activation-1.1.jar:/Users/paolo/.m2/repository/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar" destdir="doc" doctitle="ProvenanceConnector and Provenance Access API" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.5" sourcefiles="src/main/java/net/sf/taverna/t2/provenance/ProvenanceConnectorRegistry.java,src/main/java/net/sf/taverna/t2/provenance/ProvenanceConnectorFacto ry.java,src/main/java/net/sf/taverna/t2/provenance/ProvenanceConnectorFactoryRegistry.java" sourcepath="src/main/java:src/test/java:src/main/resources" splitindex="true" use="true" version="true"/> -</target> -</project> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-provenanceconnector/pom.xml ---------------------------------------------------------------------- diff --git a/taverna-provenanceconnector/pom.xml b/taverna-provenanceconnector/pom.xml deleted file mode 100644 index 7c29589..0000000 --- a/taverna-provenanceconnector/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.taverna.engine</groupId> - <artifactId>taverna-engine</artifactId> - <version>3.1.0-incubating-SNAPSHOT</version> - </parent> - <artifactId>taverna-provenanceconnector</artifactId> - <packaging>bundle</packaging> - <name>Apache Taverna Provenance Connector</name> - <description>Database storage and analysis of provenance info (LEGACY)</description> - <build> - <plugins> - <plugin> - <groupId>org.apache.felix</groupId> - <artifactId>maven-bundle-plugin</artifactId> - <extensions>true</extensions> - <configuration> - <instructions> - <Private-Package>org.openprovenance.model.*,org.tupeloproject.*</Private-Package> - <Import-Package>!com.sun.xml.bind.marshaller.*,!org.jvnet.jaxb2_commons.lang.*,*</Import-Package> - </instructions> - </configuration> - </plugin> - </plugins> - </build> - <dependencies> - <dependency> - <groupId>${project.parent.groupId}</groupId> - <artifactId>taverna-reference-impl</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>${project.parent.groupId}</groupId> - <artifactId>taverna-workflowmodel-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>${project.parent.groupId}</groupId> - <artifactId>taverna-workflowmodel-impl</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.apache.taverna.language</groupId> - <artifactId>taverna-scufl2-api</artifactId> - <version>${taverna.language.version}</version> - </dependency> - <dependency> - <groupId>${project.parent.groupId}</groupId> - <artifactId>taverna-database-configuration-api</artifactId> - <version>${project.parent.version}</version> - </dependency> - <dependency> - <groupId>org.jdom</groupId> - <artifactId>com.springsource.org.jdom</artifactId> - <version>${jdom.version}</version> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>${log4j.version}</version> - </dependency> - <dependency> - <groupId>commons-dbcp</groupId> - <artifactId>commons-dbcp</artifactId> - <version>${commons.dbcp.version}</version> - </dependency> - <!-- - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>${commons.io.version}</version> - </dependency> - --> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>com.springsource.org.apache.commons.lang</artifactId> - <version>${commons.lang.version}</version> - </dependency> - <dependency> - <groupId>org.tupeloproject</groupId> - <artifactId>tupelo-cet</artifactId> - <version>${tupelo.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.tupeloproject</groupId> - <artifactId>tupelo-kernel</artifactId> - <version>${tupelo.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.openprovenance</groupId> - <artifactId>opm-core</artifactId> - <version>${opm.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>${junit.version}</version> - <scope>test</scope> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/Provenance.java ---------------------------------------------------------------------- diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/Provenance.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/Provenance.java deleted file mode 100644 index f6009ca..0000000 --- a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/Provenance.java +++ /dev/null @@ -1,316 +0,0 @@ -package net.sf.taverna.t2.provenance; - -import java.sql.SQLException; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.sf.taverna.t2.invocation.InvocationContext; -import net.sf.taverna.t2.provenance.api.Query; -import net.sf.taverna.t2.provenance.api.QueryAnswer; -import net.sf.taverna.t2.provenance.connector.AbstractProvenanceConnector; -import net.sf.taverna.t2.provenance.lineageservice.Dependencies; -import net.sf.taverna.t2.provenance.lineageservice.LineageQueryResultRecord; -import net.sf.taverna.t2.provenance.lineageservice.ProvenanceAnalysis; -import net.sf.taverna.t2.provenance.lineageservice.ProvenanceQuery; -import net.sf.taverna.t2.provenance.lineageservice.utils.Collection; -import net.sf.taverna.t2.provenance.lineageservice.utils.DataLink; -import net.sf.taverna.t2.provenance.lineageservice.utils.DataflowInvocation; -import net.sf.taverna.t2.provenance.lineageservice.utils.Port; -import net.sf.taverna.t2.provenance.lineageservice.utils.PortBinding; -import net.sf.taverna.t2.provenance.lineageservice.utils.ProcessorEnactment; -import net.sf.taverna.t2.provenance.lineageservice.utils.ProvenanceProcessor; -import net.sf.taverna.t2.provenance.lineageservice.utils.Workflow; -import net.sf.taverna.t2.provenance.lineageservice.utils.WorkflowRun; -import net.sf.taverna.t2.provenance.lineageservice.utils.WorkflowTree; -import net.sf.taverna.t2.reference.T2Reference; - -/** - * This API is the single access point into the Taverna provenance database. Its - * main functionality is to let clients query the content of the DB, either - * using dedicated methods that retrieve specific entity values from the DB, or - * through a more general XML-based query language. Examples of XML provenance - * queries can be found in the external package - * {@link net.sf.taverna.t2.provenance.apic.client.resources}. Class - * {@link net.sf.taverna.t2.provenance.api.client.ProvenanceAPISampleClient} - * provides an example of API client that third parties would use to interact - * with this API. - * <p/> - * The XML schema for the XML query language is {@code pquery.xsd} in - * {@link net.sf.taverna.t2.provenance.apic.client.resources} - * - * @author Paolo Missier - * @author Stuart Owen - */ -public interface Provenance { - - /** - * Initialises a default Reference Service for storing data and their associated references. - * This creates a reference service using the named JNDI Data Source 'jdbc/taverna'.<br/> - * the new Reference Service is associated to the {@link AbstractProvenanceConnector}, enabling data references to be resolved - */ - InvocationContext initDefaultReferenceService(); - - /** - * Initialises the Reference Service for a given hibernate context definition. - * This mapping file must be available in the root of the classpath. - * @see #initDefaultReferenceService() - * @param hibernateContext - */ - InvocationContext initReferenceService(String hibernateContext); - - void init(); - - void init(InvocationContext context); - - /** - * Executes a provenance query. Please see separate doc. for the XML query language schema. - * @throws SQLException - */ - QueryAnswer executeQuery(Query pq) throws SQLException; - - /** - * Returns individal records from the provenance DB in response to a query - * that specifies specific elements within values associated with a - * processor port, in the context of a specific run of a workflow. <br/> - * This is used in the workbench to retrieve the "intermediate results" at - * various points during workflow execution, as opposed to a set of - * dependencies in response to a full-fledged provenance query. - * - * @param workflowRunId - * lineage scope -- a specific instance - * @param processorName - * for a specific processor [required] - * @param a - * specific (input or output) variable [optional] - * @param iteration - * and a specific iteration [optional] - * @return a list of @ LineageQueryResultRecord} , encapsulated in a - * {@link Dependencies} object - * @throws SQLException - */ - Dependencies fetchPortData(String workflowRunId, String workflowId, - String processorName, String portName, String iteration); - - /** - * @param record a record representing a single value -- possibly within a list hierarchy - * @return the URI for topmost containing collection when the input record is within a list hierarchy, or null otherwise - */ - String getContainingCollection(LineageQueryResultRecord record); - - /** - * @param workflowId - * defines the scope of the query - if null then the query runs - * on all available workflows - * @param conditions - * additional conditions to be defined. This is a placeholder as - * conditions are currently ignored - * @return a list of workflowRunId, each representing one run of the input - * workflowID - */ - List<WorkflowRun> listRuns(String workflowId, Map<String, String> conditions); - - boolean isTopLevelDataflow(String workflowId); - - boolean isTopLevelDataflow(String workflowId, String workflowRunId); - - String getLatestRunID() throws SQLException; - - /** - * Removes all records that pertain to a specific run (but not the static - * specification of the workflow run) - * - * @param runID - * the internal ID of a run. This can be obtained using - * {@link #listRuns(String, Map)} - * @return the set of data references that pertain to the deleted run. This - * can be used by the Data Manager to ensure that no dangling - * references are left in the main Taverna data repositorry - */ - Set<String> removeRun(String runID); - - /** - * removes all records pertaining to the static structure of a workflow. - * - * @param workflowId - * the ID (not the external name) of the workflow whose static - * structure is to be deleted from the DB - */ - void removeWorkflow(String workflowId); - - /** - * returns a set of workflowIDs for a given runID. The set is a singleton if - * the workflow has no nesting, but in general the list contains one - * workflowID for each nested workflow involved in the run - * - * @param runID - * the internal ID for a specific workflow run - * @return a list of workflow IDs, one for each nested workflow involved in - * the input run - */ - List<String> getWorkflowID(String runID); - - /** - * @param runID - * the internal ID for a specific workflow run - * @return the ID of the top-level workflow that executed during the input - * run - */ - String getTopLevelWorkflowID(String runID); - - List<Workflow> getWorkflowsForRun(String runID); - - /** - * @return a list of {@link WorkflowRun} beans, each representing the - * complete description of a workflow run (note that this is not - * just the ID of the run) - */ - List<WorkflowRun> getAllWorkflowIDs(); - - /** - * @param workflowID - * @return a Map: workflowID -> [ @ link ProvenanceProcessor} ] Each entry - * in the list pertains to one composing sub-workflow (if no nesting - * then this contains only one workflow, namely the top level one) - */ - Map<String, List<ProvenanceProcessor>> getProcessorsInWorkflow( - String workflowID); - - List<Collection> getCollectionsForRun(String wfInstanceID); - - List<PortBinding> getPortBindings(Map<String, String> constraints) - throws SQLException; - - /** - * lists all ports for a workflow - * - * @param workflowID - * @return a list of {@link Port} beans, each representing an input or - * output port for the workflow - */ - List<Port> getPortsForDataflow(String workflowID); - - /** - * lists all ports for a workflow - * - * @param workflowID - * @return a list of {@link Port} beans, each representing an input or - * output port for the workflow or a processor in the workflow - */ - List<Port> getAllPortsInDataflow(String workflowID); - - /** - * list all ports for a specific processor within a workflow - * - * @param workflowID - * @param processorName - * @return a list of {@link Port} beans, each representing an input or - * output port for the input processor - */ - List<Port> getPortsForProcessor(String workflowID, String processorName); - - // PM added 5/2010 - String getWorkflowNameByWorkflowID(String workflowID); - - WorkflowTree getWorkflowNestingStructure(String workflowID) - throws SQLException; - - /** - * include valus of output ports in the query result? input port values are - * always included<br> - * default is FALSE - */ - void toggleIncludeProcessorOutputs(boolean active); - - boolean isIncludeProcessorOutputs(); - - /** - * @return an instance of {@link InvocationContext} that can be used by a - * client to deref a Taverna data reference - */ - InvocationContext getInvocationContext(); - - /** - * should an OPM graph be generated in response to a query?<br> - * default is TRUE - */ - void toggleOPMGeneration(boolean active); - - /** - * - * @return true if OPM is set to be generated in response to a query - */ - boolean isOPMGenerationActive(); - - /** - * should actual artifact values be attached to OPM artifact nodes?<br> - * default is FALSE<br/> - * THIS IS CURRENTLY UNSUPPORTED -- DEFAULTS TO FALSE - * - * @param active - */ - void toggleAttachOPMArtifactValues(boolean active); - - /** - * @return true if the OPM graph artifacts are annotated with actual values - */ - boolean isAttachOPMArtifactValues(); - - /** - * @deprecated as workflow 'names' are not globally unique, this method - * should not be used! - * @param workflowName - * @return - */ - String getWorkflowIDForExternalName(String workflowName); - - List<ProvenanceProcessor> getProcessorsForWorkflowID(String workflowID); - - /** - * @return the singleton {@link AbstractProvenanceConnector} used by the API - * to operate on the DB. Currently we support MySQL - * {@link MySQLProvenanceConnector} and Derby - * {@link DerbyProvenanceConnector} connectors. The set of supported - * connectors is extensible. The available connectors are discovered - * automatically by the API upon startup, and it includes all the - * connectors that are mentioned in the <dependencies> section of - * pom.xml for Maven module - * {@code net.sf.taverna.t2.core.provenanceconnector} - */ - AbstractProvenanceConnector getProvenanceConnector(); - - /** - * @return - */ - ProvenanceAnalysis getAnalysis(); - - /** - * @return the pq - */ - ProvenanceQuery getQuery(); - - List<ProcessorEnactment> getProcessorEnactments(String workflowRunId, - String... processorPath); - - ProcessorEnactment getProcessorEnactmentByProcessId(String workflowRunId, - String processIdentifier, String iteration); - - ProcessorEnactment getProcessorEnactment(String processorEnactmentId); - - ProvenanceProcessor getProvenanceProcessor(String workflowId, - String processorNameRef); - - ProvenanceProcessor getProvenanceProcessor(String processorId); - - Map<Port, T2Reference> getDataBindings(String dataBindingId); - - DataflowInvocation getDataflowInvocation(String workflowRunId); - - DataflowInvocation getDataflowInvocation( - ProcessorEnactment processorEnactment); - - List<DataflowInvocation> getDataflowInvocations(String workflowRunId); - - List<DataLink> getDataLinks(String workflowId); - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-taverna-engine/blob/3ecb1291/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/ProvenanceConnectorFactory.java ---------------------------------------------------------------------- diff --git a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/ProvenanceConnectorFactory.java b/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/ProvenanceConnectorFactory.java deleted file mode 100644 index 0de22c2..0000000 --- a/taverna-provenanceconnector/src/main/java/net/sf/taverna/t2/provenance/ProvenanceConnectorFactory.java +++ /dev/null @@ -1,8 +0,0 @@ -package net.sf.taverna.t2.provenance; - -import net.sf.taverna.t2.provenance.connector.AbstractProvenanceConnector; - -public interface ProvenanceConnectorFactory { - public AbstractProvenanceConnector getProvenanceConnector(); - public String getConnectorType(); -}
