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

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

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

Activity.getActor介绍

[英]object

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

代码示例

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

/**
 Override this to add parameters to the request.
 */
@Override
protected Map<String, String> prepareParams(StreamsDatum entry) {
 Activity activity = mapper.convertValue(entry.getDocument(), Activity.class);
 ActivityObject actor = mapper.convertValue(activity.getActor(), ActivityObject.class);
 String username = (String) ExtensionUtil.getInstance().getExtension(actor, "screenName");
 Map<String, String> params = new HashMap<>();
 params.put("id", actor.getId());
 params.put("name", actor.getDisplayName());
 params.put("username", username);
 params.put("description", actor.getSummary());
 return params;
}

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

/**
  Override this to add parameters to the request.
  */
 @Override
 protected Map<String, String> prepareParams(StreamsDatum entry) {
  Activity activity = mapper.convertValue(entry.getDocument(), Activity.class);
  ActivityObject actor = mapper.convertValue(activity.getActor(), ActivityObject.class);
  String username = (String) ExtensionUtil.getInstance().getExtension(actor, "screenName");
  Map<String, String> params = new HashMap<>();
  params.put("id", actor.getId());
  params.put("name", actor.getDisplayName());
  params.put("username", username);
  params.put("description", actor.getSummary());
  return params;
 }
}

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

/**
 * 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

@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;
 }
}

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

activity.getAdditionalProperties().remove("$license");
if( activity.getActor().getObjectType() != null)
 objects.add(activity.getActor());
if( activity.getObject().getObjectType() != null)
 objects.add(activity.getObject());

相关文章