<!--
This is the DTD for the Service Builder parameters for Liferay Portal.

<!DOCTYPE service-builder PUBLIC
	"-//Liferay//DTD Service Builder 3.6.1//EN"
	"http://www.liferay.com/dtd/liferay-service-builder_3_6_1.dtd">
-->

<!--
The service-builder element is the root of the deployment descriptor for
a Service Builder descriptor that is used to generate services available to
portlets. The Service Builder saves the developer time by generating EJBs,
Spring utilities, SOAP utilities, and Hibernate persistence classes to ease the
development of services.

To run the service generator, go to /portal/portal-ejb (or /ext/ext-ejb) and
type "ant build-service". The ant task will check for the existence of a file
called "service.xml" that must exist in your current directory. It will parse
that file to generate the service.
-->
<!ELEMENT service-builder (portlet, entity+, exceptions?)>

<!--
The root-dir value specifies the root directory of the portal source code. If
you are running the service builder in /portal/portal-ejb or /ext/ext-ejb, then
the value is just ".." because the root is /portal or /ext.

The package-dir value specifies the package of the generated code. If the value
is "com.liferay.portlet", then all generated code will fall inside
"com.liferay.portlet" + the shortened portlet name. The portlet name is
specified in the portlet element. For example, if the portlet name is
"Message Boards", the generated code will fall under
"com.liferay.portlet.messageboards".
-->
<!ATTLIST service-builder
	root-dir CDATA #REQUIRED
	package-dir CDATA #REQUIRED
>

