Return to Snippet

Revision: 30264
at August 11, 2010 02:58 by d3developer


Initial Code
    class ChatPostWrapper {
        
        Chat_Session__Feed post;
        public String postBody      { get; set; }
        public String userHandle    { get; set; }
        public String createdDate   { get; set; }
        public Boolean newPost		{ get; set; }
        public Boolean systemMessage	{ get; private set; }
        
        public List<FeedComment> comments { get; set; }
        
        public ChatPostWrapper(Chat_Session__Feed post)
        {  
        	newPost = true; 
            this.post = post;
            createdDate = post.createdDate.format('d MMM yy HH:mm:ss Z');  
            if(post.FeedPost.Body.length() > 1)
                if(post.FeedPost.Body.substring(0,1) == '@')
                {
                	try {
	                    String[] s = post.FeedPost.Body.split(': ',2);
	                    userHandle = s[0];
	                    postBody = s[1];  
                		if(userHandle == '@System')
                			systemMessage = true;

                	}
                	catch (Exception e)
                	{
                		System.debug('ChatPostWrapperConstructor:' + e);
                		userHandle = 'Anonymous';
                		postBody = post.FeedPost.Body;
                	}
                }
                else
                {
                    postBody = post.FeedPost.Body;
                    userHandle = 'Anonymous';
                }
            //System.debug('ChatPostWrapper comment size:' + post.FeedComments.size());
            try {
            	comments = post.FeedComments;
            }
        	catch (Exception e)
        	{
        		
        	
        	}
        }
        
        public ChatPostWrapper(Chat_Session__Feed post, List<Chat_Session__Feed> oldPosts)
        {  
        	System.debug('ChatPostWrapper Constructor checking old posts... START');
            this.post = post;
            newPost = true;  
            if(oldPosts != null)
            {
        	System.debug('Old posts is not null');

	            for(Chat_Session__Feed op : oldPosts)
	            {  
        			System.debug('ChatPostWrapper Constructor checking old posts...' + op.id);
	            	if(op.id == post.id)
	            		newPost = false;
	            }	            
	            
            }
        	System.debug('New post? ' + newPost);
            
            createdDate = post.createdDate.format('d MMM yy HH:mm:ss Z');  
            if(post.FeedPost.Body.length() > 1)
                if(post.FeedPost.Body.substring(0,1) == '@')
                {
                	try {
	                    String[] s = post.FeedPost.Body.split(': ',2);
	                    userHandle = s[0];
	                    postBody = s[1];  
	                    if(userHandle == '@System')
                			systemMessage = true;
                	}
                	catch (Exception e)
                	{
                		System.debug('ChatPostWrapperConstructor:' + e);
                		userHandle = 'Anonymous';
                		postBody = post.FeedPost.Body;
                	}
                }
                else
                {
                    postBody = post.FeedPost.Body;
                    userHandle = 'Anonymous';
                }
            System.debug('ChatPostWrapper comment size:' + post.FeedComments.size());
            comments = post.FeedComments;
        }
        
        public Boolean getHasComments()
        {
        	if(comments.size() > 0)
        		return true;
        	else
        		return false;
        		
        }
        
    }

Initial URL


Initial Description


Initial Title
@fractastical ChatPostWrapper class

Initial Tags


Initial Language
Other