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

nl.vpro.domain.classification.ClassificationServiceWrapper Maven / Gradle / Ivy

Go to download

The classes needed for the 'classification' service used in POMS. This os based on ClassificationScheme xml's as provided by EBU. It at the moment is only used for genres, but it could in principle accommodate other types of classification based on a fixed list.

There is a newer version: 8.3.1
Show newest version
package nl.vpro.domain.classification;

import java.net.URI;
import java.time.Instant;
import java.util.Collection;
import java.util.List;

/**
 * Wraps another ClassifcationService. The goal is that this can implicitely use an {@link URLClassificationServiceImpl} (using cache headers), or a simple {@link ClassificationServiceImpl}.
 * @author Michiel Meeuwissen
 * @since 3.2
 */
public class ClassificationServiceWrapper implements ClassificationService {

    private final ClassificationService service;

    public ClassificationServiceWrapper(ClassificationService wrapped) {
        this.service = wrapped;
    }

    public ClassificationServiceWrapper(URI url) {
        this.service = new URLClassificationServiceImpl(url);
    }

    public ClassificationServiceWrapper(String url) {
        this.service = getService(url);
    }

    private static ClassificationService getService(String url) {
        if (url.startsWith("http")) {
            return new CachedURLClassificationServiceImpl(URI.create(url));
        } else {
            return new ClassificationServiceImpl(url);
        }
    }

    @Override
    public Term getTerm(String termId) throws TermNotFoundException {
        return service.getTerm(termId);
    }

    @Override
    public List getTermsByReference(String reference) {
        return service.getTermsByReference(reference);
    }

    @Override
    public boolean hasTerm(String termId) {
        return service.hasTerm(termId);
    }

    @Override
    public Collection values() {
        return service.values();
    }

    @Override
    public Collection valuesOf(String termId) {
        return service.valuesOf(termId);
    }

    @Override
    public ClassificationScheme getClassificationScheme() {
        return service.getClassificationScheme();
    }

    @Override
    public Instant getLastModified() {
        return service.getLastModified();
    }

    @Override
    public String toString() {
        return "" + service;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy