Skip to content

Commit

Permalink
fix #739 (#741)
Browse files Browse the repository at this point in the history
  • Loading branch information
masumcse1 authored Jul 19, 2023
1 parent 4079271 commit f52570a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -643,9 +643,8 @@ private CustomEntityTemplate fromDTO(CustomEntityTemplateDto dto, CustomEntityTe

if(dto.getCrudEventListenerScript() != null) {
var crudListenerScript = scriptInstanceService.findByCode(dto.getCrudEventListenerScript());
cet.setCrudEventListenerScript(crudListenerScript);
if(crudListenerScript == null) {
throw new IllegalArgumentException("Script " + dto.getCrudEventListenerScript() + " does not exists");
if(crudListenerScript != null) {
cet.setCrudEventListenerScript(crudListenerScript);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1761,6 +1761,11 @@ public void applyChanges(MeveoModule module, Set<MeveoModuleItemDto> installItem
meveoModuleItemInstaller.uninstallItem(options, null, item);
}

// update CET
for (var itemDto : meveoModuleItemInstaller.getSortedModuleItems(installItems)) {
meveoModuleItemInstaller.updateCetforCrudEventListenerScript(itemDto);
}

moduleCtx.end();

meveoModuleService.update(module);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,37 @@ private void addCftToModuleItem(CustomRelationshipTemplateDto dto, MeveoModule m
}
}
}

public void updateCetforCrudEventListenerScript (MeveoModuleItemDto moduleItemDto) throws BusinessException {

if (moduleItemDto.getDtoClassName().equals(CustomEntityTemplateDto.class.getName())) {
CustomEntityTemplateDto cetDto =null;
if(moduleItemDto.getDtoData() instanceof CustomEntityTemplateDto){
cetDto = (CustomEntityTemplateDto) moduleItemDto.getDtoData();
} else {
try {
Class<? extends BaseEntityDto> dtoClass = (Class<? extends BaseEntityDto>) Class.forName(moduleItemDto.getDtoClassName());
cetDto = (CustomEntityTemplateDto) JacksonUtil.convert(moduleItemDto.getDtoData(), dtoClass);
} catch (ClassNotFoundException e) {
log.error("Cannot find dto class", e);
throw new BusinessException("cannot find crusdScript class "+moduleItemDto.getDtoClassName());
}
}
if (cetDto.getCrudEventListenerScript() != null) {
CustomEntityTemplate cet = customEntityTemplateService.findByCode(cetDto.getCode());
ScriptInstance si = scriptInstanceService.findByCode(cetDto.getCrudEventListenerScript());
if (si != null) {
cet.setCrudEventListenerScript(si);
customEntityTemplateService.update(cet);
} else {
throw new BusinessException("cannot find crusdScript "+cetDto.getTransientCrudEventListenerScript()+" of entity "+cetDto.getCode());
}
}

}

}



}

0 comments on commit f52570a

Please sign in to comment.