/** * Creates a new tag. * * @param tagCreateRequest the information needed to create the tag * * @return the created tag type */ @RequestMapping(value = TAGS_URI_PREFIX, method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAGS_POST) public Tag createTag(@RequestBody TagCreateRequest tagCreateRequest) { return tagService.createTag(tagCreateRequest); }
/** * Deletes an existing tag. * * @param tagTypeCode the tag type code * @param tagCode the tag code * * @return the deleted tag */ @RequestMapping(value = TAGS_URI_PREFIX + "/tagTypes/{tagTypeCode}/tagCodes/{tagCode}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_TAGS_DELETE) public Tag deleteTag(@PathVariable("tagTypeCode") String tagTypeCode, @PathVariable("tagCode") String tagCode) { TagKey tagKey = new TagKey(tagTypeCode, tagCode); return tagService.deleteTag(tagKey); }
/** * Gets an existing tag. * * @param tagTypeCode the tag type code * @param tagCode the tag code * * @return the tag */ @RequestMapping(value = TAGS_URI_PREFIX + "/tagTypes/{tagTypeCode}/tagCodes/{tagCode}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_TAGS_GET) public Tag getTag(@PathVariable("tagTypeCode") String tagTypeCode, @PathVariable("tagCode") String tagCode) { TagKey tagKey = new TagKey(tagTypeCode, tagCode); return tagService.getTag(tagKey); }
tagService.indexValidateAllTags(indexName); sizeCheck = tagService.indexSizeCheckValidationTags(indexName); spotCheckPercentage = tagService.indexSpotCheckPercentageValidationTags(indexName); spotCheckMostRecent = tagService.indexSpotCheckMostRecentValidationTags(indexName);
/** * Updates an existing tag. * * @param tagTypeCode the tag type code * @param tagCode the tag code * @param tagUpdateRequest the information needed to update the tag * * @return the updated tag */ @RequestMapping(value = TAGS_URI_PREFIX + "/tagTypes/{tagTypeCode}/tagCodes/{tagCode}", method = RequestMethod.PUT, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAGS_PUT) public Tag updateTag(@PathVariable("tagTypeCode") String tagTypeCode, @PathVariable("tagCode") String tagCode, @RequestBody TagUpdateRequest tagUpdateRequest) { TagKey tagKey = new TagKey(tagTypeCode, tagCode); return tagService.updateTag(tagKey, tagUpdateRequest); } }
/** * Retrieves all associated tags for the specified tag type code. When tagCode is null, return all tags of the tag type code, which has no parent (i.e. root * tags). When tagCode is provided, return all tags of the tag type code and whose parent tag code is tagCode. * * @param tagTypeCode the tag type's code. * @param tagCode the parent tag code. * * @return all associated tags, with parent, itself and the children tags with has more children flag. */ @RequestMapping(value = TAGS_URI_PREFIX + "/tagTypes/{tagTypeCode}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_TAGS_ALL_GET) public TagListResponse getTags(@PathVariable("tagTypeCode") String tagTypeCode, @RequestParam(value = "tagCode", required = false) String tagCode) { return tagService.getTags(tagTypeCode, tagCode); }
/** * Retrieves all tags existing in the system per specified search filters and keys. For each tag entity, this endpoint returns tag key by default along with * any other top-level elements as specified by the "fields" query string parameter. The list of tags returned by this endpoint is sorted alphabetically by * tag's display name ascending. * * @param request the tag search request. The request can only accept a single search filter and a single search key * @param fields the field options for the tag type search response. The valid field options are: displayName, description, parentTagKey, hasChildren * * @return the tag search response */ @RequestMapping(value = TAGS_URI_PREFIX + "/search", method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAGS_SEARCH_POST) public TagSearchResponse searchTags(@RequestBody TagSearchRequest request, @RequestParam(value = "fields", required = false, defaultValue = "") Set<String> fields) { return tagService.searchTags(request, fields); }
tagService.createTag(new TagCreateRequest(parentTagKey, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION, NO_PARENT_TAG_KEY)); tagService.createTag(new TagCreateRequest(childTagKey, TAG_DISPLAY_NAME_2, TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION_2, parentTagKey)); Tag deletedTag = tagService.deleteTag(childTagKey);
tagService.indexValidateAllTags(indexName); sizeCheck = tagService.indexSizeCheckValidationTags(indexName); spotCheckPercentage = tagService.indexSpotCheckPercentageValidationTags(indexName); spotCheckMostRecent = tagService.indexSpotCheckMostRecentValidationTags(indexName);
/** * Updates an existing tag. * * @param tagTypeCode the tag type code * @param tagCode the tag code * @param tagUpdateRequest the information needed to update the tag * * @return the updated tag */ @RequestMapping(value = TAGS_URI_PREFIX + "/tagTypes/{tagTypeCode}/tagCodes/{tagCode}", method = RequestMethod.PUT, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAGS_PUT) public Tag updateTag(@PathVariable("tagTypeCode") String tagTypeCode, @PathVariable("tagCode") String tagCode, @RequestBody TagUpdateRequest tagUpdateRequest) { TagKey tagKey = new TagKey(tagTypeCode, tagCode); return tagService.updateTag(tagKey, tagUpdateRequest); } }
/** * Retrieves all associated tags for the specified tag type code. When tagCode is null, return all tags of the tag type code, which has no parent (i.e. root * tags). When tagCode is provided, return all tags of the tag type code and whose parent tag code is tagCode. * * @param tagTypeCode the tag type's code. * @param tagCode the parent tag code. * * @return all associated tags, with parent, itself and the children tags with has more children flag. */ @RequestMapping(value = TAGS_URI_PREFIX + "/tagTypes/{tagTypeCode}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_TAGS_ALL_GET) public TagListResponse getTags(@PathVariable("tagTypeCode") String tagTypeCode, @RequestParam(value = "tagCode", required = false) String tagCode) { return tagService.getTags(tagTypeCode, tagCode); }
/** * Retrieves all tags existing in the system per specified search filters and keys. For each tag entity, this endpoint returns tag key by default along with * any other top-level elements as specified by the "fields" query string parameter. The list of tags returned by this endpoint is sorted alphabetically by * tag's display name ascending. * * @param request the tag search request. The request can only accept a single search filter and a single search key * @param fields the field options for the tag type search response. The valid field options are: displayName, description, parentTagKey, hasChildren * * @return the tag search response */ @RequestMapping(value = TAGS_URI_PREFIX + "/search", method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAGS_SEARCH_POST) public TagSearchResponse searchTags(@RequestBody TagSearchRequest request, @RequestParam(value = "fields", required = false, defaultValue = "") Set<String> fields) { return tagService.searchTags(request, fields); }
when(businessObjectDefinitionService.indexSpotCheckMostRecentValidationBusinessObjectDefinitions(SEARCH_INDEX_NAME)).thenReturn(spotCheckMostRecent); when(tagService.indexValidateAllTags(SEARCH_INDEX_NAME)).thenReturn(new AsyncResult<>(null)); when(tagService.indexSizeCheckValidationTags(SEARCH_INDEX_NAME)).thenReturn(sizeCheck); when(tagService.indexSpotCheckPercentageValidationTags(SEARCH_INDEX_NAME)).thenReturn(spotCheckPercentage); when(tagService.indexSpotCheckMostRecentValidationTags(SEARCH_INDEX_NAME)).thenReturn(spotCheckMostRecent); verify(tagService, times(1)).indexValidateAllTags(SEARCH_INDEX_NAME); verify(tagService, times(0)).indexValidateAllTags(SEARCH_INDEX_NAME); verify(tagService).indexSizeCheckValidationTags(SEARCH_INDEX_NAME); verify(tagService).indexSpotCheckPercentageValidationTags(SEARCH_INDEX_NAME); verify(tagService).indexSpotCheckMostRecentValidationTags(SEARCH_INDEX_NAME); verifyNoMoreInteractions(alternateKeyHelper, searchIndexDaoHelper, tagService);
@Test public void testUpdateTag() { // Create a parent tag key. TagKey parentTagKey = new TagKey(TAG_TYPE, TAG_CODE); TagUpdateRequest request = new TagUpdateRequest(TAG_DISPLAY_NAME_3, TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3, parentTagKey); // Create a tag key. TagKey tagKey = new TagKey(TAG_TYPE, TAG_CODE_2); Tag tag = getNewTag(tagKey); when(tagService.updateTag(tagKey, request)).thenReturn(tag); // Update the tag. Tag updatedTag = tagRestController.updateTag(TAG_TYPE, TAG_CODE_2, request); // Verify the external calls. verify(tagService).updateTag(tagKey, request); verifyNoMoreInteractions(tagService); // Validate the returned object. assertEquals(tag, updatedTag); ; }
/** * Creates a new tag. * * @param tagCreateRequest the information needed to create the tag * * @return the created tag type */ @RequestMapping(value = TAGS_URI_PREFIX, method = RequestMethod.POST, consumes = {"application/xml", "application/json"}) @Secured(SecurityFunctions.FN_TAGS_POST) public Tag createTag(@RequestBody TagCreateRequest tagCreateRequest) { return tagService.createTag(tagCreateRequest); }
@Test public void testGetTagsMissingRequiredParameters() { // Try to get a tag when tag type is not specified. try { tagService.getTags(BLANK_TEXT, NO_PARENT_TAG_CODE); fail(); } catch (IllegalArgumentException e) { assertEquals("A tag type code must be specified.", e.getMessage()); } }
tagService.searchTags(null, NO_SEARCH_RESPONSE_FIELDS); fail(); tagService.searchTags(new TagSearchRequest(Arrays.asList(new TagSearchFilter())), NO_SEARCH_RESPONSE_FIELDS); fail(); tagService.searchTags(new TagSearchRequest(Arrays.asList(new TagSearchFilter(tagSearchKeys))), NO_SEARCH_RESPONSE_FIELDS); fail(); tagService.searchTags(new TagSearchRequest( Arrays.asList(new TagSearchFilter(Arrays.asList(new TagSearchKey(BLANK_TEXT, NO_PARENT_TAG_CODE, NO_IS_PARENT_TAG_NULL_FLAG))))), NO_SEARCH_RESPONSE_FIELDS);
/** * Gets an existing tag. * * @param tagTypeCode the tag type code * @param tagCode the tag code * * @return the tag */ @RequestMapping(value = TAGS_URI_PREFIX + "/tagTypes/{tagTypeCode}/tagCodes/{tagCode}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_TAGS_GET) public Tag getTag(@PathVariable("tagTypeCode") String tagTypeCode, @PathVariable("tagCode") String tagCode) { TagKey tagKey = new TagKey(tagTypeCode, tagCode); return tagService.getTag(tagKey); }
/** * Deletes an existing tag. * * @param tagTypeCode the tag type code * @param tagCode the tag code * * @return the deleted tag */ @RequestMapping(value = TAGS_URI_PREFIX + "/tagTypes/{tagTypeCode}/tagCodes/{tagCode}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_TAGS_DELETE) public Tag deleteTag(@PathVariable("tagTypeCode") String tagTypeCode, @PathVariable("tagCode") String tagCode) { TagKey tagKey = new TagKey(tagTypeCode, tagCode); return tagService.deleteTag(tagKey); }
@Test public void testUpdateTagDisplayNameAlreadyExistsForThisTagType() { // Create and persist a tag entity. tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE, TAG_DISPLAY_NAME, TAG_SEARCH_SCORE_MULTIPLIER, TAG_DESCRIPTION); // Create and persist a second tag entity for the same tag type that would have the display name to be updated to. tagDaoTestHelper.createTagEntity(TAG_TYPE, TAG_CODE_2, TAG_DISPLAY_NAME_2.toUpperCase(), TAG_SEARCH_SCORE_MULTIPLIER_2, TAG_DESCRIPTION); // Try to update a tag with an already existing display name. try { tagService.updateTag(new TagKey(TAG_TYPE, TAG_CODE), new TagUpdateRequest(TAG_DISPLAY_NAME_2.toLowerCase(), TAG_SEARCH_SCORE_MULTIPLIER_3, TAG_DESCRIPTION_3, NO_PARENT_TAG_KEY)); fail(); } catch (AlreadyExistsException e) { assertEquals(String .format("Display name \"%s\" already exists for a tag with tag type \"%s\" and tag code \"%s\".", TAG_DISPLAY_NAME_2.toLowerCase(), TAG_TYPE, TAG_CODE_2), e.getMessage()); } }