<!--
The portlet element specifies the portlet that the generated services are
designed for. Services are not limited to the specified portlet but are only
grouped by portlet for easier maintenance.
-->
<!ELEMENT portlet (#PCDATA)>

<!--
The name can be something like "Message Boards". It is used by the Service
Builder in combination with the package-dir attribute.

The short-name can be something like "MB". This is used as a namespace to
distinguish all the generated objects.
-->
<!ATTLIST portlet
	name CDATA #REQUIRED
	short-name CDATA #REQUIRED
>

<!--
An entity usually represents a business facade and a table in the database. If
an entity does not have any columns, then it only represents a business facade.
The Service Builder will always generate an empty business facade POJO if it
does not exist. Upon subsequent generations, the Service Builder will check to
see if the business facade already exists. If it exists and has additional
methods, then the Service Builder will also update the EJB and SOAP wrappers.

If an entity does have columns, then the value object, the POJO class that
is mapped to the database, and other persistence utilities are also generated
based on the order and finder elements.
-->
<!ELEMENT entity (column*, order?, finder*, reference*)>

<!--
The name value specifies the name of the entity.

The table value specifies the name of the table that this entity maps to in the
database. If this value is not set, then the name of the table is the same as
the name of the entity name.

If the local-service is true, then the service will generate the local
interfaces for the service as well as the remote interfaces.

If persistence-class specifies the name of your custom persistence class.
This class must extend the generated persistence class. By extending the
generated persistence class, you can add custom logic without modifying the
generated class. You can also specify this value in portal.properties at
runtime.
-->
<!ATTLIST entity
	name CDATA #REQUIRED
	table CDATA #IMPLIED
	local-service CDATA #IMPLIED
	persistence-class CDATA #IMPLIED
>

<!--
The column element represents a column in the database.
-->
<!ELEMENT column (#PCDATA)>

<!--
The name value specifies the getter and setter name in the entity.

The type value specifies whether the column is a String, Boolean, or int, etc.

For example:

<column name="companyId" db-name="companyId" type="String" />

The above column specifies that there will be a getter called
pojo.getCompanyId() that will return a String.

Set db-name to map the field to a physical database column that is different
from the column name.

If the primary value is set to true, then this column is part of the primary key
of the entity. If multiple columns have the primary value set to true, then a
compound key will be created.

See com.liferay.portal.service.persistence.LayoutPK for an example of a compound
primary key.

If the entity and mapping-key attributes are specified and mapping-table is not,
then the Service Builder will assume you are specifying a one to many
relationship.

For example:

<column
	name="shoppingItemPrices"
	type="Collection"
	entity="ShoppingItemPrice"
	mapping-key="itemId"
/>

The above column specifies that there will be a getter called
pojo.getShoppingItemPrices() that will return a collection. It will map to a
column called itemId in the table that maps to the entity ShoppingItemPrice.

If the entity and mapping-table attributes are specified and mapping-key is not,
then the Service Builder will assume you are specifying a many to many
relationship.

For example:

<column
	name="roles"
	type="Collection"
	entity="Role"
	mapping-table="Groups_Roles"
/>

The above column specifies that there will be a getter called
pojo.getRoles() that will return a collection. It will use a mapping table
called Groups_Roles to give a many to many relationship between groups and
roles.
-->
<!ATTLIST column
	name CDATA #REQUIRED
	db-name CDATA #IMPLIED
	type CDATA #REQUIRED
	primary CDATA #IMPLIED
	entity CDATA #IMPLIED
	mapping-key CDATA #IMPLIED
	mapping-table CDATA #IMPLIED
>

<!--
The order element specifies a default ordering and sorting of the entities when
they are retrieved from the database.
-->
<!ELEMENT order (order-column+)>

<!--
Set the by attribute to "asc" or "desc" to order by ascending or descending.
-->
<!ATTLIST order
	by CDATA #IMPLIED
>

<!--
The order-column element allows you to order the entities by specific columns.
-->
<!ELEMENT order-column (#PCDATA)>

<!--
The attributes of the order-column element allows you to fine tune the ordering
of the entity.

For example:

<order by="asc">
	<order-column name="parentLayoutId" />
	<order-column name="priority" />
</order>

The above settings will order by parentLayoutId and then by priority in an
ascending manner.

For example:

<order by="asc">
	<order-column name="name" case-sensitive="false" />
</order>

The above settings will order by name and will not be case sensitive.

For example:

<order>
	<order-column name="articleId" order-by="asc" />
	<order-column name="version" order-by="desc" />
</order>

The above settings will order by articleId in an ascending manner and then by
version in a descending manner.
-->
<!ATTLIST order-column
	name CDATA #REQUIRED
	case-sensitive CDATA #IMPLIED
	order-by CDATA #IMPLIED
>

<!--
The finder element represents a generated finder method.
-->
<!ELEMENT finder (finder-column+)>

<!--
-->
<!ATTLIST finder
	name CDATA #REQUIRED
	return-type CDATA #REQUIRED
	where CDATA #IMPLIED
	db-index CDATA #IMPLIED
>

<!--
The finder-column element specifies the columns to find by.
-->
<!ELEMENT finder-column (#PCDATA)>

<!--
The name value specifies the name of the finder method.

For example:

<finder name="CompanyId" return-type="Collection">
	<finder-column name="companyId" />
</finder>

The above settings will create a finder with the name findByCompanyId that will
return a Collection and require a given companyId. It will also generate
several more findByCompanyId methods that take in pagination fields (int begin,
int end) and more sorting options. The easiest way to understand this is to
look at a generated Persistence class. The Service Builder will also generate
removeByCompanyId and countByCompanyId.

See com.liferay.portal.service.persistence.LayoutPersistence for a good example.

The attribute check-array is deprecated and will be removed in the next release.
-->
<!ATTLIST finder-column
	name CDATA #REQUIRED
	check-array CDATA #IMPLIED
>

<!--
The reference element will automatically populate the ejb-jar.xml and other
required XML files with the proper reference from one service to another
service.
-->
<!ELEMENT reference (#PCDATA)>

<!--
See the comments in reference element.
-->
<!ATTLIST reference
	package-path CDATA #REQUIRED
	entity CDATA #REQUIRED
>

<!--
The exceptions element contain a list of generated exceptions. This doesn't save
a lot of typing, but can still be helpful.
-->
<!ELEMENT exceptions (exception*)>

<!--
See the comments in exceptions element.
-->
<!ELEMENT exception (#PCDATA)>