本文整理了Java中org.apache.streams.pojo.json.Activity.getVerb()
方法的一些代码示例,展示了Activity.getVerb()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Activity.getVerb()
方法的具体详情如下:
包路径:org.apache.streams.pojo.json.Activity
类名称:Activity
方法名:getVerb
[英]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
/**
* 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
/**
* return all matching VerbDefinitions for an Activity.
* @param activity Activity
* @return List of VerbDefinition
*/
public Set<VerbDefinition> matchingVerbDefinitions(Activity activity) {
// ConcurrentHashSet is preferable, but it's only in guava 15+
// spark 1.5.0 uses guava 14 so for the moment this is the workaround
// Set<VerbDefinition> matches = Sets.newConcurrentHashSet();
Set<VerbDefinition> matches = Collections.newSetFromMap(new ConcurrentHashMap<VerbDefinition, Boolean>());
for (VerbDefinition verbDefinition : verbDefinitionSet) {
VerbDefinition verbDefinitionCopy = SerializationUtil.cloneBySerialization(verbDefinition);
if ( activity.getVerb().equals(verbDefinition.getValue())) {
for ( ObjectCombination criteria : verbDefinitionCopy.getObjects()) {
if (!filter(activity, criteria)) {
verbDefinitionCopy.getObjects().remove(criteria);
}
}
if ( verbDefinitionCopy.getObjects().size() > 0) {
matches.add(verbDefinitionCopy);
}
}
}
return matches;
}
代码示例来源:origin: apache/streams
/**
* whether this Activity matches this VerbDefinition.
* @param activity Activity
* @param verbDefinition VerbDefinition
* @return true or false
*/
public static boolean match(Activity activity, VerbDefinition verbDefinition) {
if ( verbDefinition.getValue() != null
&& verbDefinition.getValue().equals(activity.getVerb())) {
for (ObjectCombination objectCombination : verbDefinition.getObjects()) {
if (VerbDefinitionResolver.filter(activity, objectCombination)) {
return true;
}
}
}
return false;
}
代码示例来源: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
/**
* 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
@Test
public void testPersistWriter() throws Exception {
ElasticsearchPersistWriter testPersistWriter = new ElasticsearchPersistWriter(testConfiguration);
testPersistWriter.prepare(null);
Path testdataDir = Paths.get("target/dependency/activitystreams-testdata");
List<Path> testdataPaths = Files.list(testdataDir).collect(Collectors.toList());
for( Path docPath : testdataPaths ) {
LOGGER.info("File: " + docPath );
FileInputStream testActivityFileStream = new FileInputStream(docPath.toFile());
Activity activity = MAPPER.readValue(testActivityFileStream, Activity.class);
StreamsDatum datum = new StreamsDatum(activity, activity.getVerb());
testPersistWriter.write( datum );
LOGGER.info("Wrote: " + activity.getVerb() );
}
testPersistWriter.cleanUp();
SearchRequestBuilder countRequest = testClient
.prepareSearch(testConfiguration.getIndex())
.setTypes(testConfiguration.getType());
SearchResponse countResponse = countRequest.execute().actionGet();
assertEquals(89, countResponse.getHits().getTotalHits());
}
代码示例来源:origin: apache/streams
LOGGER.info("Verb: " + verbClass.getSimpleName() );
Activity activity = (Activity) verbClass.newInstance();
String verbName = activity.getVerb();
String testfile = verbName.toLowerCase() + ".json";
LOGGER.info("Serializing: activities/" + testfile );
代码示例来源:origin: apache/streams
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
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
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
/**
* 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
/**
* 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
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());
代码示例来源: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
.getResourceAsStream("activities/" + file);
Activity activity = MAPPER.readValue(testActivityFileStream, Activity.class);
activity.setId(activity.getVerb());
activity.getAdditionalProperties().remove("$license");
assertNotNull(result.getMetadata().get("type"));
LOGGER.info("valid: " + activity.getVerb() );
代码示例来源:origin: apache/streams
MAPPER.createObjectNode().set("field", MAPPER.createArrayNode().add("item"))));
StreamsDatum datum = new StreamsDatum(update, activity.getVerb());
testPersistUpdater.write( datum );
LOGGER.info("Updated: " + activity.getVerb() );
内容来源于网络,如有侵权,请联系作者删除!