Class FormTemplateHelper
- java.lang.Object
-
- de.xima.fc.gui.designer.form.utils.FormTemplateHelper
-
public final class FormTemplateHelper extends Object
Utilities for finding, adding and deleting form templates in the form designer, seeFormDesignerTemplateBean.- Since:
- 7.0.0
- Author:
- XIMA MEDIA GmbH
-
-
Constructor Summary
Constructors Constructor Description FormTemplateHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.alibaba.fastjson.JSONArraybuildTagNames(List<FormTemplateTag> tags)static com.alibaba.fastjson.JSONArraybuildTagNames(Locale locale, FetchTemplateResult result)static com.alibaba.fastjson.JSONArraybuildTagNames(Set<String> tags)static com.alibaba.fastjson.JSONArraybuildTemplateJson(javax.faces.context.FacesContext context, Locale locale, Mandant client, FetchTemplateResult result)static org.primefaces.model.StreamedContentcreatePreviewStreamedContent(long clientId, String typeId, String templateId, String iconUri, String contentType, boolean thumbnail)static StringfetchPersistJson(Mandant client, IUser user, ETemplateType type, String id, URI uri)Gets the persist JSON for a specific template.static FetchTemplateResultfetchTagsAndTemplates(Mandant client, Locale locale, IUser user, Projekt project, FormVersion formVersion)static FormTemplateinsertNewTemplate(Mandant client, IUser user, TemplateDataParams params)static voidremoveFormTemplate(IUser user, long templateId)static FormTemplateupdateExistingTemplate(Mandant client, IUser user, long templateId, TemplateDataParams params)
-
-
-
Method Detail
-
buildTagNames
public static com.alibaba.fastjson.JSONArray buildTagNames(List<FormTemplateTag> tags)
- Parameters:
tags- A list of form template tag entities.- Returns:
- A list of tag names.
-
buildTagNames
public static com.alibaba.fastjson.JSONArray buildTagNames(Locale locale, FetchTemplateResult result)
- Parameters:
locale- Locale for localizing plugin tags.result- Result with the entity tags and the plugin templates.- Returns:
- A list of tag names.
-
buildTagNames
public static com.alibaba.fastjson.JSONArray buildTagNames(Set<String> tags)
- Parameters:
tags- A set of tag names- Returns:
- A list of tag names.
-
buildTemplateJson
public static com.alibaba.fastjson.JSONArray buildTemplateJson(javax.faces.context.FacesContext context, Locale locale, Mandant client, FetchTemplateResult result)- Parameters:
context- Currently active faces context.locale- Current locale.client- Current client who owns the project.result- Templates to convert to a JSON object.- Returns:
- A JSON array representing the templates.
-
createPreviewStreamedContent
public static org.primefaces.model.StreamedContent createPreviewStreamedContent(long clientId, String typeId, String templateId, String iconUri, String contentType, boolean thumbnail)- Parameters:
clientId- ID of theMandant.typeId- ID of theETemplateType.templateId- The ID of the template for which to retrieve the image.iconUri- The URI of the icon. ForETemplateType.PLUGIN, theURIof theicon.contentType- Content type of the icon.thumbnail- Whether to return a thumbnail or the original size.- Returns:
- Streamed content with the preview image of the template.
-
fetchPersistJson
public static String fetchPersistJson(Mandant client, IUser user, ETemplateType type, String id, URI uri) throws IOException
Gets the persist JSON for a specific template.- Parameters:
client- Current client scope.user- User who requested the template.type- Optional type of the template to which to limit the result.id- Optional ID of the template to which to limit the result.uri- URI of the template persist JSON.- Returns:
- The persist JSON for the template.
- Throws:
IOException- When the data could not be loaded.
-
fetchTagsAndTemplates
public static FetchTemplateResult fetchTagsAndTemplates(Mandant client, Locale locale, IUser user, Projekt project, FormVersion formVersion)
- Parameters:
client- Current client of the user who opened the form in the designer.locale- Current locale.user- User who initiated the action.project- Current project for which to retrieve the templates.formVersion- Current form version for which to retrieve the templates.- Returns:
- All available tags of the given template.
-
insertNewTemplate
public static FormTemplate insertNewTemplate(Mandant client, IUser user, TemplateDataParams params) throws IOException
- Parameters:
client- Current client who owns the project.user- User who initiated the action.params- Data of the template to create.- Returns:
- The newly created template.
- Throws:
IOException- When the thumbnail image could not be created.
-
removeFormTemplate
public static void removeFormTemplate(IUser user, long templateId)
- Parameters:
user- User who initiated the action.templateId- ID of the template to delete.
-
updateExistingTemplate
public static FormTemplate updateExistingTemplate(Mandant client, IUser user, long templateId, TemplateDataParams params) throws IOException
- Parameters:
client- Current client who owns the project.user- User who initiated the action.templateId- ID of the template to update.params- Data of the template to update.- Returns:
- The updated template.
- Throws:
IOException- When the thumbnail image could not be created.
-
-