streams-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (STREAMS-616) Convert timestamps to xsd:datetime (ISO8601) in AS2.0 TTL outputs
Date Wed, 31 Oct 2018 15:57:02 GMT

    [ https://issues.apache.org/jira/browse/STREAMS-616?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16670302#comment-16670302
] 

ASF GitHub Bot commented on STREAMS-616:
----------------------------------------

steveblackmon closed pull request #466: resolves STREAMS-616
URL: https://github.com/apache/streams/pull/466
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/streams-cli/src/test/resources/test.ttl.ftl b/streams-cli/src/test/resources/test.ttl.ftl
index 7712c85483..0959e4f805 100644
--- a/streams-cli/src/test/resources/test.ttl.ftl
+++ b/streams-cli/src/test/resources/test.ttl.ftl
@@ -29,6 +29,7 @@
 @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 xs: <http://www.w3.org/2001/XMLSchema#> .
 @base <${namespace}> .
 
 :${id} a as:Person .
@@ -37,5 +38,5 @@
 
 :${id}
   as:displayName "${person.displayName}" ;
-  dct:created "${now?iso_utc}" ;
+  dct:created "${now?string.xs_nz}"^^xs:dateTime ;
   .
\ No newline at end of file
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
index 54f3c2e77a..24fea4b3f6 100644
--- a/streams-contrib/streams-provider-facebook/src/main/templates/facebook.ttl.ftl
+++ b/streams-contrib/streams-provider-facebook/src/main/templates/facebook.ttl.ftl
@@ -30,6 +30,7 @@
 @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#> .
+@prefix xs: <http://www.w3.org/2001/XMLSchema#> .
 @base <${namespace}> .
 
 <#-- profile_information/profile_information.json -->
@@ -51,23 +52,40 @@
   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}" ;
+  as:displayName "${profile_information.profile.name.full_name}" ;
     <#else>
-    as:displayName "${profile_information.profile.name}" ;
+  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}" ;
+  vcard:fn "${profile_information.profile.name.full_name}" ;
     <#else>
-    vcard:fn "${profile_information.profile.name}" ;
+  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}" ;
+<#attempt>
+    <#assign registration_millis = profile_information.profile.registration_timestamp*1000>
+    <#assign registration_date = registration_millis?number_to_datetime>
+    <#assign registration_xsnz = registration_date?string.xs_nz>
+  dct:created "${registration_xsnz}"^^xs:dateTime ;
+    <#recover>
+    # REGISTRATION TIMESTAMP PROCESSING FAILED
+    # profile_information.profile.registration_timestamp: ${profile_information.profile.registration_timestamp}
+        <#if registration_millis??>
+    # registration_millis: ${registration_millis}
+        </#if>
+        <#if registration_date??>
+    # registration_date: ${registration_date}
+        </#if>
+        <#if registration_xsnz??>
+    # registration_xsnz: ${registration_xsnz}
+        </#if>
+</#attempt>
   .
 
 <#if profile_information.profile.emails??>
@@ -154,7 +172,7 @@
                             </#if>
                         </#list>
                         <#list telshash?keys as tel>
-:${id} vcard:tel "${tel}" .
+  vcard:tel "${tel}" ;
                         </#list>
                     </#if>
                 </#list>
@@ -165,34 +183,27 @@
   a as:Connect ;
   as:actor :${id} ;
   as:object :${fid} ;
-  as:published "${friend.timestamp}" .
-
+<#attempt>
+    <#assign friend_millis = friend.timestamp*1000>
+    <#assign friend_datetime = friend_millis?number_to_datetime>
+    <#assign friend_xsnz = friend_datetime?string.xs_nz>
+  as:published "${friend_xsnz}"^^xs:dateTime ;
+    <#recover>
+# FRIEND TIMESTAMP PROCESSING FAILED
+# friend.timestamp: ${friend.timestamp}
+        <#if friend_millis??>
+# friend_millis: ${friend_millis}
         </#if>
-    </#list>
-</#if>
-
-<#if friends??>
-    <#list friends.friends as friend>
-        <#assign fid=friend.name?replace("\\W","","r")>
-        <#assign nameparts=friend.name?split(" ")>
-:${fid}
-  a apst:FacebookProfile ;
-  vcard:fn "${friend.name}" ;
-  vcard:given-name "${nameparts[0]}" ;
-        <#if (nameparts?size > 2)>
-  vcard:additional-name "${nameparts[1]}" ;
-  vcard:family-name "${nameparts[2]}" ;
-        <#elseif (nameparts?size == 2)>
-  vcard:family-name "${nameparts[1]}" ;
+        <#if friend_datetime??>
+# friend_datetime: ${friend_datetime}
+        </#if>
+        <#if friend_xsnz??>
+# friend_xsnz: ${friend_xsnz}
         </#if>
