/** * Create instance of <code>CtlSchema</code>. * * @param dto data transfer object */ public CtlSchema(CTLSchemaDto dto) { this.id = getLongId(dto.getId()); this.metaInfo = new CtlSchemaMetaInfo(dto.getMetaInfo()); this.version = dto.getVersion(); this.createdUsername = dto.getCreatedUsername(); this.createdTime = dto.getCreatedTime(); update(dto); }
@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."); } }