<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../../jacoco-resources/report.gif" type="image/gif"/><title>RepositoryRecord.java</title><link rel="stylesheet" href="../../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../../index.html" class="el_report">blueMarine II :: Media Server</a> > <a href="../index.html" class="el_bundle">it-tidalwave-bluemarine2-catalog</a> > <a href="index.source.html" class="el_package">it.tidalwave.bluemarine2.model.impl.catalog</a> > <span class="el_source">RepositoryRecord.java</span></div><h1>RepositoryRecord.java</h1><pre class="source lang-java linenums">/*
* *********************************************************************************************************************
*
* blueMarine II: Semantic Media Centre
* http://tidalwave.it/projects/bluemarine2
*
* Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
*
* *********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* *********************************************************************************************************************
*
* git clone https://bitbucket.org/tidalwave/bluemarine2-src
* git clone https://github.com/tidalwave-it/bluemarine2-src
*
* *********************************************************************************************************************
*/
package it.tidalwave.bluemarine2.model.impl.catalog;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.Immutable;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.net.URL;
import org.eclipse.rdf4j.query.BindingSet;
import org.eclipse.rdf4j.repository.Repository;
import it.tidalwave.bluemarine2.model.audio.Record;
import it.tidalwave.bluemarine2.model.finder.audio.TrackFinder;
import it.tidalwave.bluemarine2.model.impl.catalog.finder.RepositoryOptimizedTrackFinder;
import it.tidalwave.bluemarine2.model.impl.catalog.finder.RepositoryRecordImageFinder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
/***********************************************************************************************************************
*
* An implementation of {@link Record} that is mapped to a {@link Repository}.
*
* @stereotype Datum
*
* @author Fabrizio Giudici
*
**********************************************************************************************************************/
<span class="fc" id="L53">@Immutable @Getter @Slf4j</span>
public class RepositoryRecord extends RepositoryEntitySupport implements Record
{
<span class="nc" id="L56"> @Getter @Nonnull</span>
private final Optional<Integer> diskNumber;
<span class="nc" id="L59"> @Getter @Nonnull</span>
private final Optional<Integer> diskCount;
<span class="fc" id="L62"> @Getter @Nonnull</span>
private final Optional<Integer> trackCount; // FIXME: should be used as a shortcut for queries
<span class="fc" id="L65"> @Getter @Nonnull</span>
private final Optional<String> asin;
<span class="fc" id="L68"> @Getter @Nonnull</span>
private final Optional<String> gtin;
public RepositoryRecord (@Nonnull final Repository repository, @Nonnull final BindingSet bindingSet)
{
<span class="fc" id="L73"> super(repository, bindingSet, "record");</span>
<span class="fc" id="L74"> diskNumber = toInteger(bindingSet.getBinding("disk_number"));</span>
<span class="fc" id="L75"> diskCount = toInteger(bindingSet.getBinding("disk_count"));</span>
<span class="fc" id="L76"> trackCount = toInteger(bindingSet.getBinding("track_count"));</span>
<span class="fc" id="L77"> asin = toString(bindingSet.getBinding("asin"));</span>
<span class="fc" id="L78"> gtin = toString(bindingSet.getBinding("gtin"));</span>
<span class="fc" id="L79"> }</span>
@Override @Nonnull
public TrackFinder findTracks()
{
<span class="fc" id="L84"> return configured(new RepositoryOptimizedTrackFinder(repository, trackCount)).inRecord(this);</span>
}
@Override @Nonnull
public Optional<URL> getImageUrl()
{
<span class="nc" id="L90"> final List<? extends URL> imageUrls = new RepositoryRecordImageFinder(repository, this).results();</span>
// FIXME: check - images are ordered by size