Interface DataTemplateService
- All Superinterfaces:
Service
public interface DataTemplateService extends Service
API for loading data from a template file similar to LoadData.xml.
-
Method Summary
Modifier and Type Method Description java.io.File
getRegisteredTemplateByName(java.lang.String name)
Returns the registered DataTemplate file by the name defined in DataTemplate.xml.java.util.List<java.io.File>
getRegisteredTemplates()
Returns the list of all DataTemplates registered viaregisterTemplate(File)
java.util.Map<java.lang.String,java.lang.Object>
loadDataTemplate(java.io.File dataTemplateFile, java.util.Map<java.lang.String,java.lang.String> bindings, PlatformUserContext context)
Loads data using a DataTemplate file.java.util.Map<java.lang.String,java.lang.Object>
loadEptDataTemplate(java.lang.String fileName, java.util.Map<java.lang.String,java.lang.String> bindings, PlatformUserContext context)
Loads data using a DataTemplate file defined in EPT under "/data" folder.void
registerTemplate(java.io.File dataTemplateFile)
Registers a DataTemplate file, typically defined in a module under the "/data" folder.
-
Method Details
-
loadDataTemplate
java.util.Map<java.lang.String,java.lang.Object> loadDataTemplate(java.io.File dataTemplateFile, java.util.Map<java.lang.String,java.lang.String> bindings, PlatformUserContext context)Loads data using a DataTemplate file. This XML file contains a combination of:- XML data template files
- CSV template files
- Scripts written in Groovy
<DataTemplate xmlns="http://www.onenetwork.com/Platform"> <ModelFile>Enterprises.xml</ModelFile> <InboundInterfaceFile inboundInterface="PLT.Organization_IB" inboundInterfaceVersion="1.0">csv/PLT.Organization_IB.csv</InboundInterfaceFile> <Script> com.onenetwork.platform.env.servicelocator.Services.get(com.onenetwork.platform.data.sql.SqlService.class).executeQuery("update enterprise set description = 'Test Update Through Script' where ent_name = 'TestEnterprise' and vc_id = " + context.getValueChainId()); </Script> </DataTemplate>
- Parameters:
dataTemplateFile
- template file containing a combination of XML, CSV template files to loadbindings
- map which will be used at runtime to replace the variables during loading of data template.context
- caller's context- Returns:
- map of file name to errors. If there are no errors, the map will be empty. For each XML file, the error value will be a
List
containing only the error Models. For each CSV file, the error value will be the String content of the CSV error file. For any XML or CSV file which had no errors, there will be no key in the map for that file.
-
loadEptDataTemplate
java.util.Map<java.lang.String,java.lang.Object> loadEptDataTemplate(java.lang.String fileName, java.util.Map<java.lang.String,java.lang.String> bindings, PlatformUserContext context)Loads data using a DataTemplate file defined in EPT under "/data" folder. Same asloadDataTemplate(File, Map, PlatformUserContext)
, this XML file contains a combination of XML, CSV and Scripts written in Groovy. XML and CSV should exist relative to DataTemplate file in EPT.- Parameters:
fileName
- template file containing a combination of XML, CSV template files to load. For EPT, DataTemplate file should exist in the "/data" folderbindings
- map which will be used at runtime to replace the variables during loading of data template.context
- enterprise level caller's context which has access to the EPT- Returns:
- map of file name to errors. If there are no errors, the map will be empty. For each XML file, the error value will be a
List
containing only the error Models. For each CSV file, the error value will be the String content of the CSV error file. For any XML or CSV file which had no errors, there will be no key in the map for that file.
-
registerTemplate
void registerTemplate(java.io.File dataTemplateFile)Registers a DataTemplate file, typically defined in a module under the "/data" folder. Registering it makes it available to be executed by a VC Admin through the Data Templates UI. The XML file contains Name, Params and combination of:- XML data template files
- CSV template files
- Scripts written in Groovy
<DataTemplate xmlns="http://www.onenetwork.com/Platform"> <Name>TMS.SampleDataTemplate</Name> <Params> <Param name="ENTERPRISE_NAME"/> <Param name="ORG_NAME"/> </Params> <ModelFile>Enterprises.xml</ModelFile> <InboundInterfaceFile inboundInterface="PLT.Organization_IB" inboundInterfaceVersion="1.0">csv/PLT.Organization_IB.csv</InboundInterfaceFile> <Script> com.onenetwork.platform.env.servicelocator.Services.get(com.onenetwork.platform.data.sql.SqlService.class).executeQuery("update enterprise set description = 'Test Update Through Script' where ent_name = 'TestEnterprise' and vc_id = " + context.getValueChainId()); </Script> </DataTemplate>
- Parameters:
dataTemplateFile
- template file containing a combination of XML, CSV template files to load
-
getRegisteredTemplates
java.util.List<java.io.File> getRegisteredTemplates()Returns the list of all DataTemplates registered viaregisterTemplate(File)
-
getRegisteredTemplateByName
java.io.File getRegisteredTemplateByName(java.lang.String name)Returns the registered DataTemplate file by the name defined in DataTemplate.xml. Similar toregisterTemplate(File)
, this XML file contains a combination of XML, CSV and Scripts written in Groovy.- Parameters:
template
- name- Returns:
- DataTemplate file currently registered by module with given name.
-