Search in sources :

Example 11 with MediaObjectMetadataDescriptor

use of org.vitrivr.cineast.core.data.entities.MediaObjectMetadataDescriptor in project cineast by vitrivr.

the class JsonMetaDataExtractor method extract.

@Override
public List<MediaObjectMetadataDescriptor> extract(String objectId, Path path) {
    File file = path.toFile();
    File parent = file.getParentFile();
    File jsonFile = new File(parent, file.getName() + ".json");
    if (!jsonFile.exists()) {
        jsonFile = new File(parent, com.google.common.io.Files.getNameWithoutExtension(file.getName()) + ".json");
    }
    if (!jsonFile.exists()) {
        return new ArrayList<>(0);
    }
    @SuppressWarnings("unchecked") Map<String, Object> json = jsonProvider.toObject(jsonFile, Map.class);
    if (json == null || json.isEmpty()) {
        return new ArrayList<>(0);
    }
    ArrayList<MediaObjectMetadataDescriptor> _return = new ArrayList<>(json.size());
    Set<String> keys = json.keySet();
    for (String key : keys) {
        _return.add(MediaObjectMetadataDescriptor.of(objectId, domain(), key, json.get(key)));
    }
    return _return;
}
Also used : ArrayList(java.util.ArrayList) MediaObjectMetadataDescriptor(org.vitrivr.cineast.core.data.entities.MediaObjectMetadataDescriptor) File(java.io.File)

Aggregations

MediaObjectMetadataDescriptor (org.vitrivr.cineast.core.data.entities.MediaObjectMetadataDescriptor)11 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 MediaObjectMetadataQueryResult (org.vitrivr.cineast.api.messages.result.MediaObjectMetadataQueryResult)3 MediaObjectMetadataReader (org.vitrivr.cineast.core.db.dao.reader.MediaObjectMetadataReader)3 File (java.io.File)2 Path (java.nio.file.Path)2 Map (java.util.Map)2 Set (java.util.Set)2 TimeUnit (java.util.concurrent.TimeUnit)2 LogManager (org.apache.logging.log4j.LogManager)2 Logger (org.apache.logging.log4j.Logger)2 MediaObjectDescriptor (org.vitrivr.cineast.core.data.entities.MediaObjectDescriptor)2 MediaObjectReader (org.vitrivr.cineast.core.db.dao.reader.MediaObjectReader)2 ExifDirectoryBase (com.drew.metadata.exif.ExifDirectoryBase)1 ExifSubIFDDirectory (com.drew.metadata.exif.ExifSubIFDDirectory)1 Maps (com.google.common.collect.Maps)1 StreamObserver (io.grpc.stub.StreamObserver)1