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

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

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

Activity.setLinks介绍

[英]Links between this object and other resources as defined in Web Linking
[中]此对象与Web链接中定义的其他资源之间的链接

代码示例

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

activity = (Activity) entry.getDocument();
activity.setLinks(new ArrayList<>(unwind(activity.getLinks())));
activity.setLinks(new ArrayList<>(unwind(activity.getLinks())));

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

/**
 * Tests that all example activities can be loaded into Activity beans.
 * @throws Exception Exception
 */
@Test
public void testActivitySerDe() throws Exception {
 Path testdataDir = Paths.get("target/dependency/activitystreams-testdata");
 List<Path> schemaPaths = Files.list(testdataDir).collect(Collectors.toList());
 for( Path schemaPath : schemaPaths ) {
  LOGGER.info("Path: " + schemaPath );
  LOGGER.info("Serializing: activities/" + schemaPath );
  FileInputStream testActivityFileStream = new FileInputStream(schemaPath.toFile());
  Activity activity = MAPPER.readValue(testActivityFileStream, Activity.class);
  activity.setGenerator(null);
  activity.setLinks(new LinkedList<>());
  String activityString = MAPPER.writeValueAsString(activity);
  LOGGER.info("Deserialized: " + activityString );
  assert ( !activityString.contains("null") );
  assert ( !activityString.contains("[]") );
 }
}

代码示例来源: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 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;
}

相关文章