Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Mohammad Danish
Service builder reverse engineering
June 29, 2012 5:53 AM
Answer

Mohammad Danish

Rank: Regular Member

Posts: 154

Join Date: March 5, 2012

Recent Posts

Hi everyone there,
I am using LR 6.1
I have been provided with a dump of database schema by my T.L .
Normally we build the tables from the XML but i need to build the services from the table structure.
Could any one tell a method to generate the services from the tables .
Hitoshi Ozawa
RE: Service builder reverse engineering
June 29, 2012 6:01 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7954

Join Date: March 23, 2010

Recent Posts

Sorry, I don't think there is any tool which generates service.xml file from database schema.
David H Nebinger
RE: Service builder reverse engineering
June 29, 2012 6:01 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7252

Join Date: September 1, 2006

Recent Posts

Currently not possible.
Mohammad Danish
RE: Service builder reverse engineering
June 29, 2012 6:09 AM
Answer

Mohammad Danish

Rank: Regular Member

Posts: 154

Join Date: March 5, 2012

Recent Posts

Thanx Both of you for your quick reply...
I was looking for the short cut because i am not able to implement the foreign key concept in service.xml

Below is the structure of one of the table .
Could you plz tell me how to write the red colored constraint in service xml

DROP TABLE IF EXISTS `company`;
CREATE TABLE IF NOT EXISTS `company` (
`companyid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`companyname` varchar(100) NOT NULL,
`companyuid` varchar(100) NOT NULL,
`companywebsite` varchar(200) DEFAULT NULL,
`dateofestablishment` date DEFAULT NULL,
`numofemployees` int(10) unsigned DEFAULT NULL,
`companydescription` longtext,
`businessoperations` longtext,
`financials` longtext,
`companytypeid` tinyint(3) unsigned DEFAULT NULL,
`companystatusid` tinyint(3) unsigned DEFAULT NULL,
`entitystatusid` tinyint(3) unsigned DEFAULT NULL,
`versionno` mediumint(8) unsigned DEFAULT NULL COMMENT 'starts from 1',
`isDeleted` tinyint(4) DEFAULT '0' COMMENT 'boolean',
`isDeletionRequested` tinyint(4) DEFAULT '0' COMMENT 'boolean',
PRIMARY KEY (`companyid`),
UNIQUE KEY `companyname` (`companyname`),
UNIQUE KEY `companyshortname` (`companyuid`),
KEY `FK_company_companytype` (`companytypeid`),
KEY `FK_company_companystatus` (`companystatusid`),
CONSTRAINT `FK_company_companystatus` FOREIGN KEY (`companystatusid`) REFERENCES `companystatus` (`companystatusid`) ON UPDATE CASCADE,
CONSTRAINT `FK_company_companytype` FOREIGN KEY (`companytypeid`) REFERENCES `companytype` (`companytypeid`) ON UPDATE CASCADE
)
Hitoshi Ozawa
RE: Service builder reverse engineering
June 29, 2012 6:19 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7954

Join Date: March 23, 2010

Recent Posts

Following page may provide you with information on specifying foreign keys.

http://liferaydemystified.blogspot.jp/2011/08/table-relationships.html
sheela mk
RE: Service builder reverse engineering
July 1, 2012 11:32 PM
Answer

sheela mk

Rank: Regular Member

Posts: 111

Join Date: February 16, 2012

Recent Posts

Hai..Varsha..Can you pls let me know your table structure in service.xml file.. and How you got that script..Which option to click on in mysql..
Mohammad Danish
RE: Service builder reverse engineering
July 1, 2012 11:40 PM
Answer

Mohammad Danish

Rank: Regular Member

Posts: 154

Join Date: March 5, 2012

Recent Posts

sheela mk:
Can you pls let me know your table structure in service.xml file..

Table structure is same as defined in the above comment. I am able to generate Primary key and the unique key. But not the other constraint.
sheela mk:
How you got that script..Which option to click on in mysql..

This script has been given to me by my TL and he uses the HeidiSQL tool for developing the table structures.
Praveen P
RE: Service builder reverse engineering
July 2, 2012 3:29 AM
Answer

Praveen P

Rank: Regular Member

Posts: 100

Join Date: February 20, 2012

Recent Posts

I am sorry varsha i also tried to build xml using foreign key and composite primary key but build was not successful emoticon
Sanjay Jat
RE: Service builder reverse engineering
July 2, 2012 5:43 AM
Answer

Sanjay Jat

Rank: New Member

Posts: 3

Join Date: June 6, 2012

Recent Posts

Me too stucked in trying to define foreign key using service.xml ,but there is way to get the solution for this ,try to use refrences ....through refrences you can achieve the the functionality of foreign key ...
David H Nebinger
RE: Service builder reverse engineering
July 2, 2012 7:11 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7252

Join Date: September 1, 2006

Recent Posts

To repeat for those that have not searched the forum before posting:

LIFERAY AND SERVICE BUILDER DO NOT SUPPORT FOREIGN KEYS!

It is left to you to manage foreign key dependencies on your own in your XxxxLocalServiceImpl class.
Nishikant sapkal
RE: Service builder reverse engineering
July 2, 2012 9:37 AM
Answer

Nishikant sapkal

Rank: Junior Member

Posts: 71

Join Date: February 15, 2010

Recent Posts

Hi
As of now LR service builder does not support foreign key feature. However you can always write a custom logic which can provide you the way of foreign key -
e.g now looking at your service.xml companytypeid is the field which is joining two table "company" and "companytype". It means you want that whenever the data is added in "company" table with companytypeid ="xyz" the entry should also be added in "companytype" table. So if i am right in understanding your requirement you can achieve using following code -

step 1} make the entry in comapny table -

Company company =CompanyServiceUtil.addCompany(companyid, companyname,companyuid,companytypeid ,..........
--------------------------------------------------------------------------isDeletionRequested);
this will return you the instance of currently added Company object and once you got it you can get the parameter you want like in your case -
Step 2} get the reference of currently added company object and get the parameter you want to use as FK.
int comapnyTypeId= company.getCompanytypeid ,

step 3} make the entry in companytype table with comapnyTypeId as PK -

companytype companytype= companytypeServiceUtil.addcompanytype (companytypeid , ------- noOffields);

steps 4} Similarly if you want to remove the entry once it will be deleted from parent table you can follow the same steps .

Cheers,
Nishikant Sapkal
Mohammad Danish
RE: Service builder reverse engineering
July 2, 2012 11:19 PM
Answer

Mohammad Danish

Rank: Regular Member

Posts: 154

Join Date: March 5, 2012

Recent Posts

Thank you everybody for your valuable answers...