@Override public LogSchemaDto saveLogSchema(LogSchemaDto logSchemaDto) throws ControlServiceException { return logSchemaService.saveLogSchema(logSchemaDto); }
@Override public LogSchemaDto getLogSchema(String logSchemaId) throws ControlServiceException { return logSchemaService.findLogSchemaById(logSchemaId); }
@Override public List<VersionDto> getLogSchemaVersionsByApplicationId(String applicationId) throws ControlServiceException { return logSchemaService.findLogSchemaVersionsByApplicationId(applicationId); }
@Test public void findLogSchemaByIdTest() { List<LogSchemaDto> schemas = logSchemaService.findLogSchemasByAppId(applicationDto.getId()); Assert.assertEquals(1, schemas.size()); LogSchemaDto dto = null; dto = logSchemaService.findLogSchemaById(schemas.get(0).getId()); Assert.assertNotNull(dto); }
@Test public void removeLogSchemasByAppIdTest() { List<LogSchemaDto> schemas = logSchemaService.findLogSchemasByAppId(applicationDto.getId()); Assert.assertEquals(1, schemas.size()); logSchemaService.removeLogSchemasByAppId(applicationDto.getId()); schemas = logSchemaService.findLogSchemasByAppId(applicationDto.getId()); Assert.assertEquals(0, schemas.size()); }
@Test public void removeLogSchemaByIdTest() { List<LogSchemaDto> schemas = logSchemaService.findLogSchemasByAppId(applicationDto.getId()); Assert.assertEquals(1, schemas.size()); logSchemaService.removeLogSchemaById(schemas.get(0).getId()); schemas = logSchemaService.findLogSchemasByAppId(applicationDto.getId()); Assert.assertEquals(0, schemas.size()); }
@Override public List<LogSchemaDto> getLogSchemasByApplicationId(String applicationId) throws ControlServiceException { return logSchemaService.findLogSchemasByAppId(applicationId); }
@Override public LogSchemaDto getLogSchemaByApplicationIdAndVersion( String applicationId, int version) throws ControlServiceException { return logSchemaService.findLogSchemaByAppIdAndVersion(applicationId, version); }
@Override public LogSchema getLogSchema(String applicationId, int logSchemaVersion) { LOG.debug("Fetching log schema for application {} and version {}", applicationId, logSchemaVersion); LogSchema logSchema = null; LogSchemaDto logSchemaDto = logSchemaService.findLogSchemaByAppIdAndVersion( applicationId, logSchemaVersion); CTLSchemaDto ctlSchema = ctlService.findCtlSchemaById(logSchemaDto.getCtlSchemaId()); String logFlatSchema = ctlService.flatExportAsString(ctlSchema); if (logSchemaDto != null) { logSchema = new LogSchema(logSchemaDto, logFlatSchema); } return logSchema; }
private LogSchemaDto createDefaultLogSchema(String appId, String createdUsername) { LogSchemaDto schema = new LogSchemaDto(); schema.setApplicationId(appId); CTLSchemaDto ctlSchema = ctlService.getOrCreateEmptySystemSchema(createdUsername); schema.setCtlSchemaId(ctlSchema.getId()); schema.setName(DEFAULT_SCHEMA_NAME); schema.setCreatedUsername(createdUsername); schema = logSchemaService.saveLogSchema(schema); return schema; }
@Test public void findLogSchemaVersionsByApplicationIdTest() { List<VersionDto> schemas = logSchemaService.findLogSchemaVersionsByApplicationId(applicationDto.getId()); Assert.assertEquals(1, schemas.size()); } }
@Override public FileData getRecordStructureSchema(String applicationId, int logSchemaVersion) throws ControlServiceException { ApplicationDto application = applicationService.findAppById(applicationId); if (application == null) { throw new NotFoundException("Application not found!"); } LogSchemaDto logSchema = logSchemaService .findLogSchemaByAppIdAndVersion(applicationId, logSchemaVersion); if (logSchema == null) { throw new NotFoundException("Log schema not found!"); } Schema recordWrapperSchema = null; try { CTLSchemaDto logCtlSchema = getCtlSchemaById(logSchema.getCtlSchemaId()); recordWrapperSchema = RecordWrapperSchemaGenerator .generateRecordWrapperSchema(logCtlSchema.getBody()); } catch (IOException ex) { LOG.error("Unable to get Record Structure Schema", ex); throw new ControlServiceException(ex); } String libraryFileName = MessageFormatter .arrayFormat(SCHEMA_NAME_PATTERN, new Object[] {logSchemaVersion}).getMessage(); String schemaInJson = recordWrapperSchema.toString(true); byte[] schemaData = schemaInJson.getBytes(StandardCharsets.UTF_8); FileData schema = new FileData(); schema.setFileName(libraryFileName); schema.setFileData(schemaData); return schema; }
schemaDto.setCreatedUsername("Test User"); schemaDto.setName("Test Name"); schemaDto = logSchemaService.saveLogSchema(schemaDto); Assert.assertNotNull(schemaDto); schemas.add(schemaDto);
@Override public FileData generateRecordStructureLibrary(String applicationId, int logSchemaVersion) throws ControlServiceException { ApplicationDto application = applicationService.findAppById(applicationId); if (application == null) { throw new NotFoundException("Application not found!"); } LogSchemaDto logSchema = logSchemaService.findLogSchemaByAppIdAndVersion(applicationId, logSchemaVersion); if (logSchema == null) { throw new NotFoundException("Log schema not found!"); } try { CTLSchemaDto logCtlSchema = getCtlSchemaById(logSchema.getCtlSchemaId()); Schema recordWrapperSchema = RecordWrapperSchemaGenerator .generateRecordWrapperSchema(getFlatSchemaByCtlSchemaId(logCtlSchema.getId())); String fileName = MessageFormatter.arrayFormat(LOG_SCHEMA_LIBRARY_NAME_PATTERN, new Object[] {logSchemaVersion}).getMessage(); return SchemaLibraryGenerator.generateSchemaLibrary(recordWrapperSchema, fileName); } catch (Exception ex) { LOG.error("Unable to generate Record Structure Library", ex); throw new ControlServiceException(ex); } }
.findLogSchemaByAppIdAndVersion(sdkProfile.getApplicationId(), sdkProfile.getLogSchemaVersion());