@Override protected GenericModel<CtlSchemaMetaInfoDto> newInstance(Long id) { return new CtlSchemaMetaInfo(id); }
private CtlSchema generateCTLSchema(String fqn, Tenant tenant, int version, String body) { CtlSchema ctlSchema = new CtlSchema(); if (tenant == null) { tenant = generateTenant(); } ctlSchema.setMetaInfo(new CtlSchemaMetaInfo(fqn, tenant, null)); ctlSchema.setVersion(version); if (isBlank(body)) { body = UUID.randomUUID().toString(); } ctlSchema.setBody(body); return ctlSchema; }
/** * 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); }
protected CtlSchema generateCTLSchema(String fqn, int version, Tenant tenant, CTLSchemaScopeDto scope) { if (scope == null) { if (tenant == null) { scope = CTLSchemaScopeDto.SYSTEM; } else { scope = CTLSchemaScopeDto.TENANT; } } CtlSchemaMetaInfo metaInfo = new CtlSchemaMetaInfo(); metaInfo.setFqn(fqn); metaInfo.setTenant(tenant); metaInfo = ctlSchemaMetaInfoDao.save(metaInfo); CtlSchema ctlSchema = new CtlSchema(); ctlSchema.setMetaInfo(metaInfo); ctlSchema.setVersion(version); ctlSchema.setBody(UUID.randomUUID().toString()); ctlSchema.setDependencySet(new HashSet<CtlSchema>()); ctlSchema = ctlSchemaDao.save(ctlSchema); return ctlSchema; }
@Override public CtlSchemaMetaInfoDto updateCtlSchemaMetaInfoScope(CtlSchemaMetaInfoDto ctlSchemaMetaInfo) { validateObject(ctlSchemaMetaInfo, "Incorrect ctl schema meta info object"); LOG.debug("Update ctl schema meta info scope with id [{}]", ctlSchemaMetaInfo.getId()); CtlSchemaMetaInfo schemaMetaInfo = ctlSchemaMetaInfoDao.findById(ctlSchemaMetaInfo.getId()); if (schemaMetaInfo != null) { synchronized (this) { ctlSchemaMetaInfoDao.lockRequest(lockOptions).setScope(true).lock(schemaMetaInfo); if (checkScopeUpdate(ctlSchemaMetaInfo, schemaMetaInfo.toDto())) { List<CtlSchemaMetaInfo> others = ctlSchemaMetaInfoDao.findOthersByFqnAndTenantId( ctlSchemaMetaInfo.getFqn(), ctlSchemaMetaInfo.getTenantId(), ctlSchemaMetaInfo .getId()); if (others != null && !others.isEmpty()) { throw new DatabaseProcessingException("Can't update scope of the common type due to " + "an FQN conflict."); } schemaMetaInfo = ctlSchemaMetaInfoDao.updateScope( new CtlSchemaMetaInfo(ctlSchemaMetaInfo)); } return DaoUtil.getDto(schemaMetaInfo); } } else { throw new DatabaseProcessingException("Can't find common type by id."); } }
new CtlSchemaMetaInfo(metaInfo)); ctlSchemaMetaInfoDao.lockRequest(lockOptions).setScope(true).lock(uniqueMetaInfo); CtlSchema ctlSchema = new CtlSchema(unSavedSchema);