Database Reference
In-Depth Information
Listing 12-31. addContent Methods in SocialAction and ContentDAO
@Action(value = "posts/add", interceptorRefs = {
@InterceptorRef(value = "cookie", params = { "cookiesName", "graphstoryUserAuthKey" }),
@InterceptorRef(value = "json", params = { "noCache", "true", "excludeNullProperties",
"true" }) },
results = {
@Result(name = "success", type = "json", params = { "noCache", "true" })
})
public String addContent () {
try {
if (graphStory.getStatusUpdate() != null) {
graphStory.setMappedContent(graphStoryDAO.getContentDAO()
. addContent (
graphStory.getStatusUpdate(),
cookiesMap.get(GraphStoryConstants.graphstoryUserAuthKey)
));
}
}
catch (Exception e) {
log.error(e);
}
return SUCCESS;
}
//addContent method in ContentDAO
public MappedContent addContent (Content content, String username) {
Date timestamp = new Date();
String tagStr = trimContentTags(content.getTagstr());
Map<String, Object> contentMap = IteratorUtil.singleOrNull(cypher.iteratorQuery(
" MATCH (user { username: {1}}) " +
" CREATE UNIQUE (user)-[:CURRENTPOST]->(newLP:Content { title:{2}, url:{3}, " +
" tagstr:{4}, timestamp:{5}, contentId:{6} }) " +
" WITH user, newLP, collect(distinct newLP.tagstr) as tstr" +
" FOREACH (tagName in {7} | " +
" MERGE (t:Tag {wordPhrase: tagName })" +
" MERGE (newLP)-[:HAS]->(t) )" +
" WITH user, newLP " +
" OPTIONAL MATCH (newLP)<-[:CURRENTPOST]-(user)-[oldRel:CURRENTPOST]->(oldLP)" +
" DELETE oldRel " +
" CREATE (newLP)-[:NEXTPOST]->(oldLP) " +
" RETURN newLP.contentId as contentId, newLP.title as title, " +
" newLP.tagstr as tagstr, " +
" newLP.timestamp as timestamp, newLP.url as url, " +
"user.username as username, true as owner ",
map("1", username, "2", content.getTitle(), "3", content.getUrl(), "4", tagStr, "5",
Search WWH ::




Custom Search