Skip to content

Package: RepositoryMediaCatalog

RepositoryMediaCatalog

nameinstructionbranchcomplexitylinemethod
RepositoryMediaCatalog()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
configured(SourceAwareFinder)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
findArtists()
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
findAudioFiles()
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
findPerformances()
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
findRecords()
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
findTracks()
M: 0 C: 11
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getFallback()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getSource()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
initialize()
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setFallback(Id)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setFallbackAsString(String)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
setSource(Id)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setSourceAsString(String)
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
static {...}
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /*
2: * *********************************************************************************************************************
3: *
4: * blueMarine II: Semantic Media Centre
5: * http://tidalwave.it/projects/bluemarine2
6: *
7: * Copyright (C) 2015 - 2021 by Tidalwave s.a.s. (http://tidalwave.it)
8: *
9: * *********************************************************************************************************************
10: *
11: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
12: * the License. You may obtain a copy of the License at
13: *
14: * http://www.apache.org/licenses/LICENSE-2.0
15: *
16: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
17: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations under the License.
19: *
20: * *********************************************************************************************************************
21: *
22: * git clone https://bitbucket.org/tidalwave/bluemarine2-src
23: * git clone https://github.com/tidalwave-it/bluemarine2-src
24: *
25: * *********************************************************************************************************************
26: */
27: package it.tidalwave.bluemarine2.model.impl.catalog;
28:
29: import javax.annotation.Nonnull;
30: import javax.annotation.PostConstruct;
31: import javax.inject.Inject;
32: import javax.inject.Provider;
33: import org.eclipse.rdf4j.repository.Repository;
34: import it.tidalwave.util.Id;
35: import it.tidalwave.bluemarine2.model.MediaCatalog;
36: import it.tidalwave.bluemarine2.model.finder.audio.AudioFileFinder;
37: import it.tidalwave.bluemarine2.model.finder.audio.MusicArtistFinder;
38: import it.tidalwave.bluemarine2.model.finder.audio.PerformanceFinder;
39: import it.tidalwave.bluemarine2.model.finder.audio.RecordFinder;
40: import it.tidalwave.bluemarine2.model.finder.audio.TrackFinder;
41: import it.tidalwave.bluemarine2.model.impl.catalog.finder.RepositoryAudioFileFinder;
42: import it.tidalwave.bluemarine2.model.impl.catalog.finder.RepositoryMusicArtistFinder;
43: import it.tidalwave.bluemarine2.model.impl.catalog.finder.RepositoryPerformanceFinder;
44: import it.tidalwave.bluemarine2.model.impl.catalog.finder.RepositoryRecordFinder;
45: import it.tidalwave.bluemarine2.model.impl.catalog.finder.RepositoryTrackFinder;
46: import it.tidalwave.bluemarine2.model.spi.SourceAwareFinder;
47: import lombok.Getter;
48: import lombok.Setter;
49: import lombok.extern.slf4j.Slf4j;
50: import static it.tidalwave.bluemarine2.model.vocabulary.BMMO.*;
51:
52: /***********************************************************************************************************************
53: *
54: * @author Fabrizio Giudici
55: *
56: **********************************************************************************************************************/
57: @Slf4j
58: public class RepositoryMediaCatalog implements MediaCatalog
59: {
60: @Getter @Setter
61: private Id source = ID_SOURCE_EMBEDDED;
62:
63: @Getter @Setter
64: private Id fallback = ID_SOURCE_EMBEDDED;
65:
66: @Inject
67: private Provider<Repository> repository;
68:
69: public void setSourceAsString (@Nonnull final String sourceAsString)
70: {
71: setSource(Id.of(sourceAsString));
72: }
73:
74: public void setFallbackAsString (@Nonnull final String fallbackAsString)
75: {
76: setFallback(Id.of(fallbackAsString));
77: }
78:
79: @Override @Nonnull
80: public MusicArtistFinder findArtists()
81: {
82: return configured(new RepositoryMusicArtistFinder(repository.get()));
83: }
84:
85: @Override @Nonnull
86: public RecordFinder findRecords()
87: {
88: return configured(new RepositoryRecordFinder(repository.get()));
89: }
90:
91: @Override @Nonnull
92: public TrackFinder findTracks()
93: {
94: return configured(new RepositoryTrackFinder(repository.get()));
95: }
96:
97: @Override @Nonnull
98: public PerformanceFinder findPerformances()
99: {
100: return configured(new RepositoryPerformanceFinder(repository.get()));
101: }
102:
103: @Override @Nonnull
104: public AudioFileFinder findAudioFiles()
105: {
106: return configured(new RepositoryAudioFileFinder(repository.get()));
107: }
108:
109: @PostConstruct
110: private void initialize()
111: {
112: log.info("Catalog configuration source: {} fallback: {}", getSource(), getFallback());
113: }
114:
115: @Nonnull
116: private <ENTITY, FINDER extends SourceAwareFinder<ENTITY, FINDER>> FINDER configured (@Nonnull final FINDER finder)
117: {
118: return finder.importedFrom(getSource()).withFallback(getFallback());
119: }
120: }