RED-9740: Added migration to add graphic type
This commit is contained in:
parent
6e2c2dfbdc
commit
1fcd3ecd6b
@ -0,0 +1,75 @@
|
|||||||
|
package com.iqser.red.service.persistence.management.v1.processor.migration.migrations;
|
||||||
|
|
||||||
|
import static com.iqser.red.service.persistence.management.v1.processor.utils.TypeIdUtils.toTypeId;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.migration.Migration;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DictionaryPersistenceService;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.DossierTemplatePersistenceService;
|
||||||
|
import com.iqser.red.service.persistence.management.v1.processor.service.persistence.repository.TypeRepository;
|
||||||
|
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Setter
|
||||||
|
@Service
|
||||||
|
public class AddGraphicDictionaryType19 extends Migration {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DossierTemplatePersistenceService dossierTemplatePersistenceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DictionaryPersistenceService dictionaryPersistenceService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TypeRepository typeRepository;
|
||||||
|
|
||||||
|
private static final String NAME = "Migration to add experimental Graphic Type";
|
||||||
|
private static final long VERSION = 19;
|
||||||
|
|
||||||
|
|
||||||
|
public AddGraphicDictionaryType19() {
|
||||||
|
|
||||||
|
super(NAME, VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void migrate() {
|
||||||
|
|
||||||
|
dossierTemplatePersistenceService.getAllDossierTemplates()
|
||||||
|
.forEach(dossierTemplateEntity -> {
|
||||||
|
|
||||||
|
String typeId = toTypeId("graphic", dossierTemplateEntity.getId(), null);
|
||||||
|
|
||||||
|
typeRepository.findById(typeId).ifPresentOrElse(type -> {
|
||||||
|
dictionaryPersistenceService.setExperimentalTrue(typeId);
|
||||||
|
log.info("Updated Graphic Type {} to experimental", typeId);
|
||||||
|
}, () -> {
|
||||||
|
dictionaryPersistenceService.addType("graphic",
|
||||||
|
dossierTemplateEntity.getId(),
|
||||||
|
"#ffbdfd",
|
||||||
|
"#8df06c",
|
||||||
|
"#c498fa",
|
||||||
|
998,
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
"Empty dictionary used to configure graphic colors.",
|
||||||
|
false,
|
||||||
|
"Graphic",
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
true);
|
||||||
|
log.info("Added Graphic Type {}", typeId);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -317,4 +317,15 @@ public class DictionaryPersistenceService {
|
|||||||
typeRepository.updateRankForType(typeId, newRank);
|
typeRepository.updateRankForType(typeId, newRank);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void setExperimentalTrue(String typeId){
|
||||||
|
typeRepository.findById(typeId).ifPresent(type -> {
|
||||||
|
type.setVersion(type.getVersion() + 1);
|
||||||
|
type.setSystemManaged(true);
|
||||||
|
type.setExperimental(true);
|
||||||
|
typeRepository.saveAndFlush(type);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user