Content of file RepositoryRecord.java.html

<?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 :: UI :: JavaFX</a> &gt; <a href="../index.html" class="el_bundle">it-tidalwave-bluemarine2-catalog</a> &gt; <a href="index.source.html" class="el_package">it.tidalwave.bluemarine2.model.impl.catalog</a> &gt; <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 &quot;License&quot;); 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 &quot;AS IS&quot; 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&lt;Integer&gt; diskNumber;

<span class="nc" id="L59">    @Getter @Nonnull</span>
    private final Optional&lt;Integer&gt; diskCount;

<span class="fc" id="L62">    @Getter @Nonnull</span>
    private final Optional&lt;Integer&gt; trackCount; // FIXME: should be used as a shortcut for queries

<span class="fc" id="L65">    @Getter @Nonnull</span>
    private final Optional&lt;String&gt; asin;

<span class="fc" id="L68">    @Getter @Nonnull</span>
    private final Optional&lt;String&gt; gtin;

    public RepositoryRecord (@Nonnull final Repository repository, @Nonnull final BindingSet bindingSet)
      {
<span class="fc" id="L73">        super(repository, bindingSet, &quot;record&quot;);</span>
<span class="fc" id="L74">        diskNumber = toInteger(bindingSet.getBinding(&quot;disk_number&quot;));</span>
<span class="fc" id="L75">        diskCount  = toInteger(bindingSet.getBinding(&quot;disk_count&quot;));</span>
<span class="fc" id="L76">        trackCount = toInteger(bindingSet.getBinding(&quot;track_count&quot;));</span>
<span class="fc" id="L77">        asin       = toString(bindingSet.getBinding(&quot;asin&quot;));</span>
<span class="fc" id="L78">        gtin       = toString(bindingSet.getBinding(&quot;gtin&quot;));</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&lt;URL&gt; getImageUrl()
      {
<span class="nc" id="L90">        final List&lt;? extends URL&gt; imageUrls = new RepositoryRecordImageFinder(repository, this).results();</span>
        // FIXME: check - images are ordered by size
check - images are ordered by size
<span class="nc" id="L92"> Collections.reverse(imageUrls);</span> <span class="nc bnc" id="L93" title="All 2 branches missed."> return imageUrls.isEmpty() ? Optional.empty() : Optional.of(imageUrls.get(0));</span> } @Override @Nonnull public String toString() { <span class="nc" id="L99"> return String.format(&quot;RepositoryRecord(rdfs:label=%s, %s)&quot;, rdfsLabel, id);</span> } } </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html>