use of com.walmartlabs.concord.server.plugins.noderoster.jooq.tables.NodeRosterHosts in project concord by walmartlabs.
the class HostsDao method list.
public List<HostEntry> list(HostFilter filter, Set<HostsDataInclude> includes, int limit, int offset) {
NodeRosterHosts nrh = NODE_ROSTER_HOSTS.as("nrh");
NodeRosterProcessHosts nrph = NODE_ROSTER_PROCESS_HOSTS.as("nrph");
NodeRosterHostArtifacts nrha = NODE_ROSTER_HOST_ARTIFACTS.as("nrha");
SelectQuery<Record> query = dsl().selectQuery();
query.addSelect(nrh.HOST_ID, nrh.NORMALIZED_HOSTNAME, nrh.CREATED_AT);
query.addFrom(nrh);
if (filter.host() != null) {
query.addConditions(nrh.NORMALIZED_HOSTNAME.containsIgnoreCase(filter.host()));
}
ProcessKey key = null;
if (filter.processInstanceId() != null) {
key = processKeyCache.get(filter.processInstanceId());
if (key == null) {
return Collections.emptyList();
}
query.addFrom(nrph);
query.addConditions(nrh.HOST_ID.eq(nrph.HOST_ID).and(nrph.INSTANCE_ID.eq(key.getInstanceId()).and(nrph.INSTANCE_CREATED_AT.eq(key.getCreatedAt()))));
}
if ((includes != null && includes.contains(HostsDataInclude.ARTIFACTS)) || filter.artifact() != null) {
query.addSelect(nrha.ARTIFACT_URL);
query.addFrom(nrha);
query.addConditions(nrh.HOST_ID.eq(nrha.HOST_ID));
}
if (filter.artifact() != null) {
query.addConditions(nrha.ARTIFACT_URL.likeRegex(filter.artifact()));
if (key != null) {
query.addConditions(nrha.INSTANCE_ID.eq(key.getInstanceId()).and(nrha.INSTANCE_CREATED_AT.eq(key.getCreatedAt())));
}
}
query.addOrderBy(nrh.CREATED_AT.desc());
query.addLimit(limit);
query.addOffset(offset);
return query.fetch(HostsDao::toHostEntry);
}
Aggregations