Liferay 7.0-ce-m6

com.liferay.portlet.dynamicdatamapping.service.impl
Class DDMTemplateLocalServiceImpl

java.lang.Object
  extended by com.liferay.portal.service.BaseLocalServiceImpl
      extended by com.liferay.portlet.dynamicdatamapping.service.base.DDMTemplateLocalServiceBaseImpl
          extended by com.liferay.portlet.dynamicdatamapping.service.impl.DDMTemplateLocalServiceImpl
All Implemented Interfaces:
IdentifiableBean, BaseLocalService, PersistedModelLocalService, DDMTemplateLocalService

public class DDMTemplateLocalServiceImpl
extends DDMTemplateLocalServiceBaseImpl

Provides the local service for accessing, adding, copying, deleting, and updating dynamic data mapping (DDM) templates.

DDM templates (templates) are used in Liferay to render templated content like applications, forms, dynamic data lists, or web contents.

Templates support a variety of templating languages, like Velocity or FreeMarker. They also support multi-language names and descriptions.

Templates can be related to many models in Liferay, such as those for structures, dynamic data lists, and applications. This relationship can be established via the class name ID and class PK.


Field Summary
 
Fields inherited from class com.liferay.portlet.dynamicdatamapping.service.base.DDMTemplateLocalServiceBaseImpl
classNameLocalService, classNamePersistence, classNameService, counterLocalService, ddmStructureFinder, ddmStructureLocalService, ddmStructurePersistence, ddmStructureService, ddmTemplateFinder, ddmTemplateLinkLocalService, ddmTemplateLinkPersistence, ddmTemplateLocalService, ddmTemplatePersistence, ddmTemplateService, ddmTemplateVersionLocalService, ddmTemplateVersionPersistence, ddmTemplateVersionService, groupFinder, groupLocalService, groupPersistence, groupService, imageLocalService, imagePersistence, imageService, persistedModelLocalServiceRegistry, resourceLocalService, systemEventLocalService, systemEventPersistence, userFinder, userLocalService, userPersistence, userService
 
Constructor Summary
DDMTemplateLocalServiceImpl()
           
 
Method Summary
 DDMTemplate addTemplate(long userId, long groupId, long classNameId, long classPK, long resourceClassNameId, Map<Locale,String> nameMap, Map<Locale,String> descriptionMap, String type, String mode, String language, String script, ServiceContext serviceContext)
          Adds a template.
 DDMTemplate addTemplate(long userId, long groupId, long classNameId, long classPK, long resourceClassNameId, String templateKey, Map<Locale,String> nameMap, Map<Locale,String> descriptionMap, String type, String mode, String language, String script, boolean cacheable, boolean smallImage, String smallImageURL, File smallImageFile, ServiceContext serviceContext)
          Adds a template with additional parameters.
 void addTemplateResources(DDMTemplate template, boolean addGroupPermissions, boolean addGuestPermissions)
          Adds the resources to the template.
 void addTemplateResources(DDMTemplate template, String[] groupPermissions, String[] guestPermissions)
          Adds the model resources with the permissions to the template.
protected  DDMTemplateVersion addTemplateVersion(User user, DDMTemplate template, String version, ServiceContext serviceContext)
           
protected  DDMTemplate copyTemplate(long userId, DDMTemplate template, long classPK, Map<Locale,String> nameMap, Map<Locale,String> descriptionMap, ServiceContext serviceContext)
           
 DDMTemplate copyTemplate(long userId, long templateId, Map<Locale,String> nameMap, Map<Locale,String> descriptionMap, ServiceContext serviceContext)
          Copies the template, creating a new template with all the values extracted from the original one.
 DDMTemplate copyTemplate(long userId, long templateId, ServiceContext serviceContext)
           
 List<DDMTemplate> copyTemplates(long userId, long classNameId, long oldClassPK, long newClassPK, String type, ServiceContext serviceContext)
          Copies all the templates matching the class name ID, class PK, and type.
 void deleteTemplate(DDMTemplate template)
          Deletes the template and its resources.
 void deleteTemplate(long templateId)
          Deletes the template and its resources.
 void deleteTemplates(long groupId)
          Deletes all the templates of the group.
 void deleteTemplates(long groupId, long classNameId)
           
 DDMTemplate fetchTemplate(long groupId, long classNameId, String templateKey)
          Returns the template matching the group and template key.
 DDMTemplate fetchTemplate(long groupId, long classNameId, String templateKey, boolean includeAncestorTemplates)
          Returns the template matching the group and template key, optionally searching ancestor sites (that have sharing enabled) and global scoped sites.
protected  String formatScript(String type, String language, String script)
           
protected  String getNextVersion(String version, boolean majorVersion)
           
