Package org.ametys.plugins.contentio.csv
Class ImportCSVFileHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.contentio.csv.ImportCSVFileHelper
-
- All Implemented Interfaces:
LogEnabled
,Component
,Serviceable
public class ImportCSVFileHelper extends AbstractLogEnabled implements Component, Serviceable
Import contents from an uploaded CSV file.
-
-
Field Summary
Fields Modifier and Type Field Description private ContentTypeExtensionPoint
_contentTypeEP
private CSVImporter
_csvImporter
static String
ROLE
Avalon Role
-
Constructor Summary
Constructors Constructor Description ImportCSVFileHelper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
_checkViewItemContainer(ViewItem viewItem, Map<String,Object> mapping, Map<String,Object> result)
private boolean
_checkViewItemContentContainer(ViewElementAccessor viewElementAccessor, Map<String,Object> mapping, Map<String,Object> result, ContentAttributeDefinition contentAttributeDefinition)
private boolean
_checkViewItemGroupContainer(ViewItem viewItem, Map<String,Object> mapping, Map<String,Object> result)
void
deleteFile(String path)
Delete the file related to the given pathprivate static Map<String,Object>
generateNestedMap(Map<String,Object> map, String attributePath, String column, boolean isId)
Map<String,Object>
importContents(Map config, Map formValues, List<Map<String,Object>> mappingValues)
Gets the configuration for creating/editing a collection of synchronizable contents.void
service(ServiceManager serviceManager)
Map<String,Object>
validateConfiguration(String contentTypeId, Map formValues, List<Map<String,Object>> mappingValues)
Gets the configuration for creating/editing a collection of synchronizable contents.-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_contentTypeEP
private ContentTypeExtensionPoint _contentTypeEP
-
_csvImporter
private CSVImporter _csvImporter
-
-
Constructor Detail
-
ImportCSVFileHelper
public ImportCSVFileHelper()
-
-
Method Detail
-
service
public void service(ServiceManager serviceManager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
validateConfiguration
public Map<String,Object> validateConfiguration(String contentTypeId, Map formValues, List<Map<String,Object>> mappingValues) throws IOException
Gets the configuration for creating/editing a collection of synchronizable contents.- Parameters:
contentTypeId
- Content type idformValues
- map of form valuesmappingValues
- list of header and content attribute mapping- Returns:
- A map containing information about what is needed to create/edit a collection of synchronizable contents
- Throws:
IOException
- IOException while reading CSV
-
importContents
public Map<String,Object> importContents(Map config, Map formValues, List<Map<String,Object>> mappingValues) throws IOException
Gets the configuration for creating/editing a collection of synchronizable contents.- Parameters:
config
- get all CSV related parameters: path, separating/escaping char, charset and contentTypeformValues
- map of form valuesmappingValues
- list of header and content attribute mapping- Returns:
- A map containing information about what is needed to create/edit a collection of synchronizable contents
- Throws:
IOException
- IOException while reading CSV
-
_checkViewItemContainer
private boolean _checkViewItemContainer(ViewItem viewItem, Map<String,Object> mapping, Map<String,Object> result)
-
_checkViewItemContentContainer
private boolean _checkViewItemContentContainer(ViewElementAccessor viewElementAccessor, Map<String,Object> mapping, Map<String,Object> result, ContentAttributeDefinition contentAttributeDefinition)
-
_checkViewItemGroupContainer
private boolean _checkViewItemGroupContainer(ViewItem viewItem, Map<String,Object> mapping, Map<String,Object> result)
-
generateNestedMap
private static Map<String,Object> generateNestedMap(Map<String,Object> map, String attributePath, String column, boolean isId)
-
deleteFile
public void deleteFile(String path) throws IOException
Delete the file related to the given path- Parameters:
path
- path of the file- Throws:
IOException
- if an error occurs while deleting the file
-
-