27 lines
1011 B
Java
27 lines
1011 B
Java
package gr.cite.notification.integrationevent.inbox.tenantremoval;
|
|
|
|
import gr.cite.notification.integrationevent.inbox.ConsistencyHandler;
|
|
import gr.cite.notification.query.TenantQuery;
|
|
import gr.cite.tools.data.query.QueryFactory;
|
|
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
|
import org.springframework.context.annotation.Scope;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
@Component
|
|
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
|
public class TenantRemovalConsistencyHandler implements ConsistencyHandler<TenantRemovalConsistencyPredicates> {
|
|
|
|
private final QueryFactory queryFactory;
|
|
|
|
public TenantRemovalConsistencyHandler(QueryFactory queryFactory) {
|
|
this.queryFactory = queryFactory;
|
|
}
|
|
|
|
@Override
|
|
public Boolean isConsistent(TenantRemovalConsistencyPredicates consistencyPredicates) {
|
|
long count = this.queryFactory.query(TenantQuery.class).ids(consistencyPredicates.getTenantId()).count();
|
|
return count > 0;
|
|
}
|
|
|
|
}
|