Saturday, June 23, 2012

Stardog and Spring Framework Example

Ever since the initial release of Stardog Spring support, I wanted to create a simple example application for people to learn how to use the Spring Beans and introduce semantic web technology using Stardog into traditional Spring technology stack implementations.  So I'm happy to announce today a small sample application is now available on Github, the Stardog PetStore.  Following the Spring PetClinic example, the Pet Store uses the metaphor of a store to go buy a pet - in this case, dogs!

What we'll see in the sample application is:
  • A Gradle build that references the Stardog library folder, one of the easiest ways to pull Stardog into a build
  • A basic Spring 3.1 Web MVC application, with one controller, and a couple views.
  • The usage of traditional Spring beans files, and some stereotype annotations for autowiring of the Data Access Object
  • Usage of the SnarlTemplate class to create a data access object for a POJO
  • Usage of the DataImporter capability to load some triples at initialization time

There are, of course, lots of fun things going on with Spring 3.1 with Java configurations, javax.inject annotations, environment abstraction, etc.  This sample was kept simple by following the standard 'Simple MVC Template' project available in SpringSource Toolsuite, so anyone learning Spring can follow the parallels of those samples.  Also SnarlTemplate is analogous to JdbcTemplate, so it uses the traditional Data Access Object design pattern as opposed to new rich domain models and Spring Data.  Like JdbcTemplate, this gives full control over the native APIs and lets the mappings manipulate or use as much of the underlying system as necessary.  in our case, mapping to triples, naming our properties with URIs (i.e. RDF predicates) is a good reason to have this access.  Using Stardog Empire support for RDF backed JPA and Spring Data JPA Repositories is certainly on the TODO list and a good evolutionary next step.

The prerequisite steps for this tutorial are:
  1. Obtain Stardog from stardog.com and unzip somewhere, make sure license is in Stardog home
  2. Create a database called 'petstore', e.g. "stardog-admin create -n petstore"
  3. Make sure you have Gradle 1.0 build available, command line, Eclipse, etc

Let's kick things off with the build.  After checking out the project from Github, update the build.gradle file and set the location where the Stardog/lib folder exists.



The next step is to run the gradle build.  I recommend the recently released Gradle 1.0 and SpringSource Toolsuite 2.9.2, since it lets you specify the gradle folder directly.  Command line builds with Gradle also work nicely.

You'll see the Stardog Spring beans in the root application context, where we are connecting to Stardog via their SNARL protocol.  The only requisite step here is to follow the Stardog documentation and create a database called 'petstore', i.e. "stardog-admin create -n petstore."



The spring/appServlet/servlet-context.xml contains the standard Spring MVC related beans, and instructs Spring to component scan the com.example.stardog package.  From here it will find the HomeController, DogDAO and wire them togeter with the corresponding SnarlTemplate and DataSource defined above.

Looking at the HomeController, we see a run of the mill Spring controller with the following URLs:
  • "/" - the default list of dogs in the store
  • "/create" - the form for adding a new dog
  • "/delete/id" - the GET URL to remove a dog
In all cases, the controller operates on a DAO to retrieve and manipulate the Dog POJO.  The Dog POJO itself has three properties:
  • Name (String, will be referenced inside a URL for the RDF subject)
  • Wiki URL (e.g. the wikipedia page for the breed)
  • Photo URL (e.g. a wikipedia page)
The DogDAO is where the interesting intersection with Stardog and Spring happens.  Each of the usual persistence methods (list, get, add, update, remove) are backed by operations on the SnarlTemplate.  The URL properties used for RDF creation are referenced in a Constants enum. In this case I reused pieces of the FOAF vocabulary - it's not hard to imagine a linked data query helping to fill out more releated information about the subject in question.

Design note: As an aside, creating the DogDAO for pure domain object abstraction highlighted the need to enhance the SnarlTemplate with more of the equivalent methods like JdbcTemplate (e.g. queryForObject), and support Spring TX management.

If everything works out correctly for you, you'll be able to browse and see a couple of entries listed on the web page.

Default List of Dogs in the Store

The list of dogs gets loaded from a dogs.n3 file, found in src/main/resources.

