only register mdm clear job definition if it is not registered yet (#3740)
Co-authored-by: Ken Stevens <ken@smilecdr.com>
This commit is contained in:
parent
49d298dba1
commit
c3f34099fb
|
@ -44,6 +44,21 @@ public class JobDefinitionRegistry {
|
|||
|
||||
private final Map<String, TreeMap<Integer, JobDefinition<?>>> myJobs = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Add a job definition only if it is not registered
|
||||
* @param theDefinition
|
||||
* @return true if it did not already exist and was registered
|
||||
* @param <PT> the job parameter type for the definition
|
||||
*/
|
||||
public <PT extends IModelJson> boolean addJobDefinitionIfNotRegistered(@Nonnull JobDefinition<PT> theDefinition) {
|
||||
Optional<JobDefinition<?>> orig = getJobDefinition(theDefinition.getJobDefinitionId(), theDefinition.getJobDefinitionVersion());
|
||||
if (orig.isPresent()) {
|
||||
return false;
|
||||
}
|
||||
addJobDefinition(theDefinition);
|
||||
return true;
|
||||
}
|
||||
|
||||
public <PT extends IModelJson> void addJobDefinition(@Nonnull JobDefinition<PT> theDefinition) {
|
||||
Validate.notNull(theDefinition);
|
||||
String jobDefinitionId = theDefinition.getJobDefinitionId();
|
||||
|
|
|
@ -24,6 +24,6 @@ public class MdmBatch2Config {
|
|||
@PostConstruct
|
||||
public void start() {
|
||||
JobDefinition jobDefinition = myApplicationContext.getBean(MDM_CLEAR_JOB_BEAN_NAME, JobDefinition.class);
|
||||
myJobDefinitionRegistry.addJobDefinition(jobDefinition);
|
||||
myJobDefinitionRegistry.addJobDefinitionIfNotRegistered(jobDefinition);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue