@Test public void searchByType() throws InvalidParameterException, org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, RepositoryErrorException, PropertyErrorException, TypeErrorException, PagingErrorException { String methodName = "searchByType"; SearchParameters searchParams = mockSearchParams(); mockTypeDef(ASSET_TYPE, ASSET_TYPE_GUID); mockSearchString(SEARCH_CRITERIA, searchParams.isCaseInsensitive()); OMRSMetadataCollection metadataCollection = mockMetadataCollection(); when(metadataCollection.findEntitiesByPropertyValue(USER, ASSET_TYPE_GUID, SEARCH_CRITERIA, FROM, Collections.singletonList(InstanceStatus.ACTIVE), null, null, null, SequencingOrder.ANY, PAGE_SIZE)).thenReturn(mockEntities()); List<AssetElements> assetElements = assetCatalogHandler.searchByType(USER, SEARCH_CRITERIA, searchParams); assertEquals(FIRST_GUID, assetElements.get(0).getGuid()); assertEquals(ASSET_TYPE, assetElements.get(0).getType().getName()); verify(invalidParameterHandler, times(1)).validateUserId(USER, methodName); verify(invalidParameterHandler, times(1)).validatePaging(searchParams.getFrom(), searchParams.getPageSize(), methodName); verify(invalidParameterHandler, times(1)).validateObject(searchParams, "searchParameter", methodName); }
public List<AssetElements> searchByType(String userId, String searchCriteria, SearchParameters searchParameters) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, PropertyErrorException, TypeErrorException, PagingErrorException, InvalidParameterException, RepositoryErrorException { String methodName = "searchByType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateSearchString(userId, searchCriteria, methodName); invalidParameterHandler.validateObject(searchParameters, SEARCH_PARAMETER, methodName); invalidParameterHandler.validatePaging(searchParameters.getFrom(), searchParameters.getPageSize(), methodName); List<EntityDetail> result; if (CollectionUtils.isNotEmpty(searchParameters.getEntityTypes())) { List<String> typesFilter = commonHandler.getTypesGUID(userId, searchParameters.getEntityTypes()); result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, typesFilter); } else { result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, defaultSearchTypes); } List<AssetElements> list = new ArrayList<>(); for (EntityDetail entityDetail : result) { try { invalidParameterHandler.validateAssetInSupportedZone(entityDetail.getGUID(), GUID_PARAMETER, commonHandler.getAssetZoneMembership(entityDetail.getClassifications()), supportedZones, serverUserName, methodName); AssetElements assetElements = assetConverter.buildAssetElements(entityDetail); list.add(assetElements); } catch (org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException e) { log.debug("This asset if a different zone: {}", entityDetail.getGUID()); } } return list; }
AssetCatalogHandler { public List<AssetElements> searchByType(String userId, String searchCriteria, SearchParameters searchParameters) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, PropertyErrorException, TypeErrorException, PagingErrorException, InvalidParameterException, RepositoryErrorException { String methodName = "searchByType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateSearchString(userId, searchCriteria, methodName); invalidParameterHandler.validateObject(searchParameters, SEARCH_PARAMETER, methodName); invalidParameterHandler.validatePaging(searchParameters.getFrom(), searchParameters.getPageSize(), methodName); List<EntityDetail> result; if (CollectionUtils.isNotEmpty(searchParameters.getEntityTypes())) { List<String> typesFilter = commonHandler.getTypesGUID(userId, searchParameters.getEntityTypes()); result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, typesFilter); } else { result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, defaultSearchTypes); } List<AssetElements> list = new ArrayList<>(); for (EntityDetail entityDetail : result) { try { invalidParameterHandler.validateAssetInSupportedZone(entityDetail.getGUID(), GUID_PARAMETER, commonHandler.getAssetZoneMembership(entityDetail.getClassifications()), supportedZones, serverUserName, methodName); AssetElements assetElements = assetConverter.buildAssetElements(entityDetail); list.add(assetElements); } catch (org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException e) { log.debug("This asset if a different zone: {}", entityDetail.getGUID()); } } return list; } }
AssetCatalogHandler { public List<AssetElements> searchByType(String userId, String searchCriteria, SearchParameters searchParameters) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, PropertyErrorException, TypeErrorException, PagingErrorException, InvalidParameterException, RepositoryErrorException { String methodName = "searchByType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateSearchString(userId, searchCriteria, methodName); invalidParameterHandler.validateObject(searchParameters, SEARCH_PARAMETER, methodName); invalidParameterHandler.validatePaging(searchParameters.getFrom(), searchParameters.getPageSize(), methodName); List<EntityDetail> result; if (CollectionUtils.isNotEmpty(searchParameters.getEntityTypes())) { List<String> typesFilter = commonHandler.getTypesGUID(userId, searchParameters.getEntityTypes()); result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, typesFilter); } else { result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, defaultSearchTypes); } List<AssetElements> list = new ArrayList<>(); for (EntityDetail entityDetail : result) { try { invalidParameterHandler.validateAssetInSupportedZone(entityDetail.getGUID(), GUID_PARAMETER, commonHandler.getAssetZoneMembership(entityDetail.getClassifications()), supportedZones, serverUserName, methodName); AssetElements assetElements = assetConverter.buildAssetElements(entityDetail); list.add(assetElements); } catch (org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException e) { log.debug("This asset if a different zone: {}", entityDetail.getGUID()); } } return list; } AssetCatalogHandler(String serverUserName, String sourceName, InvalidParameterHandler invalidParameterHandler,
                               RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
                               RepositoryErrorHandler errorHandler, List<String> supportedZones, List<String> supportedTypesForSearch); }
AssetCatalogHandler { public List<AssetElements> searchByType(String userId, String searchCriteria, SearchParameters searchParameters) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, PropertyErrorException, TypeErrorException, PagingErrorException, InvalidParameterException, RepositoryErrorException { String methodName = "searchByType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateSearchString(userId, searchCriteria, methodName); invalidParameterHandler.validateObject(searchParameters, SEARCH_PARAMETER, methodName); invalidParameterHandler.validatePaging(searchParameters.getFrom(), searchParameters.getPageSize(), methodName); List<EntityDetail> result; if (CollectionUtils.isNotEmpty(searchParameters.getEntityTypes())) { List<String> typesFilter = commonHandler.getTypesGUID(userId, searchParameters.getEntityTypes()); result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, typesFilter); } else { result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, defaultSearchTypes); } List<AssetElements> list = new ArrayList<>(); for (EntityDetail entityDetail : result) { try { invalidParameterHandler.validateAssetInSupportedZone(entityDetail.getGUID(), GUID_PARAMETER, commonHandler.getAssetZoneMembership(entityDetail.getClassifications()), supportedZones, serverUserName, methodName); AssetElements assetElements = assetConverter.buildAssetElements(entityDetail); list.add(assetElements); } catch (org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException e) { log.debug("This asset if a different zone: {}", entityDetail.getGUID()); } } return list; } AssetCatalogHandler(String serverUserName, String sourceName, InvalidParameterHandler invalidParameterHandler,
                               RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
                               RepositoryErrorHandler errorHandler, List<String> supportedZones, List<String> supportedTypesForSearch); AssetDescription getEntityDetails(String userId, String assetGUID, String assetTypeName); List<org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship> getRelationshipsByEntityGUID(String userId,
                                                                                                                   String assetGUID,
                                                                                                                   String assetTypeName); List<org.odpi.openmetadata.accessservices.assetcatalog.model.Classification> getEntityClassificationByName(String userId,
                                                                                                                      String assetGUID,
                                                                                                                      String assetTypeName,
                                                                                                                      String classificationName); List<org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship> getLinkingRelationshipsBetweenAssets(String serverName,
                                                                                                                           String userId,
                                                                                                                           String startAssetGUID,
                                                                                                                           String endAssetGUID); List<org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship> getRelationships(String userId,
                                                                                                       String assetGUID,
                                                                                                       String assetTypeName,
                                                                                                       String relationshipTypeName,
                                                                                                       Integer from, Integer pageSize); List<AssetDescription> getIntermediateAssets(String userId, String startAssetGUID, String endAssetGUID); List<AssetDescription> getEntitiesFromNeighborhood(String serverName, String userId, String assetGUID, SearchParameters searchParameters); List<AssetElements> searchByType(String userId, String searchCriteria, SearchParameters searchParameters); AssetElements buildContextByType(String userId,
                                            String entityGUID,
                                            String entityTypeDefName); List<Type> getSupportedTypes(String userId, String typeName); }
AssetCatalogHandler { public List<AssetElements> searchByType(String userId, String searchCriteria, SearchParameters searchParameters) throws org.odpi.openmetadata.repositoryservices.ffdc.exception.UserNotAuthorizedException, FunctionNotSupportedException, org.odpi.openmetadata.repositoryservices.ffdc.exception.InvalidParameterException, PropertyErrorException, TypeErrorException, PagingErrorException, InvalidParameterException, RepositoryErrorException { String methodName = "searchByType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateSearchString(userId, searchCriteria, methodName); invalidParameterHandler.validateObject(searchParameters, SEARCH_PARAMETER, methodName); invalidParameterHandler.validatePaging(searchParameters.getFrom(), searchParameters.getPageSize(), methodName); List<EntityDetail> result; if (CollectionUtils.isNotEmpty(searchParameters.getEntityTypes())) { List<String> typesFilter = commonHandler.getTypesGUID(userId, searchParameters.getEntityTypes()); result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, typesFilter); } else { result = collectSearchedEntitiesByType(userId, searchCriteria, searchParameters, defaultSearchTypes); } List<AssetElements> list = new ArrayList<>(); for (EntityDetail entityDetail : result) { try { invalidParameterHandler.validateAssetInSupportedZone(entityDetail.getGUID(), GUID_PARAMETER, commonHandler.getAssetZoneMembership(entityDetail.getClassifications()), supportedZones, serverUserName, methodName); AssetElements assetElements = assetConverter.buildAssetElements(entityDetail); list.add(assetElements); } catch (org.odpi.openmetadata.commonservices.ffdc.exceptions.InvalidParameterException e) { log.debug("This asset if a different zone: {}", entityDetail.getGUID()); } } return list; } AssetCatalogHandler(String serverUserName, String sourceName, InvalidParameterHandler invalidParameterHandler,
                               RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
                               RepositoryErrorHandler errorHandler, List<String> supportedZones, List<String> supportedTypesForSearch); AssetDescription getEntityDetails(String userId, String assetGUID, String assetTypeName); List<org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship> getRelationshipsByEntityGUID(String userId,
                                                                                                                   String assetGUID,
                                                                                                                   String assetTypeName); List<org.odpi.openmetadata.accessservices.assetcatalog.model.Classification> getEntityClassificationByName(String userId,
                                                                                                                      String assetGUID,
                                                                                                                      String assetTypeName,
                                                                                                                      String classificationName); List<org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship> getLinkingRelationshipsBetweenAssets(String serverName,
                                                                                                                           String userId,
                                                                                                                           String startAssetGUID,
                                                                                                                           String endAssetGUID); List<org.odpi.openmetadata.accessservices.assetcatalog.model.Relationship> getRelationships(String userId,
                                                                                                       String assetGUID,
                                                                                                       String assetTypeName,
                                                                                                       String relationshipTypeName,
                                                                                                       Integer from, Integer pageSize); List<AssetDescription> getIntermediateAssets(String userId, String startAssetGUID, String endAssetGUID); List<AssetDescription> getEntitiesFromNeighborhood(String serverName, String userId, String assetGUID, SearchParameters searchParameters); List<AssetElements> searchByType(String userId, String searchCriteria, SearchParameters searchParameters); AssetElements buildContextByType(String userId,
                                            String entityGUID,
                                            String entityTypeDefName); List<Type> getSupportedTypes(String userId, String typeName);  }