Search in sources :

Example 1 with SourceDescriptorComparator

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;
}
Also used : SourceDescriptor(ddf.catalog.source.SourceDescriptor) SourceDescriptorComparator(ddf.catalog.util.impl.SourceDescriptorComparator) SourceDescriptorImpl(ddf.catalog.source.impl.SourceDescriptorImpl) TreeSet(java.util.TreeSet) Source(ddf.catalog.source.Source) FederatedSource(ddf.catalog.source.FederatedSource)

Example 2 with SourceDescriptorComparator

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);
}
Also used : SourceDescriptor(ddf.catalog.source.SourceDescriptor) SourceDescriptorComparator(ddf.catalog.util.impl.SourceDescriptorComparator) SourceDescriptorImpl(ddf.catalog.source.impl.SourceDescriptorImpl) Before(org.junit.Before)

Aggregations

SourceDescriptor (ddf.catalog.source.SourceDescriptor)2 SourceDescriptorImpl (ddf.catalog.source.impl.SourceDescriptorImpl)2 SourceDescriptorComparator (ddf.catalog.util.impl.SourceDescriptorComparator)2 FederatedSource (ddf.catalog.source.FederatedSource)1 Source (ddf.catalog.source.Source)1 TreeSet (java.util.TreeSet)1 Before (org.junit.Before)1