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; }
if (dependsList.isEmpty()) { synchronized (this) { CtlSchemaMetaInfo metaInfo = ctlSchema.getMetaInfo(); ctlSchemaMetaInfoDao.lockRequest(lockOptions).setScope(true).lock(metaInfo); try {
@Override public CTLSchemaDto updateCtlSchema(CTLSchemaDto ctlSchema) { validateCtlSchemaObject(ctlSchema); LOG.debug("Update ctl schema with id [{}]", ctlSchema.getId()); CtlSchema schema = ctlSchemaDao.findById(ctlSchema.getId()); if (schema != null) { synchronized (this) { if (ctlSchema.getVersion() != schema.getVersion()) { throw new DatabaseProcessingException("Can't change version of existing common type " + "version."); } CtlSchemaMetaInfo metaInfo = schema.getMetaInfo(); if (!ctlSchema.getMetaInfo().equals(metaInfo.toDto())) { throw new DatabaseProcessingException("Can't update scope of existing common type " + "version within update procedure."); } ctlSchemaMetaInfoDao.lockRequest(lockOptions).setScope(true).lock(metaInfo); schema.update(ctlSchema); return DaoUtil.getDto(ctlSchemaDao.save(schema, true)); } } else { throw new DatabaseProcessingException("Can't find common type version by id."); } }