@Test void updateSchemaTypeWithSchemaAttribute() throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { String methodName = "createOrUpdateSchemaType"; ComplexSchemaType schemaType = new ComplexSchemaType(); SchemaAttribute schemaAttribute = new SchemaAttribute(); when(schemaTypeHandler.getEmptyComplexSchemaType(SchemaElementMapper.TABULAR_SCHEMA_TYPE_TYPE_GUID, SchemaElementMapper.TABULAR_SCHEMA_TYPE_TYPE_NAME)).thenReturn(schemaType); when(schemaTypeHandler.getEmptyTabularColumn()).thenReturn(schemaAttribute); EntityDetail schemaTypeEntity = mockFindEntity(QUALIFIED_NAME, GUID, SchemaElementMapper.SCHEMA_TYPE_TYPE_NAME); EntityDetail schemaTypeUpdatedEntity = mock(EntityDetail.class); when(dataEngineCommonHandler.buildEntityDetail(GUID, null)).thenReturn(schemaTypeUpdatedEntity); EntityDetailDifferences schemaTypeDifferences = mock(EntityDetailDifferences.class); when((schemaTypeDifferences.hasInstancePropertiesDifferences())).thenReturn(Boolean.TRUE); when(repositoryHelper.getEntityDetailDifferences(schemaTypeEntity, schemaTypeUpdatedEntity, true)).thenReturn(schemaTypeDifferences); EntityDetail schemaAttributeEntity = mockFindEntity(ATTRIBUTE_QUALIFIED_NAME, ATTRIBUTE_GUID, SchemaElementMapper.SCHEMA_ATTRIBUTE_TYPE_NAME); EntityDetail schemaAttributeUpdatedEntity = mock(EntityDetail.class); when(dataEngineCommonHandler.buildEntityDetail(ATTRIBUTE_GUID, null)).thenReturn(schemaAttributeUpdatedEntity); EntityDetailDifferences attributeDifferences = mock(EntityDetailDifferences.class); when((attributeDifferences.hasInstancePropertiesDifferences())).thenReturn(Boolean.TRUE); when(repositoryHelper.getEntityDetailDifferences(schemaAttributeEntity, schemaAttributeUpdatedEntity, true)).thenReturn(attributeDifferences); SchemaAttributeBuilder builder = mock(SchemaAttributeBuilder.class); when(schemaTypeHandler.getSchemaAttributeBuilder(schemaAttribute)).thenReturn(builder); String result = dataEngineSchemaTypeHandler.createOrUpdateSchemaType(USER, getSchemaType(), EXTERNAL_SOURCE_DE_QUALIFIED_NAME); assertEquals(GUID, result); verify(invalidParameterHandler, times(1)).validateUserId(USER, methodName); verify(invalidParameterHandler, times(1)).validateName(QUALIFIED_NAME, SchemaTypePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); verify(invalidParameterHandler, times(1)).validateName(NAME, SchemaTypePropertiesMapper.DISPLAY_NAME_PROPERTY_NAME, methodName); verify(schemaTypeHandler, times(1)).updateSchemaType(USER, GUID, schemaType); verify(schemaTypeHandler, times(1)).updateSchemaAttribute(USER, ATTRIBUTE_GUID, schemaAttribute); }
public String createOrUpdateSchemaType(String userId, org.odpi.openmetadata.accessservices.dataengine.model.SchemaType schemaType, String externalSourceName) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { final String methodName = "createOrUpdateSchemaType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(schemaType.getQualifiedName(), SchemaTypePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); invalidParameterHandler.validateName(schemaType.getDisplayName(), SchemaTypePropertiesMapper.DISPLAY_NAME_PROPERTY_NAME, methodName); SchemaType schemaTypeBean = createTabularSchemaType(schemaType.getQualifiedName(), schemaType.getDisplayName(), schemaType.getAuthor(), schemaType.getEncodingStandard(), schemaType.getUsage(), schemaType.getVersionNumber()); Optional<EntityDetail> originalSchemaTypeEntity = findSchemaTypeEntity(userId, schemaTypeBean.getQualifiedName()); String schemaTypeGUID; if (!originalSchemaTypeEntity.isPresent()) { String externalSourceGUID = dataEngineRegistrationHandler.getExternalDataEngineByQualifiedName(userId, externalSourceName); schemaTypeGUID = schemaTypeHandler.addExternalSchemaType(userId, schemaTypeBean, externalSourceGUID, externalSourceName); } else { schemaTypeGUID = originalSchemaTypeEntity.get().getGUID(); EntityDetail updatedSchemaTypeEntity = buildSchemaTypeEntityDetail(schemaTypeGUID, schemaTypeBean); EntityDetailDifferences entityDetailDifferences = repositoryHelper.getEntityDetailDifferences(originalSchemaTypeEntity.get(), updatedSchemaTypeEntity, true); if (entityDetailDifferences.hasInstancePropertiesDifferences()) { schemaTypeHandler.updateSchemaType(userId, schemaTypeGUID, schemaTypeBean); } } createOrUpdateSchemaAttributes(userId, schemaTypeGUID, schemaType.getAttributeList(), externalSourceName); return schemaTypeGUID; }
DataEngineSchemaTypeHandler { public String createOrUpdateSchemaType(String userId, org.odpi.openmetadata.accessservices.dataengine.model.SchemaType schemaType, String externalSourceName) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { final String methodName = "createOrUpdateSchemaType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(schemaType.getQualifiedName(), SchemaTypePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); invalidParameterHandler.validateName(schemaType.getDisplayName(), SchemaTypePropertiesMapper.DISPLAY_NAME_PROPERTY_NAME, methodName); SchemaType schemaTypeBean = createTabularSchemaType(schemaType.getQualifiedName(), schemaType.getDisplayName(), schemaType.getAuthor(), schemaType.getEncodingStandard(), schemaType.getUsage(), schemaType.getVersionNumber()); Optional<EntityDetail> originalSchemaTypeEntity = findSchemaTypeEntity(userId, schemaTypeBean.getQualifiedName()); String schemaTypeGUID; if (!originalSchemaTypeEntity.isPresent()) { String externalSourceGUID = dataEngineRegistrationHandler.getExternalDataEngineByQualifiedName(userId, externalSourceName); schemaTypeGUID = schemaTypeHandler.addExternalSchemaType(userId, schemaTypeBean, externalSourceGUID, externalSourceName); } else { schemaTypeGUID = originalSchemaTypeEntity.get().getGUID(); EntityDetail updatedSchemaTypeEntity = buildSchemaTypeEntityDetail(schemaTypeGUID, schemaTypeBean); EntityDetailDifferences entityDetailDifferences = repositoryHelper.getEntityDetailDifferences(originalSchemaTypeEntity.get(), updatedSchemaTypeEntity, true); if (entityDetailDifferences.hasInstancePropertiesDifferences()) { schemaTypeHandler.updateSchemaType(userId, schemaTypeGUID, schemaTypeBean); } } createOrUpdateSchemaAttributes(userId, schemaTypeGUID, schemaType.getAttributeList(), externalSourceName); return schemaTypeGUID; } }
DataEngineSchemaTypeHandler { public String createOrUpdateSchemaType(String userId, org.odpi.openmetadata.accessservices.dataengine.model.SchemaType schemaType, String externalSourceName) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { final String methodName = "createOrUpdateSchemaType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(schemaType.getQualifiedName(), SchemaTypePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); invalidParameterHandler.validateName(schemaType.getDisplayName(), SchemaTypePropertiesMapper.DISPLAY_NAME_PROPERTY_NAME, methodName); SchemaType schemaTypeBean = createTabularSchemaType(schemaType.getQualifiedName(), schemaType.getDisplayName(), schemaType.getAuthor(), schemaType.getEncodingStandard(), schemaType.getUsage(), schemaType.getVersionNumber()); Optional<EntityDetail> originalSchemaTypeEntity = findSchemaTypeEntity(userId, schemaTypeBean.getQualifiedName()); String schemaTypeGUID; if (!originalSchemaTypeEntity.isPresent()) { String externalSourceGUID = dataEngineRegistrationHandler.getExternalDataEngineByQualifiedName(userId, externalSourceName); schemaTypeGUID = schemaTypeHandler.addExternalSchemaType(userId, schemaTypeBean, externalSourceGUID, externalSourceName); } else { schemaTypeGUID = originalSchemaTypeEntity.get().getGUID(); EntityDetail updatedSchemaTypeEntity = buildSchemaTypeEntityDetail(schemaTypeGUID, schemaTypeBean); EntityDetailDifferences entityDetailDifferences = repositoryHelper.getEntityDetailDifferences(originalSchemaTypeEntity.get(), updatedSchemaTypeEntity, true); if (entityDetailDifferences.hasInstancePropertiesDifferences()) { schemaTypeHandler.updateSchemaType(userId, schemaTypeGUID, schemaTypeBean); } } createOrUpdateSchemaAttributes(userId, schemaTypeGUID, schemaType.getAttributeList(), externalSourceName); return schemaTypeGUID; } DataEngineSchemaTypeHandler(String serviceName, String serverName, InvalidParameterHandler invalidParameterHandler,
                                       RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
                                       SchemaTypeHandler schemaTypeHandler, DataEngineRegistrationHandler dataEngineRegistrationHandler,
                                       DataEngineCommonHandler dataEngineCommonHandler); }
DataEngineSchemaTypeHandler { public String createOrUpdateSchemaType(String userId, org.odpi.openmetadata.accessservices.dataengine.model.SchemaType schemaType, String externalSourceName) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { final String methodName = "createOrUpdateSchemaType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(schemaType.getQualifiedName(), SchemaTypePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); invalidParameterHandler.validateName(schemaType.getDisplayName(), SchemaTypePropertiesMapper.DISPLAY_NAME_PROPERTY_NAME, methodName); SchemaType schemaTypeBean = createTabularSchemaType(schemaType.getQualifiedName(), schemaType.getDisplayName(), schemaType.getAuthor(), schemaType.getEncodingStandard(), schemaType.getUsage(), schemaType.getVersionNumber()); Optional<EntityDetail> originalSchemaTypeEntity = findSchemaTypeEntity(userId, schemaTypeBean.getQualifiedName()); String schemaTypeGUID; if (!originalSchemaTypeEntity.isPresent()) { String externalSourceGUID = dataEngineRegistrationHandler.getExternalDataEngineByQualifiedName(userId, externalSourceName); schemaTypeGUID = schemaTypeHandler.addExternalSchemaType(userId, schemaTypeBean, externalSourceGUID, externalSourceName); } else { schemaTypeGUID = originalSchemaTypeEntity.get().getGUID(); EntityDetail updatedSchemaTypeEntity = buildSchemaTypeEntityDetail(schemaTypeGUID, schemaTypeBean); EntityDetailDifferences entityDetailDifferences = repositoryHelper.getEntityDetailDifferences(originalSchemaTypeEntity.get(), updatedSchemaTypeEntity, true); if (entityDetailDifferences.hasInstancePropertiesDifferences()) { schemaTypeHandler.updateSchemaType(userId, schemaTypeGUID, schemaTypeBean); } } createOrUpdateSchemaAttributes(userId, schemaTypeGUID, schemaType.getAttributeList(), externalSourceName); return schemaTypeGUID; } DataEngineSchemaTypeHandler(String serviceName, String serverName, InvalidParameterHandler invalidParameterHandler,
                                       RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
                                       SchemaTypeHandler schemaTypeHandler, DataEngineRegistrationHandler dataEngineRegistrationHandler,
                                       DataEngineCommonHandler dataEngineCommonHandler); String createOrUpdateSchemaType(String userId, org.odpi.openmetadata.accessservices.dataengine.model.SchemaType schemaType,
                                           String externalSourceName); Optional<EntityDetail> findSchemaTypeEntity(String userId, String qualifiedName); Optional<EntityDetail> findSchemaAttributeEntity(String userId, String qualifiedName); void addLineageMappingRelationship(String userId, String sourceSchemaAttributeQualifiedName, String targetSchemaAttributeQualifiedName,
                                              String externalSourceName); void removeSchemaType(String userId, String schemaTypeGUID); void addAnchorGUID(String userId, Attribute attribute, String processGUID); }
DataEngineSchemaTypeHandler { public String createOrUpdateSchemaType(String userId, org.odpi.openmetadata.accessservices.dataengine.model.SchemaType schemaType, String externalSourceName) throws InvalidParameterException, PropertyServerException, UserNotAuthorizedException { final String methodName = "createOrUpdateSchemaType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateName(schemaType.getQualifiedName(), SchemaTypePropertiesMapper.QUALIFIED_NAME_PROPERTY_NAME, methodName); invalidParameterHandler.validateName(schemaType.getDisplayName(), SchemaTypePropertiesMapper.DISPLAY_NAME_PROPERTY_NAME, methodName); SchemaType schemaTypeBean = createTabularSchemaType(schemaType.getQualifiedName(), schemaType.getDisplayName(), schemaType.getAuthor(), schemaType.getEncodingStandard(), schemaType.getUsage(), schemaType.getVersionNumber()); Optional<EntityDetail> originalSchemaTypeEntity = findSchemaTypeEntity(userId, schemaTypeBean.getQualifiedName()); String schemaTypeGUID; if (!originalSchemaTypeEntity.isPresent()) { String externalSourceGUID = dataEngineRegistrationHandler.getExternalDataEngineByQualifiedName(userId, externalSourceName); schemaTypeGUID = schemaTypeHandler.addExternalSchemaType(userId, schemaTypeBean, externalSourceGUID, externalSourceName); } else { schemaTypeGUID = originalSchemaTypeEntity.get().getGUID(); EntityDetail updatedSchemaTypeEntity = buildSchemaTypeEntityDetail(schemaTypeGUID, schemaTypeBean); EntityDetailDifferences entityDetailDifferences = repositoryHelper.getEntityDetailDifferences(originalSchemaTypeEntity.get(), updatedSchemaTypeEntity, true); if (entityDetailDifferences.hasInstancePropertiesDifferences()) { schemaTypeHandler.updateSchemaType(userId, schemaTypeGUID, schemaTypeBean); } } createOrUpdateSchemaAttributes(userId, schemaTypeGUID, schemaType.getAttributeList(), externalSourceName); return schemaTypeGUID; } DataEngineSchemaTypeHandler(String serviceName, String serverName, InvalidParameterHandler invalidParameterHandler,
                                       RepositoryHandler repositoryHandler, OMRSRepositoryHelper repositoryHelper,
                                       SchemaTypeHandler schemaTypeHandler, DataEngineRegistrationHandler dataEngineRegistrationHandler,
                                       DataEngineCommonHandler dataEngineCommonHandler); String createOrUpdateSchemaType(String userId, org.odpi.openmetadata.accessservices.dataengine.model.SchemaType schemaType,
                                           String externalSourceName); Optional<EntityDetail> findSchemaTypeEntity(String userId, String qualifiedName); Optional<EntityDetail> findSchemaAttributeEntity(String userId, String qualifiedName); void addLineageMappingRelationship(String userId, String sourceSchemaAttributeQualifiedName, String targetSchemaAttributeQualifiedName,
                                              String externalSourceName); void removeSchemaType(String userId, String schemaTypeGUID); void addAnchorGUID(String userId, Attribute attribute, String processGUID);  }