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

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

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

Activity.getObject介绍

[英]object

Basic object on the web. The only required property is the id
[中]对象
web上的基本对象。唯一需要的属性是id

代码示例

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

/**
 * Adds a single {@link Comment} to the Object.Attachments
 * section of the passed in {@link Activity}
 *
 * @param activity output o.a.s.p.j.Activity
 * @param comment input c.g.a.s.p.m.Comment
 */
private static void addComment(Activity activity, Comment comment) {
 ActivityObject obj = new ActivityObject();
 obj.setId(comment.getId());
 obj.setPublished(new DateTime(String.valueOf(comment.getPublished())));
 obj.setUpdated(new DateTime(String.valueOf(comment.getUpdated())));
 obj.setContent(comment.getObject().getContent());
 obj.setObjectType(comment.getObject().getObjectType());
 Map<String, Object> extensions = new HashMap<>();
 extensions.put("googlePlus", comment);
 obj.setAdditionalProperty("extensions", extensions);
 if (activity.getObject() == null) {
  activity.setObject(new ActivityObject());
 }
 if (activity.getObject().getAttachments() == null) {
  activity.getObject().setAttachments(new ArrayList<>());
 }
 activity.getObject().getAttachments().add(obj);
}

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

/**
 * Transform Activity into readable string using ObjectCombination title and specified language.
 * @param language language
 * @param activity Activity
 * @param objectCombination ObjectCombination
 * @return String
 */
public static String asString(String language, Activity activity, ObjectCombination objectCombination) {
 String template = (String) objectCombination.getTemplates().getAdditionalProperties().get(language);
 template = template.replace('{', '<');
 template = template.replace('}', '>');
 ST st = new ST(template);
 st.add("actor", displayName(activity.getActor()));
 st.add("provider", displayName(activity.getProvider()));
 st.add("object", displayName(activity.getObject()));
 st.add("target", displayName(activity.getTarget()));
 return st.render();
}

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

protected void setChannelSpecificValues(
  BeatApi.BeatResponse.Beat beat,
  Activity converted, Map<String, BeatApi.BeatResponse.Beat.Tag> mappedTags) {
 String mediaType = beat.getMediaType();
 String lowerMediaType = mediaType.toLowerCase();
 ActivityObject actor = converted.getActor();
 ActivityObject object = converted.getObject();
 if ("TWITTER".equals(mediaType)) {
  actor.setId(getPersonId(lowerMediaType, beat.getHost()));
  actor.setDisplayName(beat.getHost());
  actor.setUrl("http://twitter.com/" + beat.getHost());
  object.setObjectType("tweet");
  object.setId(getObjectId(lowerMediaType, "tweet", beat.getTweetid()));
 } else if ("FACEBOOK".equals(mediaType)) {
  String fbid = mappedTags.containsKey("FBID") ? mappedTags.get("FBID").getValue() : "";
  actor.setId(getPersonId(lowerMediaType, fbid));
  actor.setDisplayName(beat.getTitle());
  actor.setUrl(beat.getHost());
  object.setObjectType("post");
  object.setId(getObjectId(lowerMediaType, "post", String.valueOf(converted.getContent().hashCode())));
 } else {
  actor.setId(null);
  actor.setDisplayName(null);
  actor.setUrl(null);
  object.setObjectType("post");
  object.setId(getObjectId(lowerMediaType, "post", String.valueOf(converted.getContent().hashCode())));
 }
}

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

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);

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

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);

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

/**
 * count matches between this ObjectCombination and this Activity.
 * @param objectCombination ObjectCombination
 * @return count
 */
private int matchCount(ObjectCombination objectCombination) {
 int matchCount = 0;
 if ( match(activity.getActor(), objectCombination.getActor())) {
  matchCount++;
 }
 if ( match(activity.getObject(), objectCombination.getObject())) {
  matchCount++;
 }
 if ( match(activity.getTarget(), objectCombination.getTarget())) {
  matchCount++;
 }
 if ( match(activity.getProvider(), objectCombination.getProvider())) {
  matchCount++;
 }
 return matchCount;
}

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

/**
 * whether this Activity matches this ObjectCombination.
 * @param activity Activity
 * @param criteria ObjectCombination
 * @return true or false
 */
public static boolean filter(Activity activity, ObjectCombination criteria) {
 return  filterType(activity.getActor(), criteria.getActorRequired(), criteria.getActor())
   &&
   filterType(activity.getObject(), criteria.getObjectRequired(), criteria.getObject())
   &&
   filterType(activity.getProvider(), criteria.getProviderRequired(), criteria.getProvider())
   &&
   filterType(activity.getTarget(), criteria.getTargetRequired(), criteria.getTarget())
   ;
}

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

if( activity.getObject().getObjectType() != null)
 objects.add(activity.getObject());

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

@Override
public int compare(ObjectCombination left, ObjectCombination right) {
 if (matchCount(left) < matchCount(right)) {
  return 1;
 } else if ( matchCount(left) > matchCount(right)) {
  return -1;
 } else if ( !match(activity.getActor(), left.getActor()) && match(activity.getActor(), right.getActor())) {
  return 1;
 } else if ( match(activity.getActor(), left.getActor()) && !match(activity.getActor(), right.getActor())) {
  return -1;
 } else if ( !match(activity.getObject(), left.getObject()) && match(activity.getObject(), right.getObject())) {
  return 1;
 } else if ( match(activity.getObject(), left.getObject()) && !match(activity.getObject(), right.getObject())) {
  return -1;
 } else if ( !match(activity.getTarget(), left.getTarget()) && match(activity.getTarget(), right.getTarget())) {
  return 1;
 } else if ( match(activity.getTarget(), left.getTarget()) && !match(activity.getTarget(), right.getTarget())) {
  return -1;
 } else if ( !match(activity.getProvider(), left.getProvider()) && match(activity.getTarget(), right.getProvider())) {
  return 1;
 } else if ( match(activity.getProvider(), left.getProvider()) && !match(activity.getTarget(), right.getProvider())) {
  return -1;
 } else {
  return 0;
 }
}

相关文章