Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Mohammad Danish
Service builder reverse engineering
29 giugno 2012 5.53
Risposta

Mohammad Danish

Punteggio: Regular Member

Messaggi: 165

Data di Iscrizione: 5 marzo 2012

Messaggi recenti

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 giugno 2012 6.01
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7949

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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 giugno 2012 6.01
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 9214

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

Currently not possible.
Mohammad Danish
RE: Service builder reverse engineering
29 giugno 2012 6.09
Risposta

Mohammad Danish

Punteggio: Regular Member

Messaggi: 165

Data di Iscrizione: 5 marzo 2012

Messaggi recenti

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 giugno 2012 6.19
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7949

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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 luglio 2012 23.32
Risposta

sheela mk

Punteggio: Regular Member

Messaggi: 111

Data di Iscrizione: 16 febbraio 2012

Messaggi recenti

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 luglio 2012 23.40
Risposta

Mohammad Danish

Punteggio: Regular Member

Messaggi: 165

Data di Iscrizione: 5 marzo 2012

Messaggi recenti

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 luglio 2012 3.29
Risposta

Praveen P

Punteggio: Regular Member

Messaggi: 100

Data di Iscrizione: 20 febbraio 2012

Messaggi recenti

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 luglio 2012 5.43
Risposta

Sanjay Jat

Punteggio: New Member

Messaggi: 3

Data di Iscrizione: 6 giugno 2012

Messaggi recenti

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 luglio 2012 7.11
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 9214

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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 luglio 2012 9.37
Risposta

Nishikant sapkal

Punteggio: Junior Member

Messaggi: 71

Data di Iscrizione: 15 febbraio 2010

Messaggi recenti

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 luglio 2012 23.19
Risposta

Mohammad Danish

Punteggio: Regular Member

Messaggi: 165

Data di Iscrizione: 5 marzo 2012

Messaggi recenti

Thank you everybody for your valuable answers...