Wednesday May 14, 2008

Extending Project WebSynergy's Tables

Project WebSynergy 

We had recently started work on semantic enabling Project WebSynergy's community feature.

Read my blog on that.

For doing this we had to extend the existing table structure by adding new columns
and  also creating new tables.

In this blog I will show how easy it is do this using
Project WebSynergy's ServiceBuilder framework 

The use case for this example will be to add an ontologyId column
to the existing BlogsEntry table.
We would also create a new BlogsEntryOntologyMapping Table. 

Open the
<synergy-workspace>\\e2demo\\synergy\\liferay\\patch\\portal-impl\\src\\com\\liferay
\\portlet\\blogs\\service.xml

in your favorite IDE (we would recommend NetBeans)

Each <entity> tag corresponds to a table in the DB.

To add "OntologyId" column to the BlogsEntry table
add the following in <entity name="BlogsEntry"> </entity> tag

<column name="ontologyId" type="String" />

We can also add a finder method corresponding to the column that we have just added.
Using this the callers can get the blog entries corresponding to an ontologyId.

        <finder name="OntologyId" return-type="Collection">
            <finder-column name="ontologyId" />
        </finder>
This would generate a findByOntologyId() in the BlogsEntryPersistence
and BlogsEntryPersistenceImpl.

To add a new BlogsEntryOntlogyMapping table add the following 

 <entity name="BlogsEntryOntlogyMapping" local-service="true" remote-service="true">
        <column name="entryId" type="long" primary="true" />
        <column name="ontologyId" type="long" />
    </entity>

Next we need to add getBlogEntriesByOntologyId() to the BlogsEntryLocalServiceImpl class.

public List getBlogEntriesByOntologyId(String ontologyId) throws SystemException{ 

             List blogtnriesList = blogsEntryPersistence.findByOntologyId(ontologyId);

return blogtnriesList;

You will get a compilation error on the blogsEntryPersistence.findByOntologyId(ontologyId) line.
This is because the method is still not added to the BlogsEntryPersistence interface.

But dont mind that as of now :)

After making these changes,
cd to <synergy-workspace>\\e2demo\\synergy\\liferay\\portal\\portal-impl
in the command prompt and run the following ant script.

ant build-service-portlet-blogs 

This generates all the service, util, persistence and  factory classes that are relevant to Blogs.

Open the <synergy-workspace>\\e2demo\\synergy\\liferay\\portal\\portal-service\\src\\com\\liferay\\portlet\\blogs \\service\\persistence\\BlogsEntryPersistence, you will find that the findByOntologyId() is newly generated.

Open the <synergy-workspace>\\e2demo\\synergy\\liferay\\portal\\portal-service\\src\\com\\liferay\\portlet\\blogs\\ service\\BlogsEntryLocalService and BlogsEntryLocalServiceUtil, you will find that the getBlogEntriesByOntologyId() is newly generated.

Now you can call the BlogsEntryLocalServiceUtil .getBlogEntriesByOntologyId() from any portlet class or jsp,
you will get the blog entries that the specific ontologyId applied to that.

Next the changes have to be made in the db scripts.

For this run ant build-db in the command prompt that you opened before.

Open the <synergy-workspace>\\e2demo\\synergy\\liferay\\portal\\sql\\portal-tables.sql and <synergy-workspace>\\e2demo\\synergy\\liferay\\portal\\sql\\create-\*.sql.

You will find that the scripts have been suitably modifled.

For the changes to be reflected on the DB (could be MySQL, HSQL, etc),
drop the existing tables under lPortal database if any, and re-start the server.
The ontologyId column would be added to the BlogsEntry Table and BlogsEntryOntologyMapping table would have been created.

Extending Project WebSynergy's tables is as simple as this. You can extend this example to any other feature like wiki, bookmarks, etc.

 


Friday Apr 18, 2008

OpenPortal @ JavaOne 2008

OpenPortal's presence at JavaOne 2008 and surrounding events
[Read More]

Thursday May 03, 2007

JavaOne BOF: "Dynamic Portals and AJAX in Portlets"

JavaOne 2007 is only a week away.  This year, members of the portal team will be presenting the Birds Of a Feather (BOF) talk "Dynamic Portals and AJAX in Portlets". If you are interested in learning more and want to meet others with similar interests, please consider attending. We will be discussing:
  • the impact of Web 2.0 technologies on portals
  • AJAX and JSR-168
  • jMaki
  • JSR-286
  • dynamic inter-portlet communication
  • microformats, COMET, mashups, and more...
Hope to see you there.

Friday Aug 04, 2006

Open Skies, Open Source and Open Portals..

Back at the JavaOne 2006 Conference, Sun announced that it was furthering it's commitment to Open Source by stating that the Sun Java System Portal Server will be among the next set of products that will transition from Closed Source to Open Source. This is part of the overall plan to do so for all of Sun's Software products portfolio, including middleware.

So today is a big step that shows commitment to delivering on that promise; the first core infrastructure component of the Sun Portal is now out there on java.net --
The Enterprise-class Portlet Container Open Source Project

Check out Deepak's blog articulating exactly what is available today, what are the future plans for the project, and how folks can join and participate in the community.

This is an incremental first step in opening up the entire Sun Portal Platform and moving it to a truly "open development" model. Please stay tuned as the team diligently works on getting the other components out there. We look forward to your participation. And to the sharing and learning..

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-898027-2"; urchinTracker(</script>
About

atul

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
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
   
       
Today