protected  File getSmallImageFile(DDMTemplate template)
           
 DDMTemplate getTemplate(long templateId)
          Returns the template with the ID.
 DDMTemplate getTemplate(long groupId, long classNameId, String templateKey)
          Returns the template matching the group and template key.
 DDMTemplate getTemplate(long groupId, long classNameId, String templateKey, boolean includeAncestorTemplates)
          Returns the template matching the group and template key, optionally searching ancestor sites (that have sharing enabled) and global scoped sites.
 DDMTemplate getTemplateBySmallImageId(long smallImageId)
           
 List<DDMTemplate> getTemplates(long classPK)
          Returns all the templates with the class PK.
 List<DDMTemplate> getTemplates(long[] groupIds, long classNameId, long classPK)
           
 List<DDMTemplate> getTemplates(long groupId, long classNameId)
          Returns all the templates matching the group and class name ID.
 List<DDMTemplate> getTemplates(long groupId, long classNameId, long classPK)
          Returns all the templates matching the group, class name ID, and class PK.
 List<DDMTemplate> getTemplates(long groupId, long classNameId, long classPK, boolean includeAncestorTemplates)
           
 List<DDMTemplate> getTemplates(long groupId, long classNameId, long classPK, String type)
          Returns all the templates matching the group, class name ID, class PK, and type.
 List<DDMTemplate> getTemplates(long groupId, long classNameId, long classPK, String type, String mode)
          Returns all the templates matching the group, class name ID, class PK, type, and mode.
 List<DDMTemplate> getTemplatesByClassPK(long[] groupIds, long classPK)
           
 List<DDMTemplate> getTemplatesByClassPK(long groupId, long classPK)
           
 List<DDMTemplate> getTemplatesByClassPK(long groupId, long classPK, int start, int end)
           
 int getTemplatesByClassPKCount(long groupId, long classPK)
          Returns the number of templates matching the group and class PK.
 List<DDMTemplate> getTemplatesByStructureClassNameId(long groupId, long structureClassNameId, int start, int end, OrderByComparator<DDMTemplate> orderByComparator)
          Returns an ordered range of all the templates matching the group and structure class name ID.
 int getTemplatesByStructureClassNameIdCount(long groupId, long structureClassNameId)
          Returns the number of templates matching the group and structure class name ID, including Generic Templates.
 int getTemplatesCount(long groupId)
          Returns the number of templates belonging to the group.
 int getTemplatesCount(long groupId, long classNameId)
          Returns the number of templates matching the group and class name ID.
 int getTemplatesCount(long groupId, long classNameId, long classPK)
          Returns the number of templates matching the group, class name ID, and class PK.
 void revertTemplate(long userId, long templateId, String version, ServiceContext serviceContext)
           
protected  void saveImages(boolean smallImage, long smallImageId, File smallImageFile, byte[] smallImageBytes)
           
 List<DDMTemplate> search(long companyId, long[] groupIds, long[] classNameIds, long[] classPKs, long resourceClassNameId, String keywords, String type, String mode, int start, int end, OrderByComparator<DDMTemplate> orderByComparator)
          Returns an ordered range of all the templates matching the group IDs, class Name IDs, class PK, type, and mode, and include the keywords on its names and descriptions.
 List<DDMTemplate> search(long companyId, long[] groupIds, long[] classNameIds, long[] classPKs, long resourceClassNameId, String name, String description, String type, String mode, String language, boolean andOperator, int start, int end, OrderByComparator<DDMTemplate> orderByComparator)
          Returns an ordered range of all the templates matching the group IDs, class name IDs, class PK, name keyword, description keyword, type, mode, and language.
 List<DDMTemplate> search(long companyId, long groupId, long classNameId, long classPK, long resourceClassNameId, String keywords, String type, String mode, int start, int end, OrderByComparator<DDMTemplate> orderByComparator)
          Returns an ordered range of all the templates matching the group, class name ID, class PK, type, and mode, and matching the keywords in the template names and descriptions.
 List<DDMTemplate> search(long companyId, long groupId, long classNameId, long classPK, long resourceClassNameId, String name, String description, String type, String mode, String language, boolean andOperator, int start, int end, OrderByComparator<DDMTemplate> orderByComparator)
          Returns an ordered range of all the templates matching the group, class name ID, class PK, name keyword, description keyword, type, mode, and language.
 int searchCount(long companyId, long[] groupIds, long[] classNameIds, long[] classPKs, long resourceClassNameId, String keywords, String type, String mode)
          Returns the number of templates matching the group IDs, class name IDs, class PK, type, and mode, and matching the keywords in the template names and descriptions.
 int searchCount(long companyId, long[] groupIds, long[] classNameIds, long[] classPKs, long resourceClassNameId, String name, String description, String type, String mode, String language, boolean andOperator)
          Returns the number of templates matching the group IDs, class name IDs, class PKs, name keyword, description keyword, type, mode, and language.
 int searchCount(long companyId, long groupId, long classNameId, long classPK, long resourceClassNameId, String keywords, String type, String mode)
          Returns the number of templates matching the group, class name ID, class PK, type, and matching the keywords in the template names and descriptions.
 int searchCount(long companyId, long groupId, long classNameId, long classPK, long resourceClassNameId, String name, String description, String type, String mode, String language, boolean andOperator)
          Returns the number of templates matching the group, class name ID, class PK, name keyword, description keyword, type, mode, and language.
 DDMTemplate updateTemplate(long userId, long templateId, long classPK, Map<Locale,String> nameMap, Map<Locale,String> descriptionMap, String type, String mode, String language, String script, boolean cacheable, boolean smallImage, String smallImageURL, File smallImageFile, ServiceContext serviceContext)
          Updates the template matching the ID.
 DDMTemplate updateTemplate(long userId, long templateId, long classPK, Map<Locale,String> nameMap, Map<Locale,String> descriptionMap, String type, String mode, String language, String script, boolean cacheable, ServiceContext serviceContext)
          Updates the template matching the ID.
