Class JobsManagementServiceImpl
- java.lang.Object
-
- co.mastermindcms.modules.services.JobsManagementServiceImpl
-
- All Implemented Interfaces:
JobsManagementService
@Service public class JobsManagementServiceImpl extends java.lang.Object implements JobsManagementService
-
-
Field Summary
Fields Modifier and Type Field Description private JobRepository
jobRepository
private static com.fasterxml.jackson.databind.ObjectMapper
mapper
private org.springframework.data.mongodb.core.MongoTemplate
mongoTemplate
private java.util.Map<java.lang.String,java.lang.Thread>
runningJobs
private SequenceGeneratorService
sequenceGenerator
private UserManagementService
userManagementService
-
Constructor Summary
Constructors Constructor Description JobsManagementServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cancelJob(java.lang.String jobId)
Cancels the job with the specified ID.Job
createJob(Job job)
This method creates a database entity.Job
createJob(java.util.LinkedHashMap<java.lang.String,java.lang.Object> jobAsMap)
This method creates a database entity from a map-representation.Job
decrementJob(java.lang.String jobId, int step)
This method save an updates of database entity.JobRepository
getRepository()
Job
incrementJob(java.lang.String jobId, int step)
This method save an updates of database entity.void
init()
void
removeJobAndClean(java.lang.String jobId)
This method removes a database entity and clean all relationships from another entities.void
removeJobsByIds(java.util.ArrayList<java.lang.String> jobsIds)
This method removes a list of database entities.Job
saveJob(Job job)
This method save an updates of database entity.Job
saveJob(java.util.LinkedHashMap<java.lang.String,java.lang.Object> jobAsMap)
This method save an updates of database entity.co.mastermindcms.modules.beans.SearchResponse
searchJobs(co.mastermindcms.modules.beans.SearchRequest request)
This method does search requests and returns data as list.co.mastermindcms.modules.beans.SearchResponse
searchJobs(java.util.LinkedHashMap<java.lang.String,java.lang.Object> requestMap)
This method does search requests and returns data as list.void
setUnfinishedJobsToFailed()
This method updates a list of database entities.Job
startJob(java.lang.String type, int total)
This method save an updates of database entity.Job
toCanceled(java.lang.String jobId)
This method save an updates of database entity.Job
toDone(java.lang.String jobId)
This method save an updates of database entity.Job
toFailed(java.lang.String jobId)
This method save an updates of database entity.Job
updateProgress(java.lang.String jobId, int progress)
This method save an updates of database entity.
-
-
-
Field Detail
-
userManagementService
@Autowired private UserManagementService userManagementService
-
mongoTemplate
@Autowired private org.springframework.data.mongodb.core.MongoTemplate mongoTemplate
-
sequenceGenerator
@Autowired private SequenceGeneratorService sequenceGenerator
-
jobRepository
@Autowired private JobRepository jobRepository
-
runningJobs
private java.util.Map<java.lang.String,java.lang.Thread> runningJobs
-
mapper
private static final com.fasterxml.jackson.databind.ObjectMapper mapper
-
-
Method Detail
-
getRepository
public JobRepository getRepository()
- Specified by:
getRepository
in interfaceJobsManagementService
-
init
@PostConstruct public void init()
-
searchJobs
public co.mastermindcms.modules.beans.SearchResponse searchJobs(java.util.LinkedHashMap<java.lang.String,java.lang.Object> requestMap)
Description copied from interface:JobsManagementService
This method does search requests and returns data as list.- Specified by:
searchJobs
in interfaceJobsManagementService
- Parameters:
requestMap
- JSON-object of request contains an instructions for search queries- Returns:
- data transport entities as list
-
searchJobs
public co.mastermindcms.modules.beans.SearchResponse searchJobs(co.mastermindcms.modules.beans.SearchRequest request)
Description copied from interface:JobsManagementService
This method does search requests and returns data as list.- Specified by:
searchJobs
in interfaceJobsManagementService
- Parameters:
request
- JSON-object of request contains an instructions for search queries- Returns:
- data transport entities as list
-
createJob
public Job createJob(java.util.LinkedHashMap<java.lang.String,java.lang.Object> jobAsMap)
Description copied from interface:JobsManagementService
This method creates a database entity from a map-representation.- Specified by:
createJob
in interfaceJobsManagementService
- Parameters:
jobAsMap
- map-representation of database entity- Returns:
- created instance of database entity
-
createJob
public Job createJob(Job job)
Description copied from interface:JobsManagementService
This method creates a database entity.- Specified by:
createJob
in interfaceJobsManagementService
- Parameters:
job
- database entity- Returns:
- created instance of database entity
-
saveJob
public Job saveJob(java.util.LinkedHashMap<java.lang.String,java.lang.Object> jobAsMap)
Description copied from interface:JobsManagementService
This method save an updates of database entity.- Specified by:
saveJob
in interfaceJobsManagementService
- Parameters:
jobAsMap
- map-representation of database entity- Returns:
- saved instance of database entity
-
saveJob
public Job saveJob(Job job)
Description copied from interface:JobsManagementService
This method save an updates of database entity.- Specified by:
saveJob
in interfaceJobsManagementService
- Parameters:
job
- database entity for a update- Returns:
- saved instance of database entity
-
startJob
public Job startJob(java.lang.String type, int total)
Description copied from interface:JobsManagementService
This method save an updates of database entity.- Specified by:
startJob
in interfaceJobsManagementService
- Parameters:
type
- database entity type for a updatetotal
- count of iterations- Returns:
- saved instance of database entity
-
cancelJob
public void cancelJob(java.lang.String jobId)
Description copied from interface:JobsManagementService
Cancels the job with the specified ID.- Specified by:
cancelJob
in interfaceJobsManagementService
- Parameters:
jobId
- the ID of the job to be canceled
-
toCanceled
public Job toCanceled(java.lang.String jobId)
Description copied from interface:JobsManagementService
This method save an updates of database entity.- Specified by:
toCanceled
in interfaceJobsManagementService
- Parameters:
jobId
- database entity id for a update- Returns:
- saved instance of database entity
-
toDone
public Job toDone(java.lang.String jobId)
Description copied from interface:JobsManagementService
This method save an updates of database entity.- Specified by:
toDone
in interfaceJobsManagementService
- Parameters:
jobId
- database entity id for a update- Returns:
- saved instance of database entity
-
updateProgress
public Job updateProgress(java.lang.String jobId, int progress)
Description copied from interface:JobsManagementService
This method save an updates of database entity.- Specified by:
updateProgress
in interfaceJobsManagementService
- Parameters:
jobId
- database entity id for a updateprogress
- percentage of job is done- Returns:
- saved instance of database entity
-
incrementJob
public Job incrementJob(java.lang.String jobId, int step)
Description copied from interface:JobsManagementService
This method save an updates of database entity.- Specified by:
incrementJob
in interfaceJobsManagementService
- Parameters:
jobId
- database entity id for a updatestep
- step of incremental- Returns:
- saved instance of database entity
-
decrementJob
public Job decrementJob(java.lang.String jobId, int step)
Description copied from interface:JobsManagementService
This method save an updates of database entity.- Specified by:
decrementJob
in interfaceJobsManagementService
- Parameters:
jobId
- database entity id for a updatestep
- step of decremental- Returns:
- saved instance of database entity
-
toFailed
public Job toFailed(java.lang.String jobId)
Description copied from interface:JobsManagementService
This method save an updates of database entity.- Specified by:
toFailed
in interfaceJobsManagementService
- Parameters:
jobId
- database entity id for a update- Returns:
- saved instance of database entity
-
setUnfinishedJobsToFailed
public void setUnfinishedJobsToFailed()
Description copied from interface:JobsManagementService
This method updates a list of database entities.- Specified by:
setUnfinishedJobsToFailed
in interfaceJobsManagementService
-
removeJobsByIds
public void removeJobsByIds(java.util.ArrayList<java.lang.String> jobsIds)
Description copied from interface:JobsManagementService
This method removes a list of database entities.- Specified by:
removeJobsByIds
in interfaceJobsManagementService
- Parameters:
jobsIds
- the list of database entities which will be removed
-
removeJobAndClean
public void removeJobAndClean(java.lang.String jobId)
Description copied from interface:JobsManagementService
This method removes a database entity and clean all relationships from another entities.- Specified by:
removeJobAndClean
in interfaceJobsManagementService
- Parameters:
jobId
- identification for database entity which will be removed
-
-