+</#attempt>
   .
 
-:${id}-connect-${fid}
-  a as:Connect ;
-  as:actor :${id} ;
-  as:object :${fid} ;
-  as:published "${friend.timestamp}" .
-
+        </#if>
     </#list>
 </#if>
 
@@ -212,19 +223,42 @@
                 <#-- only keep the timestamps of direct messages with friends -->
                     <#if (fid?? && friendshash[fid]??)>
                         <#list messages.messages as message>
+                            <#attempt>
+                                <#assign message_millis = message.timestamp*1000>
+                                <#assign message_datetime = message_millis?number_to_datetime>
+                                <#assign message_xsnz = message_datetime?string.xs_nz>
+                                <#recover>
+# FRIEND TIMESTAMP PROCESSING FAILED
+# message.timestamp: ${message.timestamp}
+                                    <#if message_millis??>
+# message_millis: ${message_millis}
+                                    </#if>
+                                    <#if message_datetime??>
+# message_datetime: ${message_datetime}
+                                    </#if>
+                                    <#if message_xsnz??>
+# message_xsnz: ${message_xsnz}
+                                    </#if>
+                            </#attempt>
                             <#if fullname == message.sender_name>
 :${id}-message-${fid}-${message.timestamp}
-a as:Note ;
-as:actor :${id} ;
-as:object :${fid} ;
-as:published "${message.timestamp}" .
+    a as:Note ;
+    as:actor :${id} ;
+    as:object :${fid} ;
+                                <#if message_xsnz??>
+    as:published "${message_xsnz}"^^xs:dateTime ;
+                                </#if>
+    .
 
                             <#else>
 :${fid}-message-${id}-${message.timestamp}
-a as:Note ;
-as:actor :${fid} ;
-as:object :${id} ;
-as:published "${message.timestamp}" .
+    a as:Note ;
+    as:actor :${fid} ;
+    as:object :${id} ;
+                                <#if message_xsnz??>
+    as:published "${message_xsnz}"^^xs:dateTime ;
+                                </#if>
+    .
 
                             </#if>
                         </#list>
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
index 6efb116bb9..64306fa1ff 100644
--- a/streams-contrib/streams-provider-instagram/src/main/templates/instagram.ttl.ftl
+++ b/streams-contrib/streams-provider-instagram/src/main/templates/instagram.ttl.ftl
@@ -30,6 +30,7 @@
 @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#> .
+@prefix xs: <http://www.w3.org/2001/XMLSchema#> .
 @base <${namespace}> .
 <#attempt>
 <#assign id="${profile.username}">
@@ -42,19 +43,25 @@
 :${id}
   as:displayName "${profile.username}" ;
   vcard:fn "${profile.name}" ;
-  dct:created "${profile.date_joined}" ;
-  .
-
-:${id}
+<#attempt>
+  <#assign joined_date = profile.date_joined?datetime.iso>
+  <#assign joined_date_xsnz = joined_date?string.xs_nz>
+  dct:created "${joined_date_xsnz}"^^xs:dateTime ;
+  <#recover>
+  # SINCE TIMESTAMP PROCESSING FAILED
+  # profile.date_joined: ${profile.date_joined}
+    <#if joined_date??>
+  # joined_date: ${joined_date}
+    </#if>
+    <#if joined_date_xsnz??>
+  # joined_date_xsnz: ${joined_date_xsnz}
+    </#if>
+</#attempt>
   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')>
@@ -66,10 +73,25 @@
 <#assign fid = "${handle}">
 :${fid} a apst:InstagramProfile ;
         as:displayName "${handle}" .
-:${fid}follow${id} a as:Follow ;
+
+:${fid}-follow-${id} a as:Follow ;
   as:actor :${fid} ;
   as:object :${id} ;
-  as:published "${since}" .
+  <#attempt>
+    <#assign since_date = since?datetime.iso>
+    <#assign since_xsnz = since_date?string.xs_nz>
+  as:published "${since_xsnz}"^^xs:dateTime ;
+    <#recover>
+  # SINCE TIMESTAMP PROCESSING FAILED
+  # since: ${since}
+      <#if since_date??>
+  # since_date: ${since_date}
+      </#if>
+      <#if since_xsnz??>
+  # since_xsnz: ${since_xsnz}
+      </#if>
+  </#attempt>
+  .
 
 </#list>
 
@@ -77,10 +99,25 @@
 <#assign fid = "${handle}">
 :${fid} a apst:InstagramProfile ;
         as:displayName "${handle}" .
+
 :${id}-follow-${fid} a as:Follow ;
   as:actor :${id} ;
   as:object :${fid} ;