Lessons Learned from this sample:
  1.  Enterprise grade applications built with Semtech is certainly possible, and with proper encapsulation the RDF and SPARQL can live in the data layer, leaving the business logic the usual bundle of POJO joy
  2. Stardog provides a rich development experience, friendly to Java developers
  3. Gradle saves a tremendeous amount of time by being able to interweave in file system trees along side Maven style dependencies
  4. There is an opportunity for balancing the encapsulation of persistence information (i.e. predicate URIs), business logic, and semantic web exposure (i.e. generating RDFa, RDF representations of POJO resources or REST services)
 My objective is to maintain this example project as a showcase of Semantic web capability and add to it:
  • Linked Data de-reference (e.g. using Spring Jena to query DBPedia)
  • Spring Content Negotiators to expose an RDF resource or RESTful RDF service maybe with JSON-LD
  • Add Empire and a JPA sytle example so SnarlTemplate and JPA can be compared and contrasted
  • Add a few more relationships and triples to showcase the power of SPARQL

Enjoy!


------------------------------------------
References:
  1. PetStore Sample on Github
  2. Stardog - Download and obtain license here
  3. Stardog Docs - Includes chapters on Stardog Spring
  4. Clark & Parsia - creators of Stardog
  5. Spring 3.1 Documentation
  6. Gradle and SpringSource Toolsuite Tutorial

