This is an automated email from the ASF dual-hosted git repository. sblackmon pushed a commit to branch acna2018 in repository https://gitbox.apache.org/repos/asf/streams.git
commit a5df07737d54328f830a5383e17e0d0520d888c0 Author: Steve Blackmon @steveblackmon <sblack...@apache.org> AuthorDate: Thu Sep 27 18:55:30 2018 -0400 produce AS 2.0 turtle files from social network archives --- pom.xml | 50 +++-- streams-cli/pom.xml | 97 +++++++++ .../org/apache/streams/cli/RdfFreemarkerCli.java | 181 +++++++++++++++++ streams-cli/src/main/resources/default.fmpp | 4 + streams-cli/src/site/markdown/index.md | 8 + .../streams/cli/test/TestRdfFreemarkerCli.java | 49 +++++ streams-cli/src/test/resources/person.json | 6 + streams-cli/src/test/resources/test.ttl.ftl | 41 ++++ streams-contrib/pom.xml | 2 + .../src/main/templates/facebook.ttl.ftl | 139 +++++++++++++ .../src/site/markdown/experimental.md | 35 ++++ .../src/site/markdown/index.md | 1 + .../src/main/templates/googleplus.ttl.ftl | 85 ++++++++ .../google-gplus/src/site/markdown/experimental.md | 35 ++++ .../google-gplus/src/site/markdown/index.md | 2 + .../src/main/templates/instagram.ttl.ftl | 108 ++++++++++ .../src/site/markdown/experimental.md | 34 ++++ .../src/site/markdown/index.md | 4 +- streams-contrib/streams-provider-linkedin/pom.xml | 196 ++++++++++++++++++ .../src/main/templates/linkedin.ttl.ftl | 224 +++++++++++++++++++++ .../src/site/markdown/experimental.md | 34 ++++ .../src/site/markdown/index.md | 8 + .../src/main/templates/twitter.ttl.ftl | 79 ++++++++ .../src/site/markdown/experimental.md | 29 +++ .../src/site/markdown/index.md | 2 + .../src/main/templates/youtube.ttl.ftl | 68 +++++++ .../src/site/markdown/experimental.md | 34 ++++ streams-dist/pom.xml | 6 + .../streams-schema-activitystreams/pom.xml | 7 - 29 files changed, 1542 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index f450ca0..648525f 100644 --- a/pom.xml +++ b/pom.xml @@ -357,11 +357,25 @@ <war.plugin.version>2.5</war.plugin.version> <!-- Library Dependency Versions --> - <jackson.version>2.9.5</jackson.version> <aalto.version>1.1.0</aalto.version> + <commons-codec.version>1.10</commons-codec.version> + <commons-collections.version>3.2.2</commons-collections.version> + <commons-io.version>2.5</commons-io.version> + <commons-lang3.version>3.6</commons-lang3.version> + <commons-validator.version>1.6</commons-validator.version> + <clojure.version>1.4.0</clojure.version> + <doxia.version>1.7</doxia.version> + <facebook4j.version>2.4.7</facebook4j.version> + <fmpp.version>0.9.15</fmpp.version> + <freemarker.version>2.3.28</freemarker.version> + <guava.version>20.0</guava.version> + <httpcomponents.core.version>4.4.8</httpcomponents.core.version> + <httpcomponents.client.version>4.5.4</httpcomponents.client.version> + <jackson.version>2.9.5</jackson.version> <joda-time.version>2.9.9</joda-time.version> <joda-convert.version>1.8.1</joda-convert.version> <json-flattener.version>0.5.0</json-flattener.version> + <json-path.version>2.4.0</json-path.version> <json-schema-validator.version>0.1.10</json-schema-validator.version> <juneau.version>7.1.0</juneau.version> <jsonschema2pojo.version>0.4.10</jsonschema2pojo.version> @@ -369,29 +383,19 @@ <jaxb2-basics.version>0.11.1</jaxb2-basics.version> <jaxbutil.version>1.3.0</jaxbutil.version> <junit.version>4.12</junit.version> - <testng.version>6.11</testng.version> + <netty.version>3.8.0.Final</netty.version> <slf4j.version>1.7.25</slf4j.version> <log4j.version>1.2.17</log4j.version> <logback.version>1.2.3</logback.version> <hamcrest.version>1.3</hamcrest.version> - <commons-codec.version>1.10</commons-codec.version> - <commons-collections.version>3.2.2</commons-collections.version> - <commons-io.version>2.5</commons-io.version> - <commons-lang3.version>3.6</commons-lang3.version> - <commons-validator.version>1.6</commons-validator.version> - <typesafe.config.version>1.3.2</typesafe.config.version> <reflections.version>0.9.11</reflections.version> - <guava.version>20.0</guava.version> - <clojure.version>1.4.0</clojure.version> + <typesafe.config.version>1.3.2</typesafe.config.version> <zookeeper.version>3.4.5</zookeeper.version> - <netty.version>3.8.0.Final</netty.version> - <json-path.version>2.4.0</json-path.version> - <facebook4j.version>2.4.7</facebook4j.version> + + <!-- Test Library Dependency Versions --> <mockito.version>1.10.19</mockito.version> <powermock.version>1.7.1</powermock.version> - <httpcomponents.core.version>4.4.8</httpcomponents.core.version> - <httpcomponents.client.version>4.5.4</httpcomponents.client.version> - <doxia.version>1.7</doxia.version> + <testng.version>6.11</testng.version> <!-- osgi configuration --> <org.osgi.service.http.port>8080</org.osgi.service.http.port> @@ -406,6 +410,7 @@ </properties> <modules> + <module>streams-cli</module> <module>streams-core</module> <module>streams-config</module> <module>streams-contrib</module> @@ -550,6 +555,9 @@ <directory>src/main/resources</directory> </resource> <resource> + <directory>src/main/templates</directory> + </resource> + <resource> <directory>src/site/diagrams</directory> </resource> <resource> @@ -936,6 +944,16 @@ <version>${reflections.version}</version> </dependency> <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>${freemarker.version}</version> + </dependency> + <dependency> + <groupId>net.sourceforge.fmpp</groupId> + <artifactId>fmpp</artifactId> + <version>${fmpp.version}</version> + </dependency> + <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-all</artifactId> <version>${hamcrest.version}</version> diff --git a/streams-cli/pom.xml b/streams-cli/pom.xml new file mode 100644 index 0000000..1d87cce --- /dev/null +++ b/streams-cli/pom.xml @@ -0,0 +1,97 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<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"> + <parent> + <artifactId>apache-streams</artifactId> + <groupId>org.apache.streams</groupId> + <version>0.6.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>streams-cli</artifactId> + <name>${project.artifactId}</name> + + <description>Apache Streams RDF Utilities</description> + + <packaging>jar</packaging> + + <dependencies> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + </dependency> + <dependency> + <groupId>org.apache.juneau</groupId> + <artifactId>juneau-marshall</artifactId> + </dependency> + <dependency> + <groupId>org.apache.juneau</groupId> + <artifactId>juneau-marshall-rdf</artifactId> + </dependency> + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + </dependency> + <dependency> + <groupId>net.sourceforge.fmpp</groupId> + <artifactId>fmpp</artifactId> + </dependency> + <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-config</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + <build> + <sourceDirectory>src/main/java</sourceDirectory> + <testSourceDirectory>src/test/java</testSourceDirectory> + <resources> + <resource> + <directory>src/main/resources</directory> + </resource> + </resources> + <testResources> + <testResource> + <directory>src/test/resources</directory> + </testResource> + </testResources> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>test-jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file diff --git a/streams-cli/src/main/java/org/apache/streams/cli/RdfFreemarkerCli.java b/streams-cli/src/main/java/org/apache/streams/cli/RdfFreemarkerCli.java new file mode 100644 index 0000000..846d268 --- /dev/null +++ b/streams-cli/src/main/java/org/apache/streams/cli/RdfFreemarkerCli.java @@ -0,0 +1,181 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.streams.cli; + +import fmpp.Engine; +import fmpp.TemplateEnvironment; +import fmpp.localdatabuilders.MapLocalDataBuilder; +import fmpp.progresslisteners.ConsoleProgressListener; +import fmpp.progresslisteners.TerseConsoleProgressListener; +import fmpp.setting.Settings; +import freemarker.cache.FileTemplateLoader; +import freemarker.template.Configuration; + +import java.io.FileWriter; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.Callable; + +import com.typesafe.config.Config; + +import com.typesafe.config.ConfigFactory; +import freemarker.template.SimpleHash; +import freemarker.template.Template; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static fmpp.setting.Settings.DEFAULT_CFG_FILE_NAME; +import static fmpp.setting.Settings.NAME_DATA; +import static fmpp.setting.Settings.NAME_DATA_ROOT; +import static fmpp.setting.Settings.NAME_LOCAL_DATA; +import static fmpp.setting.Settings.NAME_OUTPUT_ROOT; +import static fmpp.setting.Settings.NAME_SOURCE_ROOT; + +public class RdfFreemarkerCli implements Callable { + + private final static Logger LOGGER = LoggerFactory.getLogger(RdfFreemarkerCli.class); + private String[] args; + private Config typesafe; + + public static void main(String[] args) throws Exception { + RdfFreemarkerCli cli = new RdfFreemarkerCli(args); + try { + cli.call(); + } catch( Exception e ) { + LOGGER.error("Error", e); + System.exit(1); + } + System.exit(0); + } + + public RdfFreemarkerCli(String[] args) { + ConfigFactory.invalidateCaches(); + this.args = args; + this.typesafe = ConfigFactory.load(); + } + + public Boolean call() throws Exception { + + String baseDir; + if (typesafe.hasPath("baseDir")) + baseDir = typesafe.getString("baseDir"); + else + baseDir = args[0]; + + LOGGER.info("baseDir: " + baseDir); + Path baseDirPath = Paths.get(baseDir); + assert( Files.exists(baseDirPath) ); + assert( Files.isDirectory(baseDirPath) ); + + String settingsFile; + if (typesafe.hasPath("settingsFile")) + settingsFile = typesafe.getString("settingsFile"); + else + settingsFile = args[1]; + + LOGGER.info("settingsFile: " + settingsFile); + Path settingsFilePath = Paths.get(settingsFile); + assert( Files.exists(settingsFilePath) ); + assert( !Files.isDirectory(settingsFilePath) ); + + String sourceRoot; + if (typesafe.hasPath("sourceRoot")) + sourceRoot = typesafe.getString("sourceRoot"); + else + sourceRoot = args[2]; + + LOGGER.info("sourceRoot: " + sourceRoot); + Path sourceRootPath = Paths.get(sourceRoot); + assert( Files.exists(sourceRootPath) ); + assert( Files.isDirectory(sourceRootPath) ); + + String dataRoot; + if (typesafe.hasPath("dataRoot")) + dataRoot = typesafe.getString("dataRoot"); + else + dataRoot = args[3]; + + LOGGER.info("dataRoot: " + dataRoot); + Path dataRootPath = Paths.get(dataRoot); + assert( Files.exists(dataRootPath) ); + assert( Files.isDirectory(dataRootPath) ); + + String outputRoot; + if (typesafe.hasPath("outputRoot")) + outputRoot = typesafe.getString("outputRoot"); + else + outputRoot = args[4]; + + LOGGER.info("outputRoot: " + outputRoot); + Path outputRootPath = Paths.get(outputRoot); + assert( Files.exists(outputRootPath) ); + assert( Files.isDirectory(outputRootPath) ); + + String namespace; + if (typesafe.hasPath("namespace")) + namespace = typesafe.getString("namespace"); + else + namespace = args[5]; + + String id; + if (typesafe.hasPath("id")) + id = typesafe.getString("id"); + else + id = args[6]; + + Settings settings = new Settings(baseDirPath.toFile()); + settings.load(settingsFilePath.toFile()); + settings.set(NAME_DATA_ROOT, dataRoot); + settings.set(NAME_SOURCE_ROOT, sourceRoot); + settings.set(NAME_OUTPUT_ROOT, outputRoot); + + Map<String, String> vars = new HashMap<>(); + vars.put("dataRoot", dataRoot); + vars.put("id", id); + vars.put("namespace", namespace); + + settings.set(NAME_DATA, vars); + +// settings.define("id", Settings.TYPE_STRING, true, true); +// settings.set("id", id); +// settings.define("namespace", Settings.TYPE_STRING, true, true); +// settings.set("namespace", namespace); + + ConsoleProgressListener listener = new ConsoleProgressListener(); + settings.addProgressListener(listener); + + try { + settings.execute(); + } catch( Exception ex ) { + LOGGER.error("settings.execute() Exception", ex); + return false; + } + LOGGER.info("settings.execute() Success"); + return true; + } + + public String dropExtension(String path) { + return path.substring(0, path.lastIndexOf('.')); + } + +} \ No newline at end of file diff --git a/streams-cli/src/main/resources/default.fmpp b/streams-cli/src/main/resources/default.fmpp new file mode 100644 index 0000000..8f15179 --- /dev/null +++ b/streams-cli/src/main/resources/default.fmpp @@ -0,0 +1,4 @@ +# Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 +alwaysCreateDirectories: true +logFile: streams-cli.log +removeExtensions: ["ftl"] \ No newline at end of file diff --git a/streams-cli/src/site/markdown/index.md b/streams-cli/src/site/markdown/index.md new file mode 100644 index 0000000..46c2068 --- /dev/null +++ b/streams-cli/src/site/markdown/index.md @@ -0,0 +1,8 @@ +streams-rdf +============== + +streams-rdf contains classes for produce RDF datasets, primarily using the Activity Streams 2.0 ontology. + +[JavaDocs](apidocs/index.html "JavaDocs") + +###### Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 diff --git a/streams-cli/src/test/java/org/apache/streams/cli/test/TestRdfFreemarkerCli.java b/streams-cli/src/test/java/org/apache/streams/cli/test/TestRdfFreemarkerCli.java new file mode 100644 index 0000000..3cb2d80 --- /dev/null +++ b/streams-cli/src/test/java/org/apache/streams/cli/test/TestRdfFreemarkerCli.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.streams.cli.test; + +import org.apache.streams.cli.RdfFreemarkerCli; + +import org.junit.Test; + +import java.nio.file.Files; +import java.nio.file.Paths; + +/** + * Tests for {$link: org.apache.streams.cli.RdfFreemarkerCli} + */ +public class TestRdfFreemarkerCli { + + @Test + public void testRdfFreemarkerCli() throws Exception { + String[] testArgs = { + ".", //baseDir + "src/main/resources/default.fmpp", //settingsFile + "src/test/resources", //sourceRoot + "src/test/resources", //dataRoot + "target/test-classes", //outputRoot + "http://streams.apache.org/streams-cli", //namespace + "testPerson" //id + }; + RdfFreemarkerCli rdfFreemarkerCli = new RdfFreemarkerCli(testArgs); + Boolean success = rdfFreemarkerCli.call(); + assert(success); + assert(Files.exists(Paths.get("target/test-classes/test.ttl"))); + } +} diff --git a/streams-cli/src/test/resources/person.json b/streams-cli/src/test/resources/person.json new file mode 100644 index 0000000..11b5d32 --- /dev/null +++ b/streams-cli/src/test/resources/person.json @@ -0,0 +1,6 @@ +{ + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "displayName": "Testy Testerson" +} \ No newline at end of file diff --git a/streams-cli/src/test/resources/test.ttl.ftl b/streams-cli/src/test/resources/test.ttl.ftl new file mode 100644 index 0000000..7712c85 --- /dev/null +++ b/streams-cli/src/test/resources/test.ttl.ftl @@ -0,0 +1,41 @@ +<#ftl output_format="XML" auto_esc=true> +<#-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<#attempt> + <#assign person = pp.loadData('json', 'person.json')> + <#recover> + <#stop "NO_PROFILE_INFORMATION"> +</#attempt> +@prefix : <${namespace}#> . +@prefix as: <http://www.w3.org/ns/activitystreams#> . +@prefix apst: <http://streams.apache.org/ns#> . +@prefix dc: <http://purl.org/dc/elements/1.1/#> . +@prefix dct: <http://purl.org/dc/terms/#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@base <${namespace}> . + +:${id} a as:Person . + +<#assign now = .now> + +:${id} + as:displayName "${person.displayName}" ; + dct:created "${now?iso_utc}" ; + . \ No newline at end of file diff --git a/streams-contrib/pom.xml b/streams-contrib/pom.xml index e1a4ef7..341a6b7 100644 --- a/streams-contrib/pom.xml +++ b/streams-contrib/pom.xml @@ -56,6 +56,7 @@ <module>streams-provider-facebook</module> <module>streams-provider-google</module> <module>streams-provider-instagram</module> + <module>streams-provider-linkedin</module> <module>streams-provider-moreover</module> <module>streams-provider-twitter</module> <module>streams-provider-sysomos</module> @@ -88,4 +89,5 @@ </dependency> </dependencies> </dependencyManagement> + </project> diff --git a/streams-contrib/streams-provider-facebook/src/main/templates/facebook.ttl.ftl b/streams-contrib/streams-provider-facebook/src/main/templates/facebook.ttl.ftl new file mode 100644 index 0000000..a2071a5 --- /dev/null +++ b/streams-contrib/streams-provider-facebook/src/main/templates/facebook.ttl.ftl @@ -0,0 +1,139 @@ +<#ftl output_format="XML" auto_esc=true> +<#-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<#attempt> + <#assign profile_information = pp.loadData('json', 'profile_information/profile_information.json')> + <#recover> + <#stop "NO_PROFILE_INFORMATION"> +</#attempt> +@prefix : <${namespace}#> . +@prefix as: <http://www.w3.org/ns/activitystreams#> . +@prefix apst: <http://streams.apache.org/ns#> . +@prefix dc: <http://purl.org/dc/elements/1.1/#> . +@prefix dct: <http://purl.org/dc/terms/#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . +@base <${namespace}> . + +<#-- profile_information/profile_information.json --> +<#if profile_information.profile.name?is_hash> +<#assign fullname=profile_information.profile.name.full_name> +<#else> +<#assign fullname=profile_information.profile.name> +</#if> +<#attempt> +<#assign id=fullname?replace("\\W","","r")> +<#recover> +<#stop "NO_ID"> +</#attempt> + +:${id} a apst:FacebookProfile . + +:${id} +<#if profile_information.profile.username??> + as:displayName "${profile_information.profile.username!profile_information.profile.name.full_name!profile_information.profile.name}" ; +<#elseif profile_information.profile.name??> + <#if profile_information.profile.name?is_hash> + as:displayName "${profile_information.profile.name.full_name}" ; + <#else> + as:displayName "${profile_information.profile.name}" ; + </#if> +</#if> +<#if profile_information.profile.name??> + <#if profile_information.profile.name?is_hash> + vcard:fn "${profile_information.profile.name.full_name}" ; + <#else> + vcard:fn "${profile_information.profile.name}" ; + </#if> +</#if> +<#if profile_information.profile.name?is_hash> + vcard:given-name "${profile_information.profile.name.first_name}" ; + vcard:family-name "${profile_information.profile.name.last_name}" ; +</#if> + dct:created "${profile_information.profile.registration_timestamp}" ; + . + +<#if profile_information.profile.emails??> +<#list profile_information.profile.emails.emails![] as email> +:${id} vcard:email "mailto:${email}" . +</#list> +</#if> + +<#if profile_information.profile.phone_numbers??> +<#list profile_information.profile.phone_numbers![] as phone_number_obj> +:${id} vcard:tel "tel:${phone_number_obj.phone_number}" . +</#list> +</#if> + +<#if profile_information.profile.address??> +:${id} +<#if profile_information.profile.address.street??> + vcard:street-address "${profile_information.profile.address.street}" ; +</#if> + vcard:locality "${profile_information.profile.address.city}" ; + vcard:region "${profile_information.profile.address.region}" ; + vcard:country-name "${profile_information.profile.address.country}" ; +<#if profile_information.profile.address.zipcode??> + vcard:postal-code "${profile_information.profile.address.zipcode}" ; +</#if> + . +</#if> + +<#attempt> +<#assign friends = pp.loadData('json', 'friends/friends.json')> +<#recover> +</#attempt> + +<#if friends??> +<#list friends.friends as friend> +<#assign fid=friend.name?replace("\\W","","r")> +:${fid} + a apst:FacebookProfile ; + vcard:fn "${friend.name}" . + +:${id}-connect-${fid} + a as:Connect ; + as:actor :${id} ; + as:object :${fid} ; + as:published "${friend.timestamp}" . + +</#list> +</#if> + +<#attempt> +<#assign messages = pp.loadData('json', 'messages/messages.json')> +<#recover> +</#attempt> + +<#if friends??> +<#list friends.friends as friend> +<#assign fid=friend.name?replace("\\W","","r")> +:${fid} + a apst:FacebookProfile ; + vcard:fn "${friend.name}" . + +:${id}-connect-${fid} + a as:Connect ; + as:actor :${id} ; + as:object :${fid} ; + as:published "${friend.timestamp}" . + +</#list> +</#if> diff --git a/streams-contrib/streams-provider-facebook/src/site/markdown/experimental.md b/streams-contrib/streams-provider-facebook/src/site/markdown/experimental.md new file mode 100644 index 0000000..171f6f3 --- /dev/null +++ b/streams-contrib/streams-provider-facebook/src/site/markdown/experimental.md @@ -0,0 +1,35 @@ +## Experimental Features + +To object a facebook export archive, follow these steps: + + *TODO* + +Unzip the archive file into a local directory, $DATAROOT. + +Define the namespace you want to use for the generated triples, $NAMESPACE. + + export NAMESPACE=http://streams.apache.org/streams-contrib/streams-provider-facebook + +Define the id you want to attach the generated triples to, $ID. + + export ID=id + +Specify where you want the generated triples to be written, $OUTPUTROOT. + + export OUTPUTROOT=target/generated-resources/facebook/ + +To generate RDF triples from a facebook export archive, follow these steps: + + cd streams-contrib/streams-provider-facebook + java -cp ../../streams-dist/dist/streams-dist-jar-with-dependencies.jar \ + -DbaseDir=. \ + -DsettingsFile=../../streams-cli/src/main/resources/default.fmpp \ + -DsourceRoot=src/main/templates \ + -DdataRoot=$DATAROOT \ + -DoutputRoot=$OUTPUTROOT \ + -Dnamespace=$NAMESPACE \ + -Did=$ID \ + org.apache.streams.cli.RdfFreemarkerCli + + +###### Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 diff --git a/streams-contrib/streams-provider-facebook/src/site/markdown/index.md b/streams-contrib/streams-provider-facebook/src/site/markdown/index.md index b80f2f0..757825c 100644 --- a/streams-contrib/streams-provider-facebook/src/site/markdown/index.md +++ b/streams-contrib/streams-provider-facebook/src/site/markdown/index.md @@ -45,6 +45,7 @@ Confirm that you can get data from testing endpoints with Graph API Explorer: [https://developers.facebook.com/tools/explorer/](https://developers.facebook.com/tools/explorer/ "https://developers.facebook.com/tools/explorer/") +[Experimental Features](experimental.html "Experimental Features") [JavaDocs](apidocs/index.html "JavaDocs") diff --git a/streams-contrib/streams-provider-google/google-gplus/src/main/templates/googleplus.ttl.ftl b/streams-contrib/streams-provider-google/google-gplus/src/main/templates/googleplus.ttl.ftl new file mode 100644 index 0000000..cd70fe7 --- /dev/null +++ b/streams-contrib/streams-provider-google/google-gplus/src/main/templates/googleplus.ttl.ftl @@ -0,0 +1,85 @@ +<#ftl output_format="XML" auto_esc=true> +<#-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<#attempt> + <#assign profile = pp.loadData('json', 'Takeout/Profile/Profile.json')> + <#recover> + <#stop "NO_PROFILE_INFORMATION"> +</#attempt> +@prefix : <${namespace}#> . +@prefix as: <http://www.w3.org/ns/activitystreams#> . +@prefix apst: <http://streams.apache.org/ns#> . +@prefix dc: <http://purl.org/dc/elements/1.1/#> . +@prefix dct: <http://purl.org/dc/terms/#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . +@base <${namespace}> . + +<#attempt> +<#assign raw=profile.name.formattedName> +<#assign id=raw?replace("\\W","","r")> +<#recover> +<#stop "NO_ID"> +</#attempt> + +# profile.json +:${id} a apst:GooglePlusProfile . + +:${id} + as:displayName "${profile.displayName}" ; + vcard:fn "${profile.name.formattedName}" ; + vcard:given-name "${profile.name.givenName}" ; + vcard:fn "${profile.name.familyName}" ; + . + +<#if profile.email??> +:${id} + vcard:email "mailto:${profile.email}" ; + . +</#if> + +<#if profile.phone_number??> +:${id} + vcard:tel "tel:${profile.phone_number}" ; + . +</#if> + +<#-- +Google+ Circles\*.csv +First Name,Last Name,Nickname,Display Name,Profile URL +--> + +<#assign friends = pp.loadData('csv', 'Takeout/Google+ Circles/Friends.csv', {'separator':',', 'normalizeHeaders': true})> + +<#if friends??> +<#list friends as friend> +<#assign fraw = "${friend.display_name}"> +<#assign fid=fraw?replace("\\W","","r")> +:${fid} a apst:GooglePlusProfile ; + as:displayName "${friend.display_name}" . + +:${id}-connect-${fid} a as:Connect ; + as:actor :${id} ; + as:object :${fid} + . + +</#list> +</#if> + diff --git a/streams-contrib/streams-provider-google/google-gplus/src/site/markdown/experimental.md b/streams-contrib/streams-provider-google/google-gplus/src/site/markdown/experimental.md new file mode 100644 index 0000000..af52db8 --- /dev/null +++ b/streams-contrib/streams-provider-google/google-gplus/src/site/markdown/experimental.md @@ -0,0 +1,35 @@ +## Experimental Features + +To object a google plus export archive, follow these steps: + + *TODO* + +Unzip the archive file into a local directory, $DATAROOT. + +Define the namespace you want to use for the generated triples, $NAMESPACE. + + export NAMESPACE=http://streams.apache.org/streams-contrib/streams-provider-facebook + +Define the id you want to attach the generated triples to, $ID. + + export ID=id + +Specify where you want the generated triples to be written, $OUTPUTROOT. + + export OUTPUTROOT=target/generated-resources/googleplus/ + +To generate RDF triples from the export archive, follow these steps: + + cd streams-contrib/streams-provider-google/google-gplus + java -cp ../../../streams-dist/dist/streams-dist-jar-with-dependencies.jar \ + -DbaseDir=. \ + -DsettingsFile=../../../streams-cli/src/main/resources/default.fmpp \ + -DsourceRoot=src/main/templates \ + -DdataRoot=$DATAROOT \ + -DoutputRoot=$OUTPUTROOT \ + -Dnamespace=$NAMESPACE \ + -Did=$ID \ + org.apache.streams.cli.RdfFreemarkerCli + + +###### Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 diff --git a/streams-contrib/streams-provider-google/google-gplus/src/site/markdown/index.md b/streams-contrib/streams-provider-google/google-gplus/src/site/markdown/index.md index ec5bcee..fc56bf4 100644 --- a/streams-contrib/streams-provider-google/google-gplus/src/site/markdown/index.md +++ b/streams-contrib/streams-provider-google/google-gplus/src/site/markdown/index.md @@ -41,6 +41,8 @@ Create a local file `gplus.conf` with valid gplus credentials Build with integration testing enabled, using your credentials mvn clean test verify -DskipITs=false -DargLine="-Dconfig.file=`pwd`/gplus.conf" + +[Experimental Features](experimental.html "Experimental Features") [JavaDocs](apidocs/index.html "JavaDocs") diff --git a/streams-contrib/streams-provider-instagram/src/main/templates/instagram.ttl.ftl b/streams-contrib/streams-provider-instagram/src/main/templates/instagram.ttl.ftl new file mode 100644 index 0000000..ed05ea7 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/main/templates/instagram.ttl.ftl @@ -0,0 +1,108 @@ +<#ftl output_format="XML" auto_esc=true> +<#-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<#attempt> + <#assign profile = pp.loadData('json', 'profile.json')> + <#recover> + <#stop "NO_PROFILE_INFORMATION"> +</#attempt> +@prefix : <${namespace}#> . +@prefix as: <http://www.w3.org/ns/activitystreams#> . +@prefix apst: <http://streams.apache.org/ns#> . +@prefix dc: <http://purl.org/dc/elements/1.1/#> . +@prefix dct: <http://purl.org/dc/terms/#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . +@base <${namespace}> . +<#attempt> +<#assign id="${profile.username}"> +<#recover> +<#stop "NO_ID"> +</#attempt> + +:${id} a apst:InstagramProfile . + +:${id} + as:displayName "${profile.username}" ; + vcard:fn "${profile.name}" ; + dct:created "${profile.date_joined}" ; + . + +:${id} + vcard:email "mailto:${profile.email}" ; + . + +<#if profile.phone_number??> +:${profile.username} + vcard:tel "tel:${profile.phone_number}" ; + . + +</#if> + +<#attempt> +<#assign connections = pp.loadData('json', 'connections.json')> +<#recover> +</#attempt> + +<#if connections??> +<#list connections.followers as handle, since> +<#assign fid = "${handle}"> +:${fid} a apst:InstagramProfile ; + as:displayName "${handle}" . +:${fid}follow${id} a as:Follow ; + as:actor :${fid} ; + as:object :${id} ; + as:published "${since}" . + +</#list> + +<#list connections.following as handle, since> +<#assign fid = "${handle}"> +:${fid} a ap:InstagramProfile ; + as:displayName "${handle}" . +:${id}-follow-${fid} a as:Follow ; + as:actor :${id} ; + as:object :${fid} ; + as:published "${since}" . + +</#list> +</#if> + +<#attempt> +<#assign messages = pp.loadData('json', 'messages.json')> +<#recover> +</#attempt> + +<#if messages??> +<#list messages as thread> +<#assign fids = thread.participants![]> +<#list fids as fid> +<#if fid != profile.username> +:${fid} a ap:InstagramProfile ; + as:displayName "${fid}" . +:${id}-message-${fid} a as:Note ; + as:actor :${id} ; + as:object :${fid} . + +</#if> +</#list> +</#list> +</#if> + diff --git a/streams-contrib/streams-provider-instagram/src/site/markdown/experimental.md b/streams-contrib/streams-provider-instagram/src/site/markdown/experimental.md new file mode 100644 index 0000000..6e22978 --- /dev/null +++ b/streams-contrib/streams-provider-instagram/src/site/markdown/experimental.md @@ -0,0 +1,34 @@ +## Experimental Features + +To obtain an instagram export archive, follow these steps: + + *TODO* + +Unzip the archive file into a local directory, $DATAROOT. + +Define the namespace you want to use for the generated triples, $NAMESPACE. + + export NAMESPACE=http://streams.apache.org/streams-contrib/streams-provider-instagram + +Define the id you want to attach the generated tripes to, $ID. + + export ID=id + +Specify where you want the generated triples to be written, $OUTPUTROOT. + + export OUTPUTROOT=target/generated-resources/instagram/ + +To generate RDF triples from an instagram export archive, follow these steps: + + cd streams-contrib/streams-provider-instagram + java -cp ../../streams-dist/dist/streams-dist-jar-with-dependencies.jar \ + -DbaseDir=. \ + -DsettingsFile=../../streams-cli/src/main/resources/default.fmpp \ + -DsourceRoot=src/main/templates \ + -DdataRoot=$DATAROOT \ + -DoutputRoot=$OUTPUTROOT \ + -Dnamespace=$NAMESPACE \ + -Did=$ID \ + org.apache.streams.cli.RdfFreemarkerCli + +###### Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 diff --git a/streams-contrib/streams-provider-instagram/src/site/markdown/index.md b/streams-contrib/streams-provider-instagram/src/site/markdown/index.md index 5cb60b0..b06b136 100644 --- a/streams-contrib/streams-provider-instagram/src/site/markdown/index.md +++ b/streams-contrib/streams-provider-instagram/src/site/markdown/index.md @@ -41,9 +41,7 @@ If you only have sandbox credentials, you'll have to edit src/test/resources/*IT Resources: ---------- -[https://elfsight.com/blog/2016/05/how-to-get-instagram-access-token/](https://elfsight.com/blog/2016/05/how-to-get-instagram-access-token/ "https://elfsight.com/blog/2016/05/how-to-get-instagram-access-token/") - -[https://smashballoon.com/instagram-feed/find-instagram-user-id/](https://smashballoon.com/instagram-feed/find-instagram-user-id/ "https://smashballoon.com/instagram-feed/find-instagram-user-id/") +[Experimental Features](experimental.html "Experimental Features") [JavaDocs](apidocs/index.html "JavaDocs") diff --git a/streams-contrib/streams-provider-linkedin/pom.xml b/streams-contrib/streams-provider-linkedin/pom.xml new file mode 100644 index 0000000..f585e3b --- /dev/null +++ b/streams-contrib/streams-provider-linkedin/pom.xml @@ -0,0 +1,196 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<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"> + <parent> + <groupId>org.apache.streams</groupId> + <artifactId>streams-contrib</artifactId> + <version>0.6.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>streams-provider-linkedin</artifactId> + <name>streams-provider-linkedin</name> + + <description>LinkedIn Provider</description> + + <properties> + <skipITs>true</skipITs> + </properties> + + <dependencies> + <dependency> + <groupId>com.typesafe</groupId> + <artifactId>config</artifactId> + </dependency> + <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-config</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-core</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-annotations</artifactId> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.datatype</groupId> + <artifactId>jackson-datatype-joda</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-core</artifactId> + </dependency> + <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-pojo</artifactId> + </dependency> + <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-converters</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-util</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-http</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-csv</artifactId> + <version>1.5</version> + </dependency> + <dependency> + <groupId>org.apache.juneau</groupId> + <artifactId>juneau-rest-client</artifactId> + </dependency> + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <exclusions> + <exclusion> + <groupId>commons-logging</groupId> + <artifactId>commons-logging</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <version>1.3</version> + </dependency> + <dependency> + <groupId>org.apache.streams</groupId> + <artifactId>streams-testing</artifactId> + <version>${project.version}</version> + <scope>test</scope> + <type>test-jar</type> + </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>${mockito.version}</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <sourceDirectory>src/main/java</sourceDirectory> + <testSourceDirectory>src/test/java</testSourceDirectory> + <resources> + <resource> + <directory>src/main/resources</directory> + </resource> + </resources> + <testResources> + <testResource> + <directory>src/test/resources</directory> + </testResource> + </testResources> + <plugins> + <plugin> + <groupId>org.apache.streams.plugins</groupId> + <artifactId>streams-plugin-pojo</artifactId> + <version>${project.version}</version> + <configuration> + <sourcePaths> + <sourcePath>${project.basedir}/src/main/jsonschema</sourcePath> + </sourcePaths> + <targetDirectory>${project.basedir}/target/generated-sources/pojo</targetDirectory> + <targetPackage>org.apache.streams.linkedin.pojo</targetPackage> + </configuration> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>target/generated-sources/pojo</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <configuration> + <skipTests>${skipITs}</skipTests> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.5.0</version> + <executions> + <execution> + <goals> + <goal>exec</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/streams-contrib/streams-provider-linkedin/src/main/templates/linkedin.ttl.ftl b/streams-contrib/streams-provider-linkedin/src/main/templates/linkedin.ttl.ftl new file mode 100644 index 0000000..f796bb6 --- /dev/null +++ b/streams-contrib/streams-provider-linkedin/src/main/templates/linkedin.ttl.ftl @@ -0,0 +1,224 @@ +<#ftl output_format="XML" auto_esc=true> +<#-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<#attempt> + <#assign profiles=pp.loadData('csv', 'Profile.csv', {'separator':',', 'normalizeHeaders': true})> + <#recover> + <#stop "NO_PROFILES"> +</#attempt> +<#attempt> + <#assign profile=profiles[0]> + <#recover> + <#stop "NO_PROFILE"> +</#attempt> +@prefix : <${namespace}#> . +@prefix as: <http://www.w3.org/ns/activitystreams#> . +@prefix apst: <http://streams.apache.org/ns#> . +@prefix dc: <http://purl.org/dc/elements/1.1/#> . +@prefix dct: <http://purl.org/dc/terms/#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . +@base <${namespace}> . + +<#-- +# Profile.csv +# First Name,Last Name,Maiden Name,Created Date,Address,Birth Date,Contact Instructions,Marital Status,Headline,Summary,Industry,Association +# <#list profiles as profile> <#list profile as key, value>${key}: ${value} </#list> </#list> +--> +<#attempt> +<#assign raw="${profile.first_name}${profile.last_name}"> +<#assign id=raw?replace("\\W","","r")> +<#recover> +<#stop "NO_ID"> +</#attempt> + +:${id} a apst:LinkedinProfile . + +:${id} +<#-- first row only --> + as:displayName "${profile.first_name}" ; + vcard:fn "${profile.first_name} ${profile.last_name}" ; + vcard:given-name "${profile.first_name}" ; + vcard:family-name "${profile.last_name}" ; + . + +<#-- +# Registration.csv +# Registration Date,Registration IP,Subscription Type,Inviter First Name,Inviter Last Name +# <#list registration_infos as registration_info> <#list registration_info as key, value>${key}: ${value} </#list> </#list> +--> + +<#attempt> +<#assign registrations = pp.loadData('csv', 'Registration.csv', {'separator':',', 'normalizeHeaders': true})> +<#recover> +</#attempt> + +<#if registrations??> +:${id} +<#list registrations as registration> + dct:createdAt "${registration.registration_date}" ; +</#list> + . +</#if> + +<#-- +# Email Addresses.csv +# Email Address,Confirmed,Is primary,Status Updated On +# <#list email_addresses as email_address> <#list email_address as key, value>${key}: ${value} </#list> </#list> +--> + +<#attempt> +<#assign email_addresses = pp.loadData('csv', 'Email Addresses.csv', {'separator':',', 'normalizeHeaders': true})> +<#recover> +</#attempt> + +<#if email_addresses??> +:${id} +<#list email_addresses as email_address> + vcard:email "mailto:${email_address.email_address}" ; +</#list> + . +</#if> + +<#-- +# PhoneNumbers.csv +# Number,Extension,Type +# <#list phone_numbers as phone_number> <#list phone_number as key, value>${key}: ${value} </#list> </#list> +--> + +<#attempt> +<#assign phone_numbers = pp.loadData('csv', 'Phone Numbers.csv', {'separator':',', 'normalizeHeaders': true})> +<#recover> +</#attempt> + +<#if phone_numbers??> +:${id} +<#list phone_numbers as phone_number> + vcard:tel "tel:${phone_number.number}" ; +</#list> + . +</#if> + +<#-- +# Connections.csv +# First Name,Last Name,Address,Email Address,Company,Position,Connected On,Websites,Instant Messengers +--> + +<#attempt> +<#assign connections = pp.loadData('csv', 'Connections.csv', {'separator':',', 'normalizeHeaders': true})> +<#recover> +</#attempt> + +<#if connections??> +<#list connections as connection> +<#assign craw = "${connection.first_name}${connection.last_name}"> +<#assign cid=craw?replace("\\W","","r")> +:${cid} + a apst:LinkedinProfile ; + vcard:fn "${connection.first_name} ${connection.last_name}" ; + vcard:given-name "${connection.first_name}" ; + vcard:family-name "${connection.last_name}" ; + vcard:email "mailto:${connection.email_address}" ; + vcard:org "${connection.company?replace("\\W"," ","r")}" ; + vcard:title "${connection.position?replace("\\W"," ","r")}" ; + . + +:${id}-connect-${cid} + a as:Connect ; + as:actor :${id} ; + as:object :${cid} ; + as:published "${connection.connected_on}" ; + . + +</#list> +</#if> + +<#-- +Messages.csv +From,To,Date,Subject,Content,Direction,Folder +--> + +<#attempt> +<#assign messages = pp.loadData('csv', 'Messages.csv', {'separator':',', 'normalizeHeaders': true})> +<#recover> +</#attempt> + +<#if messages??> +<#list messages as message> +<#assign aidraw = "${message.from}"> +<#assign aid=aidraw?replace("\\W","","r")> +<#assign oidraw = "${message.to}"> +<#assign oid=oidraw?replace("\\W","","r")> +<#assign subjectraw = "${message.subject}"> +<#assign subjectid=subjectraw?replace("\\W","","r")> +:${aid}-message-${oid}-${subjectid} + a as:Note ; + as:actor :${aid} ; + as:object :${oid} ; + . +</#list> +</#if> + +<#-- +Recommendations Given.csv +First Name,Last Name,Company,Job Title,Text,Creation Date,Status +--> + +<#attempt> +<#assign recommendations_given = pp.loadData('csv', 'Recommendations Given.csv', {'separator':',', 'normalizeHeaders': true})> +<#recover> +</#attempt> + +<#if recommendations_given??> +<#list recommendations_given as recommendation> +<#assign oidraw = "${recommendation.first_name}${recommendation.last_name}"> +<#assign oid=oidraw?replace("\\W","","r")> +:${id}-like-${oid} + a as:Like ; + as:actor :${id} ; + as:object :${oid} ; + as:published "${recommendation.creation_date}" ; + . +</#list> +</#if> + +<#-- +Recommendations Received.csv +First Name,Last Name,Company,Job Title,Text,Creation Date,Status +--> + +<#attempt> +<#assign recommendations_received = pp.loadData('csv', 'Recommendations Received.csv', {'separator':',', 'normalizeHeaders': true})> +<#recover> +</#attempt> + +<#if recommendations_given??> +<#list recommendations_given as recommendation> +<#assign aidraw = "${recommendation.first_name}${recommendation.last_name}"> +<#assign aid=aidraw?replace("\\W","","r")> +:${aid}-like-${id} + a as:Like ; + as:actor :${aid} ; + as:object :${id} ; + as:published "${recommendation.creation_date}" ; + . +</#list> +</#if> + diff --git a/streams-contrib/streams-provider-linkedin/src/site/markdown/experimental.md b/streams-contrib/streams-provider-linkedin/src/site/markdown/experimental.md new file mode 100644 index 0000000..3fa67fd --- /dev/null +++ b/streams-contrib/streams-provider-linkedin/src/site/markdown/experimental.md @@ -0,0 +1,34 @@ +## Experimental Features + +To object a linkedin export archive, follow these steps: + + *TODO* + +Unzip the archive file into a local directory, $DATAROOT. + +Define the namespace you want to use for the generated triples, $NAMESPACE. + + export NAMESPACE=http://streams.apache.org/streams-contrib/streams-provider-linkedin + +Define the id you want to attach the generated tripes to, $ID. + + export ID=id + +Specify where you want the generated triples to be written, $OUTPUTROOT. + + export OUTPUTROOT=target/generated-resources/linkedin/ + +To generate RDF triples from a linkedin export archive, follow these steps: + + cd streams-contrib/streams-provider-linkedin + java -cp ../../streams-dist/dist/streams-dist-jar-with-dependencies.jar \ + -DbaseDir=. \ + -DsettingsFile=../../streams-cli/src/main/resources/default.fmpp \ + -DsourceRoot=src/main/templates \ + -DdataRoot=$DATAROOT \ + -DoutputRoot=$OUTPUTROOT \ + -Dnamespace=$NAMESPACE \ + -Did=$ID \ + org.apache.streams.cli.RdfFreemarkerCli + +###### Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 diff --git a/streams-contrib/streams-provider-linkedin/src/site/markdown/index.md b/streams-contrib/streams-provider-linkedin/src/site/markdown/index.md new file mode 100644 index 0000000..217902f --- /dev/null +++ b/streams-contrib/streams-provider-linkedin/src/site/markdown/index.md @@ -0,0 +1,8 @@ +org.apache.streams:streams-provider-linkedin +=========================================== + +streams-provider-linkedin contains utility classes for LinkedIn. + +[Experimental Features](experimental.html "Experimental Features") + +###### Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 diff --git a/streams-contrib/streams-provider-twitter/src/main/templates/twitter.ttl.ftl b/streams-contrib/streams-provider-twitter/src/main/templates/twitter.ttl.ftl new file mode 100644 index 0000000..179c8ce --- /dev/null +++ b/streams-contrib/streams-provider-twitter/src/main/templates/twitter.ttl.ftl @@ -0,0 +1,79 @@ +<#ftl output_format="XML" auto_esc=true> + +@prefix : <http://graph.bluesquad.co/twitter#> . +@prefix ap: <http://streams.apache.org/ns#> . +@prefix as: <http://www.w3.org/ns/activitystreams#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix xml: <http://www.w3.org/XML/1998/namespace> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . +@prefix prov: <http://www.w3.org/ns/prov#> . +@prefix dc: <http://purl.org/dc/elements/1.1/#> . +@prefix dct: <http://purl.org/dc/terms/#> . +@base <http://graph.bluesquad.co/twitter> . + +# account.js +<#attempt> +<#assign accounts = pp.loadData('json', '${root}/account.js')> +<#assign account = accounts[0].account> +<#recover> +<#stop "NO_PROFILE_INFORMATION"> +</#attempt> + +<#attempt> +<#assign id="${account.accountId}"> +<#recover> +<#stop "NO_ID"> +</#attempt> + +:${id} a ap:TwitterProfile . + +:${id} + as:displayName "${account.accountDisplayName}" ; + as:name "${account.username}" ; + dct:created "${account.createdAt}" ; + vcard:email "${account.email}" ; + . + +# profile.js +<#assign profiles = pp.loadData('json', '${root}/profile.js')> +<#assign profile = profiles[0].profile> + +:${id} + as:summary "${profile.description.bio}" ; + as:url "${profile.description.website}" ; + . + +<#attempt> +<#assign followers = pp.loadData('json', '${root}/follower.js')> +<#recover> +</#attempt> + +<#if followers??> +<#list followers as follower> +<#assign fid = "${follower.follower.accountId}"> +:${fid} a ap:TwitterProfile . +:${fid}-follow-${id} a as:Follow ; + as:actor :${fid} ; + as:object :${id} . + +</#list> +</#if> + +<#attempt> +<#assign friends = pp.loadData('json', '${root}/following.js')> +<#recover> +</#attempt> + +<#if friends??> +<#list friends as friend> +<#assign fid = "${friend.following.accountId}"> +:${fid} a ap:TwitterProfile . +:${id}-follow-${fid} a as:Follow ; + as:actor :${id} ; + as:object :${fid} . + +</#list> +</#if> diff --git a/streams-contrib/streams-provider-twitter/src/site/markdown/experimental.md b/streams-contrib/streams-provider-twitter/src/site/markdown/experimental.md new file mode 100644 index 0000000..b16196f --- /dev/null +++ b/streams-contrib/streams-provider-twitter/src/site/markdown/experimental.md @@ -0,0 +1,29 @@ +## Experimental Features + +To object a twitter export archive, follow these steps: + + *TODO* + +Unzip the archive file into a local directory, $DATAROOT. + +Define the namespace you want to use for the generated triples, $NAMESPACE. + + export NAMESPACE=http://streams.apache.org/streams-contrib/streams-provider-twitter + +Define the id you want to attach the generated tripes to, $ID. + + export ID=id + +To generate RDF triples from a twitter export archive, follow these steps: + + java -jar streams-dist-jar-with-dependencies.jar \ + org.apache.streams.cli.RdfFreemarkerCli \ + . \ + target/dependency/default.fmpp \ + src/main/templates \ + $DATAROOT \ + . \ + $NAMESPACE \ + $ID + +###### Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 diff --git a/streams-contrib/streams-provider-twitter/src/site/markdown/index.md b/streams-contrib/streams-provider-twitter/src/site/markdown/index.md index 4249956..b9c5524 100644 --- a/streams-contrib/streams-provider-twitter/src/site/markdown/index.md +++ b/streams-contrib/streams-provider-twitter/src/site/markdown/index.md @@ -49,6 +49,8 @@ Build with integration testing enabled, using your credentials mvn clean test verify -DskipITs=false -DargLine="-Dconfig.file=`pwd`/application.conf" +[Experimental Features](experimental.html "Experimental Features") + [JavaDocs](apidocs/index.html "JavaDocs") ###### Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 diff --git a/streams-contrib/streams-provider-youtube/src/main/templates/youtube.ttl.ftl b/streams-contrib/streams-provider-youtube/src/main/templates/youtube.ttl.ftl new file mode 100644 index 0000000..00bb36d --- /dev/null +++ b/streams-contrib/streams-provider-youtube/src/main/templates/youtube.ttl.ftl @@ -0,0 +1,68 @@ +<#ftl output_format="XML" auto_esc=true> +<#-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> +<#attempt> + <#assign profile = pp.loadData('json', 'Takeout/Profile/Profile.json')> + <#recover> + <#stop "NO_PROFILE_INFORMATION"> +</#attempt> +@prefix : <http://graph.bluesquad.co/youtube#> . +@prefix ap: <http://streams.apache.org/ns#> . +@prefix as: <http://www.w3.org/ns/activitystreams#> . +@prefix owl: <http://www.w3.org/2002/07/owl#> . +@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . +@prefix xml: <http://www.w3.org/XML/1998/namespace> . +@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . +@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . +@prefix vcard: <http://www.w3.org/2006/vcard/ns#> . +@prefix prov: <http://www.w3.org/ns/prov#> . +@prefix dc: <http://purl.org/dc/elements/1.1/#> . +@prefix dct: <http://purl.org/dc/terms/#> . +@base <http://graph.bluesquad.co/youtube> . + +<#attempt> +<#assign raw=profile.name.formattedName> +<#assign id=raw?replace("\\W","","r")> +<#recover> +<#stop "NO_ID"> +</#attempt> + +# profile.json +:${id} a ap:YouTubeProfile . + +:${id} + as:displayName "${profile.displayName}" ; + vcard:fn "${profile.name.formattedName}" ; + vcard:given-name "${profile.name.givenName}" ; + vcard:fn "${profile.name.familyName}" ; + . + +<#if profile.email??> +:${id} + vcard:email "mailto:${profile.email}" ; + . +</#if> + +<#if profile.phone_number??> +:${id} + vcard:tel "tel:${profile.phone_number}" ; + . +</#if> + + + diff --git a/streams-contrib/streams-provider-youtube/src/site/markdown/experimental.md b/streams-contrib/streams-provider-youtube/src/site/markdown/experimental.md new file mode 100644 index 0000000..02668ad --- /dev/null +++ b/streams-contrib/streams-provider-youtube/src/site/markdown/experimental.md @@ -0,0 +1,34 @@ +## Experimental Features + +To object a youtube export archive, follow these steps: + + *TODO* + +Unzip the archive file into a local directory, $DATAROOT. + +Define the namespace you want to use for the generated triples, $NAMESPACE. + + export NAMESPACE=http://streams.apache.org/streams-contrib/streams-provider-youtube + +Define the id you want to attach the generated tripes to, $ID. + + export ID=id + +Specify where you want the generated triples to be written, $OUTPUTROOT. + + export OUTPUTROOT=target/generated-resources/youtube/ + +To generate RDF triples from a youtube export archive, follow these steps: + + cd streams-contrib/streams-provider-youtube + java -cp ../../streams-dist/dist/streams-dist-jar-with-dependencies.jar \ + -DbaseDir=. \ + -DsettingsFile=../../streams-cli/src/main/resources/default.fmpp \ + -DsourceRoot=src/main/templates \ + -DdataRoot=$DATAROOT \ + -DoutputRoot=$OUTPUTROOT \ + -Dnamespace=$NAMESPACE \ + -Did=$ID \ + org.apache.streams.cli.RdfFreemarkerCli + +###### Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 diff --git a/streams-dist/pom.xml b/streams-dist/pom.xml index 70027f8..193e52a 100644 --- a/streams-dist/pom.xml +++ b/streams-dist/pom.xml @@ -34,6 +34,12 @@ under the License. <dependency> <groupId>org.apache.streams</groupId> + <artifactId>streams-cli</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.apache.streams</groupId> <artifactId>streams-config</artifactId> <version>${project.version}</version> </dependency> diff --git a/streams-schemas/streams-schema-activitystreams/pom.xml b/streams-schemas/streams-schema-activitystreams/pom.xml index a7dd3ee..7e637f2 100644 --- a/streams-schemas/streams-schema-activitystreams/pom.xml +++ b/streams-schemas/streams-schema-activitystreams/pom.xml @@ -63,13 +63,6 @@ <type>test-jar</type> </dependency> <dependency> - <groupId>org.apache.streams</groupId> - <artifactId>streams-testing</artifactId> - <version>${project.version}</version> - <scope>test</scope> - <type>test-jar</type> - </dependency> - <dependency> <groupId>com.networknt</groupId> <artifactId>json-schema-validator</artifactId> <type>jar</type>