-  as:published "${since}" .
+<#attempt>
+  <#assign since_date = since?datetime.iso>
+  <#assign since_xsnz = since_date?string.xs_nz>
+  as:published "${since_xsnz}"^^xs:dateTime ;
+  <#recover>
+  # SINCE TIMESTAMP PROCESSING FAILED
+  # since: ${since}
+    <#if since_date??>
+  # since_date: ${since_date}
+    </#if>
+    <#if since_xsnz??>
+  # since_xsnz: ${since_xsnz}
+    </#if>
+</#attempt>
+   .
 
 </#list>
 </#if>
@@ -97,9 +134,27 @@
 <#if fid != profile.username>
 :${fid} a apst:InstagramProfile ;
         as:displayName "${fid}" .
+
 :${id}-message-${fid} a as:Note ;
   as:actor :${id} ;
-  as:object :${fid} .
+  as:object :${fid} ;
+<#attempt>
+  <#assign createdAt_date = thread.created_at?datetime.iso>
+  <#assign createdAt_xsnz = createdAt_date?string.xs_nz>
+  as:published "${createdAt_xsnz}"^^xs:dateTime ;
+  <#recover>
+  # CREATED_AT TIMESTAMP PROCESSING FAILED
+    <#if thread.created_at??>
+  # thread.created_at: ${thread.created_at}
+    </#if>
+    <#if createdAt_date??>
+  # createdAt_date: ${createdAt_date}
+    </#if>
+    <#if createdAt_xsnz??>
+  # createdAt_xsnz: ${createdAt_xsnz}
+    </#if>
+</#attempt>
+  .
 
 </#if>
 </#list>
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
index 4f794cf186..8cb2b2522e 100644
--- a/streams-contrib/streams-provider-linkedin/src/main/templates/linkedin.ttl.ftl
+++ b/streams-contrib/streams-provider-linkedin/src/main/templates/linkedin.ttl.ftl
@@ -35,6 +35,7 @@
 @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#> .
+@prefix xs: <http://www.w3.org/2001/XMLSchema#> .
 @base <${namespace}> .
 
 <#--
@@ -71,11 +72,22 @@
 </#attempt>
 
 <#if registrations??>
-:${id}
-<#list registrations as registration>
-  dct:createdAt "${registration.registration_date}" ;
-</#list>
-  .
+  <#attempt>
+    <#list registrations as registration>
+      <#assign registration_date = registration.registration_date?datetime("MM/dd/YY,
HH:mm a")>
+      <#assign registration_xsnz = registration_date?string.xs_nz>
+:${id} dct:createdAt "${registration_xsnz}"^^xs:dateTime .
+    </#list>
+    <#recover>
+    # REGISTRATION TIMESTAMP PROCESSING FAILED
+    # registration.registration_date: ${registration.registration_date}
+      <#if registration_date??>
+    # registration_date: ${registration_date}
+      </#if>
+      <#if registration_xsnz??>
+    # registration_xsnz: ${registration_xsnz}
+      </#if>
+  </#attempt>
 </#if>
 
 <#--  
@@ -168,14 +180,14 @@
   <#recover>
   </#attempt>
   <#attempt>
-    <#list contact.phone_numbers?split(",") as raw_phone_number>
-      <#assign raw_phone_number = pp.loadData('eval', '
+    <#list contact.phone_numbers?split(",") as raw_contact_phone_number>
+      <#assign contact_phone_number = pp.loadData('eval', '
         com.google.i18n.phonenumbers.PhoneNumberUtil phoneUtil = com.google.i18n.phonenumbers.PhoneNumberUtil.getInstance();
-        String rawPhoneNumber = "${raw_phone_number}";
+        String rawPhoneNumber = "${raw_contact_phone_number}";
         phoneNumber = phoneUtil.parse(rawPhoneNumber, "US");
         return phoneUtil.format(phoneNumber, com.google.i18n.phonenumbers.PhoneNumberUtil$PhoneNumberFormat.RFC3966);
       ')>
-  vcard:tel "${phone_number}" ;
+  vcard:tel "${contact_phone_number}" ;
     </#list>
     <#recover>
   </#attempt>
@@ -188,7 +200,20 @@
   a as:Connect ;
   as:actor :${id} ;
   as:object :${cid} ;
-  as:published "${connection.connected_on}" ;
+<#attempt>
+  <#assign connection_date = connection.connected_on?datetime("MM/dd/YY, HH:mm a")>
+  <#assign connection_xsnz = connection_date?string.xs_nz>
+  as:published "${connection_xsnz}"^^xs:dateTime ;
+  <#recover>
+  # CONNECTION TIMESTAMP PROCESSING FAILED
+  # connection.connected_on: ${connection.connected_on}
+    <#if connection_date??>
+  # connection_date: ${connection_date}
+    </#if>
+    <#if connection_xsnz??>
+  # connection_xsnz: ${connection_xsnz}
+    </#if>
+</#attempt>
   .
 
 </#list>