protected  void validate(long groupId, long classNameId, String templateKey, Map<Locale,String> nameMap, String script, boolean smallImage, String smallImageURL, File smallImageFile, byte[] smallImageBytes)
           
protected  void validate(Map<Locale,String> nameMap, String script)
           
protected  void validate(Map<Locale,String> nameMap, String script, boolean smallImage, String smallImageURL, File smallImageFile, byte[] smallImageBytes)
           
protected  void validateName(Map<Locale,String> nameMap)
           
 
Methods inherited from class com.liferay.portlet.dynamicdatamapping.service.base.DDMTemplateLocalServiceBaseImpl
addDDMTemplate, afterPropertiesSet, createDDMTemplate, deleteDDMTemplate, deleteDDMTemplate, deletePersistedModel, destroy, dynamicQuery, dynamicQuery, dynamicQuery, dynamicQuery, dynamicQueryCount, dynamicQueryCount, fetchDDMTemplate, fetchDDMTemplateByUuidAndGroupId, getActionableDynamicQuery, getBeanIdentifier, getClassNameLocalService, getClassNamePersistence, getClassNameService, getCounterLocalService, getDDMStructureFinder, getDDMStructureLocalService, getDDMStructurePersistence, getDDMStructureService, getDDMTemplate, getDDMTemplateByUuidAndGroupId, getDDMTemplateFinder, getDDMTemplateLinkLocalService, getDDMTemplateLinkPersistence, getDDMTemplateLocalService, getDDMTemplatePersistence, getDDMTemplates, getDDMTemplatesByUuidAndCompanyId, getDDMTemplatesByUuidAndCompanyId, getDDMTemplatesCount, getDDMTemplateService, getDDMTemplateVersionLocalService, getDDMTemplateVersionPersistence, getDDMTemplateVersionService, getExportActionableDynamicQuery, getGroupFinder, getGroupLocalService, getGroupPersistence, getGroupService, getImageLocalService, getImagePersistence, getImageService, getModelClass, getModelClassName, getPersistedModel, getResourceLocalService, getSystemEventLocalService, getSystemEventPersistence, getUserFinder, getUserLocalService, getUserPersistence, getUserService, initActionableDynamicQuery, runSQL, setBeanIdentifier, setClassNameLocalService, setClassNamePersistence, setClassNameService, setCounterLocalService, setDDMStructureFinder, setDDMStructureLocalService, setDDMStructurePersistence, setDDMStructureService, setDDMTemplateFinder, setDDMTemplateLinkLocalService, setDDMTemplateLinkPersistence, setDDMTemplateLocalService, setDDMTemplatePersistence, setDDMTemplateService, setDDMTemplateVersionLocalService, setDDMTemplateVersionPersistence, setDDMTemplateVersionService, setGroupFinder, setGroupLocalService, setGroupPersistence, setGroupService, setImageLocalService, setImagePersistence, setImageService, setResourceLocalService, setSystemEventLocalService, setSystemEventPersistence, setUserFinder, setUserLocalService, setUserPersistence, setUserService, updateDDMTemplate
 
Methods inherited from class com.liferay.portal.service.BaseLocalServiceImpl
getClassLoader, getLocalizationMap
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DDMTemplateLocalServiceImpl

public DDMTemplateLocalServiceImpl()
Method Detail

addTemplate

public DDMTemplate addTemplate(long userId,
                               long groupId,
                               long classNameId,
                               long classPK,
                               long resourceClassNameId,
                               Map<Locale,String> nameMap,
                               Map<Locale,String> descriptionMap,
                               String type,
                               String mode,
                               String language,
                               String script,
                               ServiceContext serviceContext)
                        throws PortalException
Adds a template.