76 comments:

  1. Really something grate in This Article thanks for sharing this. We are providing Java courses training online. After reading this slightly am changed my way of introduction about my training to people. And also refer my website for JAVA Training and solutions of JAVA applications. Please Visit Us @ JAVA training courses online

    ReplyDelete
  2. thanks,You can find material related to Spring Framework by following below link.Spring Framework Online Training in USA

    ReplyDelete
  3. wow..it's very nice post..really i like this post..we are giving spring online training ..if any one want to learn plz once visit the link..

    ReplyDelete
  4. thank u for giving such a nice information..spring online training ..

    ReplyDelete
  5. nice video about servicenow well done thanks for valuable information awful piece of information, I had come to know about your blog from my friend vimal, mumbai,i have read atleast 3 posts of yours by now, and let me tell you, your blog gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanks a million once again, Regardsdevops training in hyderabad

    ReplyDelete
  6. very nice article.Thanks for sharing the post...!
    OBIEE Online Training

    ReplyDelete
  7. very nice article.Thanks for sharing the post...! Java Spring Online Training

    ReplyDelete
  8. I have read your blog its very attractive and impressive. I like it your blog.

    Spring online training Spring online training Spring Hibernate online training Spring Hibernate online training Java online training

    spring training in chennai spring hibernate training in chennai

    ReplyDelete
  9. Excellent Blog very imperative good content, this article is useful to beginners and real time
    employees.Thank u for sharing...
    Hadoop Training in Hyderabad
    JAVA Training in Hyderabad

    ReplyDelete
  10. Hi, your article really nice. That is so logical and clearly explained. Keep it up! I will follow up your site for the future post.
    Regards,
    Java Online Training
    Java Online Training in India

    ReplyDelete
  11. Stardog and Spring Frame work withholds the specific set of things, While I was searching for a good institute in Pune for pmp certification then I found certain projects which enriched with certain modules where they are been examined through different Frameworks Anywayz Thank you for providing the information

    ReplyDelete
  12. An astounding web diary I visit this blog, it's inconceivably magnificent. Strangely, in this current blog's substance made point of fact and sensible. The substance of information is instructive.
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  13. Creating a set-up checklist for payment in both desktop & online versions is an essential task which should be shown to every QuickBooks user. Hope, you liked your site. If any method or technology you can not understand, if so your better choice is which will make call us at our Quickbooks Payroll Support Phone Number.

    ReplyDelete
  14. Reflects regarding the efficiency graph of business. Its not merely simple but in addition may be manage easily , accounting software which helps to manage finances smartly. The
    Quickbooks Support Number is active at any hour for assistance.

    ReplyDelete
  15. It really is nearly not possible not to wander away once in a very whereas following the written account to control the accounts. That is why intuit created QuickBooks Customer Support Number: associate degree accounting and management code. Today, QuickBooks is the most used accounting and management code out there.

    ReplyDelete
  16. One will manage the QuickBooks Customer Support Number, produce Reports and Invoices, Track sales, file W2’s, maintain Inventories by victimization QuickBooks. detain mind that QuickBooks isn’t solely restricted towards the options that we have a tendency to simply told you, it's going to do a lot more and it’ll all feel as simple as pie.

    ReplyDelete
  17. These Are Many Of The Errors And Aspects Of Support That A Person Can Encounter When Using The Support For QuickBooks Enterprise Software. An Abundance Of Book Keepers And Payroll Managers Keep On Switching The Tabs Of Different Files While Managing Accounts Thus They Find Some Hurdles.

    ReplyDelete
  18. Entering your details every time you make any transaction takes your own time and also opens windows of committing mistake specially when you're in hurry and so this phenomenal property of QuickBooks Enterprise Support Phone Number helps to make your work easy.

    ReplyDelete
  19. Problems are inevitable and they also will not come with a bang. All of us at QuickBooks Tech Support Number Usa is ready beforehand to give you you customer-friendly assistance if you speak to a problem using QuickBooks Pro.

    ReplyDelete
  20. Simply speak to us at our website . and now we will pro-actively resolve all the errors and issues faced by you in your as a type of QuickBooks Tech Support Number Premier.

    ReplyDelete
  21. If you're a QuickBooks POS Users having trouble in your QuickBooks you are able to reach us at QuickBooks POS Support telephone number to receive support from our dedicated team.We have a different team to serve the QuickBooks POS users. Our QuickBooks Tech Support Number will allow you to out 24X7 with all your QuickBooks POS.

    ReplyDelete
  22. QuickBooks Tech Support Number brings the essential affordable technical support at comfort of your home. Look at selection of technical errors in QuickBooks for which you need certainly to e mail us for support.

    ReplyDelete
  23. You might have trapped into a problem with Intuit product and payroll services? You're going to be ready to understand the best approach to get your hands on the customer support team. Quickbooks Support Number welcome you 24*7 to access the various support services of Intuit products asking for help.

    ReplyDelete
  24. QuickBooks Enterprise customer support cell phone number. We understand that your growing business needs your precious time which explains why we offer the most effective to the QucikBooks Enterprise Support Phone Number

    ReplyDelete
  25. We provide Quickbooks Payroll tech support team when it comes to customers who find QuickBooks Payroll Support Phone Number hard to use. As Quickbooks Payroll customer support we utilize the responsibility of resolving every one of the problems that hinder the performance associated with exuberant software.

    ReplyDelete
  26. QuickBooks 2019 will be the better account management product till now. The recent improvement that is built in this system regarding current user requirements and the solutions to overcome the limitation of previous QuickBooks versions. We've been here to improve your understanding with regards to the payroll updates happens in QuickBooks Enterprise, desktop, pro, premier 2019 versions. Solve your queries related to QuickBooks Online Payroll whether Enhanced or Full Service. Fix all of the issues for QuickBooks Desktop Payroll Basic, Standard, & Payroll Assisted. Check out the aforementioned number to get hold of our ProAdvisor to possess support for Support for QuickBooks Payroll, Intuit Online & Full Service Payroll.

    ReplyDelete
  27. Sometimes, it also happens when an interruption happens during the update procedure. When the Error 15215 is caused, then you won’t be able to use the payroll feature of QuickBooks Online Phone Number software.

    ReplyDelete
  28. The yearly medical benefit is vital. The employer needs to allocate. But, accomplishing this manually will require enough time. Aim for QuickBooks Payroll Support Phone Number This can be an excellent software. You can actually manage your finances here. That is right after your accounts software. You'll be able to manage staffs with ease.

    ReplyDelete
  29. There may be some issue with file and the network connection because of which you might get these errors. These errors in QuickBooks Tech Support Phone Number software are caused when the hosting settings are not configured in a proper way.

    ReplyDelete
  30. move heaven and earth to provide you with the most effective solution they can. Our customer service executives have significant amounts of experience and so are sharp along with smart in finding out the particular QuickBooks Support Number solution each and every error that you could face.

    ReplyDelete
  31. The principal intent behind QuickBooks Support number is to provide the technical help 24*7 so as in order to avoid wasting your productivity hours. This is completely a toll-free QuickBooks client Service variety that you won’t pay any call charges. Of course, QuickBooks is one among the list of awesome package in the company world. The accounting part of the many companies varies according to this package. You'll find so many fields it covers like creating invoices, managing taxes, managing payroll etc. However exceptions are typical over, sometimes it generates the down sides and user wants QuickBook Tech Support Phone Number .

    ReplyDelete
  32. QuickBooks Payroll Support Number provides 24/7 make it possible to our customer. Only you need to do is make an individual call at our toll-free QuickBooks Payroll tech support number .

    ReplyDelete
  33. Although Intuit has pops up many accounting software like Quicken , Intuit Tax Online Accountant, QuickBook Support Phone Number, Mint,TaxCaster by TurboTax,MyTaxRefund by TurboTax,TurboTax SnapTax,Online Payroll, QuickBooks Online but the users of Quickbooks are more than many other products .

    ReplyDelete
  34. Within the manual, you are easily surely got to know to get in touch the HP Printer Support Number to a PC or Wi-Fi by changing the settings to the default state.

    ReplyDelete
  35. QuickBooks Desktop version can be additionally divided in to QuickBooks professional, QuickBooks Premier and QuickBooks Customer Support Phone Number. you’ll get the version and that can be additional apt for your needs.

    ReplyDelete
  36. And in the upcoming 2019 version of excellent QuickBooks Tech Support Number accounting software, you will observe lots of developments and improvements, especially provisioned to simply improve the consumer experience.

    ReplyDelete
  37. Though these features be seemingly extremely useful as well as in fact these are typically so, yet there are lots of loopholes that will trigger a couple of errors. These errors may be resolvable at QuickBook Tech Support, by our supremely talented, dedicated and well-informed tech support team team.

    ReplyDelete
  38. We make sure that your calls don't get bounced. Should your calls are failing woefully to connect with us at QuickBooks Support Number, then you can certainly also join all of us by dropping a contact without feeling shy. Our customer service support will continue to be available even in the wee hours.

    ReplyDelete
  39. Are you currently utilizing the software the first time? You can find some technical glitch. You will have errors also. Where can you turn? Take assistance from QuickBooks Support Number straight away. We are going to provide full support to you personally. It is possible to deal with a lot of the errors.

    ReplyDelete
  40. Earnings: to begin with, a company can only just survive when it is making adequate profits to smoothly run the operations regarding the work. Our QuickBooks Support Phone Number team will surely show you in helping you discover concerning the profit projections in QuickBooks.

    ReplyDelete
  41. QuickBooks Payroll Tech Support Phone Number
    has emerged one of the better accounting software that has had changed the meaning of payroll. Quickbooks Payroll Support contact number will be the team that provide you Quickbooks Payroll Support. This software of QuickBooks is sold with various versions and sub versions. Online Payroll and Payroll for Desktop may be the two major versions and they're further bifurcated into sub versions. Enhanced Payroll and Full-service payroll are encompassed in Online Payroll whereas Basic, Enhanced and Assisted Payroll come under Payroll for Desktop.

    ReplyDelete
  42. Very interesting blog Thank you for sharing such a nice and interesting blog and really very helpful article

    Workday Online Training

    ReplyDelete
  43. QuickBooks Payroll Support USA offer complete assistance that will help you learn the fundamentals of the QB accounting software. From setting up a payroll to handling all payroll related activities, our expert technicians can provide you hands-on training to enable you to use QuickBooks Payroll with confidence.

    ReplyDelete
  44. QuickBooks, managed by Intuit provides a platform to supervise the financial and accounting services of one's company and business. It works as both desktop and cloud-based accounting software. QuickBooks Online, services provided QuickBooks Support Phone Number in which is an application that may work minus the worry regarding the installation process.

    ReplyDelete
  45. Our team offers a complete financial solution for your account. So just call us on our QuickBooks support Phone Number and share all your accounting worries with us. We will definitely help in solving all of your QuickBooks related errors.And you also get the best technical support through the QuickBooks Support Number team so that you work properly on your accounts and boost your business.

    ReplyDelete
  46. QuickBooks accounting software is integrated with different products like QuickBooks Enterprise(developed by Intuit) and tools like QuickBooks file doctor. And it offers a number of incredible features (Business plans, cash flow projections, and advanced inventory ) that make it unique from other Quickbooks product. It is really best suited for small to medium businesses though it is incredibly expensive. No doubt, it has good compatibility with almost every version of Windows OS, Mac OS, iOS, and Android. Yet you may require an efficient QuickBooks Enterprise Support to handle payroll management, account management, inventory, and other accounting activities. AccountWizy provides you an ideal and efficient QuickBooks Enterprise Customer service to make it all possible. The moment you get in touch with QuickBooks Enterprise Support Number, our world class team of QB Enterprise Experts will be right at your disposal to comprehend the nature of support needed for addressing your issue.

    ReplyDelete
  47. Our team at QuickBooks Payroll Support Phone Number +1 855-236-7529 puts a full stop to the occurrence of all the technical glitches in QuickBooks. QuickBooks Payroll Support Phone Number: +1-855-236-7529. Ring us at QUICKBOOKS PAYROLL SUPPORT PHONE NUMBER +1-855-236-7529 to enjoy our phenomenal services. Or contact at QuickBooks Error 6032, 158
    Read more: https://www.techiesupportnumber.com/quickbooks-payroll/

    ReplyDelete
    Replies
    1. Hey! Nice post. You have done a fabulous job. Thanks for making this type of article. After reading your article, I immediately subscribed to your blogging channel. Do you know QuickBooks POS is an acclaimed version of QuickBooks that manages your retail business? To get support for errors, reach our experts via QuickBooks POS Support Phone Number 1-855-907-0605. Read more: https://tinyurl.com/uysk7lb

      Delete
  48. QuickBooks is a straightforward, intuitive and acclaimed accounting software. It has attracted millions of customers through its lucrative features. But sometimes all these wonderful features of QuickBooks are hampered by emergence of some unwanted QuickBooks errors. In such situations dial our QuickBooks Support Phone number 1-888-238-7409 and get instant help for your QuickBooks problems. Visit us:- https://www.enetquickbookenterprise.com/quickbooks-support/

    ReplyDelete
  49. Hello Friend!
    What an engaging post. This post of yours is a reader’s delight with authentic information and
    valuable facts. Keep posting more my friend. QuickBooks is leading accounting software which
    has fascinated millions of customers across the globe. Apart from the beneficial features, this
    software is host to several errors. QuickBooks Error 15215 is one among them which hampers
    the performance of your software. Well, if you have encountered this error or any other type
    then call our QuickBooks POS Support Phone Number 1-844-235-3996 and avail splendid solution for this error instantly.visit us:- https://tinyurl.com/yyyb3ql6

    ReplyDelete
  50. Hey, what a delightful post, it will help the readers in having a better understanding. This is
    an amazing post and a reader’s delight, I must say. QuickBooks is astounding accounting
    software that assists users in several ways. All their accounting, bookkeeping and financial
    tasks are done within a just few clicks with the help of this amazing software. This software is
    also prone to glitches and errors and thus to fix them in an optimal way you to need to call
    our QuickBooks Support Phone Number 1-844-235-3996 and avail instant solution.visit us:-herf="https://tinyurl.com/y5vx3u4g

    ReplyDelete
  51. Hello friend. I am impressed by your outstanding blog. Your blog has a balance for all the information and supporting statements. Wish you a successful blogging career ahead. If you are using QuickBooks software as your business accounting solutions, then you may be wondering When QuickBooks Error Code 3140 Occurs? Error 3140 is a run-time error it generally occurs when the user is trying to install his/her QuickBooks software. To get solution for this error, call us on our tollfree error support phone number 1-833-422-8848. Our error support line is open for you 24X7 with solutions for all the errors.

    ReplyDelete
  52. Hey, greetings and applause for your excellent post. You never fail to provide quality information in an appropriate quantity. I must say you must be consistent in this activity of yours. Hey, if you are a QuickBooks user, then pay attention to my advice. Consult the best tech support service providers for 24*7 services at QuickBooks Helpline Number +1 833-228-2822.
    QuickBooks Error 6000

    ReplyDelete
  53. Your blog is the best blog that I have read on the internet today. QuickBooks great features are available for the users at an affordable rate. It has easy to use and interactive interface, which can be used by users with no accounting history. To get support for the software, call us on tollfree Quickbooks Customer Care Number +1-800-329-0391

    ReplyDelete
  54. Hi Friend, what an outstanding Post. I liked the writing style and the way, you have presented the post. The points have helped to grab more information. QuickBooks Point of Sale is accounting software that helps in managing time and easily completes your tedious accounting task. In case of any problem, contact QuickBooks Customer Service Number +1 833-441-8848 and avail outstanding help from the experts.

    ReplyDelete
  55. This post is amazing and wonderful. Thank you for sharing such creativity. Are you looking for an ideal accounting software to manage your entire accounting and financial tasks. Then, there is no substitute for the QuickBooks Accounting Software. However, this software like others too is not immune to errors and bugs, thus if you come across one any time, make an immediate call to QuickBooks Support Phone Number +1-844-200-2627 and avail the right solutions instantly.

    ReplyDelete
  56. I am impressed by your blog. For a business like yours, you can use QuickBooks accounting software for managing your accounting process. To get support for the software, contact us on our tollfree QuickBooks Helpline Number 1-844-235-3996. Through our helpline number, one can easily get support for all the error at an affordable price. We offer 24X7 support and use 100% working and trusted solutions that are framed by our certified advisor.visit us:https://www.qbsoln.com/

    ReplyDelete
  57. Mind-blowing stuff! Must say this is a great post. Just like QuickBooks which is a great accounting software for accountants and bookkeepers all over the world. However, there are some minor bugs which one can come across with but not to worry as at QuickBooks
    Support Phone Number
    1-833-441-8848 you will get all the solution 24x7 and that too at nominal price. So, call now!

    ReplyDelete
  58. Thumbs Up for The Good Work…! I Like Your Style and Wish You All the Best for Your Blog. In Case, Maintaining Accounts Is Becoming Difficult for You, Take Help From Quickbooks Support Phone Number +1-833-441-8848. Here, You Get the Certified Solutions for All the Accounting Errors. It Is A Third-Party Service, Certified by Quickbooks To Provide Quick Assistance in Times of Need. Read More: -Https://Tinyurl.Com/Yx46h9wh

    ReplyDelete
  59. Wow…! What a tremendous piece of work. You have covered all the topics with brevity. I liked your style. QuickBooks is accounting software that has made it easy for businesses and enterprises to perform auditing. It even allows the businesses to manage inventory by keeping track of sales and purchase of stock. To know more about it call on QuickBooks Error Support +1-844-200-2627.
    read more:-https://tinyurl.com/roltoyo

    ReplyDelete
  60. Quickbooks is one of such applications that have powerful features and efficient tools for your medium-sized business for User. Quickbooks software is designed for the best account management experience of this era. If you may face the problem with your Quickbooks Software and start searching for the solution. If you would like to learn How To Resolve Quickbooks Error 9999 yourself, you can continue reading this blog.

    ReplyDelete
  61. QuickBooks error 9999 appears during program installation. Also, an error occurs while QuickBooks is running, during windows start up or shut down or even during the installation of the Windows operating system. If you would like to learn how to Troubleshoot Quickbooks Error 9999, you can continue reading this blog.

    ReplyDelete
  62. QuickBooks error H202 can keep you from getting to your organization records and thusly, requirements to get settled right away. To fix the Quickbooks error h202,Ping the Server to Verify the Workstation-Server Connectivity Status.

    ReplyDelete
  63. This comment has been removed by the author.

    ReplyDelete
  64. Thank you for sharing such a nice and interesting blog and really very helpful article.python fullstack training in hyderabad

    ReplyDelete