Package org.cyclos.impl.system
Class ImportServiceImpl
-
- All Implemented Interfaces:
CRUDServiceLocal<ImportedFile,ImportedFileDTO,ImportedFileData,ImportedFileDataParams>,ImportServiceLocal,CRUDService<ImportedFileDTO,ImportedFileData,ImportedFileDataParams>,CRUDWithConfirmationPasswordService<ImportedFileDTO,ImportedFileData,ImportedFileDataParams>,Service,ImportService
@Service public class ImportServiceImpl extends CRUDServiceImpl<ImportedFile,QImportedFile,ImportedFileDTO,ImportedFileData,ImportedFileDataParams> implements ImportServiceLocal
implementation forImportService
-
-
Field Summary
Fields Modifier and Type Field Description protected InvokerHandlerinvokerHandlerprotected ServiceInvokerHandlerserviceInvokerHandler-
Fields inherited from class org.cyclos.impl.CRUDServiceImpl
$, ATTR_CURRENT_COPY, cacheHandler, dtoClass, entityClass, idPath, internalNamePath, namePath, ownerEntityIdPath, ownerEntityPath, ownerEntityPropertyName, passwordHandler, richTextHandler, withConfirmationPassword
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
Fields inherited from interface org.cyclos.impl.system.ImportServiceLocal
ATTR_ENTITY, ATTR_ERROR, ATTR_FILE, ATTR_LINE, ATTR_NEW_STATUS, ATTR_OLD_STATUS
-
-
Constructor Summary
Constructors Constructor Description ImportServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanabort(Long importedFileId)Attempts to trigger the abort process of the given import.longarchiveImports()Gets the old imports that were not finished and deletes them.voidfillImportedLineValues(ImportedLine importedLine, ImportedLineVO importedLineVO)Fills the values of an importedLineVOprotected ImportedFileDatagetData(ImportedFile file)Returns details data for the given entityprotected CreateDeviceConfirmationParamsgetDeviceConfirmationParams(ImportedFileDTO dto, ImportedFile entity, CRUDOperation operation)If the confirmation password must be checked then subclasses must overwrite this method to return a no-nullCreateDeviceConfirmationParamsobject.LonggetImportedFileIdForLine(Long importedLineId)Returns the imported file id of the imported line.ImportedLineDatagetImportedLineData(Long importedLineId)Returns the imported line dataImportProgressVOgetImportProgress(Long importedFileId)Returns a double between 0 and 1 indicating the progress of the given import.ImportTypegetImportType(ImportedFileDTO dto)Returns the import type which matches with the given dtoImportedFileSearchDatagetSearchData(ImportSearchContext context, UserLocatorVO locator)Returns information to perform searches over imports.voidinitialize()voidmarkAsSkipped(Long importedFileId, List<Long> lineIds, boolean skipped)Sets if the lines should be skipped by the import process or not based on the skipped parameter.ImportedFilenewEntity(ImportedFileDataParams params)Should be implemented in order to instantiate a new entity based on the given context parametersprotected voidonBeforeRemove(ImportedFile file)May be overridden in order to perform custom logic before removing an entityprotected ObjectonBeforeSave(ImportedFile entity, ImportedFile currentCopy)May be overridden in order to perform custom logic before saving an entity.voidprocess(Long importedFileId)Starts an importprotected voidprocess(ImportedFile importedFile)protected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the networkprotected ValidatorresolveValidator(ImportedFileDTO dto)longresumeImport(Long importedFileId)Triggers the execution of an import.voidsaveDescription(Long importedFileId, String description)Saves the description for the specified imported file id.voidsaveImportedLine(ImportedLineDTO importedLineDTO)Saves the values of the imported linePage<ImportedFileVO>search(ImportedFileQuery params)Returns the imports that satisfy the query restrictions.Page<ImportedLineVO>searchImportedLines(ImportedLineQuery params)Returns the imported lines that matches the query restrictions.protected booleanshouldCheckConfirmationPassword(ImportedFile file, CRUDOperation operation)Controls whether confirmation password should be checked for the given entity and operation.protected voidupdateImportedLineSkipCounter(Long importedFileId)protected voidupdateImportedLineValidationErrorCounter(Long importedFileId)protected voidupdateImportedLineValidationSuccessCounter(Long importedFileId)Longupload(ImportedFileDTO dto, SerializableInputStream input, String confirmationPassword)Uploads a file to be imported.-
Methods inherited from class org.cyclos.impl.CRUDServiceImpl
addCustomInternalNameValidations, addCustomNameValidations, checkConfirmationPassword, doRemove, find, findAll, from, getConfirmationPasswordInput, getConfirmationPasswordInputForRemove, getData, getDataForNew, getEntityClass, getEntityInternalNameKey, getExcludedPropertiesToDTO, getExcludedPropertiesToEntity, getNameLabel, getUniqueInternalNameQuery, getUniqueNameQuery, isEntityInternalNameRequired, isNameRequired, load, logEntity, onAfterRemove, onAfterSave, preProcessCurrentCopy, remove, remove, removeAll, removeAll, removeAllWithConfirmationPassword, removeWithConfirmationPassword, resolveDTOType, resolveEntityType, resolveExtensionPointAccessor, save, saveOrder, saveSkippingEntityLog, saveWithConfirmationPassword, subClassMappings, toDTO, toEntity, validate
-
Methods inherited from class org.cyclos.impl.BaseServiceImpl
initializeNetworkMappings
-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.services.CRUDService
getData, getDataForNew, load, remove, removeAll, save
-
Methods inherited from interface org.cyclos.impl.CRUDServiceLocal
find, findAll, getEntityClass, remove, removeAll, saveEntity, saveSkippingEntityLog, toDTO, toEntity, validate
-
Methods inherited from interface org.cyclos.services.CRUDWithConfirmationPasswordService
getConfirmationPasswordInputForRemove, removeAllWithConfirmationPassword, removeWithConfirmationPassword, saveWithConfirmationPassword
-
-
-
-
Field Detail
-
invokerHandler
@Autowired protected InvokerHandler invokerHandler
-
serviceInvokerHandler
@Autowired protected ServiceInvokerHandler serviceInvokerHandler
-
-
Method Detail
-
abort
public boolean abort(Long importedFileId)
Description copied from interface:ImportServiceAttempts to trigger the abort process of the given import. If can returns true, otherwise returns false.- Specified by:
abortin interfaceImportService
-
archiveImports
public long archiveImports()
Description copied from interface:ImportServiceLocalGets the old imports that were not finished and deletes them. Gets the finished old imports and removes the associated information (lines and values) leaving some stats and dates.- Specified by:
archiveImportsin interfaceImportServiceLocal
-
fillImportedLineValues
public void fillImportedLineValues(ImportedLine importedLine, ImportedLineVO importedLineVO)
Description copied from interface:ImportServiceLocalFills the values of an importedLineVO- Specified by:
fillImportedLineValuesin interfaceImportServiceLocal
-
getImportedFileIdForLine
public Long getImportedFileIdForLine(Long importedLineId)
Description copied from interface:ImportServiceLocalReturns the imported file id of the imported line.- Specified by:
getImportedFileIdForLinein interfaceImportServiceLocal
-
getImportedLineData
public ImportedLineData getImportedLineData(Long importedLineId)
Description copied from interface:ImportServiceReturns the imported line data- Specified by:
getImportedLineDatain interfaceImportService
-
getImportProgress
public ImportProgressVO getImportProgress(Long importedFileId)
Description copied from interface:ImportServiceReturns a double between 0 and 1 indicating the progress of the given import.- Specified by:
getImportProgressin interfaceImportService
-
getImportType
public ImportType getImportType(ImportedFileDTO dto)
Description copied from interface:ImportServiceLocalReturns the import type which matches with the given dto- Specified by:
getImportTypein interfaceImportServiceLocal
-
getSearchData
public ImportedFileSearchData getSearchData(ImportSearchContext context, UserLocatorVO locator) throws FrameworkException
Description copied from interface:ImportServiceReturns information to perform searches over imports.- Specified by:
getSearchDatain interfaceImportService- Throws:
FrameworkException
-
initialize
@PostConstruct public void initialize()
-
markAsSkipped
public void markAsSkipped(Long importedFileId, List<Long> lineIds, boolean skipped)
Description copied from interface:ImportServiceSets if the lines should be skipped by the import process or not based on the skipped parameter. It is only possible to mark as skipped/not skipped the lines that were validated successfully.- Specified by:
markAsSkippedin interfaceImportService
-
newEntity
public ImportedFile newEntity(ImportedFileDataParams params)
Description copied from class:CRUDServiceImplShould be implemented in order to instantiate a new entity based on the given context parameters- Specified by:
newEntityin interfaceCRUDServiceLocal<ImportedFile,ImportedFileDTO,ImportedFileData,ImportedFileDataParams>- Specified by:
newEntityin classCRUDServiceImpl<ImportedFile,QImportedFile,ImportedFileDTO,ImportedFileData,ImportedFileDataParams>
-
process
public void process(Long importedFileId)
Description copied from interface:ImportServiceStarts an import- Specified by:
processin interfaceImportService
-
resumeImport
public long resumeImport(Long importedFileId)
Description copied from interface:ImportServiceLocalTriggers the execution of an import.- Specified by:
resumeImportin interfaceImportServiceLocal
-
saveDescription
public void saveDescription(Long importedFileId, String description) throws FrameworkException
Description copied from interface:ImportServiceSaves the description for the specified imported file id.- Specified by:
saveDescriptionin interfaceImportService- Throws:
FrameworkException
-
saveImportedLine
public void saveImportedLine(ImportedLineDTO importedLineDTO)
Description copied from interface:ImportServiceSaves the values of the imported line- Specified by:
saveImportedLinein interfaceImportService
-
search
public Page<ImportedFileVO> search(ImportedFileQuery params)
Description copied from interface:ImportServiceReturns the imports that satisfy the query restrictions.- Specified by:
searchin interfaceImportService
-
searchImportedLines
public Page<ImportedLineVO> searchImportedLines(ImportedLineQuery params)
Description copied from interface:ImportServiceReturns the imported lines that matches the query restrictions.- Specified by:
searchImportedLinesin interfaceImportService
-
upload
public Long upload(ImportedFileDTO dto, SerializableInputStream input, String confirmationPassword)
Description copied from interface:ImportServiceUploads a file to be imported. The confirmation password is only checked depending on the imported file type.- Specified by:
uploadin interfaceImportService- Returns:
- the imported file id.
- See Also:
ImportType.requiresConfirmationPassword()
-
getData
protected ImportedFileData getData(ImportedFile file)
Description copied from class:CRUDServiceImplReturns details data for the given entity- Specified by:
getDatain classCRUDServiceImpl<ImportedFile,QImportedFile,ImportedFileDTO,ImportedFileData,ImportedFileDataParams>
-
getDeviceConfirmationParams
protected CreateDeviceConfirmationParams getDeviceConfirmationParams(ImportedFileDTO dto, ImportedFile entity, CRUDOperation operation)
Description copied from class:CRUDServiceImplIf the confirmation password must be checked then subclasses must overwrite this method to return a no-nullCreateDeviceConfirmationParamsobject. This object is required to validate the confirmation when the operation was confirmed with a device.- Overrides:
getDeviceConfirmationParamsin classCRUDServiceImpl<ImportedFile,QImportedFile,ImportedFileDTO,ImportedFileData,ImportedFileDataParams>- Parameters:
dto- , it can be null, subclasses must take it into account. E.g: to disable a mobile phone for SMS, the confirmation password must be check and for this case there is no DTO instance.entity- never null, represents the current value (i.e before apply the dto).
-
onBeforeRemove
protected void onBeforeRemove(ImportedFile file)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic before removing an entity- Overrides:
onBeforeRemovein classCRUDServiceImpl<ImportedFile,QImportedFile,ImportedFileDTO,ImportedFileData,ImportedFileDataParams>
-
onBeforeSave
protected Object onBeforeSave(ImportedFile entity, ImportedFile currentCopy)
Description copied from class:CRUDServiceImplMay be overridden in order to perform custom logic before saving an entity. Any returned value will be passed to theCRUDServiceImpl.onAfterSave(BaseEntity, BaseEntity, Object)method- Overrides:
onBeforeSavein classCRUDServiceImpl<ImportedFile,QImportedFile,ImportedFileDTO,ImportedFileData,ImportedFileDataParams>
-
process
protected void process(ImportedFile importedFile)
-
registerNetworkMappings
protected void registerNetworkMappings(NetworkPathRegistry networkPathRegistry)
Description copied from class:BaseServiceImplNeeds to be overridden by subclasses to register the path up to the network- Specified by:
registerNetworkMappingsin classBaseServiceImpl
-
resolveValidator
protected Validator resolveValidator(ImportedFileDTO dto)
- Specified by:
resolveValidatorin classCRUDServiceImpl<ImportedFile,QImportedFile,ImportedFileDTO,ImportedFileData,ImportedFileDataParams>
-
shouldCheckConfirmationPassword
protected boolean shouldCheckConfirmationPassword(ImportedFile file, CRUDOperation operation)
Description copied from class:CRUDServiceImplControls whether confirmation password should be checked for the given entity and operation. By default returns true if this service indirectly implementsCRUDWithConfirmationPasswordService(for example, if the remote service interface extends it).- Overrides:
shouldCheckConfirmationPasswordin classCRUDServiceImpl<ImportedFile,QImportedFile,ImportedFileDTO,ImportedFileData,ImportedFileDataParams>
-
updateImportedLineSkipCounter
protected void updateImportedLineSkipCounter(Long importedFileId)
-
updateImportedLineValidationErrorCounter
protected void updateImportedLineValidationErrorCounter(Long importedFileId)
-
updateImportedLineValidationSuccessCounter
protected void updateImportedLineValidationSuccessCounter(Long importedFileId)
-
-