All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.capitalone.dashboard.repository.ScopeOwnerRepository Maven / Gradle / Ivy

package com.capitalone.dashboard.repository;

import com.capitalone.dashboard.model.ScopeOwnerCollectorItem;
import org.apache.commons.collections4.CollectionUtils;
import org.bson.types.ObjectId;

import java.util.Collections;
import java.util.List;

/**
 * CollectorItem repository for {@link ScopeOwnerCollectorItem}.
 */
public interface ScopeOwnerRepository extends BaseCollectorItemRepository {

	default ScopeOwnerCollectorItem findTeamCollector(ObjectId collectorId, String teamId) {
		return findOne("collectorId eq " + quote(collectorId.toHexString()) + " and " + "options.teamId eq " + quote(teamId) + " and options.assetState equalsIgnoreCase 'active'");
	}

	default ScopeOwnerCollectorItem findTeamCollector(ObjectId collectorId, String teamId, String name) {
		return findOne("collectorId eq " + quote(collectorId.toHexString()) + " and " + "options.teamId eq " + quote(teamId) + " and options.name eq " + quote(name) + " and options.assetState equalsIgnoreCase 'active'");
	}

	default List findEnabledTeamCollectors(ObjectId collectorId, String teamId) {
		return findAll("collectorId eq " + quote(collectorId.toHexString()) + " and " + "options.teamId eq " + quote(teamId) + " and enabled isTrue and options.assetState equalsIgnoreCase 'active'");
	}

	default List findTopByChangeDateDesc(ObjectId collectorId, String changeDate) {
		return findAll("collectorId eq " + quote(collectorId.toHexString()) + " and options.changeDate gt " + quote(changeDate) + " and " + "options.assetState equalsIgnoreCase 'active'");
	}

	default List getTeamIdById(String teamId) {
		return findAll("options.teamId eq " + quote(teamId));
	}

	default List delete(String assetState) {
		List items = findAll("options.assetState equalsIgnoreCase " + quote(assetState));
		if (!CollectionUtils.isEmpty(items)) {
			deleteAll(items);
			return items;
		}
		return Collections.emptyList();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy