Fórum

Service builder reverse engineering

thumbnail
Varsha ., modificado 11 Anos atrás.

Service builder reverse engineering

Regular Member Postagens: 187 Data de Entrada: 05/03/12 Postagens Recentes
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 .
thumbnail
Hitoshi Ozawa, modificado 11 Anos atrás.

RE: Service builder reverse engineering

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
Sorry, I don't think there is any tool which generates service.xml file from database schema.
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Service builder reverse engineering

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
Currently not possible.
thumbnail
Varsha ., modificado 11 Anos atrás.

RE: Service builder reverse engineering

Regular Member Postagens: 187 Data de Entrada: 05/03/12 Postagens Recentes
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
)
thumbnail
Hitoshi Ozawa, modificado 11 Anos atrás.

RE: Service builder reverse engineering

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
Following page may provide you with information on specifying foreign keys.

http://liferaydemystified.blogspot.jp/2011/08/table-relationships.html
thumbnail
sheela mk, modificado 11 Anos atrás.

RE: Service builder reverse engineering

Regular Member Postagens: 111 Data de Entrada: 17/02/12 Postagens Recentes
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..
thumbnail
Varsha ., modificado 11 Anos atrás.

RE: Service builder reverse engineering

Regular Member Postagens: 187 Data de Entrada: 05/03/12 Postagens Recentes
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.
thumbnail
Praveen P, modificado 11 Anos atrás.

RE: Service builder reverse engineering

Regular Member Postagens: 100 Data de Entrada: 21/02/12 Postagens Recentes
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, modificado 11 Anos atrás.

RE: Service builder reverse engineering

New Member Postagens: 3 Data de Entrada: 07/06/12 Postagens Recentes
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 ...
thumbnail
David H Nebinger, modificado 11 Anos atrás.

RE: Service builder reverse engineering

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
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.
thumbnail
Nishikant sapkal, modificado 11 Anos atrás.

RE: Service builder reverse engineering (Resposta)

Junior Member Postagens: 80 Data de Entrada: 16/02/10 Postagens Recentes
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
thumbnail
Varsha ., modificado 11 Anos atrás.

RE: Service builder reverse engineering

Regular Member Postagens: 187 Data de Entrada: 05/03/12 Postagens Recentes
Thank you everybody for your valuable answers...