Parameters:
userId - the primary key of the template's creator/owner
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
classPK - the primary key of the template's related entity
resourceClassNameId - the primary key of the class name for template's resource model
nameMap - the template's locales and localized names
descriptionMap - the template's locales and localized descriptions
type - the template's type. For more information, see DDMTemplateConstants.
mode - the template's mode. For more information, see DDMTemplateConstants.
language - the template's script language. For more information, see DDMTemplateConstants.
script - the template's script
serviceContext - the service context to be applied. Can set the UUID, creation date, modification date, guest permissions, and group permissions for the template.
Returns:
the template
Throws:
PortalException - if a portal exception occurred

addTemplate

public DDMTemplate addTemplate(long userId,
                               long groupId,
                               long classNameId,
                               long classPK,
                               long resourceClassNameId,
                               String templateKey,
                               Map<Locale,String> nameMap,
                               Map<Locale,String> descriptionMap,
                               String type,
                               String mode,
                               String language,
                               String script,
                               boolean cacheable,
                               boolean smallImage,
                               String smallImageURL,
                               File smallImageFile,
                               ServiceContext serviceContext)
                        throws PortalException
Adds a template with additional parameters.

Parameters:
userId - the primary key of the template's creator/owner
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
classPK - the primary key of the template's related entity
resourceClassNameId - the primary key of the class name for template's resource model
templateKey - the unique string identifying the template (optionally null)
nameMap - the template's locales and localized names
descriptionMap - the template's locales and localized descriptions
type - the template's type. For more information, see DDMTemplateConstants.
mode - the template's mode. For more information, see DDMTemplateConstants.
language - the template's script language. For more information, see DDMTemplateConstants.
script - the template's script
cacheable - whether the template is cacheable
smallImage - whether the template has a small image
smallImageURL - the template's small image URL (optionally null)
smallImageFile - the template's small image file (optionally null)
serviceContext - the service context to be applied. Can set the UUID, creation date, modification date, guest permissions, and group permissions for the template.
Returns:
the template
Throws:
PortalException - if a portal exception occurred

addTemplateResources

public void addTemplateResources(DDMTemplate template,
                                 boolean addGroupPermissions,
                                 boolean addGuestPermissions)
                          throws PortalException
Adds the resources to the template.

Parameters:
template - the template to add resources to
addGroupPermissions - whether to add group permissions
addGuestPermissions - whether to add guest permissions
Throws:
PortalException - if a portal exception occurred

addTemplateResources

public void addTemplateResources(DDMTemplate template,
                                 String[] groupPermissions,
                                 String[] guestPermissions)
                          throws PortalException
Adds the model resources with the permissions to the template.

Parameters:
template - the template to add resources to
groupPermissions - the group permissions to be added
guestPermissions - the guest permissions to be added
Throws:
PortalException - if a portal exception occurred

copyTemplate

public DDMTemplate copyTemplate(long userId,
                                long templateId,
                                Map<Locale,String> nameMap,
                                Map<Locale,String> descriptionMap,
                                ServiceContext serviceContext)
                         throws PortalException
Copies the template, creating a new template with all the values extracted from the original one. This method supports defining a new name and description.

Parameters:
userId - the primary key of the template's creator/owner
templateId - the primary key of the template to be copied
nameMap - the new template's locales and localized names
descriptionMap - the new template's locales and localized descriptions
serviceContext - the service context to be applied. Can set the UUID, creation date, modification date, guest permissions, and group permissions for the template.
Returns:
the new template
Throws:
PortalException - if a portal exception occurred

copyTemplate

public DDMTemplate copyTemplate(long userId,
                                long templateId,
                                ServiceContext serviceContext)
                         throws PortalException
Throws:
PortalException

copyTemplates

public List<DDMTemplate> copyTemplates(long userId,
                                       long classNameId,
                                       long oldClassPK,
                                       long newClassPK,
                                       String type,
                                       ServiceContext serviceContext)
                                throws PortalException
Copies all the templates matching the class name ID, class PK, and type. This method creates new templates, extracting all the values from the old ones and updating their class PKs.

Parameters:
userId - the primary key of the template's creator/owner
classNameId - the primary key of the class name for the template's related model
oldClassPK - the primary key of the old template's related entity
newClassPK - the primary key of the new template's related entity
type - the template's type. For more information, see DDMTemplateConstants.
serviceContext - the service context to be applied. Can set the creation date, modification date, guest permissions, and group permissions for the new templates.
Returns:
the new templates
Throws:
PortalException - if a portal exception occurred

deleteTemplate

@SystemEvent(type=1)
public void deleteTemplate(DDMTemplate template)
                    throws PortalException
Deletes the template and its resources.

Parameters:
template - the template to be deleted
Throws:
PortalException - if a portal exception occurred

deleteTemplate

public void deleteTemplate(long templateId)
                    throws PortalException
Deletes the template and its resources.

Parameters:
templateId - the primary key of the template to be deleted
Throws:
PortalException - if a portal exception occurred

deleteTemplates

