org.apache.streams.pojo.json.Activity.setVerb()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(110)

本文整理了Java中org.apache.streams.pojo.json.Activity.setVerb()方法的一些代码示例,展示了Activity.setVerb()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.setVerb()方法的具体详情如下:
包路径:org.apache.streams.pojo.json.Activity
类名称:Activity
方法名:setVerb

Activity.setVerb介绍

[英]verb

Identifies the action that the activity describes. An activity MUST contain a verb property whose value is a JSON String that is non-empty and matches either the "isegment-nz-nc" or the "IRI" production in [RFC3987]. Note that the use of a relative reference other than a simple name is not allowed. (Required)
[中]动词
标识活动描述的操作。活动必须包含一个谓词属性,其值为非空的JSON字符串,并与[RFC3987]中的“ISEMENT nz nc”或“IRI”产品相匹配。请注意,不允许使用简单名称以外的相对引用。(必选)

代码示例

代码示例来源:origin: apache/streams

/**
 * Given a {@link Channel} object and an
 * {@link Activity} object, fill out the appropriate details
 *
 * @param channel Channel
 * @param activity Activity
 * @throws ActivitySerializerException ActivitySerializerException
 */
public static void updateActivity(Channel channel, Activity activity, String channelId) throws ActivitySerializerException {
 try {
  activity.setProvider(getProvider());
  activity.setVerb("post");
  activity.setActor(createActorForChannel(channel));
  Map<String, Object> extensions = new HashMap<>();
  extensions.put("youtube", channel);
  activity.setAdditionalProperty("extensions", extensions);
 } catch (Throwable throwable) {
  throw new ActivitySerializerException(throwable);
 }
}

代码示例来源:origin: apache/streams

/**
 * Given a {@link Person} object and an
 * {@link Activity} object, fill out the appropriate details.
 *
 * @param item Person
 * @param activity Activity
 * @throws ActivitySerializerException ActivitySerializerException
 */
public static void updateActivity(Person item, Activity activity) throws ActivitySerializerException {
 activity.setActor(buildActor(item));
 activity.setVerb("update");
 activity.setId(formatId(activity.getVerb(), Optional.ofNullable(item.getId()).orElse(null)));
 activity.setProvider(getProvider());
}

代码示例来源:origin: apache/streams

/**
 * Updates the given Activity object with the values from the item
 * @param item the object to use as the source
 * @param activity the target of the updates.  Will receive all values from the tweet.
 * @throws ActivityConversionException ActivityConversionException
 */
public static void updateActivity(Media item, Activity activity) throws ActivityConversionException {
 activity.setActor(buildActor(item));
 activity.setVerb("post");
 if (item.getCreatedTime() != null) {
  activity.setPublished(new DateTime(Long.parseLong(item.getCreatedTime()) * 1000));
 }
 activity.setId(formatId(activity.getVerb(),
   Optional.ofNullable(item.getId()).orElse(null)));
 activity.setProvider(getProvider());
 activity.setUrl(item.getLink());
 activity.setObject(buildActivityObject(item));
 if (item.getCaption() != null) {
  activity.setContent(item.getCaption().getText());
 }
 addInstagramExtensions(activity, item);
}

代码示例来源:origin: apache/streams

activity.setProvider(provider);
activity.setActor(actor);
activity.setVerb("post");
activity.setId("id:rss:post:" + activity.getUrl());

代码示例来源:origin: apache/streams

/**
 * Given a Google Plus {@link com.google.api.services.plus.model.Activity},
 * convert that into an Activity streams formatted {@link Activity}
 *
 * @param gPlusActivity input c.g.a.s.p.m.Activity
 * @param activity output o.a.s.p.j.Activity
 */
public static void updateActivity(com.google.api.services.plus.model.Activity gPlusActivity, Activity activity) {
 activity.setActor(buildActor(gPlusActivity.getActor()));
 activity.setVerb("post");
 activity.setTitle(gPlusActivity.getTitle());
 activity.setUrl(gPlusActivity.getUrl());
 activity.setProvider(getProvider());
 if (gPlusActivity.getObject() != null) {
  activity.setContent(gPlusActivity.getObject().getContent());
 }
 activity.setId(formatId(activity.getVerb(), Optional.ofNullable(gPlusActivity.getId()).orElse(null)));
 DateTime published = new DateTime(String.valueOf(gPlusActivity.getPublished()));
 activity.setPublished(published);
 setObject(activity, gPlusActivity.getObject());
 addGPlusExtensions(activity, gPlusActivity);
}

代码示例来源:origin: apache/streams

/**
 * Updates the given Activity object with the values from the Post.
 * @param post post
 * @param activity activity
 * @throws ActivitySerializerException
 */
