Package org.ametys.plugins.contentio.csv
Class CSVImporter
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.contentio.csv.CSVImporter
- All Implemented Interfaces:
LogEnabled,Component,Serviceable
- Direct Known Subclasses:
SkillCSVImporter
Import contents from an uploaded CSV file.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static final recordSynchronize result -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List<Expression> additionalExpressionToRetrieveContent(Map<String, Object> mapping, Map<String, String> row, ContentType contentType, Optional<? extends Content> parentContent, Map<String, Object> additionalTransientVars, List<String> valuesUsedAsIds) Returns a list of additional expression to retrieve the existing contentimportContentsFromCSV(Map<String, Object> mapping, View view, ContentType contentType, ICsvListReader listReader, int createAction, int editAction, String workflowName, String language, SynchronizeModeEnumerator.ImportMode importMode, Optional<? extends Content> parentContent, Map<String, Object> additionalTransientVars) Extract contents from CSV fileprotected CSVImporter.SynchronizeResultprocessContent(View view, Map<String, String> row, ContentType contentType, Map<String, Object> mapping, int createAction, int editAction, String workflowName, String language, List<ViewItem> errors, SynchronizeModeEnumerator.ImportMode importMode, Optional<? extends Content> parentContent, Map<String, Object> additionalTransientVars) Process content for CSV import or synchronizationvoidservice(ServiceManager smanager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
Avalon Role -
RESULT_CONTENT_IDS
Result key containing updated content's ids- See Also:
-
RESULT_NB_ERRORS
Result key containing number of errors- See Also:
-
RESULT_NB_WARNINGS
Result key containing number of warnings- See Also:
-
-
Constructor Details
-
CSVImporter
public CSVImporter()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
importContentsFromCSV
public Map<String,Object> importContentsFromCSV(Map<String, Object> mapping, View view, ContentType contentType, ICsvListReader listReader, int createAction, int editAction, String workflowName, String language, SynchronizeModeEnumerator.ImportMode importMode, Optional<? extends Content> parentContent, Map<String, throws IOExceptionObject> additionalTransientVars) Extract contents from CSV file- Parameters:
mapping- mapping of content attributes and CSV file headerview- View of importing contentcontentType- content type to importlistReader- mapReader to parse CSV filecreateAction- creation action ideditAction- edition action idworkflowName- workflow namelanguage- language of created content.importMode- The import modeparentContent- Optional parent contentadditionalTransientVars- The optional additional transient vars to add to the transient vars- Returns:
- list of created contents
- Throws:
IOException- IOException while reading CSV
-
processContent
protected CSVImporter.SynchronizeResult processContent(View view, Map<String, String> row, ContentType contentType, Map<String, throws ExceptionObject> mapping, int createAction, int editAction, String workflowName, String language, List<ViewItem> errors, SynchronizeModeEnumerator.ImportMode importMode, Optional<? extends Content> parentContent, Map<String, Object> additionalTransientVars) Process content for CSV import or synchronization- Parameters:
view- The viewrow- The row containing the valuescontentType- The content typemapping- The mappingcreateAction- The create actioneditAction- The edit actionworkflowName- The wokflow namelanguage- The languageerrors- The errorsimportMode- The import modeparentContent- The parent contentadditionalTransientVars- The additional transient vars- Returns:
- The synchronize result
- Throws:
Exception- If an error occurs
-
additionalExpressionToRetrieveContent
protected List<Expression> additionalExpressionToRetrieveContent(Map<String, Object> mapping, Map<String, String> row, ContentType contentType, Optional<? extends Content> parentContent, Map<String, Object> additionalTransientVars, List<String> valuesUsedAsIds) Returns a list of additional expression to retrieve the existing content- Parameters:
mapping- The mappingrow- The rowcontentType- The content typeparentContent- The parent contentadditionalTransientVars- Additional transients varsvaluesUsedAsIds- The values used as ids, if some values are added in expression, they can be added in this list to be printed in error logs- Returns:
- a list of additional expression to retrieve the existing content
-