public void deleteTemplates(long groupId)
                     throws PortalException
Deletes all the templates of the group.

Parameters:
groupId - the primary key of the group
Throws:
PortalException - if a portal exception occurred

deleteTemplates

public void deleteTemplates(long groupId,
                            long classNameId)
                     throws PortalException
Throws:
PortalException

fetchTemplate

public DDMTemplate fetchTemplate(long groupId,
                                 long classNameId,
                                 String templateKey)
Returns the template matching the group and template key.

Parameters:
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
templateKey - the unique string identifying the template
Returns:
the matching template, or null if a matching template could not be found

fetchTemplate

public DDMTemplate fetchTemplate(long groupId,
                                 long classNameId,
                                 String templateKey,
                                 boolean includeAncestorTemplates)
                          throws PortalException
Returns the template matching the group and template key, optionally searching ancestor sites (that have sharing enabled) and global scoped sites.

This method first searches in the given group. If the template is still not found and includeAncestorTemplates is set to true, this method searches the group's ancestor sites (that have sharing enabled) and lastly searches global scoped sites.

Parameters:
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
templateKey - the unique string identifying the template
includeAncestorTemplates - whether to include ancestor sites (that have sharing enabled) and include global scoped sites in the search in the search
Returns:
the matching template, or null if a matching template could not be found
Throws:
PortalException - if a portal exception occurred

getTemplate

public DDMTemplate getTemplate(long templateId)
                        throws PortalException
Returns the template with the ID.

Parameters:
templateId - the primary key of the template
Returns:
the template with the ID
Throws:
PortalException - if a matching template could not be found

getTemplate

public DDMTemplate getTemplate(long groupId,
                               long classNameId,
                               String templateKey)
                        throws PortalException
Returns the template matching the group and template key.

Parameters:
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
templateKey - the unique string identifying the template
Returns:
the matching template
Throws:
PortalException - if a matching template could not be found

getTemplate

public DDMTemplate getTemplate(long groupId,
                               long classNameId,
                               String templateKey,
                               boolean includeAncestorTemplates)
                        throws PortalException
Returns the template matching the group and template key, optionally searching ancestor sites (that have sharing enabled) and global scoped sites.

This method first searches in the group. If the template is still not found and includeAncestorTemplates is set to true, this method searches the group's ancestor sites (that have sharing enabled) and lastly searches global scoped sites.

Parameters:
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
templateKey - the unique string identifying the template
includeAncestorTemplates - whether to include ancestor sites (that have sharing enabled) and include global scoped sites in the search in the search
Returns:
the matching template
Throws:
PortalException - if a matching template could not be found

getTemplateBySmallImageId

public DDMTemplate getTemplateBySmallImageId(long smallImageId)
                                      throws PortalException
Throws:
PortalException

getTemplates

public List<DDMTemplate> getTemplates(long classPK)
Returns all the templates with the class PK.

Parameters:
classPK - the primary key of the template's related entity
Returns:
the templates with the class PK

getTemplates

public List<DDMTemplate> getTemplates(long groupId,
                                      long classNameId)
Returns all the templates matching the group and class name ID.

Parameters:
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
Returns:
the matching templates

getTemplates

public List<DDMTemplate> getTemplates(long groupId,
                                      long classNameId,
                                      long classPK)
Returns all the templates matching the group, class name ID, and class PK.

Parameters:
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
classPK - the primary key of the template's related entity
Returns:
the matching templates

getTemplates

public List<DDMTemplate> getTemplates(long groupId,
                                      long classNameId,
                                      long classPK,
                                      boolean includeAncestorTemplates)
                               throws PortalException
Throws:
PortalException

getTemplates

public List<DDMTemplate> getTemplates(long groupId,
                                      long classNameId,
                                      long classPK,
                                      String type)
Returns all the templates matching the group, class name ID, class PK, and type.

Parameters:
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
classPK - the primary key of the template's related entity
type - the template's type. For more information, see DDMTemplateConstants.
Returns:
the matching templates

getTemplates

public List<DDMTemplate> getTemplates(long groupId,
                                      long classNameId,
                                      long classPK,
                                      String type,
                                      String mode)
Returns all the templates matching the group, class name ID, class PK, type, and mode.

Parameters:
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
classPK - the primary key of the template's related entity
type - the template's type. For more information, see DDMTemplateConstants.
mode - the template's mode. For more information, see DDMTemplateConstants.
Returns:
the matching templates

getTemplates

public List<DDMTemplate> getTemplates(long[] groupIds,
                                      long classNameId,
                                      long classPK)

getTemplatesByClassPK

public List<DDMTemplate> getTemplatesByClassPK(long groupId,
                                               long classPK)

getTemplatesByClassPK

public List<DDMTemplate> getTemplatesByClassPK(long groupId,
                                               long classPK,
                                               int start,
                                               int end)

