<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeff Douglas - Technology, Coding and Bears... OH MY!</title>
	<atom:link href="http://blog.jeffdouglas.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jeffdouglas.com</link>
	<description>Get your head out of your #@! and into the clouds!</description>
	<lastBuildDate>Thu, 02 Feb 2012 11:57:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Using Node.js to Host Development Web Services</title>
		<link>http://blog.jeffdouglas.com/2012/02/02/using-node-js-to-host-development-web-services/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=using-node-js-to-host-development-web-services</link>
		<comments>http://blog.jeffdouglas.com/2012/02/02/using-node-js-to-host-development-web-services/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 11:54:53 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[CloudSpokes]]></category>
		<category><![CDATA[Heroku]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=4357</guid>
		<description><![CDATA[One of the cool things about Node.js, besides the fact that it&#8217;s fast and scalable, is that it&#8217;s extremely easy to setup and get running. In a couple of minutes you can get a fully operational web server running with minimal code. I&#8217;ve been playing around with the Express library and it makes developing Node.js [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2012%2F02%2F02%2Fusing-node-js-to-host-development-web-services%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2012%2F02%2F02%2Fusing-node-js-to-host-development-web-services%2F&amp;source=jeffdonthemic&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://blog.jeffdouglas.com/wp-content/uploads/2012/02/node-logo.png" rel="lightbox[4357]"><img src="http://blog.jeffdouglas.com/wp-content/uploads/2012/02/node-logo.png" alt="" title="node-logo" width="175" height="55" class="alignleft size-full wp-image-4379" /></a>One of the cool things about <a href="http://nodejs.org/">Node.js</a>, besides the fact that it&#8217;s fast and scalable, is that it&#8217;s extremely easy to setup and get running. In a couple of minutes you can get a fully operational web server running with minimal code. I&#8217;ve been playing around with the <a href="http://expressjs.com/">Express</a> library and it makes developing Node.js app <strong>sooo</strong> much easier. It&#8217;s early but I&#8217;m really impressed with it so far. Check out <a href="http://expressjs.com/screencasts.html">this screencast</a> for a 5 minute overview.</p>
<p>One use case that we&#8217;ve come across is to use Node.js to mock up web services for development and testing. It&#8217;s easy to put together a small app the stubs out a return structure to get your POC up and running quickly. How many times have you wanted to test your Apex callouts but the web service wasn&#8217;t finished or stable yet? Now you can setup a quick Node.js app on Heroku that returns dummy data, develop your callouts and then switch to the production endpoint when available. This use case is extremely useful when developing mobile apps as you can run the Node.js server locally while developing with your simulator! (Another great idea from <a href="https://twitter.com/#!/iromin">Romin</a>).</p>
<p>We&#8217;ve found a really cool use case for Node.js at <a href="http://www.cloudspokes.com">CloudSpokes</a>.  Most of our challenges use some sort of backend datastore or API and this can become tedious when working on jQuery, Rails or HTML challenges where the developer really doesn&#8217;t care where the data comes from. Typically their first step in development is authenticating to the API which is a pain when all you really care about is the UI. Now with Node.js we&#8217;ve decoupled the frontend and backend requirements. We&#8217;ve made available a little Node.js app with resources that simply return JSON in the structure that they&#8217;d receive from actual calls to Database.com. They can modify the Node.js app to return different hashes or extend the app to simulate different calls if needed. Now the developers don&#8217;t have to worry about authenticating to Database.com and we don&#8217;t have to setup an org, enter dummy data and configurations and provide them access. Birds are chirping, the sun is shining and everyone is happy.</p>
<p>The source code for the CloudSpokes Node.js devserver is <a href="https://github.com/cloudspokes/cs-node-devserver">available at github</a> and you can <a href="http://node-demo-devserver.herokuapp.com/">run the app on heroku</a>.</p>
<p>James Ward has a <a href="http://www.jamesward.com/2011/06/21/getting-started-with-node-js-on-the-cloud/">great article about getting a Node.js app up and running on heroku</a>. It&#8217;s a little long if you are familiar with Heroku but it&#8217;s well worth the read. Make sure you don&#8217;t skip the section about configuring your app to listen on the port defined by Heroku&#8217;s environment variables.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2012/02/02/using-node-js-to-host-development-web-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome to CloudSpokes Rob Cheng!</title>
		<link>http://blog.jeffdouglas.com/2012/02/02/welcome-to-cloudspokes-rob-cheng/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=welcome-to-cloudspokes-rob-cheng</link>
		<comments>http://blog.jeffdouglas.com/2012/02/02/welcome-to-cloudspokes-rob-cheng/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 11:05:09 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=4367</guid>
		<description><![CDATA[We just announced on the CloudSpokes blog that Rob Cheng has joined the team and will be heading up our CloudSpokes strategy. Rob came from salesforce.com where he was the Director of Force.com Platform Product Marketing and has also had stints at CollabNet and Borland. He actually has a really cool blog as well that [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2012%2F02%2F02%2Fwelcome-to-cloudspokes-rob-cheng%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2012%2F02%2F02%2Fwelcome-to-cloudspokes-rob-cheng%2F&amp;source=jeffdonthemic&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://blog.jeffdouglas.com/wp-content/uploads/2012/02/rob.jpeg" rel="lightbox[4367]"><img src="http://blog.jeffdouglas.com/wp-content/uploads/2012/02/rob-150x150.jpg" alt="" title="rob" width="150" height="150" class="alignleft size-thumbnail wp-image-4368" /></a>We just announced on the <a href="http://blog.cloudspokes.com/2012/02/welcome-to-newest-member-of-cloudspokes.html">CloudSpokes blog</a> that <a href="http://www.linkedin.com/in/robcheng">Rob Cheng</a> has joined the team and will be heading up our CloudSpokes strategy. Rob came from salesforce.com where he was the Director of Force.com Platform Product Marketing and has also had stints at CollabNet and Borland. He actually has a <a href="http://robcheng.wordpress.com/">really cool blog</a> as well that you should check out.</p>
<p>Personally, this is a great addition to the team and since Rob is focusing on partners, sponsors and strategy, this allows me to have more time to work with the community. A few less tasks on my plate.</p>
<p>The CloudSpokes platform and community is growing wickedly fast and Rob was badly needed. We will be adding more people to the team shortly. Are you interested? Drop me a line.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2012/02/02/welcome-to-cloudspokes-rob-cheng/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Video &#8211; Getting Started with Rails &amp; Databasedotcom Gem</title>
		<link>http://blog.jeffdouglas.com/2012/01/27/video-getting-started-with-rails-databasedotcom-gem/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=video-getting-started-with-rails-databasedotcom-gem</link>
		<comments>http://blog.jeffdouglas.com/2012/01/27/video-getting-started-with-rails-databasedotcom-gem/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 22:24:50 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Heroku]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=4341</guid>
		<description><![CDATA[It the new year again and time for resolutions. I made a resolution about a year ago to learn ruby. If you are looking for something to learn this year I would recommend ruby and here&#8217;s why: Salesforce.com bought Heroku for $220M Salesforce.com has been pushing &#8220;Open. Social. Mobile&#8221; for quite some time. Ruby is [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2012%2F01%2F27%2Fvideo-getting-started-with-rails-databasedotcom-gem%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2012%2F01%2F27%2Fvideo-getting-started-with-rails-databasedotcom-gem%2F&amp;source=jeffdonthemic&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>It the new year again and time for resolutions. I made a resolution about a year ago to learn ruby. If you are looking for something to learn this year I would recommend ruby and here&#8217;s why:</p>
<ol>
<li>Salesforce.com bought Heroku for $220M</li>
<li>Salesforce.com has been pushing &#8220;Open. Social. Mobile&#8221; for quite some time.</li>
<li>Ruby is great for creating social and mobile apps with open source technologies.</li>
</ol>
<p>Do you see a correlation here? There are big things ahead for Force.com developers using Heroku. Eventhough Heroku is a <a href="http://blog.heroku.com/archives/2011/8/3/polyglot_platform/">polyglot platform</a>, it shines with ruby. If you have the time, add ruby to your toolbox.</p>
<p>I presented this topic today at an Appirio Continuing Education webinar and thought it might come in handy to other trying to learn ruby. In the video I build a small app that displays a list of accounts, the details for a selected account and then queries for accounts by keyword. I reference some links to help you get started with ruby and rails and I&#8217;ve added them after the video. </p>
<p><strong>You can find the source code <a href="https://github.com/jeffdonthemic/Databasedotcom-Gem-Demo">here</a>.</strong></p>
<p><span class="youtube">
<object width="560" height="340">
<param name="movie" value="http://www.youtube.com/v/_jWUOn8z-UM?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;loop=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&amp;hd=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="opaque" src="http://www.youtube.com/v/_jWUOn8z-UM?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;loop=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" width="560" height="340"></embed>
<param name="wmode" value="opaque" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=_jWUOn8z-UM&fmt=18">www.youtube.com/watch?v=_jWUOn8z-UM</a></p></p>
<p><strong>Links Referenced in the Video</strong></p>
<p><a href="http://www.railsinstaller.org">Railsnstaller</a> (Windows)<br />
<a href="http://mxcl.github.com/homebrew">Homebrew</a><br />
<a href="http://beginrescueend.com/">Ruby Version Manager (RVM)</a></p>
<p><a href="http://guides.rubyonrails.org/getting_started.html">Rails Guides</a><br />
<a href="http://www.railscasts.com">Railscasts</a><br />
<a href="http://railsforzombies.com">Rails for Zombies</a><br />
<a href="http://www.codeschool.com">Code School</a><br />
<a href="http://www.codeschool.com/courses/try-ruby">Try Ruby</a><br />
<a href="http://ruby.railstutorial.org">Ruby on Rails Tutorial</a><br />
<a href="http://api.rubyonrails.org/">Ruby on Rails Documentation</a></p>
<p><a href="https://github.com/heroku/databasedotcom">Databasedotcom gem</a><br />
<a href="http://www.youtube.com/watch?v=7zeGJLXd600">Building and Deploying Great Applications with Salesforce, Ruby, and Heroku</a> (Dreamforce)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2012/01/27/video-getting-started-with-rails-databasedotcom-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Amazon DynamoDB Demo</title>
		<link>http://blog.jeffdouglas.com/2012/01/19/amazon-dynamodb-demo/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=amazon-dynamodb-demo</link>
		<comments>http://blog.jeffdouglas.com/2012/01/19/amazon-dynamodb-demo/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 14:48:20 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=4312</guid>
		<description><![CDATA[Yesterday Amazon announced Amazon DynamoDB, their Internet-scale NoSQL database service. Back in November we were fortunate enough at CloudSpokes to be invited to participate in a private beta for Amazon DynamoDB. We’ve since then had some time to “work it over” a bit and I have put together a demo application to show off some [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2012%2F01%2F19%2Famazon-dynamodb-demo%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2012%2F01%2F19%2Famazon-dynamodb-demo%2F&amp;source=jeffdonthemic&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Yesterday <a href="http://aws.typepad.com/aws/2012/01/amazon-dynamodb-internet-scale-data-storage-the-nosql-way.html" target="_blank">Amazon announced Amazon DynamoDB</a>, their Internet-scale NoSQL database service. Back in November we were fortunate enough at <a href="http://www.cloudspokes.com" target="_blank">CloudSpokes</a> to be invited to participate in a private beta for <a href="http://aws.amazon.com/dynamodb/" target="_blank">Amazon DynamoDB</a>. We’ve since then had some time to “work it over” a bit and I have put together a <a href="http://kivabrowser.elasticbeanstalk.com/" target="_blank">demo application</a> to show off some functionality. The code for the HomeController is below but you can find source for the entire applications at <a href="https://github.com/cloudspokes/Amazon-DynamoDB-Demo" target="_blank">our GitHub repo</a> for your forking convenience.</p>
<p><a href="http://kivabrowser.elasticbeanstalk.com"><img src="http://blog.jeffdouglas.com/wp-content/uploads/2012/01/kiva-browser-1.png" alt="" title="kiva-browser" width="400" height="321" class="aligncenter size-full wp-image-4327" /></a></p>
<div style="text-align: center;">
<b><a href="http://kivabrowser.elasticbeanstalk.com/" target="_blank">Demo application</a>&nbsp;and <a href="https://github.com/cloudspokes/Amazon-DynamoDB-Demo" target="_blank">source code</a></b></div>
</p>
<p>The API is very straight forward and easy to work with. If you’ve used other NoSQL databases then you should have no problem wrapping your head around <a href="http://aws.amazon.com/dynamodb/" target="_blank">Amazon DynamoDB</a>. It has simple storage and query methods, allowing you to store and access data items with a flexible number of attributes using simple “Put” or “Get” web services APIs. Amazon DynamoDB provides a native API for HTTP and SDKs for Java, PHP and .NET. More are reportedly in the works.</p>
<p><span style="font-size: large;">What is Amazon DynamoDB and why would I want to use it?</span></p>
<p><a href="http://aws.amazon.com/dynamodb/" target="_blank">Amazon DynamoDB</a> is a fast, highly scalable, highly available, cost-effective non-relational database service that scales automatically without limits or administration. This service is tightly coupled with Amazon S3 andAmazon EC2, collectively providing the ability to store, process and query data sets in the cloud.</p>
<p>If you have massive amounts of highly transactional data then Amazon DynamoDB might be for you:</p>
<ul>
<li>Store Social Graph data for processing</li>
<li>Storing GPS data for devices</li>
<li>Data storage for Hadoop processes</li>
<li>Record user activity logs</li>
<li>NFC processes</li>
<li>Recording clicks for A/B testing</li>
</ul>
<p>
<b>Blazing Fast</b> &#8211; Amazon DynamoDB runs on a new solid state disk (SSD) architecture for low-latency response times. Read latencies average less than 5 milliseconds, and write latencies average less than 10 milliseconds. We found our applications to be extremely responsive.</p>
<p><b>Hands Off Administration</b> &#8211; Amazon DynamoDB is a fully managed service – no need to worry about hardware or software provisioning, setup and configuration, software patching, or partitioning data over multiple instances as you scale. For instance, when you create a table, you need to specify the request throughput you want for your table. In the background, Amazon DynamoDB handles the provisioning of resources to meet the requested throughput rate.</p>
<p><b>Auto Scaling</b> &#8211; To continue with the “no administration” theme, Amazon DynamoDB can automatically scale machine resources in response to increases in database traffic without the need of client-side partitioning. Alternatively, you can also proactively manage performance with a few simple commands.</p>
<p><b>Security Baked In</b> &#8211; Amazon DynamoDB is integrated with AWS Identity and Access Management (access keys and tokens) allowing you to provide access to defined users and groups, assign granular security credentials and user access, much more.</p>
<p><b>Centralized Monitoring</b> &#8211; As with most everything in AWS-land, you can easily view metrics for your Amazon DynamoDB table in the AWS Management Console. You can also view your request throughput and latency for each API as well as resource consumption through Amazon CloudWatch.</p>
<p><span style="font-size: large;">API Overview</span></p>
<p>From a high level, Amazon DynamoDB API provides the following functionality:</p>
<ul>
<li>Create a table</li>
<li>Delete a table</li>
<li>Request the current state of a table</li>
<li>Get a list of all of the tables for the current account</li>
<li>Put an item</li>
<li>Get one or more items by primary key</li>
<li>Update the attributes in a single item</li>
<li>Delete an item</li>
<li>Scan a table and optionally filter the items returned using comparison operators</li>
<li>Query for items using a range index and comparison operators</li>
<li>Increment or decrement a numeric value</li>
</ul>
<p><span style="font-size: large;">Data Model</span></p>
<p>Amazon DynamoDB stores data in tables containing items with a collection of name-value pairs (attributes). Items (anaglous to a record) are managed by assigning each item a primary key value. Unlike traditional databases, the table is schemaless and only relies on the primary key. Items can contain combination of attributes. For example:</p>
<p>&#8220;Name&#8221; = &#8220;Member Search with Redis&#8221;<br />
&#8220;ChallengeId&#8221; = 1219<br />
&#8220;Categories&#8221; = &#8220;aws&#8221;, &#8220;ruby&#8221;, &#8220;mobile&#8221;<br />
&#8220;Ratings&#8221; = 17, 36</p>
<p><b>Primary Keys &amp; Indexes</b></p>
<p>When creating a new table, you define the primary key and type of key to be used. Amazon DynamoDB supports a one name/value pair primary key (a hash primary key; string or number) or two name/value pair primary key (a hash-and-range primary key) for index values.</p>
<p>Hash key example: &#8220;ChallengeId&#8221; = 1219<br />
Hash-and-range key example: &#8220;MemberId&#8221; = &#8220;romin&#8221;, &#8220;MemberNumber&#8221; = &#8220;976&#8243;</p>
<p>Note: the Query API is only available for hash-and-range primary key tables. If you are using a simple hash key, then you need to use the Scan API.</p>
<p><b>Data Types</b></p>
<p>Amazon DynamoDB supports two scalar data types (Number and String) and multi-valued types (String Set and Number Set). Everything is stored in Amazon DynamoDB as a UTF-8 string value. You designate the data as a Number, String, String Set, or Number Set in the request but there is no distinction between an int, long, float, etc. For example:</p>
<p>item.put(&#8220;member&#8221;, new AttributeValue().withS(&#8220;romin&#8221;));<br />
item.put(&#8220;challenge&#8221;, new AttributeValue().withN(&#8220;1219&#8243;));</p>
<p>Amazon DynamoDB supports both Number Sets and String Sets:</p>
<p>&#8220;Challenges&#8221;:[{<br />
&nbsp;"members":{"SS":["kenji776, romin, akkishore"]},<br />
&nbsp;&#8221;wins&#8221; : {&#8220;NS&#8221;:["14", "10", "8"]}<br />
}]</p>
<p>Amazon DynamoDB uses JSON as the transport protocol. However, the JSON data is parsed and stored nativly on disk.</p>
<p>That’s a quick overview so make sure to check out the DynamoDB documentation for more details. The documentation is very well done and has clear instructions and code samples for Java, PHP and .Net. If you are into database performance, check out the details on provisioned throughput, data consistency, conditional operations, performance factors and more.</p>
<p><span style="font-size: large;">How to get started?</span></p>
<p>Sign up for a new AWS account (if you don’t already have one) and get your AWS Access Key ID and Secret Access Key from your account’s security section. Walk through their <a href="http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/GettingStartedDynamoDB.html" target="_blank">Getting Started Guide</a> for samples. In your code, just add your credentials to the AWSDynamoDBClient and you are ready to start making requests. All of the API calls are pretty straightforward and work as you would expect them to.</p>
<p>Pricing is, again, pay as you go but Amazon DynamoDB is part of the&nbsp;<a href="http://aws.amazon.com/free/" target="_blank">AWS’s Free Usage Tier</a> so check it out for more info.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">package com.cloudspokes.dynamodb;
&nbsp;
@Controller
public class HomeController {
&nbsp;
  static AmazonDynamoDBClient dynamoDB;
  private String tableName = &quot;kiva-loans&quot;;
  // aws keys
  public static final String ACCESSKEY = &quot;YOURKEY&quot;;
  public static final String SECRETKEY = &quot;YOURSECRET&quot;;
&nbsp;
  public HomeController() {
    try {
      setup();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
&nbsp;
  /**
   * Displays the list of loans from the table
   */
  @RequestMapping(value = &quot;/loans&quot;, method = RequestMethod.GET)
  public String loans(Locale locale,
      @RequestParam(value = &quot;keyword&quot;, required = false) String keyword,
      Model model) {
&nbsp;
    ArrayList&lt;Loan&gt; loans = new ArrayList&lt;Loan&gt;();
    ScanRequest scanRequest = new ScanRequest(tableName);
&nbsp;
    if (keyword != null) {
      HashMap&lt;String, Condition&gt; scanFilter = new HashMap&lt;String, Condition&gt;();
      Condition condition = new Condition().withComparisonOperator(
          ComparisonOperator.EQ.toString()).withAttributeValueList(
          new AttributeValue().withS(keyword));
      scanFilter.put(&quot;country&quot;, condition);
      scanRequest = new ScanRequest(tableName).withScanFilter(scanFilter);
    }
    ScanResult scanResult = dynamoDB.scan(scanRequest);
&nbsp;
    for (int i = 0; i &lt; scanResult.getCount(); i++) {
      HashMap&lt;String, AttributeValue&gt; item = (HashMap&lt;String, AttributeValue&gt;) scanResult
          .getItems().get(i);
      Loan loan = new Loan();
      loan.setActivity(item.get(&quot;activity&quot;).getS());
      loan.setCountry(item.get(&quot;country&quot;).getS());
      loan.setFunded_amount(Double.parseDouble(item.get(&quot;funded_amount&quot;)
          .getN()));
      loan.setId(Integer.parseInt(item.get(&quot;id&quot;).getN()));
      loan.setName(item.get(&quot;name&quot;).getS());
      loan.setStatus(item.get(&quot;status&quot;).getS());
      loan.setUse(item.get(&quot;use&quot;).getS());
      loans.add(loan);
    }
&nbsp;
    model.addAttribute(&quot;loans&quot;, loans);
    return &quot;loans&quot;;
  }
&nbsp;
  /**
   * Displays a loan item
   */
  @RequestMapping(value = &quot;/show/{id}&quot;, method = RequestMethod.GET)
  public String show(@PathVariable String id, Locale locale, Model model) {
    model.addAttribute(&quot;loan&quot;, getLoan(id));
    return &quot;show&quot;;
  }
&nbsp;
  /**
   * Displays a form to create a new loan item
   */
  @RequestMapping(value = &quot;/new&quot;, method = RequestMethod.GET)
  public String newLoan(Locale locale, Model model) {
    model.addAttribute(&quot;loan&quot;, new Loan());
    return &quot;new&quot;;
  }
&nbsp;
  /**
   * Inserts a new loan item into dynamodb
   */
  @RequestMapping(value = &quot;/new&quot;, method = RequestMethod.POST)
  public String addLoan(@ModelAttribute(&quot;loan&quot;) Loan loan,
      BindingResult result) {
&nbsp;
    // populate an item with the data to put
    HashMap&lt;String, AttributeValue&gt; item = new HashMap&lt;String, AttributeValue&gt;();
    item.put(&quot;id&quot;, new AttributeValue().withN(String.valueOf(loan.getId())));
    item.put(&quot;activity&quot;, new AttributeValue().withS(loan.getActivity()));
    item.put(&quot;country&quot;, new AttributeValue().withS(loan.getCountry()));
    item.put(&quot;funded_amount&quot;, new AttributeValue().withN(String
        .valueOf(loan.getFunded_amount())));
    item.put(&quot;name&quot;, new AttributeValue().withS(loan.getName()));
    item.put(&quot;status&quot;, new AttributeValue().withS(loan.getStatus()));
    item.put(&quot;use&quot;, new AttributeValue().withS(loan.getUse()));
&nbsp;
    // put the item to the table
    try {
      PutItemRequest req = new PutItemRequest(tableName, item);
      PutItemResult res = dynamoDB.putItem(req);
    } catch (AmazonServiceException ase) {
      System.err.println(&quot;Failed to create item in &quot; + tableName);
    }
&nbsp;
    return &quot;redirect:show/&quot; + loan.getId();
  }
&nbsp;
  /**
   * Displays the item for editing
   */
  @RequestMapping(value = &quot;/edit/{id}&quot;, method = RequestMethod.GET)
  public String editLoan(@PathVariable String id, Locale locale, Model model) {
    model.addAttribute(&quot;loan&quot;, getLoan(id));
    return &quot;edit&quot;;
  }
&nbsp;
  /**
   * Submits the updates loan data to dynamodb
   */
  @RequestMapping(value = &quot;/edit/{id}&quot;, method = RequestMethod.POST)
  public String updateLoan(@PathVariable String id,
      @ModelAttribute(&quot;loan&quot;) Loan loan, BindingResult result) {
&nbsp;
    Key key = new Key().withHashKeyElement(new AttributeValue().withN(id));
    HashMap&lt;String, AttributeValueUpdate&gt; updates = new HashMap&lt;String, AttributeValueUpdate&gt;();
&nbsp;
    AttributeValueUpdate update = new AttributeValueUpdate().withValue(
        new AttributeValue(loan.getStatus())).withAction(&quot;PUT&quot;);
    updates.put(&quot;status&quot;, update);
&nbsp;
    // update the item to the table
    try {
      UpdateItemRequest req = new UpdateItemRequest(tableName, key,
          updates);
      UpdateItemResult res = dynamoDB.updateItem(req);
    } catch (AmazonServiceException ase) {
      System.err.println(&quot;Failed to update item: &quot; + ase.getMessage());
    }
&nbsp;
    return &quot;redirect:../show/&quot; + id;
  }
&nbsp;
  /**
   * Fetches loan data from Kiva an inserts it into dynamodb
   */
  @RequestMapping(value = &quot;/loadData&quot;, method = RequestMethod.GET)
  public String loadData(Locale locale, Model model) {
&nbsp;
    // delete all of the current loans
    deleteAllLoans();
&nbsp;
    // make the REST call to kiva
    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpGet getRequest = new HttpGet(
        &quot;http://api.kivaws.org/v1/loans/newest.json&quot;);
    getRequest.addHeader(&quot;accept&quot;, &quot;application/json&quot;);
    HttpResponse response;
    String payload = &quot;&quot;;
&nbsp;
    try {
      response = httpClient.execute(getRequest);
&nbsp;
      if (response.getStatusLine().getStatusCode() != 200) {
        throw new RuntimeException(&quot;Failed : HTTP error code : &quot;
            + response.getStatusLine().getStatusCode());
      }
&nbsp;
      BufferedReader br = new BufferedReader(new InputStreamReader(
          (response.getEntity().getContent())));
      payload = br.readLine();
    } catch (ClientProtocolException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
&nbsp;
    JSONObject json = (JSONObject) JSONSerializer.toJSON(payload);
    // get the array of loans
    JSONArray loans = json.getJSONArray(&quot;loans&quot;);
&nbsp;
    for (int i = 0; i &lt; loans.size(); ++i) {
      JSONObject loan = loans.getJSONObject(i);
      // populate an item with the data to put
      HashMap&lt;String, AttributeValue&gt; item = new HashMap&lt;String, AttributeValue&gt;();
      item.put(&quot;id&quot;, new AttributeValue().withN(loan.getString(&quot;id&quot;)));
      item.put(&quot;name&quot;, new AttributeValue().withS(loan.getString(&quot;name&quot;)));
      item.put(&quot;status&quot;,
          new AttributeValue().withS(loan.getString(&quot;status&quot;)));
      item.put(&quot;funded_amount&quot;,
          new AttributeValue().withN(loan.getString(&quot;funded_amount&quot;)));
      item.put(&quot;activity&quot;,
          new AttributeValue().withS(loan.getString(&quot;activity&quot;)));
      item.put(&quot;use&quot;, new AttributeValue().withS(loan.getString(&quot;use&quot;)));
      item.put(&quot;country&quot;, new AttributeValue().withS(loan.getJSONObject(
          &quot;location&quot;).getString(&quot;country&quot;)));
&nbsp;
      try {
        PutItemRequest req = new PutItemRequest(tableName, item);
        PutItemResult res = dynamoDB.putItem(req);
        System.out.println(&quot;Put result: &quot; + res);
      } catch (AmazonServiceException ase) {
        System.err.println(&quot;Failed to create item in &quot; + tableName);
      }
&nbsp;
    }
&nbsp;
    httpClient.getConnectionManager().shutdown();
&nbsp;
    return &quot;redirect:loans&quot;;
  }
&nbsp;
  /**
   * Displays the home page
   */
  @RequestMapping(value = &quot;/&quot;, method = RequestMethod.GET)
  public String home(Locale locale, Model model) {
    return &quot;home&quot;;
  }
&nbsp;
  /**
   * Fetches a specific loan item
   */
  private Loan getLoan(String id) {
    Key key = new Key().withHashKeyElement(new AttributeValue().withN(id));
    GetItemRequest req = new GetItemRequest(tableName, key);
    GetItemResult res = dynamoDB.getItem(req);
    HashMap&lt;String, AttributeValue&gt; item = (HashMap&lt;String, AttributeValue&gt;) res
        .getItem();
&nbsp;
    Loan loan = new Loan();
    loan.setActivity(item.get(&quot;activity&quot;).getS());
    loan.setCountry(item.get(&quot;country&quot;).getS());
    loan.setFunded_amount(Double.parseDouble(item.get(&quot;funded_amount&quot;)
        .getN()));
    loan.setId(Integer.parseInt(item.get(&quot;id&quot;).getN()));
    loan.setName(item.get(&quot;name&quot;).getS());
    loan.setStatus(item.get(&quot;status&quot;).getS());
    loan.setUse(item.get(&quot;use&quot;).getS());
    return loan;
  }
&nbsp;
  /**
   * Deletes all items from dynamodb
   */
  private void deleteAllLoans() {
    ScanRequest scanRequest = new ScanRequest(tableName);
    ScanResult scanResult = dynamoDB.scan(scanRequest);
    for (int i = 0; i &lt; scanResult.getItems().size(); i++) {
      HashMap&lt;String, AttributeValue&gt; item = (HashMap&lt;String, AttributeValue&gt;) scanResult
          .getItems().get(i);
      try {
        Key key = new Key()
            .withHashKeyElement(new AttributeValue(&quot;id&quot;))
            .withHashKeyElement(item.get(&quot;id&quot;));
        DeleteItemRequest request = new DeleteItemRequest(tableName,
            key);
        DeleteItemResult result = dynamoDB.deleteItem(request);
        System.out.println(&quot;Result: &quot; + result);
      } catch (AmazonServiceException ase) {
        System.err.println(&quot;Failed to delete item in &quot; + tableName);
      }
    }
  }
&nbsp;
  private void setup() throws Exception {
    BasicAWSCredentials creds = new BasicAWSCredentials(ACCESSKEY,
        SECRETKEY);
    dynamoDB = new AmazonDynamoDBClient(creds);
    dynamoDB.setEndpoint(&quot;http://dynamodb.us-east-1.amazonaws.com&quot;);
  }
&nbsp;
}</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2012/01/19/amazon-dynamodb-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apex Test Coverage Does Not Match?</title>
		<link>http://blog.jeffdouglas.com/2011/11/22/apex-test-coverage-does-not-match/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=apex-test-coverage-does-not-match</link>
		<comments>http://blog.jeffdouglas.com/2011/11/22/apex-test-coverage-does-not-match/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 16:38:49 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=4294</guid>
		<description><![CDATA[Writing unit test in Salesforce is, in my opinion, a &#8220;black art&#8221;. There are so many workarounds and &#8220;techniques&#8221; that it makes the process extremely frustrating. The issue below makes me enjoy the process even less based upon the amount of time/money I spent wasting on it. BTW, go vote on my idea to make [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F11%2F22%2Fapex-test-coverage-does-not-match%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F11%2F22%2Fapex-test-coverage-does-not-match%2F&amp;source=jeffdonthemic&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Writing unit test in Salesforce is, in my opinion, a &#8220;black art&#8221;. There are so many workarounds and &#8220;techniques&#8221; that it makes the process extremely frustrating. The issue below makes me enjoy the process even less based upon the amount of time/money I spent wasting on it. </p>
<p>BTW, go <a href="http://success.salesforce.com/ideaView?c=09a30000000D9xtAAC&#038;id=08730000000BrPiAAK" target="_blank">vote on my idea</a> to make Apex testing easier. You&#8217;ll thank me later.</p>
<p>I&#8217;ve seen a number of people on twitter recently comment that unit test coverage display different percentages when tests run in the browser vs. in Eclipse with &#8220;Run All Tests&#8221;. I just ran across this same issue and finally found the way to &#8220;work around&#8221; it. </p>
<p>I had an existing test class that I was updating and when I &#8220;Ran All Tests&#8221; from Eclipse I received a different result than when I &#8220;Ran All Tests&#8221; in my browser.</p>
<p><a href="http://blog.jeffdouglas.com/wp-content/uploads/2011/11/runall-1.png" rel="lightbox[4294]"><img src="http://blog.jeffdouglas.com/wp-content/uploads/2011/11/runall-1.png" alt="" title="runall-1" width="550" height="115" class="aligncenter size-full wp-image-4300" /></a></p>
<p>For some reason it looks like salesforce.com is caching the class and not re-running the actual test cases. When I <strong>edited the class, saved it and &#8220;Ran All Tests&#8221; again</strong> in the browser it finally displayed the same-ish results.</p>
<p><a href="http://blog.jeffdouglas.com/wp-content/uploads/2011/11/runall-2.png" rel="lightbox[4294]"><img src="http://blog.jeffdouglas.com/wp-content/uploads/2011/11/runall-2.png" alt="" title="runall-2" width="550" height="68" class="aligncenter size-full wp-image-4302" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2011/11/22/apex-test-coverage-does-not-match/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>&#8220;Chow Finder&#8221; &#8211; My Veterans Hackday 2011 App</title>
		<link>http://blog.jeffdouglas.com/2011/11/15/chow-finder/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=chow-finder</link>
		<comments>http://blog.jeffdouglas.com/2011/11/15/chow-finder/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 11:53:16 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[CloudSpokes]]></category>
		<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Heroku]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=4264</guid>
		<description><![CDATA[This is my submission for the LinkedIn Veterans Hackday 2011. CloudSpokes threw in an extra $100 for any member that submitted as an extra incentive. Our members created some pretty cool apps and I&#8217;ll be highlighting them shortly. Chow Finder is a mobile application for services members to easily locate dining facilities, aka &#8220;chow halls&#8221;, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F11%2F15%2Fchow-finder%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F11%2F15%2Fchow-finder%2F&amp;source=jeffdonthemic&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://blog.jeffdouglas.com/wp-content/uploads/2011/11/chow-finder1.png" rel="lightbox[4264]"><img src="http://blog.jeffdouglas.com/wp-content/uploads/2011/11/chow-finder1.png" alt="" title="chow-finder1" width="200" class="alignleft size-full wp-image-4266" /></a>This is my submission for the <a href="http://veterans2011.linkedin.com/">LinkedIn Veterans Hackday 2011</a>. <a href="http://blog.cloudspokes.com/2011/11/veterans-hackday-2011-get-involved.html">CloudSpokes threw in an extra $100</a> for any member that submitted as an extra incentive. Our members created some pretty cool apps and I&#8217;ll be highlighting them shortly.</p>
<p>Chow Finder is a mobile application for services members to easily locate dining facilities, aka &#8220;chow halls&#8221;, on any military installation. It was inspired by my sons in the Army and Navy who are always looking for their next meal.</p>
<p>The application was written using <a href="http://jquerymobile.com/">jQuery Mobile</a> and <a href="http://rubyonrails.org/">Ruby on Rails</a>. I used <a href="http://database.com">Database.com</a> for the data store and it is hosted on <a href="http://www.heroku.com">Heroku</a>. All of this for free!</p>

<div class="ngg-galleryoverview" id="ngg-gallery-2-4264">

	<!-- Slideshow link -->
	<div class="slideshowlink">
		<a class="slideshowlink" href="http://blog.jeffdouglas.com/2011/11/15/chow-finder/?show=slide">
			[Show as slideshow]		</a>
	</div>

	
	<!-- Thumbnails -->
		
	<div id="ngg-image-9" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://blog.jeffdouglas.com/wp-content/gallery/chow-finder/chow-finder1.png" title=" " class="shutterset_set_2"  rel="lightbox[4264]">
								<img title="chow-finder1" alt="chow-finder1" src="http://blog.jeffdouglas.com/wp-content/gallery/chow-finder/thumbs/thumbs_chow-finder1.png" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-10" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://blog.jeffdouglas.com/wp-content/gallery/chow-finder/chow-finder2.png" title=" " class="shutterset_set_2"  rel="lightbox[4264]">
								<img title="chow-finder2" alt="chow-finder2" src="http://blog.jeffdouglas.com/wp-content/gallery/chow-finder/thumbs/thumbs_chow-finder2.png" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-11" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://blog.jeffdouglas.com/wp-content/gallery/chow-finder/chow-finder3.png" title=" " class="shutterset_set_2"  rel="lightbox[4264]">
								<img title="chow-finder3" alt="chow-finder3" src="http://blog.jeffdouglas.com/wp-content/gallery/chow-finder/thumbs/thumbs_chow-finder3.png" width="100" height="75" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class='ngg-clear'></div>
 	
</div>


<p><br/>You can run the <a href="http://chow-finder.herokuapp.com">Chow Finder here</a> or <a href="https://github.com/jeffdonthemic/Chow-Finder">fork the code at GitHub</a>. I&#8217;m still working on some loose ends.</p>
<p><span class="youtube">
<object width="560" height="340">
<param name="movie" value="http://www.youtube.com/v/eCyVbFne12Q?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;loop=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&amp;hd=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="opaque" src="http://www.youtube.com/v/eCyVbFne12Q?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;loop=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" width="560" height="340"></embed>
<param name="wmode" value="opaque" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=eCyVbFne12Q&fmt=18">www.youtube.com/watch?v=eCyVbFne12Q</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2011/11/15/chow-finder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dependency Management with Play!</title>
		<link>http://blog.jeffdouglas.com/2011/10/25/dependency-management-with-play/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=dependency-management-with-play</link>
		<comments>http://blog.jeffdouglas.com/2011/10/25/dependency-management-with-play/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 11:43:39 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Play!]]></category>
		<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=4243</guid>
		<description><![CDATA[Play! has dependency management baked into it. This allows you to express your application’s external dependencies in a single dependencies.yml file. So if your app requires commons-lang or log4j, you can list them in your depencies.yml file and Play! will download them for you and place them in your lib directory. So I&#8217;m making changes [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F10%2F25%2Fdependency-management-with-play%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F10%2F25%2Fdependency-management-with-play%2F&amp;source=jeffdonthemic&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Play! has <a href="http://www.playframework.org/documentation/1.2.3/dependency">dependency management baked into it</a>. This allows you to express your application’s external dependencies in a single dependencies.yml file. So if your app requires commons-lang or log4j, you can list them in your depencies.yml file and Play! will download them for you and place them in your lib directory.</p>
<p>So I&#8217;m making changes to my <a href="http://blog.jeffdouglas.com/2011/09/26/telesales-play/">Play! demo app for salesforce.com</a> and am trying to specify the <a href="http://code.google.com/p/sfdc-wsc/">Force.com Web Service Connector (WSC)</a> in my dependencies.yml file. However, I think that I&#8217;m not referencing them correctly as the module is not being found in mavenscentral and downloaded. I&#8217;ve tried different combinations with the artifactId and groupId but nothing seems to work. Here&#8217;s my dependencies.yml:</p>
<pre>
require:
    - play
    - force-wsc -> force-wsc
&nbsp;
</pre>
<p>When I run <em>play dependencies &#8211;verbose</em> in Terminal I get the following:</p>
<pre>
:::: WARNINGS
module not found: force-wsc#force-wsc;->
==== mavenCentral: tried

http://repo1.maven.org/maven2/force-wsc/force-wsc/->/force-wsc-->.pom

-- artifact force-wsc#force-wsc;->!force-wsc.jar:

http://repo1.maven.org/maven2/force-wsc/force-wsc/->/force-wsc-->.jar

::::::::::::::::::::::::::::::::::::::::::::::
::          UNRESOLVED DEPENDENCIES         ::
::::::::::::::::::::::::::::::::::::::::::::::
:: force-wsc#force-wsc;->: not found
::::::::::::::::::::::::::::::::::::::::::::::
</pre>
<p>Any help with this issue would be greatly appreciated!</p>
<p><font color="red"><b>Update!!</b></font></p>
<p>I worked with <a href="http://twitter.com/jesperfj">@jesperfj</a> this morning and he pointed me in the right direction. I needed to include the groupId and version as well. The correct syntax looks like:</p>
<pre>
require:
    - play
    - com.force.api -> force-wsc 22.0.0
&nbsp;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2011/10/25/dependency-management-with-play/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m Addicted to Play! on Heroku</title>
		<link>http://blog.jeffdouglas.com/2011/10/25/im-addicted-to-play-on-heroku/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=im-addicted-to-play-on-heroku</link>
		<comments>http://blog.jeffdouglas.com/2011/10/25/im-addicted-to-play-on-heroku/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 11:19:53 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Heroku]]></category>
		<category><![CDATA[Play!]]></category>
		<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=4227</guid>
		<description><![CDATA[I&#8217;ve been using Play! since Dreamforce 11 when Heroku announced support for it and I have to say that I&#8217;m addicted to it. If you love Java (and who doesn&#8217;t) but hate developing Java applications with all of the crap that goes along with it (Maven, XML config files, deployments, etc.) then the Play! framework [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F10%2F25%2Fim-addicted-to-play-on-heroku%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F10%2F25%2Fim-addicted-to-play-on-heroku%2F&amp;source=jeffdonthemic&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve been using <a href="http://www.playframework.org/">Play!</a> since Dreamforce 11 when <a href="http://blog.heroku.com/archives/2011/8/29/play/">Heroku announced support for it</a> and I have to say that I&#8217;m addicted to it. If you love Java (and who doesn&#8217;t) but hate developing Java applications with all of the crap that goes along with it (Maven, XML config files, deployments, etc.) then the Play! framework my just be your savior.</p>
<p>I did a <a href="http://blog.jeffdouglas.com/2011/09/26/telesales-play/">small demo</a> with salesforce.com integration with Heroku and Play! if you would like some <a href="https://github.com/jeffdonthemic/Telesales-Play">sample code</a> or to <a href="http://telesales-play.herokuapp.com/">run it</a> for yourself.</p>
<p>Here&#8217;s what I like the most about Play!: it makes me productive. The development style is similar to Rails and I can simply get stuff done. I don&#8217;t have to save my Java code, restart Tomcat, wait for Hibernate to fire up and then see if my code runs as expected. With Play! I make my modifications, hit refresh in the browser and presto! my new app is either up and running or there is a nice, pretty error message. </p>
<p>Running Play! is a breeze. The framework comes bundled with <a href="http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty">Jetty</a> so I don&#8217;t have to install and maintain Tomcat locally and when I&#8217;m ready to put the app into production, I just push it to Heroku and they take care of the rest.</p>
<p>If you want a great intro to Play! and why you might to use it, check out the first 10 minutes of this video from Dreamforce 11, &#8220;Introducing Play! Framework: Painless Java and Scala Web Applications&#8221;. The reset of the preso gets into actually building an app so if you want to see some code, feel free to continue watching.</p>
<p><span class="youtube">
<object width="480" height="385">
<param name="movie" value="http://www.youtube.com/v/kAjERGwhmog?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;loop=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="opaque" src="http://www.youtube.com/v/kAjERGwhmog?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;loop=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1" type="application/x-shockwave-flash" allowfullscreen="true" width="480" height="385"></embed>
<param name="wmode" value="opaque" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=kAjERGwhmog">www.youtube.com/watch?v=kAjERGwhmog</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2011/10/25/im-addicted-to-play-on-heroku/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Video &#8211; Debugging Apex Tools and Techniques (DF11)</title>
		<link>http://blog.jeffdouglas.com/2011/10/24/debugging-apex-tools-and-techniques/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=debugging-apex-tools-and-techniques</link>
		<comments>http://blog.jeffdouglas.com/2011/10/24/debugging-apex-tools-and-techniques/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 12:00:43 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Apex]]></category>
		<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=4221</guid>
		<description><![CDATA[The new System Log (aka Apex CSI) is a cool new part of Winter 12 that significantly reduces the pain of debugging Force.com applications. This is a great video from Dreamforce 11 showing you how to use the new console to debug code, set &#8220;breakpoints&#8221; and examine heap variables and more. www.youtube.com/watch?v=Hl2cY7eW2Ko]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F10%2F24%2Fdebugging-apex-tools-and-techniques%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F10%2F24%2Fdebugging-apex-tools-and-techniques%2F&amp;source=jeffdonthemic&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>The new System Log (aka Apex CSI) is a cool new part of Winter 12 that significantly reduces the pain of debugging Force.com applications. This is a great video from Dreamforce 11 showing you how to use the new console to debug code, set &#8220;breakpoints&#8221; and examine heap variables and more. </p>
<p><span class="youtube">
<object width="560" height="340">
<param name="movie" value="http://www.youtube.com/v/Hl2cY7eW2Ko?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;loop=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&amp;hd=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="opaque" src="http://www.youtube.com/v/Hl2cY7eW2Ko?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;loop=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&amp;hd=1" type="application/x-shockwave-flash" allowfullscreen="true" width="560" height="340"></embed>
<param name="wmode" value="opaque" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=Hl2cY7eW2Ko&fmt=18">www.youtube.com/watch?v=Hl2cY7eW2Ko</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2011/10/24/debugging-apex-tools-and-techniques/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Salesforce Field Metadata the Easy Way</title>
		<link>http://blog.jeffdouglas.com/2011/10/20/getting-salesforce-field-metadata-the-easy-way/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=getting-salesforce-field-metadata-the-easy-way</link>
		<comments>http://blog.jeffdouglas.com/2011/10/20/getting-salesforce-field-metadata-the-easy-way/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 18:38:01 +0000</pubDate>
		<dc:creator>Jeff Douglas</dc:creator>
				<category><![CDATA[Code Sample]]></category>
		<category><![CDATA[Salesforce]]></category>

		<guid isPermaLink="false">http://blog.jeffdouglas.com/?p=4203</guid>
		<description><![CDATA[I&#8217;m working on some of the Apex REST services for our CloudSpokes org and needed some code to fetch field level metadata using Apex Describe. I poked around and realized that there isn&#8217;t really much out there. So I decided to write something up and hopefully people find it useful or instructional. Perhaps it should [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F10%2F20%2Fgetting-salesforce-field-metadata-the-easy-way%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fblog.jeffdouglas.com%2F2011%2F10%2F20%2Fgetting-salesforce-field-metadata-the-easy-way%2F&amp;source=jeffdonthemic&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://blog.jeffdouglas.com/wp-content/uploads/2011/10/metadata.png" rel="lightbox[4203]"><img src="http://blog.jeffdouglas.com/wp-content/uploads/2011/10/metadata.png" alt="" title="metadata" width="150" height="183" class="alignleft size-full wp-image-4205" /></a>I&#8217;m working on some of the Apex REST services for our <a href="http://www.cloudspokes.com">CloudSpokes</a> org and needed some code to fetch field level metadata using Apex Describe. I poked around and realized that there isn&#8217;t really much out there. So I decided to write something up and hopefully people find it useful or instructional. Perhaps it should be part of <a href="http://code.google.com/p/apex-lang/">apex-lang</a>? </p>
<p>If you&#8217;ve ever worked with Apex Describe before you&#8217;ll quickly realize that it&#8217;s not the easiest thing to work with. You&#8217;ll want to <a href="http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_fields_describe.htm">take a peek at the docs</a>. Don&#8217;t get me wrong, it&#8217;s power, fast and very handy. But it is rather confusing and cumbersome to work with at first. So I wanted some code that returns the metadata for specific fields in an object so that I could look at field types and lengths and perform &#8220;stuff&#8221; accordingly. </p>
<p>So here&#8217;s what I can up with. You pass the method the DescribeFieldResult for an object and a collection of fields that you want metadata for. The method returns a map where the field names are the keys and the values contain the metadata for the corresponding field. It looks pretty hard but that&#8217;s the great thing about utility methods, they encapsulate and hide the complexity of the implementation.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">public static Map&lt;String, Schema.DescribeFieldResult&gt; getFieldMetaData(
  Schema.DescribeSObjectResult dsor, Set&lt;String&gt; fields) {
&nbsp;
  // the map to be returned with the final data
  Map&lt;String,Schema.DescribeFieldResult&gt; finalMap = 
    new Map&lt;String, Schema.DescribeFieldResult&gt;();
  // map of all fields in the object
  Map&lt;String, Schema.SObjectField&gt; objectFields = dsor.fields.getMap();
&nbsp;
  // iterate over the requested fields and get the describe info for each one. 
  // add it to a map with field name as key
  for(String field : fields){
    // skip fields that are not part of the object
    if (objectFields.containsKey(field)) {
      Schema.DescribeFieldResult dr = objectFields.get(field).getDescribe();
      // add the results to the map to be returned
      finalMap.put(field, dr); 
    }
  }
  return finalMap;
}</pre></td></tr></table></div>

<p>So now in my code I can call this static method in my Utils class and access the field metadata easily by fetching it from the map by it&#8217;s field name:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">// field to return -- skips fields not actually part of the sobject
Set&lt;String&gt; fields = new Set&lt;String&gt;{'name','annualrevenue','BADFIELD'};
&nbsp;
Map&lt;String, Schema.DescribeFieldResult&gt; finalMap = 
  Utils.getFieldMetaData(Account.getSObjectType().getDescribe(), fields);
&nbsp;
// only print out the 'good' fields
for (String field : new Set&lt;String&gt;{'name','annualrevenue'}) {
  System.debug(finalMap.get(field).getName()); // field name
  System.debug(finalMap.get(field).getType()); // field type
  System.debug(finalMap.get(field).getLength()); // field length
}</pre></td></tr></table></div>

<p>So if you run this, you&#8217;ll see something like:</p>
<p>DEBUG|Name<br />
DEBUG|STRING<br />
DEBUG|255<br />
DEBUG|AnnualRevenue<br />
DEBUG|CURRENCY<br />
DEBUG|0</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jeffdouglas.com/2011/10/20/getting-salesforce-field-metadata-the-easy-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

