chore: Split get existing entities for refactor (#29055)
This commit is contained in:
parent
c1884fa25c
commit
bcf75900ae
|
|
@ -68,21 +68,10 @@ public class ActionCollectionRefactoringServiceCEImpl implements EntityRefactori
|
|||
.flatMap(actionCollection -> {
|
||||
final ActionCollectionDTO unpublishedCollection = actionCollection.getUnpublishedCollection();
|
||||
|
||||
return astService
|
||||
.replaceValueInMustacheKeys(
|
||||
new HashSet<>(Collections.singletonList(
|
||||
new MustacheBindingToken(unpublishedCollection.getBody(), 0, true))),
|
||||
oldName,
|
||||
newName,
|
||||
evalVersion,
|
||||
oldNamePattern,
|
||||
true)
|
||||
.flatMap(replacedMap -> {
|
||||
Optional<String> replacedValue =
|
||||
replacedMap.values().stream().findFirst();
|
||||
// This value should always be there
|
||||
if (replacedValue.isPresent()) {
|
||||
unpublishedCollection.setBody(replacedValue.get());
|
||||
return this.refactorNameInActionCollection(
|
||||
unpublishedCollection, oldName, newName, evalVersion, oldNamePattern)
|
||||
.flatMap(isPresent -> {
|
||||
if (Boolean.TRUE.equals(isPresent)) {
|
||||
return actionCollectionService.save(actionCollection);
|
||||
}
|
||||
return Mono.just(actionCollection);
|
||||
|
|
@ -93,6 +82,32 @@ public class ActionCollectionRefactoringServiceCEImpl implements EntityRefactori
|
|||
return actionCollectionsMono.then();
|
||||
}
|
||||
|
||||
protected Mono<Boolean> refactorNameInActionCollection(
|
||||
ActionCollectionDTO unpublishedCollection,
|
||||
String oldName,
|
||||
String newName,
|
||||
int evalVersion,
|
||||
Pattern oldNamePattern) {
|
||||
return astService
|
||||
.replaceValueInMustacheKeys(
|
||||
new HashSet<>(Collections.singletonList(
|
||||
new MustacheBindingToken(unpublishedCollection.getBody(), 0, true))),
|
||||
oldName,
|
||||
newName,
|
||||
evalVersion,
|
||||
oldNamePattern,
|
||||
true)
|
||||
.map(replacedMap -> {
|
||||
Optional<String> replacedValue =
|
||||
replacedMap.values().stream().findFirst();
|
||||
// This value should always be there
|
||||
if (replacedValue.isPresent()) {
|
||||
unpublishedCollection.setBody(replacedValue.get());
|
||||
}
|
||||
return replacedValue.isPresent();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<Void> updateRefactoredEntity(RefactorEntityNameDTO refactorEntityNameDTO, String branchName) {
|
||||
String newName = refactorEntityNameDTO.getNewName();
|
||||
|
|
@ -145,12 +160,15 @@ public class ActionCollectionRefactoringServiceCEImpl implements EntityRefactori
|
|||
|
||||
@Override
|
||||
public Flux<String> getExistingEntityNames(String contextId, CreatorContextType contextType, String layoutId) {
|
||||
return getExistingEntities(contextId, contextType, layoutId).map(ActionCollectionDTO::getName);
|
||||
}
|
||||
|
||||
protected Flux<ActionCollectionDTO> getExistingEntities(
|
||||
String contextId, CreatorContextType contextType, String layoutId) {
|
||||
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
||||
if (StringUtils.hasText(contextId)) {
|
||||
params.add(FieldName.PAGE_ID, contextId);
|
||||
}
|
||||
return actionCollectionService
|
||||
.getActionCollectionsByViewMode(params, false)
|
||||
.map(ActionCollectionDTO::getName);
|
||||
return actionCollectionService.getActionCollectionsByViewMode(params, false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,12 +133,16 @@ public class NewActionRefactoringServiceCEImpl implements EntityRefactoringServi
|
|||
|
||||
@Override
|
||||
public Flux<String> getExistingEntityNames(String contextId, CreatorContextType contextType, String layoutId) {
|
||||
return this.getExistingEntities(contextId, contextType, layoutId).map(ActionDTO::getValidName);
|
||||
}
|
||||
|
||||
protected Flux<ActionDTO> getExistingEntities(String contextId, CreatorContextType contextType, String layoutId) {
|
||||
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
|
||||
if (contextId != null) {
|
||||
params.add(FieldName.PAGE_ID, contextId);
|
||||
}
|
||||
|
||||
return newActionService
|
||||
Flux<ActionDTO> actionDTOFlux = newActionService
|
||||
.getUnpublishedActions(params)
|
||||
.flatMap(actionDTO -> {
|
||||
/*
|
||||
|
|
@ -158,8 +162,8 @@ public class NewActionRefactoringServiceCEImpl implements EntityRefactoringServi
|
|||
} else {
|
||||
return Mono.just(actionDTO);
|
||||
}
|
||||
})
|
||||
.map(ActionDTO::getValidName);
|
||||
});
|
||||
return actionDTOFlux;
|
||||
}
|
||||
|
||||
protected Mono<Set<String>> refactorNameInAction(
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user