getTemplatesByClassPK

public List<DDMTemplate> getTemplatesByClassPK(long[] groupIds,
                                               long classPK)

getTemplatesByClassPKCount

public int getTemplatesByClassPKCount(long groupId,
                                      long classPK)
Returns the number of templates matching the group and class PK.

Parameters:
groupId - the primary key of the group
classPK - the primary key of the template's related entity
Returns:
the number of templates belonging to the group and class PK

getTemplatesByStructureClassNameId

public List<DDMTemplate> getTemplatesByStructureClassNameId(long groupId,
                                                            long structureClassNameId,
                                                            int start,
                                                            int end,
                                                            OrderByComparator<DDMTemplate> orderByComparator)
Returns an ordered range of all the templates matching the group and structure class name ID.

Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

Parameters:
groupId - the primary key of the group
structureClassNameId - the primary key of the class name for the template's related structure
start - the lower bound of the range of templates to return
end - the upper bound of the range of templates to return (not inclusive)
orderByComparator - the comparator to order the templates (optionally null)
Returns:
the range of matching templates ordered by the comparator

getTemplatesByStructureClassNameIdCount

public int getTemplatesByStructureClassNameIdCount(long groupId,
                                                   long structureClassNameId)
Returns the number of templates matching the group and structure class name ID, including Generic Templates.

Parameters:
groupId - the primary key of the group
structureClassNameId - the primary key of the class name for the template's related structure
Returns:
the number of matching templates

getTemplatesCount

public int getTemplatesCount(long groupId)
Returns the number of templates belonging to the group.

Parameters:
groupId - the primary key of the group
Returns:
the number of templates belonging to the group

getTemplatesCount

public int getTemplatesCount(long groupId,
                             long classNameId)
Returns the number of templates matching the group and class name ID.

Parameters:
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
Returns:
the number of matching templates

getTemplatesCount

public int getTemplatesCount(long groupId,
                             long classNameId,
                             long classPK)
Returns the number of templates matching the group, class name ID, and class PK.

Parameters:
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
classPK - the primary key of the template's related entity
Returns:
the number of matching templates

revertTemplate

public void revertTemplate(long userId,
                           long templateId,
                           String version,
                           ServiceContext serviceContext)
                    throws PortalException
Throws:
PortalException

search

public List<DDMTemplate> search(long companyId,
                                long groupId,
                                long classNameId,
                                long classPK,
                                long resourceClassNameId,
                                String keywords,
                                String type,
                                String mode,
                                int start,
                                int end,
                                OrderByComparator<DDMTemplate> orderByComparator)
Returns an ordered range of all the templates matching the group, class name ID, class PK, type, and mode, and matching the keywords in the template names and descriptions.

Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

Parameters:
companyId - the primary key of the template's company
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
classPK - the primary key of the template's related entity
resourceClassNameId - the primary key of the class name for template's resource model
keywords - the keywords (space separated), which may occur in the template's name or description (optionally null)
type - the template's type (optionally null). For more information, see DDMTemplateConstants.
mode - the template's mode (optionally null). For more information, see DDMTemplateConstants.
start - the lower bound of the range of templates to return
end - the upper bound of the range of templates to return (not inclusive)
orderByComparator - the comparator to order the templates (optionally null)
Returns:
the range of matching templates ordered by the comparator

search

public List<DDMTemplate> search(long companyId,
                                long groupId,
                                long classNameId,
                                long classPK,
                                long resourceClassNameId,
                                String name,
                                String description,
                                String type,
                                String mode,
                                String language,
                                boolean andOperator,
                                int start,
                                int end,
                                OrderByComparator<DDMTemplate> orderByComparator)
Returns an ordered range of all the templates matching the group, class name ID, class PK, name keyword, description keyword, type, mode, and language.

Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

Parameters:
companyId - the primary key of the template's company
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
classPK - the primary key of the template's related entity
resourceClassNameId - the primary key of the class name for template's resource model
name - the name keywords (optionally null)
description - the description keywords (optionally null)
type - the template's type (optionally null). For more information, see DDMTemplateConstants.
mode - the template's mode (optionally null). For more information, see DDMTemplateConstants.
language - the template's script language (optionally null). For more information, see DDMTemplateConstants.
andOperator - whether every field must match its keywords, or just one field
start - the lower bound of the range of templates to return
end - the upper bound of the range of templates to return (not inclusive)
orderByComparator - the comparator to order the templates (optionally null)
Returns:
the range of matching templates ordered by the comparator

search

public List<DDMTemplate> search(long companyId,
                                long[] groupIds,
                                long[] classNameIds,
                                long[] classPKs,
                                long resourceClassNameId,
                                String keywords,
                                String type,
                                String mode,
                                int start,
                                int end,
                                OrderByComparator<DDMTemplate> orderByComparator)
Returns an ordered range of all the templates matching the group IDs, class Name IDs, class PK, type, and mode, and include the keywords on its names and descriptions.

Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

