Play Project Setup in IntelliJ ( Play + Java)

Tags

, , ,


1. Tips:

Install your play framework in directory name without white space:

2. Creating a New Project

To create a new project in Play you need to follow the following steps:

1. Open CMD and go to your play installation directory.

clip_image001

2. Create a new play Project and continue with option and Have fun!

clip_image002

Now, the project is created. Our next task is to make the project available in Intellij IDE.

3. Installing Play Plugin in Intellij

Before we open the project in Intellij, we need to add Play2.0 plugin in Intellij. Notice that, intellij already has Play1.0 plugin.

It can be done from the settings menu under file Menu or from Intellij open dialog.

clip_image004

1. Select Configure and then Select Plugins

clip_image006

2. Click on Install JetBrains Plugin: Select Play 2.0 support and Scala Support and Install

clip_image008

clip_image010

4. Making Project in Intellij

1. Go to your newly created Project Folder in CMD: cd TestPlayProject

2. Type in CMD : play idea

clip_image012

3. Now open the project in Intellij

clip_image013

Now we have our project opened in Intellij.

clip_image014

5. Creating Build Configuration in Intellij

1. Go to Run Menu and Select Edit Configuration and Click on “+” Button

clip_image015

2. Select Play 2 App and name the Build Configuration

clip_image017

6. Creating Build Configuration in Intellij

Now we will add required modules. We can see there is some error in the projects:

clip_image019

Here I will add two example modules, Scala and JPA.

To Add Modules:

1. Go to File Menu and the Project Structure Menu:

clip_image021

2. Click on the “Modules” and Select “+” to add Modules: Scala and Java

clip_image023

For Scala, add Language Level and Compiler Library. For JPA select Hibernate or suitable Provider. Then click apply.

3. Now We can compile the project. For first compile we need to compile the project in CMD. Type: Play Compile

clip_image024

4. Now We can Run the Project without any Error : Type : play run

clip_image025

5. To Test Project Run : go to browser and type url : http://lcoalhost:9000

clip_image026

NOTE:

1. If there is any error in framework, use command : Play clean-all

Reading Ontology With OWL: IMPORT using JENA

Tags

, , , , , , , ,


If we want to read an ontology that also import another ontology ( have an OWL: IMPORT), both the ontology URI has to resolve.

But, most of the time we may need to load both the ontology from file system. The default JENA “read” method will process the ontology automatically and try to resolve the Import ontology when it read the base ontology.

Let, we have the following ontology import statement in our base ontology:


<Ontology rdf:about=”http://cli.altaf.org/ontology/ServiceMetaDataOntology”>
      <imports rdf:resource=”http://cli.stfx.ca/altaf/PatientOntology”/>
  </Ontology>


Now, If we read the base ontology from our file system, clearly the imported ontology URI will not get resolved. This will result exception reading the ontology.

We can solve the problem using JENA provided OntDocumentManager and FileManager classes. OntDocumentManager let us use a policy file which can be defined in rdf.  In this policy rdf we can define our import ontology file as OntologySpec and OntDocumentManger can resolve the relative url of the imported ontology automatically.

You could find an example ont-policy file in your JENA download directory at : …./etc/ont-policy.rdf

Now, we will follow the following steps:

1) Create a Ont-Policy file and add our import ontology reference there.

2) Read our Base ontology file

This should automatically load both the ontology without any error.

1) Adding the Ont-Policy File: In our source folder or any other location of convenience.

image

Now add an OntologySpec node containing the relative url of the import ontology/ontologies


<OntologySpec>
    <!– local version of the OWL language ontology (in OWL) –>
    <publicURI rdf:resource=”http://cli.stfx.ca/altaf/PatientOntology” />
    <!– uncomment the following line to re-direct attempts to http get the file–>
   <altURL    rdf:resource=”file:./src/PatientOntology.rdf”/>
    <language  rdf:resource=”http://www.w3.org/2002/07/owl” />
    <prefix    rdf:datatype=”&xsd;string”>PO</prefix>
</OntologySpec>

We may add more of OntologySpec Node as the number of imports in File.

2) Now we can read the file using following method:

public static void ReadOntologyWithImport() {
    //Set document manager policy file
    OntDocumentManager dm = new OntDocumentManager(“file:./src/ont-policy.rdf”);
    OntModelSpec modelSpec = PelletReasonerFactory.THE_SPEC;
    modelSpec.setDocumentManager(dm);
    OntoModel  ontModelWithImport = ModelFactory.createOntologyModel(modelSpec);

//Read the base Ontology File ; Here its SmdWithImport
    ontModelWithImport.read(FileManager.get().open(“./src/SmdWithRule.rdf”), NS);
}


NOW YOUR ONTOLOGY should be in the OntModel without any exception with imported ontology. Cheers.! Smile

Workarounds:

There are few other work around.

1) If you don’t want to use document manager, you must make sure the url resolve:

One way of doing that is to create a server (may be in your localhost) and store ontologies there and read.

2) Use setProcessImport(false) and remove import statement from ontology. Then you can read the import files and add the model to the base model.

3) We can use the document manager and add OntologySpec using Jena Programmatically.

Also, there is way to programmatically add  Imports programmatically.

 

You can see the JENA ontology API documentation for more details.

Continue reading

Installing RavenDB as Service

Tags

, , , ,


RavenDB

For fewdays I was playing with RavenDB, a document database developed in C# supporting Linq. So, as developed in .NET, you can use it as .NET managed code other than MongoDB APIs. 

To Install as service, Download Latest build of RavenDB, from here: RavenDB Download

Extract the file in a folder. Now Open the command prompt: RUN >> CMD.

1. GO to the your RavenDB Folder and go to Server Directory.

2. Type: Raven.Server.exe /install.

3. Now you should have RavenDB installed as service.

You can view the service in your service listing using: Run> Services.msc

To Uninstall: go to the Server diretory and type: Raven.Server.exe /uninstall.

 

In addition, RavenDB also provide a management console called STUDIO. As you installed, you can go to the console :RavenBD STUDIO

1. There you can generate sample data to play with the feature.

RavenStudio