public static void updateActivity(Post post, Activity activity) throws ActivitySerializerException {
 activity.setActor(buildActor(post));
 activity.setId(formatId(post.getId()));
 activity.setProvider(getProvider());
 activity.setUpdated(post.getUpdatedTime());
 activity.setPublished(post.getCreatedTime());
 if (post.getLink() != null && post.getLink().length() > 0) {
  List<String> links = new ArrayList<>();
  links.add(post.getLink());
  activity.setLinks(links);
 }
 activity.setContent(post.getMessage());
 activity.setVerb("post");
 activity.setObject(buildObject(post));
 buildExtensions(activity, post);
}

代码示例来源:origin: apache/streams

/**
 * convert BeatApi.BeatResponse.Beat to Activity
 * @param beat BeatApi.BeatResponse.Beat
 * @return Activity
 */
public Activity convert(BeatApi.BeatResponse.Beat beat) {
 Activity converted = new Activity();
 converted.setId(beat.getDocid());
 converted.setVerb("post");
 converted.setContent(beat.getContent());
 converted.setTitle(beat.getTitle());
 converted.setPublished(new DateTime(beat.getTime()));
 converted.setUrl(beat.getLink());
 converted.setActor(new ActivityObject());
 Map<String, Object> extensions = ExtensionUtil.getInstance().ensureExtensions(converted);
 extensions.put("keywords", beat.getContent());
 setLocation(beat, extensions);
 setObject(beat, converted);
 setProvider(beat, converted);
 Map<String, BeatApi.BeatResponse.Beat.Tag> mappedTags = mapTags(beat);
 setLanguage(mappedTags, extensions);
 extensions.put("sysomos", beat);
 setChannelSpecificValues(beat, converted, mappedTags);
 return converted;
}

代码示例来源:origin: apache/streams

/**
 * Given a {@link YouTube.Videos} object and an
 * {@link Activity} object, fill out the appropriate details
 *
 * @param video Video
 * @param activity Activity
 * @throws ActivitySerializerException ActivitySerializerException
 */
public static void updateActivity(Video video, Activity activity, String channelId) throws ActivitySerializerException {
 activity.setActor(buildActor(video, video.getSnippet().getChannelId()));
 activity.setVerb("post");
 activity.setId(formatId(activity.getVerb(), Optional.ofNullable(video.getId()).orElse(null)));
 activity.setPublished(new DateTime(video.getSnippet().getPublishedAt().getValue()));
 activity.setTitle(video.getSnippet().getTitle());
 activity.setContent(video.getSnippet().getDescription());
 activity.setUrl("https://www.youtube.com/watch?v=" + video.getId());
 activity.setProvider(getProvider());
 activity.setObject(buildActivityObject(video));
 addYoutubeExtensions(activity, video);
}

代码示例来源:origin: apache/streams

@Override
public Activity deserialize(GmailMessage gmailMessage) {
 Activity activity = new Activity();
 activity.setId(formatId(this.provider.getConfig().getUserName(), String.valueOf(gmailMessage.getMessageNumber())));
 activity.setPublished(new DateTime(gmailMessage.getSendDate()));
 Provider provider = new Provider();
 provider.setId("http://gmail.com");
 provider.setDisplayName("GMail");
 activity.setProvider(provider);
 ActivityObject actor = new ActivityObject();
 actor.setId(gmailMessage.getFrom().getEmail());
 actor.setDisplayName(gmailMessage.getFrom().getName());
 activity.setActor(actor);
 activity.setVerb("email");
 ActivityObject object = new ActivityObject();
 try {
  object.setId(gmailMessage.getTo().get(0).getEmail());
  object.setDisplayName(gmailMessage.getTo().get(0).getName());
 } catch (GmailException e) {
  LOGGER.warn(e.getMessage());
 }
 activity.setTitle(gmailMessage.getSubject());
 try {
  activity.setContent(gmailMessage.getContentText());
 } catch (GmailException e) {
  LOGGER.warn(e.getMessage());
 }
 activity.setObject(object);
 return activity;
}

代码示例来源:origin: apache/streams

/**
 * convert article into Activity.
 * @param article article
 * @return Activity
 */
public static Activity convert(Article article) {
 Activity activity = new Activity();
 Source source = article.getSource();
 activity.setActor(convert(article.getAuthor(), source.getName()));
 activity.setProvider(convert(source));
 activity.setTarget(convertTarget(source));
 activity.setObject(convertObject(article));
 activity.setPublished(DateTime.parse(article.getPublishedDate()));
 activity.setContent(article.getContent());
 activity.setTitle(article.getTitle());
 activity.setVerb("posted");
 fixActivityId(activity);
 addLocationExtension(activity, source);
 addLanguageExtension(activity, article);
 activity.setLinks(convertLinks(article));
 return activity;
}

相关文章