Skip to main content

Posts

Showing posts from January, 2022

Aggregate identifier must be non-null

Aggregate identifier must be non-null after applying an event. Make sure the aggregate identifier is initialized at the latest when handling the creation event. For this I have force fully passed a random variable to CreateRemarkCommand() which is given below: Users.kt class CreateRemarkEvent(val id: Int, val remarkDto: RemarkDto) : BaseEvent(); class CreateRemarkCommand(val id: Int, val remarkDto: RemarkDto) : BaseCommand(); RemarksController: public BaseResponseDto storeRemarks(@RequestBody RemarkDto remarkDto){ remarkDto.setRemarkDate(new Date()); remarkDto.setUserType(UserType.SUBSCRIBER); int remarkAggregate = Integer.parseInt(RandomStringUtils.randomNumeric(6).toString()); CreateRemarkCommand remarkCommand = new CreateRemarkCommand(remarkAggregate, remarkDto); commandBus.dispatch(new GenericCommandMessage (remarkCommand)); log.info("Dispatched command"); return BaseResponseDto.builder() .stat...

Pagination in Java

Remark Controller: PageRequest pageRequest = new PageRequest(remarkDto.getPageNumber(), Constants.REPORT_ITEM_PER_PAGE); Page remarksList = remarksQueryRepository.findAll(pageRequest); remarksList.getContent().stream().sorted((Comparator.comparing(UserRemarks::getRemarkDate) .reversed())).collect(Collectors.toList()); RemarkDtoPaginationResponse response = getRemarkDtoPaginationResponse(remarkDto, remarksList); return response; @NotNull private RemarkDtoPaginationResponse getRemarkDtoPaginationResponse(RemarkDto remarkDto, Page remarksList) { List remarkDtos = mapperFactory.getMapperFacade().mapAsList(remarksList.getContent(), RemarkDto.class); RemarkDtoPaginationResponse response = new RemarkDtoPaginationResponse(); response.setContent(remarkDtos); response.setLast(remarksList.isLast()); response.setTotalElements((int) remarksList.getNumberOfElements()); response.setSize(remarksList.getSize...

Remarks Creation in project

Make Combobox by Admin Type Map adminTypes = new HashMap (); adminTypes.put(AdminType.SUPER_ADMIN.toString(), AdminType.SUPER_ADMIN.toString().replace("_", " ")); adminTypes.put(AdminType.NETWORK_ADMIN.toString(), AdminType.NETWORK_ADMIN.toString().replace("_", " ")); adminTypes.put(AdminType.CUSTOMER_CARE.toString(), AdminType.CUSTOMER_CARE.toString().replace("_", " ")); SearchCriteria searchCriteria3 = new SearchCriteria("admin-type", "Admin Type", SearchCriteriaFieldType.ENUM, ":", prevSearchedValues.get("admin-type"), adminTypes); searchCriteriaList.add(searchCriteria3); Assign Admin Type in Search Criteria AdminType enumAdminType = (adminType != null && !adminType.isEmpty()) ? AdminType.valueOf(adminType) : null; Filtered Admin List List remarksList = remarksQueryRepository.findAll(); ...