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
public class CSVImporter extends AbstractLogEnabled implements Component, Serviceable
Import contents from an uploaded CSV file.
-
-
Field Summary
Fields Modifier and Type Field Description private ContentTypeExtensionPoint_contentTypeEPprivate ContentWorkflowHelper_contentWorkflowHelperprivate I18nUtils_i18nUtilsprivate AmetysObjectResolver_resolverstatic StringROLEAvalon Role
-
Constructor Summary
Constructors Constructor Description CSVImporter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void_editContent(int editAction, Map<String,Object> values, ModifiableWorkflowAwareContent content)private Object_getAttributeDefinitionValues(Map<String,Object> mapping, Map<String,String> row, ElementDefinition elementDefinition, String language)private Map<String,Object>_getCompositeValues(ModifiableModelAwareDataHolder dataHolder, ViewItem viewItem, Map<String,String> row, int createAction, int editAction, String workflowName, String language, List<ViewItem> children, Map<String,Object> nestedMapValues, List<ViewItem> errors, String prefix)private Object_getContentAttributeDefinitionValues(ViewItem viewItem, Map<String,Object> mapping, Map<String,String> row, int createAction, int editAction, String workflowName, String language, ViewElement viewElement, ElementDefinition elementDefinition, List<ViewItem> errors)private ModifiableWorkflowAwareContent_getOrCreateContent(Map<String,Object> mapping, Map<String,String> row, ContentType contentType, String workflowName, int createAction, String language, ViewItem viewItem)private SynchronizableRepeater_getRepeaterValues(ModifiableModelAwareDataHolder dataHolder, ModelViewItemGroup viewItem, Map<String,String> row, int createAction, int editAction, String workflowName, String language, List<ViewItem> children, Map<String,Object> nestedMap, List<ViewItem> errors, String prefix)private Object_getValue(ModifiableModelAwareDataHolder dataHolder, ViewItem viewItem, Map<String,Object> mapping, Map<String,String> row, int createAction, int editAction, String workflowName, String language, List<ViewItem> errors, String prefix)private boolean_isId(ViewItem viewItem, String attributeName)private Content_processContent(View view, Map<String,String> row, ContentType contentType, Map<String,Object> mapping, int createAction, int editAction, String workflowName, String language, List<ViewItem> errors)Map<String,Object>importContentsFromCSV(Map<String,Object> mapping, View view, ContentType contentType, ICsvListReader listReader, int createAction, int editAction, String workflowName, String language)Extract contents from CSV filevoidservice(ServiceManager smanager)-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_contentWorkflowHelper
private ContentWorkflowHelper _contentWorkflowHelper
-
_contentTypeEP
private ContentTypeExtensionPoint _contentTypeEP
-
_resolver
private AmetysObjectResolver _resolver
-
_i18nUtils
private I18nUtils _i18nUtils
-
-
Constructor Detail
-
CSVImporter
public CSVImporter()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- 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) throws IOException
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.- Returns:
- list of created contents
- Throws:
IOException- IOException while reading CSV
-
_processContent
private Content _processContent(View view, Map<String,String> row, ContentType contentType, Map<String,Object> mapping, int createAction, int editAction, String workflowName, String language, List<ViewItem> errors) throws Exception
- Throws:
Exception
-
_editContent
private void _editContent(int editAction, Map<String,Object> values, ModifiableWorkflowAwareContent content) throws com.opensymphony.workflow.WorkflowException
- Throws:
com.opensymphony.workflow.WorkflowException
-
_getValue
private Object _getValue(ModifiableModelAwareDataHolder dataHolder, ViewItem viewItem, Map<String,Object> mapping, Map<String,String> row, int createAction, int editAction, String workflowName, String language, List<ViewItem> errors, String prefix) throws Exception
- Throws:
Exception
-
_getCompositeValues
private Map<String,Object> _getCompositeValues(ModifiableModelAwareDataHolder dataHolder, ViewItem viewItem, Map<String,String> row, int createAction, int editAction, String workflowName, String language, List<ViewItem> children, Map<String,Object> nestedMapValues, List<ViewItem> errors, String prefix)
-
_getRepeaterValues
private SynchronizableRepeater _getRepeaterValues(ModifiableModelAwareDataHolder dataHolder, ModelViewItemGroup viewItem, Map<String,String> row, int createAction, int editAction, String workflowName, String language, List<ViewItem> children, Map<String,Object> nestedMap, List<ViewItem> errors, String prefix)
-
_getContentAttributeDefinitionValues
private Object _getContentAttributeDefinitionValues(ViewItem viewItem, Map<String,Object> mapping, Map<String,String> row, int createAction, int editAction, String workflowName, String language, ViewElement viewElement, ElementDefinition elementDefinition, List<ViewItem> errors) throws Exception
- Throws:
Exception
-
_getAttributeDefinitionValues
private Object _getAttributeDefinitionValues(Map<String,Object> mapping, Map<String,String> row, ElementDefinition elementDefinition, String language)
-
_getOrCreateContent
private ModifiableWorkflowAwareContent _getOrCreateContent(Map<String,Object> mapping, Map<String,String> row, ContentType contentType, String workflowName, int createAction, String language, ViewItem viewItem) throws ContentImportException, com.opensymphony.workflow.WorkflowException
- Throws:
ContentImportExceptioncom.opensymphony.workflow.WorkflowException
-
-