/** * Update fields <code>tenant</code> and <code>application</code>, * create new instances by using ids in parameters. * @param tenantId is tenant id * @param applicationId is application id */ public void updateScope(String tenantId, String applicationId) { Long tenId = getLongId(tenantId); this.tenant = tenId != null ? new Tenant(tenId) : null; Long appId = getLongId(applicationId); this.application = appId != null ? new Application(appId) : null; }
private Criterion buildEqIdCriterion(String reference, String id) { Criterion criterion; if (isBlank(id)) { criterion = Restrictions.isNull(reference); } else { criterion = Restrictions.eq(reference, ModelUtils.getLongId(id)); } return criterion; } }
/** * Create new instance of tenant. * * @param dto data transfer object that used for creating new instance, * it hold id and name of new instance */ public Tenant(TenantDto dto) { if (dto != null) { this.id = getLongId(dto); this.name = dto.getName(); } }
@Override public List<ServerProfileSchema> findByAppId(String appId) { List<ServerProfileSchema> schemas = Collections.emptyList(); LOG.debug("Searching server profile schemas by application id [{}] ", appId); if (isNotBlank(appId)) { schemas = findListByCriterion(Restrictions.eq(APPLICATION_REFERENCE, getLongId(appId))); } if (LOG.isTraceEnabled()) { LOG.trace("[{}] Search result: {}.", appId, Arrays.toString(schemas.toArray())); } else { LOG.debug("[{}] Search result: {}.", appId, schemas.size()); } return schemas; }
/** * Get Long id from object with id. * * @param hasId the object with id * @return id */ public static Long getLongId(HasId hasId) { Long longId = null; if (hasId != null) { String id = hasId.getId(); longId = getLongId(id); } return longId; }
protected abstract GenericModel<T> newInstance(Long id);
/** * Create new instance of CTL schema meta info. * @param fqn is full qualified name * @param tenantId is tenant id, it used for creating * <code>Tenant</code> with corresponding id and * set it on field <code>tenant</code> * @param applicationId is application id, it used for creating * <code>Application</code> with corresponding id and * set it on field <code>application</code> */ public CtlSchemaMetaInfo(String fqn, String tenantId, String applicationId) { this.fqn = fqn; Long tenId = getLongId(tenantId); this.tenant = tenId != null ? new Tenant(tenId) : null; Long appId = getLongId(applicationId); this.application = appId != null ? new Application(appId) : null; }
@Override public void removeByAppId(String appId) { if (isNotBlank(appId)) { List<ServerProfileSchema> schemaList = findListByCriterion(Restrictions.eq( APPLICATION_REFERENCE, getLongId(appId))); removeList(schemaList); } LOG.debug("Removed server profile schemas by application id [{}]", appId); } }
/** * Create new instance of <code>Change</code>. * * @param dto data transfer object */ public Change(ChangeDto dto) { if (dto != null) { this.id = getLongId(dto.getId()); this.type = dto.getType(); this.configurationVersion = dto.getCfVersion(); this.groupId = getLongId(dto.getEndpointGroupId()); this.profileFilterId = getLongId(dto.getProfileFilterId()); this.configurationId = getLongId(dto.getConfigurationId()); this.topicId = getLongId(dto.getTopicId()); } }
/** * Create new instance of CTL schema meta info. * * @param dto data transfer object that used for creating new instance, * it hold id, full qualified name, tenant id and application id * of new instance */ public CtlSchemaMetaInfo(CtlSchemaMetaInfoDto dto) { this.id = ModelUtils.getLongId(dto.getId()); this.fqn = dto.getFqn(); Long tenantId = getLongId(dto.getTenantId()); this.tenant = tenantId != null ? new Tenant(tenantId) : null; Long appId = getLongId(dto.getApplicationId()); this.application = appId != null ? new Application(appId) : null; }
@Override public ServerProfileSchema findLatestByAppId(String appId) { ServerProfileSchema latestSchema = null; LOG.debug("Searching latest server profile schema by application id [{}] ", appId); if (isNotBlank(appId)) { Criteria criteria = getCriteria().createAlias(APPLICATION_PROPERTY, APPLICATION_ALIAS) .add(Restrictions.eq(APPLICATION_REFERENCE, getLongId(appId))) .addOrder(Order.desc(VERSION_PROPERTY)).setMaxResults(FIRST); latestSchema = findOneByCriteria(criteria); } if (LOG.isTraceEnabled()) { LOG.trace("[{}] Search result: {}.", appId, latestSchema); } else { LOG.debug("[{}] Search result: {}.", appId, latestSchema != null); } return latestSchema; }
/** * Instantiates the ApplicationEventMap. */ public ApplicationEventMap(ApplicationEventMapDto dto) { this.id = getLongId(dto.getId()); Long eventClassId = getLongId(dto.getEventClassId()); if (eventClassId != null) { this.eventClass = new EventClass(eventClassId); } this.fqn = dto.getFqn(); this.action = dto.getAction(); }
/** * Instantiates new user. */ public User(UserDto dto) { if (dto != null) { this.id = getLongId(dto); this.username = dto.getUsername(); this.externalUid = dto.getExternalUid(); this.authority = dto.getAuthority(); Long tenantId = getLongId(dto.getTenantId()); this.tenant = tenantId != null ? new Tenant(tenantId) : null; } }
/** * Create new instance of <code>History</code>. * @param dto data transfer object contain data that * assign on fields of new instance */ public History(HistoryDto dto) { if (dto != null) { this.id = getLongId(dto); this.sequenceNumber = dto.getSequenceNumber(); this.change = new Change(dto.getChange()); this.lastModifyTime = dto.getLastModifyTime(); Long applicationId = getLongId(dto.getApplicationId()); if (applicationId != null) { this.application = new Application(applicationId); } } }
/** * Create new instance of <code>Application</code>. * @param dto data transfer object contain data that * assign on fields of new instance */ public Application(ApplicationDto dto) { if (dto != null) { this.id = getLongId(dto); this.applicationToken = dto.getApplicationToken(); this.name = dto.getName(); this.sequenceNumber = dto.getSequenceNumber(); Long tenantId = getLongId(dto.getTenantId()); if (tenantId != null) { this.tenant = new Tenant(tenantId); } this.credentialsServiceName = dto.getCredentialsServiceName(); } }
/** * Instantiates the EventClassFamilyVersion. */ public EventClassFamilyVersion(EventClassFamilyVersionDto dto) { this.id = getLongId(dto.getId()); this.version = dto.getVersion(); this.createdUsername = dto.getCreatedUsername(); this.createdTime = dto.getCreatedTime(); if (dto.getRecords() != null) { this.records = new ArrayList<>(dto.getRecords().size()); for (EventClassDto record : dto.getRecords()) { this.records.add(new EventClass(record)); } } }
/** * Instantiates new topic. */ public Topic(TopicDto dto) { if (dto != null) { this.id = getLongId(dto); this.name = dto.getName(); this.description = dto.getDescription(); this.createdUsername = dto.getCreatedUsername(); this.createdTime = dto.getCreatedTime(); this.sequenceNumber = dto.getSecNum(); this.type = dto.getType(); Long appId = getLongId(dto.getApplicationId()); this.application = appId != null ? new Application(appId) : null; } }
/** * Instantiates the Configuration. */ public Configuration(ConfigurationDto dto) { super(dto); if (dto != null) { Long schemaId = getLongId(dto.getSchemaId()); this.configurationSchema = schemaId != null ? new ConfigurationSchema(schemaId) : null; this.configurationBody = stringToBinary(dto.getBody()); this.schemaVersion = dto.getSchemaVersion(); } }
/** * Create instance of <code>EndpointGroup</code>. * * @param dto data transfer object */ public EndpointGroup(EndpointGroupDto dto) { if (dto != null) { this.id = getLongId(dto); this.name = dto.getName(); this.sequenceNumber = dto.getSequenceNumber(); this.weight = dto.getWeight(); this.description = dto.getDescription(); this.createdUsername = dto.getCreatedUsername(); this.createdTime = dto.getCreatedTime(); Long appId = getLongId(dto.getApplicationId()); this.application = appId != null ? new Application(appId) : null; this.topics = getTopic(dto.getTopics()); } }
/** * 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); }