@@ -216,7 +241,22 @@ From,To,Date,Subject,Content,Direction,Folder
   a as:Note ;
   as:actor :${aid} ;
   as:object :${oid} ;
+  <#attempt>
+    <#assign message_date = message.date?datetime("MM/dd/YY, HH:mm a")>
+    <#assign message_xsnz = message_date?string.xs_nz>
+  as:published "${message_xsnz}"^^xs:dateTime ;
+    <#recover>
+  # MESSAGE TIMESTAMP PROCESSING FAILED
+  # message.date: ${message.date}
+      <#if message_date??>
+  # message_date: ${message_date}
+      </#if>
+      <#if message_xsnz??>
+  # message_xsnz: ${message_xsnz}
+      </#if>
+  </#attempt>
   .
+
 </#list>
 </#if>
 
@@ -238,7 +278,20 @@ First Name,Last Name,Company,Job Title,Text,Creation Date,Status
   a as:Like ;
   as:actor :${id} ;
   as:object :${oid} ;
-  as:published "${recommendation.creation_date}" ;
+  <#attempt>
+    <#assign recommendation_date = recommendation.creation_date?datetime("MM/dd/YY, HH:mm
a")>
+    <#assign recommendation_xsnz = recommendation_date?string.xs_nz>
+  as:published "${recommendation_xsnz}"^^xs:dateTime ;
+    <#recover>
+  # MESSAGE TIMESTAMP PROCESSING FAILED
+  # recommendation.creation_date: ${recommendation.creation_date}
+      <#if recommendation_date??>
+  # recommendation_date: ${recommendation_date}
+      </#if>
+      <#if recommendation_xsnz??>
+  # recommendation_xsnz: ${recommendation_xsnz}
+      </#if>
+  </#attempt>
   .
 </#list>
 </#if>
@@ -261,7 +314,20 @@ First Name,Last Name,Company,Job Title,Text,Creation Date,Status
   a as:Like ;
   as:actor :${aid} ;
   as:object :${id} ;
-  as:published "${recommendation.creation_date}" ;
+  <#attempt>
+    <#assign recommendation_date = recommendation.creation_date?datetime("MM/dd/YY, HH:mm
a")>
+    <#assign recommendation_xsnz = recommendation_date?string.xs_nz>
+  as:published "${recommendation_xsnz}"^^xs:dateTime ;
+    <#recover>
+  # MESSAGE TIMESTAMP PROCESSING FAILED
+  # recommendation.creation_date: ${recommendation.creation_date}
+      <#if recommendation_date??>
+  # recommendation_date: ${recommendation_date}
+      </#if>
+      <#if recommendation_xsnz??>
+  # recommendation_xsnz: ${recommendation_xsnz}
+      </#if>
+  </#attempt>
   .
 </#list>
 </#if>
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
index 1f13837849..548075698f 100644
--- a/streams-contrib/streams-provider-twitter/src/main/templates/twitter.ttl.ftl
+++ b/streams-contrib/streams-provider-twitter/src/main/templates/twitter.ttl.ftl
@@ -31,6 +31,7 @@
 @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#> .
+@prefix xs: <http://www.w3.org/2001/XMLSchema#> .
 @base <${namespace}> .
 
 # account.js
@@ -46,8 +47,21 @@
 :${id}
   as:displayName "${account.accountDisplayName}" ;
   as:name "${account.username}" ;
-  dct:created "${account.createdAt}" ;
   vcard:email "${account.email}" ;
+<#attempt>
+  <#assign createdAt_date = account.createdAt?datetime.iso>
+  <#assign createdAt_xsnz = createdAt_date?string.xs_nz>
+  dct:created "${createdAt_xsnz}"^^xs:dateTime ;
+  <#recover>
+    # CREATED_AT TIMESTAMP PROCESSING FAILED
+    # account.createdAt: ${account.createdAt}
+    <#if createdAt_date??>
+    # createdAt_date: ${createdAt_date}
+    </#if>
+    <#if createdAt_xsnz??>
+    # createdAt_xsnz: ${createdAt_xsnz}
+    </#if>
+</#attempt>
   .
 
 # profile.js


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Convert timestamps to xsd:datetime (ISO8601) in AS2.0 TTL outputs
> -----------------------------------------------------------------
>
>                 Key: STREAMS-616
>                 URL: https://issues.apache.org/jira/browse/STREAMS-616
>             Project: Streams
>          Issue Type: Improvement
>            Reporter: Steve Blackmon
>            Priority: Major
>
> Always convert timestamps to xsd:datetime (ISO8601) in AS2.0 TTL outputs.
> Freemarker should contain necessary directives to handle conversion of numeric and various
string formatted timestamps to ISO8601.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message