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

82 comments:

  1. very good infromation and thanks for sharing this keepitup.
    JAVA Online Tutorials

    ReplyDelete
  2. 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
  3. thanks,You can find material related to Spring Framework by following below link.Spring Framework Online Training in USA

    ReplyDelete
  4. This information which you provided is very much useful for us.It was very interesting and useful for JAVA online training.We also Spring online training in USA

    ReplyDelete
  5. 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
  6. 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
  7. very nice article.Thanks for sharing the post...!
    OBIEE Online Training

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

    ReplyDelete
  9. Nice explanation with snapshots, On SAP Modules SAP TOOLS

    ReplyDelete
  10. 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
  11. 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
  12. 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
  13. 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
  14. Each department of CAD have specific programmes which, while completed could provide you with a recognisable qualification that could assist you get a job in anything design enterprise which you would really like.

    AutoCAD training in Noida

    AutoCAD training institute in Noida


    Best AutoCAD training institute in Noida

    ReplyDelete
  15. An amazing web journal I visit this blog, it's unbelievably wonderful. Oddly, in this blog's content made without a doubt and reasonable. The substance of data is informative.
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training
    oracle Fusion Technical online training

    ReplyDelete
  16. 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
    oracle Fusion Technical online training

    ReplyDelete
  17. Great Post,really it was very helpful for us.
    Thanks a lot for sharing!
    I found this blog to be very useful!!
    JAVA training in Bangalore

    ReplyDelete
  18. 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
  19. QuickBooks has almost changed it is of accounting. Nowadays accounting has exploded to become everyone’s cup of tea and that’s only become possible because because of the birth of QuickBooks accounting software. We have the best and the most convenient answer to enhance your productivity by solving every issue you face with the software. Give us a call at Support For QuickBooks to avail the greatest customer service services designed for you.

    ReplyDelete
  20. 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
  21. A befuddling web diary I visit this blog, it's incredibly grand. Strangely, in this present blog's substance made motivation behind 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
  22. You might be always able to relate with us at our QuickBooks Support Phone Number to extract the very best support services from our highly dedicated and supportive QuickBooks Support executives at any point of time as all of us is oftentimes prepared to work with you. Most of us is responsible and makes sure to deliver hundred percent assistance by working 24*7 to suit your needs. Go ahead and mail us at our QuickBooks Support email id whenever you are in need. You could reach us via call at our toll-free number.

    ReplyDelete
  23. Take delight in with an array of outshined customer service services for QuickBooks via QuickBooks Tech Support at any time and from anywhere. It signifies that one can access our tech support for QuickBooks at any moment. Our backing team is dedicated enough to bestow you with end-to-end QuickBooks solutions when you desire to procure them for every single QuickBooks query.

    ReplyDelete
  24. 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
  25. QuickBooks Enterprise Support Phone Number We understand that your growing business needs your precious time which explains why we offer the most effective to the customers. Our technically skilled professionals are well regarded for smart technical assistance around the world.

    ReplyDelete
  26. 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
  27. 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
  28. 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
  29. 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
  30. 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
  31. 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
  32. 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
  33. 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
  34. 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
  35. QuickBooks Enterprise by Intuit offers extended properties and functionalities to users. It really is specially developed when it comes to wholesale, contract, nonprofit retail, and related industries. QuickBooks Enterprise Support is advised for users to provide you with intuitive accounting treatment for SMEs running enterprise kind of QuickBooks.

    ReplyDelete
  36. 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
  37. 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
  38. 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
  39. 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
  40. 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
  41. 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
  42. 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
  43. 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
  44. A QuickBooks Payroll Tech Support is a type of subscription this is certainly done to activate the payroll features in your QuickBooks Desktop Software. Intuit Online Payroll exports transactions to QuickBooks Desktop along with Quickbooks Online as standalone software.

    ReplyDelete
  45. 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
  46. 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
  47. QuickBooks Payroll Support Number helps one to resolve all your valuable technical and functional problems whilst looking after this well known extensive, premium and end-to-end business accounting and payroll management software. Our experts team at QuickBooks payroll support number is going to make you understand its advanced functions and assists someone to lift up your business growth.

    ReplyDelete
  48. An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  49. 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
  50. 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
  51. 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
  52. 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
  53. An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  54. Every business wishes to obtain revenues all the time. But, not all of you can be capable. Were you aware why? It really is because of lack of support service. You'll be a new comer to the company enterprise and make lots of errors. You yourself don’t understand how much errors you will be making. If this occurs it really is natural to possess a loss in operation. But, i am at your side. In the event that you hire our service, you may be receiving the greatest solution. We are going to assure you as a result of error-free service. QuickBooks Support Number is internationally recognized. You must come to used to comprehend this help.

    ReplyDelete
  55. 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
  56. A small grouping of execs can handle you manually as a result of they’re absolute to offer the standard services. So, in the event that you face any issue along with your package you don’t need to go anywhere except us. You just need certainly to build a straightforward charge less call on our QuickBooks Tech Support Phone Number variety and rest leave on united states country. No doubt, here you'll find the unmatchable services by our supportive technical workers.

    ReplyDelete
  57. 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
  58. An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  59. 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
  60. 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
  61. Such a nice blog, I really like what you write in this blog, I also have some relevant Information about if you want more information.

    Workday HCM Online Training

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

    Workday Online Training

    ReplyDelete
  63. An overwhelming web journal I visit this blog, it's unfathomably amazing. Unusually, in this present blog's substance made inspiration driving truth and reasonable. The substance of data is enlightening
    Oracle Fusion Financials Online Training
    Oracle Fusion HCM Online Training
    Oracle Fusion SCM Online Training

    ReplyDelete
  64. 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
  65. 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
  66. 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
  67. 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