Search in sources :

Example 1 with NothingProvider

use of org.vitrivr.cineast.core.data.providers.primitive.NothingProvider in project cineast by vitrivr.

the class EXIFMetadataExtractor method extract.

/**
 * Extracts the metadata from the specified path and returns a List of MediaObjectMetadataDescriptor objects (one for each metadata entry).
 *
 * @param objectId ID of the multimedia object for which metadata will be generated.
 * @param path     Path to the file for which metadata should be extracted.
 * @return List of MultimediaMetadataDescriptors. The list may be empty but must always be returned!
 */
@Override
public List<MediaObjectMetadataDescriptor> extract(String objectId, Path path) {
    ExifSubIFDDirectory md = MetadataUtil.getMetadataDirectoryOfType(path, ExifSubIFDDirectory.class);
    if (md == null) {
        return Collections.emptyList();
    }
    Set<Entry<String, Object>> set = Maps.transformValues(FIELDS, md::getObject).entrySet();
    return set.stream().filter(e -> e.getValue() != null).map(e -> MediaObjectMetadataDescriptor.of(objectId, this.domain(), e.getKey(), e.getValue())).filter(e -> !(e.getValueProvider() instanceof NothingProvider)).collect(Collectors.toList());
}
Also used : ExifDirectoryBase(com.drew.metadata.exif.ExifDirectoryBase) Set(java.util.Set) HashMap(java.util.HashMap) MediaObjectMetadataDescriptor(org.vitrivr.cineast.core.data.entities.MediaObjectMetadataDescriptor) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) ExifSubIFDDirectory(com.drew.metadata.exif.ExifSubIFDDirectory) List(java.util.List) NothingProvider(org.vitrivr.cineast.core.data.providers.primitive.NothingProvider) MetadataUtil(org.vitrivr.cineast.core.util.MetadataUtil) Entry(java.util.Map.Entry) Path(java.nio.file.Path) Collections(java.util.Collections) ExifSubIFDDirectory(com.drew.metadata.exif.ExifSubIFDDirectory) Entry(java.util.Map.Entry) NothingProvider(org.vitrivr.cineast.core.data.providers.primitive.NothingProvider)

Aggregations

ExifDirectoryBase (com.drew.metadata.exif.ExifDirectoryBase)1 ExifSubIFDDirectory (com.drew.metadata.exif.ExifSubIFDDirectory)1 Maps (com.google.common.collect.Maps)1 Path (java.nio.file.Path)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 MediaObjectMetadataDescriptor (org.vitrivr.cineast.core.data.entities.MediaObjectMetadataDescriptor)1 NothingProvider (org.vitrivr.cineast.core.data.providers.primitive.NothingProvider)1 MetadataUtil (org.vitrivr.cineast.core.util.MetadataUtil)1