private List<CtlSchemaMetaInfoDto> getMetaInfoFromCtlSchema(List<CtlSchema> schemas) { Map<String, CtlSchemaMetaInfoDto> metaInfoMap = new HashMap<>(); if (!schemas.isEmpty()) { for (CtlSchema schema : schemas) { String metaInfoId = schema.getMetaInfo().getStringId(); CtlSchemaMetaInfoDto metaInfoDto = metaInfoMap.get(metaInfoId); if (metaInfoDto == null) { metaInfoDto = getDto(schema.getMetaInfo()); metaInfoMap.put(metaInfoId, metaInfoDto); } List<Integer> versions = metaInfoDto.getVersions(); if (versions == null) { versions = new ArrayList<>(); metaInfoDto.setVersions(versions); } versions.add(schema.getVersion()); } } List<CtlSchemaMetaInfoDto> result = new ArrayList<>(metaInfoMap.values()); return result; }
@Override public CtlSchemaMetaInfo updateScope(CtlSchemaMetaInfo ctlSchemaMetaInfo) { LOG.debug("Updating ctl meta info scope {}", ctlSchemaMetaInfo); CtlSchemaMetaInfo metaInfo = findById(ctlSchemaMetaInfo.getStringId()); if (metaInfo != null) { metaInfo.setTenant(ctlSchemaMetaInfo.getTenant()); metaInfo.setApplication(ctlSchemaMetaInfo.getApplication()); metaInfo = super.save(metaInfo); } LOG.debug("Update result: {}", metaInfo != null); return metaInfo; }
try { ctlSchemaDao.removeById(ctlSchema.getStringId()); List<CtlSchema> schemas = ctlSchemaDao.findAllByMetaInfoId(metaInfo.getStringId()); if (schemas == null || schemas.isEmpty()) { ctlSchemaMetaInfoDao.removeById(metaInfo.getStringId());
@Override public CtlSchemaMetaInfoDto toDto() { CtlSchemaMetaInfoDto ctlSchemaMetaInfoDto = createDto(); ctlSchemaMetaInfoDto.setId(getStringId()); ctlSchemaMetaInfoDto.setFqn(fqn); ctlSchemaMetaInfoDto.setApplicationId(application != null ? application.getStringId() : null); ctlSchemaMetaInfoDto.setTenantId(tenant != null ? tenant.getStringId() : null); return ctlSchemaMetaInfoDto; }