How-To Create and Use Table Templates
This document describes how to create and use a table template to create configurable tables for document planning record. Configuration of a table is stored in the child planning record of type TABLE and the content metadata of the child planning record.
1 Introduction
This document describes how to create and use a table template to create configurable tables for document planning record. Configuration of a table is stored in the child planning record of type TABLE and the content metadata of the child planning record.
2 Glossary
- Table Template This is a data mapping method which is annotated. This data mapping method has a config file. In this config file, different configurations of the data mapping method can be used. It is necessary for the config file to contain minimum one configuration. Optionally: In each config, it can be defined which content meta data are used. Note: This is not the old table template from comet desktop plug-ins.
- Table Setup Link to configuration inside the config file of the data-mapping method.
- Table Configuration of a table for a planning record. This configuration is done by storing table config identifier in TABLE type planning record and the content meta data of this TABLE planning record.
3 Table Template Method
This chapter describes what a table template data mapping method should contain.
3.1 Interface
Plugin class should implement the TableTemplate interface
3.2 Interface Methods Implementation Examples
3.2.1 Method getConfigs()
Gets possible table setups configuration objects based on .xml config.
3.2.2 Method getDefaultContentMetadata(DefaultContentMetadataFunctionParameters defaultContentMetadataFunctionParameters)
Uploads the default content metadata for TABLE planning record. Class DefaultContentMetadataFunctionParameters
is used to send multiple parameters in one class. This class contains Map<String, String>
. Parameters value can be get using getParameter(String parameterName)
function. This function return parameter value if it exists or null if parameterName
does not exist in map. Right now we support four parameters: configId
, documentId
, planningIdentifier
and bucketId
.
3.2.3 Method getTable()
Creates a table object based on the configs and the content metadata to be displayed in documents.
To be visible in GUI as a table template, the plug-in method must have:
- Method type set to TABLE_TEMPLATE (
PluginMethod.Methodtype.TABLE_TEMPLATE
), - Defined function variable parameter to identify placeholder where the table should be delivered. (
@PubServerMethodParameter(name = "placeholderUID", defaultValue = "<Variable.PlaceholderUID>", description = "placeholder unique identifier") String placeholderUID
)
To generate a table based on the config and the content metadata, the method should be able to:
- Read and find the proper config for configId stored in TABLE planning record
- Read the content metadata of TABLE child planning record
4 Data Provider
Data provider should be created the same way as a standard data provider for data mapping.
4.1 Query Method
Table template operates on planning so query method should return the current planning record. Standard PubServer method getEntityPlanningsByIdentifier
can be used (see below).
4.2 Mapping Method
Methods annotated as TABLE_TEMPLATE
are visible in Mapping section of the data provider as an option to pick. (see below)
5 Placeholder
Placeholder should be created the same way as a standard placeholder which delivers a Table to a document.
Data Provider which returns Table object should be chosen and converted to Tagged Text for InDesign using tableDataToTaggedText
(or tableDataToTaggedTextWithOption
) in Data Processing Load tab.
6 Templates
If table template placeholders are used, special meta data is needed for the templates. In these metadata the pubserver automatically recognizes which templates contain table placeholders. The metadata are saved for templates, when the login script (session::after login) contains the following command:
prefs::add_metadata_to_templates(1);
prefs::add_w2ml_to_templates(2);
A placeholder should be placed in a template in the normal way. An important difference is that custom unique value of the function variable PlaceholderUID
must be created for each placeholder (see below). Thanks to that, it is possible to use the same placeholder several times in one template with different configuration.
7 GUI Behavior
For information on the implementation of the UI in Neowise, please consult Neowise Flatplan documentation.
8 Rendering Scripts
Standard rendering script for planning can be used to render a document containing Table template. It is important to use IDs of the Planning records, not bucket IDs of the bucket in get_document_product_planning
:
get_document_product_planning(char* documentId = "", char* entityIdentifier = "", char* searchString = "", int mappingFlag = 0)function
To achieve it, parameter mappingFlag
should be set to 1.
For example:
ProductList prds = publication::get\_document\_product\_planning(0,"","",1);