Fóruns

Início » Liferay Portal » English » 3. Development

Visualização combinada Visão plana Exibição em árvore
Tópicos [ Anterior | Próximo ]
toggle
Mohammad Danish
Service builder reverse engineering
29 de Junho de 2012 05:53
Resposta

Mohammad Danish

Ranking: Regular Member

Mensagens: 175

Data de entrada: 5 de Março de 2012

Mensagens 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 .
Hitoshi Ozawa
RE: Service builder reverse engineering
29 de Junho de 2012 06:01
Resposta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensagens: 7949

Data de entrada: 23 de Março de 2010

Mensagens recentes

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
29 de Junho de 2012 06:01
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 11046

Data de entrada: 1 de Setembro de 2006

Mensagens recentes

Currently not possible.
Mohammad Danish
RE: Service builder reverse engineering
29 de Junho de 2012 06:09
Resposta

Mohammad Danish

Ranking: Regular Member

Mensagens: 175

Data de entrada: 5 de Março de 2012

Mensagens 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
)
Hitoshi Ozawa
RE: Service builder reverse engineering
29 de Junho de 2012 06:19
Resposta

Hitoshi Ozawa

Ranking: Liferay Legend

Mensagens: 7949

Data de entrada: 23 de Março de 2010

Mensagens recentes

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
1 de Julho de 2012 23:32
Resposta

sheela mk

Ranking: Regular Member

Mensagens: 111

Data de entrada: 16 de Fevereiro de 2012

Mensagens 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..
Mohammad Danish
RE: Service builder reverse engineering
1 de Julho de 2012 23:40
Resposta

Mohammad Danish

Ranking: Regular Member

Mensagens: 175

Data de entrada: 5 de Março de 2012

Mensagens 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.
Praveen P
RE: Service builder reverse engineering
2 de Julho de 2012 03:29
Resposta

Praveen P

Ranking: Regular Member

Mensagens: 100

Data de entrada: 20 de Fevereiro de 2012

Mensagens 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
RE: Service builder reverse engineering
2 de Julho de 2012 05:43
Resposta

Sanjay Jat

Ranking: New Member

Mensagens: 3

Data de entrada: 6 de Junho de 2012

Mensagens 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 ...
David H Nebinger
RE: Service builder reverse engineering
2 de Julho de 2012 07:11
Resposta

David H Nebinger

Community Moderator

Ranking: Liferay Legend

Mensagens: 11046

Data de entrada: 1 de Setembro de 2006

Mensagens 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.
Nishikant sapkal
RE: Service builder reverse engineering
2 de Julho de 2012 09:37
Resposta

Nishikant sapkal

Ranking: Junior Member

Mensagens: 76

Data de entrada: 15 de Fevereiro de 2010

Mensagens 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
Mohammad Danish
RE: Service builder reverse engineering
2 de Julho de 2012 23:19
Resposta

Mohammad Danish

Ranking: Regular Member

Mensagens: 175

Data de entrada: 5 de Março de 2012

Mensagens recentes

Thank you everybody for your valuable answers...