Parameters:
companyId - the primary key of the template's company
groupIds - the primary keys of the groups
classNameIds - the primary keys of the entity's instances the templates are related to
classPKs - the primary keys of the template's related entities
resourceClassNameId - the primary key of the class name for template's resource model
keywords - the keywords (space separated), which may occur in the template's name or description (optionally null)
type - the template's type (optionally null). For more information, see DDMTemplateConstants.
mode - the template's mode (optionally null). For more information, see DDMTemplateConstants.
start - the lower bound of the range of templates to return
end - the upper bound of the range of templates to return (not inclusive)
orderByComparator - the comparator to order the templates (optionally null)
Returns:
the range of matching templates ordered by the comparator

search

public List<DDMTemplate> search(long companyId,
                                long[] groupIds,
                                long[] classNameIds,
                                long[] classPKs,
                                long resourceClassNameId,
                                String name,
                                String description,
                                String type,
                                String mode,
                                String language,
                                boolean andOperator,
                                int start,
                                int end,
                                OrderByComparator<DDMTemplate> orderByComparator)
Returns an ordered range of all the templates matching the group IDs, class name IDs, class PK, name keyword, description keyword, type, mode, and language.

Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil.ALL_POS will return the full result set.

Parameters:
companyId - the primary key of the template's company
groupIds - the primary keys of the groups
classNameIds - the primary keys of the entity's instances the templates are related to
classPKs - the primary keys of the template's related entities
resourceClassNameId - the primary key of the class name for template's resource model
name - the name keywords (optionally null)
description - the description keywords (optionally null)
type - the template's type (optionally null). For more information, see DDMTemplateConstants.
mode - the template's mode (optionally null). For more information, see DDMTemplateConstants.
language - the template's script language (optionally null). For more information, see DDMTemplateConstants.
andOperator - whether every field must match its keywords, or just one field.
start - the lower bound of the range of templates to return
end - the upper bound of the range of templates to return (not inclusive)
orderByComparator - the comparator to order the templates (optionally null)
Returns:
the range of matching templates ordered by the comparator

searchCount

public int searchCount(long companyId,
                       long groupId,
                       long classNameId,
                       long classPK,
                       long resourceClassNameId,
                       String keywords,
                       String type,
                       String mode)
Returns the number of templates matching the group, class name ID, class PK, type, and matching the keywords in the template names and descriptions.

Parameters:
companyId - the primary key of the template's company
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
classPK - the primary key of the template's related entity
resourceClassNameId - the primary key of the class name for template's resource model
keywords - the keywords (space separated), which may occur in the template's name or description (optionally null)
type - the template's type (optionally null). For more information, see DDMTemplateConstants.
mode - the template's mode (optionally null). For more information, see DDMTemplateConstants.
Returns:
the number of matching templates

searchCount

public int searchCount(long companyId,
                       long groupId,
                       long classNameId,
                       long classPK,
                       long resourceClassNameId,
                       String name,
                       String description,
                       String type,
                       String mode,
                       String language,
                       boolean andOperator)
Returns the number of templates matching the group, class name ID, class PK, name keyword, description keyword, type, mode, and language.

Parameters:
companyId - the primary key of the template's company
groupId - the primary key of the group
classNameId - the primary key of the class name for the template's related model
classPK - the primary key of the template's related entity
resourceClassNameId - the primary key of the class name for template's resource model
name - the name keywords (optionally null)
description - the description keywords (optionally null)
type - the template's type (optionally null). For more information, see DDMTemplateConstants.
mode - the template's mode (optionally null). For more information, see DDMTemplateConstants.
language - the template's script language (optionally null). For more information, see DDMTemplateConstants.
andOperator - whether every field must match its keywords, or just one field.
Returns:
the number of matching templates

searchCount

public int searchCount(long companyId,
                       long[] groupIds,
                       long[] classNameIds,
                       long[] classPKs,
                       long resourceClassNameId,
                       String keywords,
                       String type,
                       String mode)
Returns the number of templates matching the group IDs, class name IDs, class PK, type, and mode, and matching the keywords in the template names and descriptions.

Parameters:
companyId - the primary key of the template's company
groupIds - the primary keys of the groups
classNameIds - the primary keys of the entity's instance the templates are related to
classPKs - the primary keys of the template's related entities
resourceClassNameId - the primary key of the class name for template's resource model
keywords - the keywords (space separated), which may occur in the template's name or description (optionally null)
type - the template's type (optionally null). For more information, see DDMTemplateConstants.
mode - the template's mode (optionally null). For more information, see DDMTemplateConstants.
Returns:
the number of matching templates

searchCount

public int searchCount(long companyId,
                       long[] groupIds,
                       long[] classNameIds,
                       long[] classPKs,
                       long resourceClassNameId,
                       String name,
                       String description,
                       String type,
                       String mode,
                       String language,
                       boolean andOperator)
