use of ddf.catalog.util.impl.SourceDescriptorComparator in project ddf by codice.
the class SourceOperations method getFederatedSourceDescriptors.
/**
* Creates a {@link Set} of {@link SourceDescriptor} based on the incoming list of
* {@link Source}.
*
* @param sources {@link Collection} of {@link Source} to obtain descriptor information from
* @return new {@link Set} of {@link SourceDescriptor}
*/
private Set<SourceDescriptor> getFederatedSourceDescriptors(Collection<FederatedSource> sources, boolean addCatalogProviderDescriptor) {
SourceDescriptorImpl sourceDescriptor;
Set<SourceDescriptor> sourceDescriptors = new TreeSet<>(new SourceDescriptorComparator());
if (sources != null) {
for (Source source : sources) {
if (source != null) {
String sourceId = source.getId();
LOGGER.debug("adding sourceId: {}", sourceId);
Source cachedSource = null;
// check the poller for cached information
if (frameworkProperties.getSourcePoller() != null && frameworkProperties.getSourcePoller().getCachedSource(source) != null) {
cachedSource = frameworkProperties.getSourcePoller().getCachedSource(source);
}
sourceDescriptor = new SourceDescriptorImpl(sourceId, source.getContentTypes());
sourceDescriptor.setVersion(source.getVersion());
sourceDescriptor.setAvailable((cachedSource != null) && cachedSource.isAvailable());
sourceDescriptors.add(sourceDescriptor);
}
}
}
if (addCatalogProviderDescriptor) {
addCatalogSourceDescriptor(sourceDescriptors);
}
return sourceDescriptors;
}
use of ddf.catalog.util.impl.SourceDescriptorComparator in project ddf by codice.
the class SourceInfoResponseImplTest method setup.
@Before
public void setup() {
firstSource = new SourceDescriptorImpl("aSource", null);
nextSource = new SourceDescriptorImpl("BSource", null);
lastSource = new SourceDescriptorImpl("cSource", null);
sourceDescriptors = new TreeSet<SourceDescriptor>(new SourceDescriptorComparator());
sourceDescriptors.add(lastSource);
sourceDescriptors.add(firstSource);
sourceDescriptors.add(nextSource);
}
Aggregations