@Override public Optional<MongoEndpointRegistration> findByEndpointId(String endpointId) { LOG.debug("Searching for endpoint registration by endpoint ID [{}]", endpointId); Query query = Query.query( Criteria.where(MongoModelConstants.EP_REGISTRATION_ENDPOINT_ID) .is(endpointId)); return Optional.ofNullable(this.findOne(query)); }
@Override public Optional<MongoEndpointRegistration> findByCredentialsId(String credentialsId) { LOG.debug("Searching for endpoint registration by credentials ID [{}]", credentialsId); Query query = Query.query( Criteria.where(MongoModelConstants.EP_REGISTRATION_CREDENTIALS_ID) .is(credentialsId)); return Optional.ofNullable(this.findOne(query)); }
@Override public void removeNotificationsByAppId(final String appId) { LOG.debug("Remove unicast notifications by application id [{}] ", appId); remove(query(where(EP_NF_APPLICATION_ID).is(appId))); }
@Override public List<MongoEndpointProfile> findByEndpointUserId(String endpointUserId) { LOG.debug("Find endpoint profiles by endpoint user id [{}] ", endpointUserId); return find(query(where(EP_USER_ID).is(endpointUserId))); }
@Override public void removeByEndpointId(String endpointId) { LOG.debug("Removing endpoint registration by endpoint ID [{}]", endpointId); Query query = Query.query( Criteria.where(MongoModelConstants.EP_REGISTRATION_ENDPOINT_ID) .is(endpointId)); this.remove(query); } }
@Override public void removeByHash(byte[] hash) { LOG.debug("Remove topic list entry by hash [{}] ", hash); remove(query(where(ID).is(hash))); } }
@Override public void removeByAppId(String appId) { LOG.debug("Remove endpoint profile by application id [{}] ", appId); remove(query(where(EP_APPLICATION_ID).is(appId))); }
@Override public void removeNotificationsByKeyHash(final byte[] keyHash) { LOG.debug("Remove unicast notifications by endpoint key hash [{}] ", keyHash); mongoTemplate.remove(query(where(EP_ENDPOINT_KEY_HASH).is(keyHash)), getCollectionName()); }
@Override public Optional<MongoCredentials> find(String applicationId, String credentialsId) { LOG.debug("Searching for credentials by application ID [{}] and credentials ID [{}]", applicationId, credentialsId); Query query = Query.query(Criteria.where(MongoModelConstants.CREDENTIALS_ID) .is(credentialsId) .and(MongoModelConstants.APPLICATION_ID) .is(applicationId)); return Optional.ofNullable(this.findOne(query)); }
@Override public void removeByExternalIdAndTenantId(String externalId, String tenantId) { LOG.debug("Remove user by external uid [{}] and tenant id [{}] ", externalId, tenantId); remove(query(where(EP_USER_EXTERNAL_ID) .is(externalId) .and(EP_USER_TENANT_ID) .is(tenantId))); }
@Override public MongoEndpointProfile findEndpointIdByKeyHash(byte[] endpointKeyHash) { LOG.debug("Get count of endpoint profiles by endpoint key hash [{}] ", endpointKeyHash); Query query = query(where(EP_ENDPOINT_KEY_HASH).is(endpointKeyHash)); query.fields().include(ID); return findOne(query); }
@Override public MongoEndpointUser findByExternalIdAndTenantId(String externalId, String tenantId) { LOG.debug("Find user by external uid [{}] and tenant id [{}] ", externalId, tenantId); return findOne(query(where(EP_USER_EXTERNAL_ID) .is(externalId).and(EP_USER_TENANT_ID) .is(tenantId))); }
@Override public void removeByEndpointKeyHashAndConfigurationVersion(byte[] endpointKeyHash, Integer confSchemaVersion) { LOG.debug("Remove endpoint specific configuration by endpoint key hash [{}] ", endpointKeyHash); mongoTemplate.remove( query(where(EP_SPECIFIC_CONFIGURATION_KEY_HASH).is(endpointKeyHash) .and(EP_CONFIGURATION_VERSION).is(confSchemaVersion)), getCollectionName()); }
@Override public List<MongoEndpointNotification> findNotificationsByKeyHash(final byte[] keyHash) { LOG.debug("Find unicast notifications by endpoint key hash [{}] ", keyHash); DBObject dbObject = query(where(EP_ENDPOINT_KEY_HASH).is(keyHash)).getQueryObject(); DBCursor cursor = mongoTemplate.getDb().getCollection(getCollectionName()).find(dbObject); List<MongoEndpointNotification> endpointNotifications = new ArrayList<>(); while (cursor.hasNext()) { endpointNotifications.add(mongoTemplate.getConverter() .read(MongoEndpointNotification.class, cursor.next())); } return endpointNotifications; }
private Mono<Process> finish(ReactiveMongoOperations operations, Process process) { return operations.update(Process.class).matching(Query.query(Criteria.where("id").is(process.getId()))) .apply(Update.update("state", State.DONE).inc("transitionCount", 1)).first() // .then(Mono.just(process)); }
Mono<Process> start(ReactiveMongoOperations operations, Process process) { return operations.update(Process.class).matching(Query.query(Criteria.where("id").is(process.getId()))) .apply(Update.update("state", State.ACTIVE).inc("transitionCount", 1)).first() // .then(Mono.just(process)); }
@Override public MongoEndpointProfile findByKeyHash(byte[] endpointKeyHash) { LOG.debug("Find endpoint profile by endpoint key hash [{}] ", endpointKeyHash); DBObject dbObject = query(where(EP_ENDPOINT_KEY_HASH) .is(endpointKeyHash)) .getQueryObject(); DBObject result = mongoTemplate.getDb() .getCollection(getCollectionName()) .findOne(dbObject); return mongoTemplate.getConverter().read(getDocumentClass(), result); }
@Override public MongoTopicListEntry findByHash(byte[] hash) { LOG.debug("Find topic list entry by hash [{}] ", hash); DBObject dbObject = query(where(ID).is(hash)).getQueryObject(); DBObject result = mongoTemplate.getDb() .getCollection(getCollectionName()) .findOne(dbObject); return mongoTemplate.getConverter().read(getDocumentClass(), result); }
private void finish(Process process) { template.update(Process.class).matching(Query.query(Criteria.where("id").is(process.getId()))) .apply(Update.update("state", State.DONE).inc("transitionCount", 1)).first(); }
void start(Process process) { template.update(Process.class).matching(Query.query(Criteria.where("id").is(process.getId()))) .apply(Update.update("state", State.ACTIVE).inc("transitionCount", 1)).first(); }