Returns the number of templates matching the group IDs, class name IDs, class PKs, name keyword, description keyword, type, mode, and language.

Parameters:
companyId - the primary key of the templates company
groupIds - the primary keys of the groups
classNameIds - the primary keys of the entity's instance the templates are related to
classPKs - the primary keys of the template's related entities
resourceClassNameId - the primary key of the class name for template's resource model
name - the name keywords (optionally null)
description - the description keywords (optionally null)
type - the template's type (optionally null). For more information, see DDMTemplateConstants.
mode - the template's mode (optionally null). For more information, see DDMTemplateConstants.
language - the template's script language (optionally null). For more information, see DDMTemplateConstants.
andOperator - whether every field must match its keywords, or just one field.
Returns:
the number of matching templates

updateTemplate

public DDMTemplate updateTemplate(long userId,
                                  long templateId,
                                  long classPK,
                                  Map<Locale,String> nameMap,
                                  Map<Locale,String> descriptionMap,
                                  String type,
                                  String mode,
                                  String language,
                                  String script,
                                  boolean cacheable,
                                  boolean smallImage,
                                  String smallImageURL,
                                  File smallImageFile,
                                  ServiceContext serviceContext)
                           throws PortalException
Updates the template matching the ID.

Parameters:
userId - the primary key of the template's creator/owner
templateId - the primary key of the template
classPK - the primary key of the template's related entity
nameMap - the template's new locales and localized names
descriptionMap - the template's new locales and localized description
type - the template's type. For more information, see DDMTemplateConstants.
mode - the template's mode. For more information, see DDMTemplateConstants.
language - the template's script language. For more information, see DDMTemplateConstants.
script - the template's script
cacheable - whether the template is cacheable
smallImage - whether the template has a small image
smallImageURL - the template's small image URL (optionally null)
smallImageFile - the template's small image file (optionally null)
serviceContext - the service context to be applied. Can set the modification date.
Returns:
the updated template
Throws:
PortalException - if a portal exception occurred

updateTemplate

public DDMTemplate updateTemplate(long userId,
                                  long templateId,
                                  long classPK,
                                  Map<Locale,String> nameMap,
                                  Map<Locale,String> descriptionMap,
                                  String type,
                                  String mode,
                                  String language,
                                  String script,
                                  boolean cacheable,
                                  ServiceContext serviceContext)
                           throws PortalException
Updates the template matching the ID.

Parameters:
userId - the primary key of the template's creator/owner
templateId - the primary key of the template
classPK - the primary key of the template's related entity
nameMap - the template's new locales and localized names
descriptionMap - the template's new locales and localized description
type - the template's type. For more information, see DDMTemplateConstants.
mode - the template's mode. For more information, see DDMTemplateConstants.
language - the template's script language. For more information, see DDMTemplateConstants.
script - the template's script
cacheable - whether the template is cacheable
serviceContext - the service context to be applied. Can set the modification date.
Returns:
the updated template
Throws:
PortalException - if a portal exception occurred

addTemplateVersion

protected DDMTemplateVersion addTemplateVersion(User user,
                                                DDMTemplate template,
                                                String version,
                                                ServiceContext serviceContext)

copyTemplate

protected DDMTemplate copyTemplate(long userId,
                                   DDMTemplate template,
                                   long classPK,
                                   Map<Locale,String> nameMap,
                                   Map<Locale,String> descriptionMap,
                                   ServiceContext serviceContext)
                            throws PortalException
Throws:
PortalException

formatScript

protected String formatScript(String type,
                              String language,
                              String script)
                       throws PortalException
Throws:
PortalException

getNextVersion

protected String getNextVersion(String version,
                                boolean majorVersion)

getSmallImageFile

protected File getSmallImageFile(DDMTemplate template)

saveImages

protected void saveImages(boolean smallImage,
                          long smallImageId,
                          File smallImageFile,
                          byte[] smallImageBytes)
                   throws PortalException
Throws:
PortalException

validate

protected void validate(long groupId,
                        long classNameId,
                        String templateKey,
                        Map<Locale,String> nameMap,
                        String script,
                        boolean smallImage,
                        String smallImageURL,
                        File smallImageFile,
                        byte[] smallImageBytes)
                 throws PortalException
Throws:
PortalException

validate

protected void validate(Map<Locale,String> nameMap,
                        String script)
                 throws PortalException
Throws:
PortalException

validate

protected void validate(Map<Locale,String> nameMap,
                        String script,
                        boolean smallImage,
                        String smallImageURL,
                        File smallImageFile,
                        byte[] smallImageBytes)
                 throws PortalException
Throws:
PortalException

validateName

protected void validateName(Map<Locale,String> nameMap)
                     throws PortalException
Throws:
PortalException

Liferay 7.0-ce-m6