com.elasticpath.service.dataimport.impl
Class ImportServiceImpl

java.lang.Object
  extended by com.elasticpath.service.impl.AbstractEpServiceImpl
      extended by com.elasticpath.service.impl.AbstractEpPersistenceServiceImpl
          extended by com.elasticpath.service.dataimport.impl.ImportServiceImpl
All Implemented Interfaces:
ImportService, EpPersistenceService, EpService

public class ImportServiceImpl
extends AbstractEpPersistenceServiceImpl
implements ImportService

A defautl implementation of ImportService.


Constructor Summary
ImportServiceImpl()
           
 
Method Summary
 ImportDataType findImportDataType(java.lang.String name)
          Find an import data type by name.
 ImportJob findImportJob(java.lang.String name)
          Find an import job by name.
 ImportJob getImportJob(long importJobUid)
          Get the import job with the given UID.
 ImportType getImportType(int importTypeId)
          Returns the import type with the given id.
 java.lang.Object getObject(long uid)
          Returns an import job.
 java.util.List getPreviewData(ImportJob importJob)
          Returns the preview data of the import data file.
 ImportRunningJob getRunningJob()
          Returns the running import job.
 java.util.List getTitleLine(ImportJob importJob)
          Returns the title line of the import csv data file.
 java.util.List listImportDataTypes()
          List all import data types.
 java.util.List listImportJobs()
          List all saved import jobs.
 java.util.List listImportTypes()
          List all import types.
 java.util.List runImportJob(ImportJob importJob)
          Run the import job.
 void saveOrUpdateImportJob(ImportJob importJob)
          Save or update the given importjob.
 java.util.List validataCsvFormat(ImportJob importJob)
          Validate the csv format of the import data file.
 java.util.List validateMappings(ImportJob importJob)
          Validate the import mappings specified in the importjob.
 
Methods inherited from class com.elasticpath.service.impl.AbstractEpPersistenceServiceImpl
getPersistenceEngine, setPersistenceEngine
 
Methods inherited from class com.elasticpath.service.impl.AbstractEpServiceImpl
getElasticPath, setElasticPath
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.elasticpath.service.EpPersistenceService
getPersistenceEngine, setPersistenceEngine
 
Methods inherited from interface com.elasticpath.service.EpService
getElasticPath, setElasticPath
 

Constructor Detail

ImportServiceImpl

public ImportServiceImpl()
Method Detail

findImportDataType

public ImportDataType findImportDataType(java.lang.String name)
Find an import data type by name.

Specified by:
findImportDataType in interface ImportService
Parameters:
name - the import data type name
Returns:
the import data type of the given name if it exist, otherwise, null.

findImportJob

public ImportJob findImportJob(java.lang.String name)
Find an import job by name.

Specified by:
findImportJob in interface ImportService
Parameters:
name - the import job name
Returns:
the import job of the given name if it exist, otherwise, null.

getImportJob

public ImportJob getImportJob(long importJobUid)
                       throws EpServiceException
Get the import job with the given UID. Return null if no matching record exists.

Specified by:
getImportJob in interface ImportService
Parameters:
importJobUid - the importJob UID, give 0 if you want to create a new import job.
Returns:
the importJob if UID exists, otherwise null
Throws:
EpServiceException - - in case of any errors

getImportType

public ImportType getImportType(int importTypeId)
Returns the import type with the given id.

Specified by:
getImportType in interface ImportService
Parameters:
importTypeId - the import type id
Returns:
the import type with the given id

getObject

public java.lang.Object getObject(long uid)
                           throws EpServiceException
Returns an import job.

Specified by:
getObject in interface EpPersistenceService
Parameters:
uid - the persistent instance uid
Returns:
the persistent instance if exists, otherwise null
Throws:
EpServiceException - - in case of any errors

getPreviewData

public java.util.List getPreviewData(ImportJob importJob)
Returns the preview data of the import data file.

Specified by:
getPreviewData in interface ImportService
Parameters:
importJob - the import job
Returns:
a list of records for previewing

getRunningJob

public ImportRunningJob getRunningJob()
Returns the running import job.

Specified by:
getRunningJob in interface ImportService
Returns:
the running import job

getTitleLine

public java.util.List getTitleLine(ImportJob importJob)
Returns the title line of the import csv data file.

Specified by:
getTitleLine in interface ImportService
Parameters:
importJob - the import job
Returns:
a list of fields of the title line

listImportDataTypes

public java.util.List listImportDataTypes()
List all import data types.

Specified by:
listImportDataTypes in interface ImportService
Returns:
a list of import data types

listImportJobs

public java.util.List listImportJobs()
List all saved import jobs.

Specified by:
listImportJobs in interface ImportService
Returns:
a list of saved import jobs.

listImportTypes

public java.util.List listImportTypes()
List all import types.

Specified by:
listImportTypes in interface ImportService
Returns:
a list of import types.

runImportJob

public java.util.List runImportJob(ImportJob importJob)
                            throws AnotherImportJobRunningException
Run the import job.

Specified by:
runImportJob in interface ImportService
Parameters:
importJob - the import job to run
Returns:
a list of lines that failed validation. If all lines are good, then returns an empty list.
Throws:
AnotherImportJobRunningException - when another job is still running

saveOrUpdateImportJob

public void saveOrUpdateImportJob(ImportJob importJob)
                           throws ImportJobExistException
Save or update the given importjob.

Specified by:
saveOrUpdateImportJob in interface ImportService
Parameters:
importJob - the importJob to save or update
Throws:
ImportJobExistException - - if the specified import job name is already in use.

validataCsvFormat

public java.util.List validataCsvFormat(ImportJob importJob)
Validate the csv format of the import data file.

Specified by:
validataCsvFormat in interface ImportService
Parameters:
importJob - the import job
Returns:
a list of lines that not complying with the csv format. If all lines are good, then returns an empty list.

validateMappings

public java.util.List validateMappings(ImportJob importJob)
Validate the import mappings specified in the importjob.

Specified by:
validateMappings in interface ImportService
Parameters:
importJob - the import job
Returns:
a list of lines that not complying with the mappings. If all lines are good, then returns an empty list.