@Override public List<CTLSchemaDto> findCtlSchemaDependents(String schemaId) { validateSqlId(schemaId, "Incorrect schema id for ctl schema request."); LOG.debug("Find dependents schemas for schema with id [{}]", schemaId); List<CTLSchemaDto> list = Collections.emptyList(); CtlSchema schemaDto = ctlSchemaDao.findById(schemaId); if (schemaDto != null) { list = convertDtoList(ctlSchemaDao.findDependentSchemas(schemaDto.getStringId())); } return list; }
@Override public List<CTLSchemaDto> findCtlSchemaDependents(String fqn, Integer version, String tenantId, String applicationId) { if (isBlank(fqn) || version == null) { throw new IncorrectParameterException("Incorrect parameters for ctl schema request."); } LOG.debug("Find dependents schemas for schema with fqn {} version {}, tenantId {} and " + "applicationId ()", fqn, version, tenantId, applicationId); List<CTLSchemaDto> schemas = Collections.emptyList(); CtlSchema schema = ctlSchemaDao.findByFqnAndVerAndTenantIdAndApplicationId(fqn, version, tenantId, applicationId); if (schema != null) { schemas = convertDtoList(ctlSchemaDao.findDependentSchemas(schema.getStringId())); } return schemas; }
@Test public void saveCTLSchemaWithDependency() throws InterruptedException { List<CTLSchemaDto> dep = convertDtoList(ctlSchemaDao.findDependentSchemas(mainSchema.getId())); Assert.assertTrue(dep.isEmpty()); List<CTLSchemaDto> expected = Arrays.asList(mainSchema); dep = convertDtoList(ctlSchemaDao.findDependentSchemas(firstSchema.getId())); Assert.assertEquals(expected.size(), dep.size()); dep = convertDtoList(ctlSchemaDao.findDependentSchemas(secondSchema.getId())); Assert.assertEquals(expected.size(), dep.size()); dep = convertDtoList(ctlSchemaDao.findDependentSchemas(thirdSchema.getId())); Assert.assertEquals(expected.size(), dep.size()); dep = convertDtoList(ctlSchemaDao.findDependentSchemas(fourthSchema.getId())); Assert.assertEquals(expected.size(), dep.size()); }
if (ctlSchema != null) { List<CtlSchema> dependsList = ctlSchemaDao.findDependentSchemas(ctlSchema.getStringId()); if (dependsList.isEmpty()) { synchronized (this) {