org.apache.streams.pojo.json.Activity类的使用及代码示例

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

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

Activity介绍

[英]activity

An activity construct recounts what an actor did to an object in the past. If there is no actor it simply describes the change.
[中]活动
活动构造描述了参与者过去对对象所做的操作。如果没有参与者,它只描述更改。

代码示例

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

@Override
public Activity deserialize(Post post) throws ActivitySerializerException {
 Activity activity = new Activity();
 activity.setActor(createActor(post));
 activity.setId(post.getId());
 activity.setContent(post.getMessage());
 return null;
}

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

/**
 * Creates a standard extension property.
 * @param activity activity to create the property in
 * @return the Map representing the extensions property
 */
@SuppressWarnings("unchecked")
@Deprecated
public static Map<String, Object> ensureExtensions(Activity activity) {
 Map<String, Object> extensions = (Map)activity.getAdditionalProperties().get(EXTENSION_PROPERTY);
 if (extensions == null) {
  extensions = new HashMap<>();
  activity.setAdditionalProperty(EXTENSION_PROPERTY, extensions);
 }
 return extensions;
}

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

private static void fixActivityId(Activity activity) {
 if (activity.getId() != null && activity.getId().matches("\\{[a-z]*\\}")) {
  activity.setId(null);
 }
}

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

/**
 * Check validity of Activity.
 * @param activity Activity
 * @return isValid
 */
public static boolean isValid(Activity activity) {
 return activity != null
   && activity.getId() != null
   && activity.getVerb() != null
   && activity.getProvider() != null
   && activity.getProvider().getId() != null;
}

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

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

Objects.requireNonNull(entry);
Activity activity = new Activity();
Provider provider = buildProvider(entry);
ActivityObject actor = buildActor(entry);
activityObject.setAuthor(actor.getAuthor());
activity.setUrl(provider.getUrl());
activity.setProvider(provider);
activity.setActor(actor);
activity.setVerb("post");
activity.setId("id:rss:post:" + activity.getUrl());
  activity.setPublished(RFC3339Utils.parseToUTC(published.textValue()));
 } catch (Exception ex) {
  LOGGER.warn("Failed to parse date : {}", published.textValue());
  activity.setPublished(now);
activity.setUpdated(activityObject.getUpdated());
activity.setObject(activityObject);

代码示例来源: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 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 ActivitySerializerException ActivitySerializerException
 */
public static void updateActivity(UserInfo item, Activity activity) throws ActivitySerializerException {
 activity.setActor(buildActor(item));
 activity.setId(null);
 activity.setProvider(getProvider());
}

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

.getResourceAsStream("activities/" + file);
Activity activity = MAPPER.readValue(testActivityFileStream, Activity.class);
activity.setId(activity.getVerb());
activity.getAdditionalProperties().remove("$license");
if( activity.getActor().getObjectType() != null)
 objects.add(activity.getActor());
if( activity.getObject().getObjectType() != null)
 objects.add(activity.getObject());
assertNotNull(result.getMetadata().get("type"));
LOGGER.info("valid: " + activity.getVerb() );

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

FileInputStream testActivityFileStream = new FileInputStream(docPath.toFile());
Activity activity = MAPPER.readValue(testActivityFileStream, Activity.class);
Activity update = new Activity();
update.setAdditionalProperty("updated", Boolean.TRUE);
update.setAdditionalProperty("str", "str");
update.setAdditionalProperty("long", 10L);
update.setActor(
  new ActivityObject()
    .withAdditionalProperty("updated", Boolean.TRUE)
      MAPPER.createObjectNode().set("field", MAPPER.createArrayNode().add("item"))));
StreamsDatum datum = new StreamsDatum(update, activity.getVerb());
testPersistUpdater.write( datum );
LOGGER.info("Updated: " + activity.getVerb() );

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

@Override
public Activity deserialize(Post post) throws ActivitySerializerException {
 Activity activity = new Activity();
 FacebookActivityUtil.updateActivity(post, activity);
 return activity;
}

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

FileInputStream testActivityFileStream = new FileInputStream(docPath.toFile());
Activity activity = MAPPER.readValue(testActivityFileStream, Activity.class);
activity.getAdditionalProperties().remove("$license");
StreamsDatum datum = new StreamsDatum(activity, activity.getVerb());
writer.write(datum);
LOGGER.info("Wrote: " + activity.getVerb() );
count++;

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

/**
 * return all matching ObjectCombinations for an Activity.
 * @param activity Activity
 * @return List of ObjectCombination
 */
public List<ObjectCombination> matchingObjectCombinations(Activity activity) {
 List<ObjectCombination> results = new ArrayList<>();
 for ( VerbDefinition verbDefinition : verbDefinitionSet ) {
  if ( activity.getVerb().equals(verbDefinition.getValue())) {
   for ( ObjectCombination criteria : verbDefinition.getObjects()) {
    if (filter(activity, criteria)) {
     results.add(criteria);
    }
   }
  }
 }
 results.sort(new ObjectCombinationSpecificOrdering(activity));
 return results;
}

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

FileInputStream testActivityFileStream = new FileInputStream(docPath.toFile());
Activity activity = MAPPER.readValue(testActivityFileStream, Activity.class);
activity.setAdditionalProperty("updated", Boolean.TRUE);
StreamsDatum datum = new StreamsDatum(activity, activity.getVerb());
if( !StringUtils.isEmpty(activity.getObject().getObjectType())) {
 datum.getMetadata().put("parent", activity.getObject().getObjectType());
 datum.getMetadata().put("type", "activity");
 testPersistUpdater.write(datum);
 LOGGER.info("Updated: " + activity.getVerb() );

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

FileInputStream testActivityFileStream = new FileInputStream(docPath.toFile());
Activity activity = MAPPER.readValue(testActivityFileStream, Activity.class);
StreamsDatum datum = new StreamsDatum(activity, activity.getVerb());
if( !StringUtils.isEmpty(activity.getObject().getObjectType())) {
 datum.getMetadata().put("parent", activity.getObject().getObjectType());
 datum.getMetadata().put("type", "activity");
 testPersistWriter.write(datum);
 LOGGER.info("Wrote: " + activity.getVerb());

相关文章