« Zurück zu Service Builder

Service Builder and Liferay Database Table Creation

Start Here:

http://www.liferay.com/community/wiki/-/wiki/Main/How+to+create+a+database+portlet

Make sure you create a new portlet project. That way, you can avoid being paranoid you screwed something up. It will also help you grasp all the 10 or so files generated. It will create a lot of advanced configuration files. Nevertheless, the tutorial is a breeze.

Now, have a look at what service.xml properties are here(open on a text editor): http://www.liferay.com/dtd/liferay-service-builder_6_0_0.dtd

This tutorial looks good too, but I never tried: http://www.null-pointer.co.uk/wiki/index.php/Building_a_Portlet . Let me know if it works easily.

Digging deep on the generated files

Here is the list of configuration files generated at <sdk>\portlets\<example-portlet>\docroot\WEB-INF\classes\META-INF\<here.xmls>

and <sdk>\portlets\<example-portlet>\docroot\WEB-INF\classes\service.properties

service.properties

Have a look a the file itself. It is pretty verbose.

base-spring.xml

See: portal-impl.jar>META-INF\base-spring.xml
cluster-spring.xml

See: portal-impl.jar>META-INF\cluster-spring.xml
dynamic-data-source-spring.xml

See: portal-impl.jar>META-INF\dynamic-data-source-spring.xml
hibernate-spring.xml

See: portal-impl.jar>META-INF\hibernate-spring.xml
infrastructure-spring.xml

See: portal-impl.jar>META-INF\infrastructure-spring.xml
portlet-hbm.xml

See: portal-impl.jar>META-INF\portal-hbm.xml
portlet-model-hints.xml

