Getting data using OAI-PMH from an insitutional repository - java

I'm developing an application where I've requested data from an external institution's website. They have informed me that the data will be provided by OAI-PMH.
Could someone show me some sample code in Java how data is extracted from a OAI-PMH ?
I wonder how different it is from reading and parsing XML data.
Thank you.
Warmest wishes,
Shoubhik

For a Java implementation, for example, you could use some already existent library, like XOAI with an easy to use API. There are some provided samples.
To extract metadata from each Record you could use a XML Parser or a XML bind approach (JAXB). For other languages, like PHP and Perl there are also other alternatives.

Related

Storing all data of a website on Apache Jena as RDF?

I am trying to build a web site build on semantic technologies. It is a CMS, to make it simple lets say it's a blog. I need to be able to do simple CRUD operations. All data will be saved on Jena like blog posts, user informations, blog categories etc.
I have a php system. Here is the path what i am planing to follow:
Use Apache Jena as RDF Store
Use Apache Jena for storing and retrieving the data.
Write a web service on java
Communicate through web service with PHP in JSON format to view, control the data.
My main focus is to build a web site on semantic technologies.
Is there anything wrong with my approach?
If not the main question is when a user made a blog post how will i create a relation with the blog post and user.
With mysql it was just a froeign key. How can i make a relations on Jena between new blog post and existing user?
I can't see anything wrong with your approach. Maybe I would suggest to use JSON-LD as an interchange format, because Jena can read it and write it directly instead of having to create your own converters to RDF (see https://jena.apache.org/documentation/io/).
Regarding the modeling question, I strongly recommend to have a look at the SIOC vocabulary (http://rdfs.org/sioc/spec/), which aims to represent exactly what you are looking for, and more.
Another hardcore solution would be to create the pages of the website in RDF (serialized in RDF/XML), and use XSL to generate the HTML version on demand for each page. It really depends on the size of your website.

CRUD on XML using Java

I am developing a java application and i am using XML to store the settings and other data in the application.I have read about Java preferences manager API but i felt storing in XML is more convenient in my application.I started usng JAXB first but then i dint find any tutorials to modify the XML once it is created.My application involves storing the Email account details of the users.As the user adds his accounts dynamically , i need to add them to XML as well.So i dint find JAXB convenient(or rather i dint find any tutorials to update or modify the XML ).The only other option i found was DOM parser here http://docs.oracle.com/javase/tutorial/jaxp/dom/readingXML.html .But i feel it is too complicated for such a simple application.speed , memory etc doesnt matter to me.Are there any other alternatives to do this?
This can be a good (java-oriented) solution. Besides being Berkeley DB enables the development of custom data management solutions, without the overhead traditionally associated with such custom projects. yet based on XML files. It's has a very complete documentation for integration with Java lang.
With JAXB you can:
Unmarshal the XML into Java objects.
Manipulate the Java objects to modify the XML.
Marshal the objects producing a new XML document which you can use to replace the original XML.
Or:
Parse the XML into a DOM
Unmarshal the XML using a JAXB Binder
Modify the object
Use the Binder to apply the changes back to the DOM.
Write out the DOM replacing the original XML
I like to point you to XMLBeam (Disclosure: I'm affiliated with that project). This library is ideal to store configuration values in XML and while the application grows maintain the XML format without changing your Java API.
This is how IO operations look like:
Projection projection = projector.io().file(file).read(Projection.class);
projector.io().file(file).write(projection);
You get one liner IO handling and static typed access to the XML content. A pattern for configuration data would be to include a default value template in your JAR, read this if no config file was found on disk and write it back to disk on config changes. But of course you can also create documents from scratch (described in tutorials).

Is there a json schema for the SurveyMonkey API?

Using the SurveyMonkey API, I'm writing some Java code to do survey analysis. The survey monkey API returns JSON data. I would like to generate some Java classes so I get some type safety and conciseness while I'm manipulating the data. I've had no luck finding a json schema for the Survey Monkey API.
So, I'm looking into tools that generate a schema from json directly, but obviously that will be less desirable than getting it from the canonical source.
The question:
Can anyone recommend a tool-chain that will take me from a set of json examples to a set of java classes that can be used to read an manipulate that json. This might include the intermediate step of generating a schema, but the end-game I'm after is the classes.
If anyone knows of a schema for the API, though, that would be even better.
Why don't you go with polljoy, it's Opensource and I have already integreat it on one of my site and it's working perfectly, you can find it out one below menioned link.
Polljoy

Podio API, attaching files to items

I have a problem with attaching a file to a specific item using Java API. I know it should be possible as this functionality described here in the Podio documentation https://developers.podio.com/doc/files/attach-file-22518 and examples for PHP and Ruby are given. However I cannot find such method in the podio java library. I could find in FileAPI just methods that provide uploading files, but not attaching them to specific objects as described in documentation.
I use Podio APi version 0.7.1
Any ideas how it should be done in Java?
Podio uses a REST-Style API. You send standard http-request, and you get back json-formatted data. So you can do it all without a special library for your programming language.
If there is no predefined java class for you, you can just do the call yourself. In the end it is just a HTTP-call.
From the ruby implemention, I see that you attach the file as multipart/form-data,
so it is the same a browser would do it. There should be http-handling java classes to help you.
You also need to add the information from the API-Page, like the POST-Parameters and of course the url. The most difficult part is probably the authentication headers, but you need to solve this problem only once.

Clientside Javascript --> Serverside Java --> user is served a .doc

I am helping someone out with a javascript-based web app (even though I know next to nothing about web development) and we are unsure about the best way to implement a feature we'd like to have.
Basically, the user will be using our tool to view all kinds of boring data in tables, columns, etc. via javascript. We want to implement a feature where the user can click a button or link that then allows the user to download the displayed data in a .doc file.
Our basic idea so far is something like:
call a Java function on the server with the desired data passed in as a String when the link is clicked
generate the .doc file on the server
automatically "open" a link to the file in the client's browser to initiate the download
Is this possible? If so, is it feasible? Or, can you recommend a better solution?
edit: the data does not reside on the server; rather, it is queried from a SQL database
Yep, its possible. Your saviour is the Apache POI library. Its HWPF library will help you generate Microsoft word files using java. The rest is just clever use of HTTP.
Your basic idea sounds a bit Rube-Goldbergesque.
Is the data you want in the document present on the server? If so, then all you need to do is display a plain HTML link with GET parameters that describes the data (i.e. data for customer X from date A to date B). The link will be handled on the server by a Servlet that gets the data and produces the .DOC file as its output to be downloaded by the browser - a very simple one-step process that doesn't even involve any JavaScript.
Passing large amount data as GET/POST around might not be the best idea. You could just pass in the same parameters you used to generate the HTML page earlier. You don't even need to use 3rd party library to generate DOC. You could just generate a plain old HTML file with DOC extension and Word will be happy to open it.
Sounds like Docmosis Java library could help - check out theonline demo since shows it something similar to what you're asking - generating a real doc file from a web site based on selections in the web page. Docmosis can query from databases and run pretty much anywhere.

Categories