@ApiOperation( value = "Delete categorization rule", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @DeleteMapping(value = "/{ruleId}") public HttpEntity<Void> deleteRule(@PathVariable String ruleId) { rulesService.deleteById(ruleId); log.info("Rule [{}] deleted.", ruleId); return new ResponseEntity<>(HttpStatus.NO_CONTENT); }
@ApiOperation( value = "Update contract blacklist configuration", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @PutMapping public HttpEntity<Void> updateContractBlackList(@RequestBody ContractBlacklist contractBlacklist) { contractBlacklistService.saveContractBlacklist(contractBlacklist); return new ResponseEntity<>(HttpStatus.NO_CONTENT); }
@ApiOperation( value = "Update booking groups configuration", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @PutMapping public HttpEntity<Void> updateBookingGroups(@RequestBody GroupConfig groupsContainer) { bookingGroupsService.saveBookingGroups(groupsContainer); return new ResponseEntity<>(HttpStatus.NO_CONTENT); }
@ApiOperation( value = "Update categories tree", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @PutMapping public HttpEntity<Void> updateCategories(@RequestBody CategoriesTree categoriesContainer) { categoriesService.saveCategories(categoriesContainer); return new ResponseEntity<>(HttpStatus.NO_CONTENT); }
@ApiOperation( value = "Download categorization rules", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @GetMapping(path = "/download", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) public HttpEntity<InputStreamResource> downloadRules(@RequestParam(required = false, defaultValue = "CSV") RulesService.FileFormat format) throws IOException { return ResponseEntity.ok() .body(new InputStreamResource(new ByteArrayInputStream(rulesService.rulesAsByteArray(format)))); }
@ApiOperation( value = "Update categorization rule", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @PutMapping(value = "/{ruleId}") public HttpEntity<Void> updateRule(@PathVariable String ruleId, @RequestBody RuleEntity ruleEntity) { ruleEntity.updateSearchIndex(); rulesService.save(ruleEntity); return new ResponseEntity<>(HttpStatus.NO_CONTENT); }
@ApiOperation( value = "Create categorization rule", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @PostMapping public HttpEntity<Void> createRule(@RequestBody RuleEntity ruleEntity) { ruleEntity.updateSearchIndex(); rulesService.save(ruleEntity); return new ResponseEntity<>(HttpStatus.CREATED); }
@ApiOperation( value = "Find categorization rule", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @GetMapping(value = "/search") public Resources<RuleEntity> searchRules(@RequestParam String query) { return new Resources<>(rulesService.search(query)); }
@PutMapping @ApiOperation( value = "Create analytics", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) public Resource<AnalyticsResult> categorize(@RequestBody AnalyticsRequest request) { AnalyticsResult categoryResult = analyticsService.analytics(request); return new Resource<>(categoryResult); }
@ApiOperation( value = "Read smartanalytics configuration state", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) public Resource<ConfigStatus> status() { return new Resource(statusService.getStatus()); }
@ApiOperation( value = "Read categorization rule", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @GetMapping(value = "/{ruleId}") public Resource<RuleEntity> getRule(@PathVariable String ruleId) { RuleEntity ruleEntity = rulesService.getRuleByRuleId(ruleId) .orElseThrow(() -> new ResourceNotFoundException(RuleEntity.class, ruleId)); return mapToResource(ruleEntity); }
@ApiOperation( value = "Upload categorization rules file", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @PostMapping(path = "/upload") public HttpEntity<?> uploadRules(@RequestParam MultipartFile rulesFile) { if (!rulesFile.isEmpty()) { try { rulesService.newRules(rulesFile.getOriginalFilename(), rulesFile.getInputStream()); return new ResponseEntity<>(HttpStatus.CREATED); } catch (Exception e) { log.error("unable import rules", e); throw new InvalidRulesException(rulesFile.getOriginalFilename()); } } else { throw new InvalidRulesException("File is empty"); } }
@ApiOperation( value = "Read categorization rules", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @GetMapping public PagedResources<Resource<RuleEntity>> getRules(@PageableDefault(size = 20, sort = "order") Pageable pageable, PagedResourcesAssembler<RuleEntity> assembler) { Page<RuleEntity> pageableResult = rulesService.findAll(pageable); return assembler.toResource(pageableResult); }
@ApiOperation( value = "Read booking groups configuration", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @GetMapping public Resource<GroupConfig> getBookingGroups() { BookingGroupConfigEntity groupConfig = analyticsConfigProvider.getBookingGroupConfig(); if (groupConfig == null) { throw new ResourceNotFoundException(GroupConfig.class, "groups"); } return new Resource(groupConfig); }
@ApiOperation( value = "Upload images file", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @PostMapping(path = "/upload") public HttpEntity<?> uploadImages(@RequestParam MultipartFile imagesFile) { if (!imagesFile.isEmpty()) { try { imageService.importImages(imagesFile.getInputStream()); return new ResponseEntity<>(HttpStatus.CREATED); } catch (Exception e) { log.error("unable import images", e); throw new FileUploadException(imagesFile.getOriginalFilename()); } } else { throw new FileUploadException("File is empty"); } } }
@ApiOperation( value = "Read contract blacklist configuration", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @GetMapping public Resource<ContractBlacklist> getContractBlackList() { ContractBlacklistEntity contractBlacklist = analyticsConfigProvider.getContractBlacklist(); if (contractBlacklist == null) { throw new ResourceNotFoundException(ContractBlacklist.class, "contract-blacklist"); } return new Resource(contractBlacklist); }
@ApiOperation( value = "Read categories tree", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @GetMapping public Resource<CategoriesTree> getCategories() { CategoriesTreeEntity categoriesTree = analyticsConfigProvider.getCategoriesContainer(); if (categoriesTree == null) { throw new ResourceNotFoundException(CategoriesTree.class, "categories"); } return new Resource(categoriesTree); }
@ApiOperation( value = "Upload contract blacklist configuration file", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @PostMapping(path = "/upload") public HttpEntity<?> uploadContractBlackList(@RequestParam MultipartFile contractBlacklistFile) { if (!contractBlacklistFile.isEmpty()) { try { contractBlacklistService.saveContractBlacklist(ImportUtils.importContractBlackList(contractBlacklistFile.getInputStream())); return new ResponseEntity<>(HttpStatus.CREATED); } catch (Exception e) { log.error("unable import groups", e); throw new FileUploadException(contractBlacklistFile.getOriginalFilename()); } } else { throw new FileUploadException("File is empty"); } } }
@ApiOperation( value = "Upload booking groups configuration file", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @PostMapping(path = "/upload") public HttpEntity<?> uploadBookingGroups(@RequestParam MultipartFile bookingGroupsFile) { if (!bookingGroupsFile.isEmpty()) { try { bookingGroupsService.saveBookingGroups(ImportUtils.importBookingGroups(bookingGroupsFile.getInputStream())); return new ResponseEntity<>(HttpStatus.CREATED); } catch (Exception e) { log.error("unable import groups", e); throw new FileUploadException(bookingGroupsFile.getOriginalFilename()); } } else { throw new FileUploadException("File is empty"); } } }
@ApiOperation( value = "Upload categories tree file", authorizations = { @Authorization(value = "multibanking_auth", scopes = { @AuthorizationScope(scope = "openid", description = "") })}) @PostMapping(path = "/upload") public HttpEntity<?> uploadCategories(@RequestParam MultipartFile categoriesFile) { if (!categoriesFile.isEmpty()) { try { categoriesService.saveCategories(ImportUtils.importCategories(categoriesFile.getInputStream())); return new ResponseEntity<>(HttpStatus.CREATED); } catch (Exception e) { log.error("unable import categories", e); throw new FileUploadException(categoriesFile.getOriginalFilename()); } } else { throw new FileUploadException("File is empty"); } } }