Have a look at the place it reads this file just FYI (http://docs.liferay.com/portal/5.2/javadocs/portal-impl/com/liferay/portal/service/impl/ServiceComponentLocalServiceImpl.java.html ). Now note that we can specify our own hints as in http://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Portal+Properties+5.1.1#section-Portal+Properties+5.1.1-ModelHints ( I have not yet tried this). Now check here http://www.null-pointer.co.uk/wiki/index.php/Building_a_Portlet#Setting_the_column_size for a good explanation. Since it is an external source, in case we loose the link, I am pasting the essentials below.

 

Setting the column size

By default all String colums are set to VARCHAR(75), if this is not big enough you will need to adjust the size. This is set in /docroot/META-INF/portlet-model.hints.xml. You may need to run build-service before setting the size, and again once you have set the size.

<model name="com.linhopesolutions.canopy.model.Overview">
 <field name="overviewId" type="long" />
 <field name="text" type="String">
  <hint name="max-length">10000</hint>
 </field>
 <field name="published" type="boolean" />
 <field name="lastModifiedBy" type="long" />
 <field name="lastModifiedOn" type="Date" />
</model>

max-length < 4000 = VARCHAR(max-length)

max-length = 4000 = STRING

max-length > 4000 = TEXT

(Attribution: http://www.null-pointer.co.uk/wiki/index.php/Building_a_Portlet)

See: portal-impl.jar>META-INF\portal-model-hints.xml


portlet-orm.xml

I could not find any internet or Liferay site sources for this. The only hope is Liferay's own portlet-org.xml file. Have a look at it to see what they do with it. Find it at portal-impl.jar>META-INF\portal-orm.xml . Note that is is portal-orm.xml, not portlet-org.xml.

portlet-spring.xml

See: portal-impl.jar>META-INF\portal-spring.xml
shard-data-source-spring.xml

 See: portal-impl.jar>META-INF\shard-data-source-spring.xml

Also, check

http://www.liferay.com/community/wiki/-/wiki/Main/Upgrading+ServiceBuilder+generated+classes+to+Liferay+5.1.x last section.

http://docs.liferay.com/portal/6.0/javadocs/src-html/com/liferay/portal/tools/servicebuilder/ServiceBuilder.html which says,

 System.out.println(
        "Please set these required system properties. Sample values are:\n" +
        "\n" +
        "\t-Dservice.input.file=${service.file}\n" +
        "\t-Dservice.hbm.file=src/META-INF/portal-hbm.xml\n" +
        "\t-Dservice.orm.file=src/META-INF/portal-orm.xml\n" +
        "\t-Dservice.model.hints.file=src/META-INF/portal-model-hints.xml\n" +
        "\t-Dservice.spring.file=src/META-INF/portal-spring.xml\n" +
        "\t-Dservice.api.dir=${project.dir}/portal-service/src\n" +
        "\t-Dservice.impl.dir=src\n" +
        "\t-Dservice.json.file=${project.dir}/portal-web/docroot/html/js/liferay/service_unpacked.js\n" +
        "\t-Dservice.remoting.file=${project.dir}/tunnel-web/docroot/WEB-INF/remoting-servlet.xml\n" +
        "\t-Dservice.sql.dir=../sql\n" +
        "\t-Dservice.sql.file=portal-tables.sql\n" +
        "\t-Dservice.sql.indexes.file=indexes.sql\n" +
        "\t-Dservice.sql.indexes.properties.file=indexes.properties\n" +
        "\t-Dservice.sql.sequences.file=sequences.sql\n" +
        "\t-Dservice.bean.locator.util.package=com.liferay.portal.kernel.bean\n" +
        "\t-Dservice.props.util.package=com.liferay.portal.util\n" +
        "\n" +
        "You can also customize the generated code by overriding the default templates with these optional properties:\n" +
        "\n" +
        "\t-Dservice.tpl.bad_alias_names=" + _TPL_ROOT + "bad_alias_names.txt\n"+
        "\t-Dservice.tpl.bad_column_names=" + _TPL_ROOT + "bad_column_names.txt\n"+
        "\t-Dservice.tpl.bad_json_types=" + _TPL_ROOT + "bad_json_types.txt\n"+
        "\t-Dservice.tpl.bad_table_names=" + _TPL_ROOT + "bad_table_names.txt\n"+
        "\t-Dservice.tpl.base_mode_impl=" + _TPL_ROOT + "base_mode_impl.ftl\n"+
        "\t-Dservice.tpl.copyright.txt=copyright.txt\n"+
        "\t-Dservice.tpl.ejb_pk=" + _TPL_ROOT + "ejb_pk.ftl\n"+
        "\t-Dservice.tpl.exception=" + _TPL_ROOT + "exception.ftl\n"+
        "\t-Dservice.tpl.extended_model=" + _TPL_ROOT + "extended_model.ftl\n"+
        "\t-Dservice.tpl.extended_model_impl=" + _TPL_ROOT + "extended_model_impl.ftl\n"+
        "\t-Dservice.tpl.finder=" + _TPL_ROOT + "finder.ftl\n"+
        "\t-Dservice.tpl.finder_util=" + _TPL_ROOT + "finder_util.ftl\n"+
        "\t-Dservice.tpl.hbm_xml=" + _TPL_ROOT + "hbm_xml.ftl\n"+
        "\t-Dservice.tpl.orm_xml=" + _TPL_ROOT + "orm_xml.ftl\n"+
        "\t-Dservice.tpl.json_js=" + _TPL_ROOT + "json_js.ftl\n"+
        "\t-Dservice.tpl.json_js_method=" + _TPL_ROOT + "json_js_method.ftl\n"+
        "\t-Dservice.tpl.model=" + _TPL_ROOT + "model.ftl\n"+
        "\t-Dservice.tpl.model_hints_xml=" + _TPL_ROOT + "model_hints_xml.ftl\n"+
        "\t-Dservice.tpl.model_impl=" + _TPL_ROOT + "model_impl.ftl\n"+
        "\t-Dservice.tpl.model_soap=" + _TPL_ROOT + "model_soap.ftl\n"+
        "\t-Dservice.tpl.model_wrapper=" + _TPL_ROOT + "model_wrapper.ftl\n"+
        "\t-Dservice.tpl.persistence=" + _TPL_ROOT + "persistence.ftl\n"+
        "\t-Dservice.tpl.persistence_impl=" + _TPL_ROOT + "persistence_impl.ftl\n"+
        "\t-Dservice.tpl.persistence_util=" + _TPL_ROOT + "persistence_util.ftl\n"+
        "\t-Dservice.tpl.props=" + _TPL_ROOT + "props.ftl\n"+
        "\t-Dservice.tpl.remoting_xml=" + _TPL_ROOT + "remoting_xml.ftl\n"+
        "\t-Dservice.tpl.service=" + _TPL_ROOT + "service.ftl\n"+
        "\t-Dservice.tpl.service_base_impl=" + _TPL_ROOT + "service_base_impl.ftl\n"+
        "\t-Dservice.tpl.service_clp=" + _TPL_ROOT + "service_clp.ftl\n"+
        "\t-Dservice.tpl.service_clp_message_listener=" + _TPL_ROOT + "service_clp_message_listener.ftl\n"+
        "\t-Dservice.tpl.service_clp_serializer=" + _TPL_ROOT + "service_clp_serializer.ftl\n"+
        "\t-Dservice.tpl.service_http=" + _TPL_ROOT + "service_http.ftl\n"+
        "\t-Dservice.tpl.service_impl=" + _TPL_ROOT + "service_impl.ftl\n"+
        "\t-Dservice.tpl.service_json_serializer=" + _TPL_ROOT + "service_json_serializer.ftl\n"+
        "\t-Dservice.tpl.service_soap=" + _TPL_ROOT + "service_soap.ftl\n"+
        "\t-Dservice.tpl.service_util=" + _TPL_ROOT + "service_util.ftl\n"+
        "\t-Dservice.tpl.service_wrapper=" + _TPL_ROOT + "service_wrapper.ftl\n"+
        "\t-Dservice.tpl.spring_base_xml=" + _TPL_ROOT + "spring_base_xml.ftl\n"+
        "\t-Dservice.tpl.spring_dynamic_data_source_xml=" + _TPL_ROOT + "spring_dynamic_data_source_xml.ftl\n"+
        "\t-Dservice.tpl.spring_hibernate_xml=" + _TPL_ROOT + "spring_hibernate_xml.ftl\n"+
        "\t-Dservice.tpl.spring_infrastructure_xml=" + _TPL_ROOT + "spring_infrastructure_xml.ftl\n"+
        "\t-Dservice.tpl.spring_xml=" + _TPL_ROOT + "spring_xml.ftl\n"+
        "\t-Dservice.tpl.spring_xml_session=" + _TPL_ROOT + "spring_xml_session.ftl");
 

Though, this is to override the "portAL's" properties.

 

0 Anhänge
63612 Angesehen
Durchschnitt (0 Stimmen)
Die durchschnittliche Bewertung ist 0.0 von max. 5 Sternen.
Kommentare
Antworten im Thread Autor Datum
I'm formatting the doc, but if someone has time... Ravindranath Akila 14. Oktober 2010 22:37
Links updated. Chris Becker 15. Oktober 2010 05:50
Thanks Chris. But I should apologize as I/we've... Ravindranath Akila 30. Januar 2011 20:48

I'm formatting the doc, but if someone has time please change the links to click-able links
Gepostet am 14.10.10 22:37.
Gepostet am 15.10.10 05:50 als Antwort auf Ravindranath Akila.
Thanks Chris. But I should apologize as I/we've moved on from this agenda as the current work "stopped" using Liferay's Service Builder. But hopefully some others can contribute to the pages as well.
Gepostet am 30.01.11 20:48 als Antwort auf Chris Becker.