Package: RepositoryPerformanceFinder
RepositoryPerformanceFinder
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
RepositoryPerformanceFinder(Repository) |
|
|
|
|
|
||||||||||||||||||||
RepositoryPerformanceFinder(Repository, Optional, Optional) |
|
|
|
|
|
||||||||||||||||||||
RepositoryPerformanceFinder(RepositoryPerformanceFinder, Object) |
|
|
|
|
|
||||||||||||||||||||
ofTrack(Id) |
|
|
|
|
|
||||||||||||||||||||
performedBy(Id) |
|
|
|
|
|
||||||||||||||||||||
prepareQuery() |
|
|
|
|
|
||||||||||||||||||||
readResolve() |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
||||||||||||||||||||
toString() |
|
|
|
|
|
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.finder;
28:
29: import javax.annotation.Nonnull;
30: import java.util.Optional;
31: import org.eclipse.rdf4j.repository.Repository;
32: import it.tidalwave.util.Id;
33: import it.tidalwave.bluemarine2.model.audio.Performance;
34: import it.tidalwave.bluemarine2.model.finder.audio.PerformanceFinder;
35: import lombok.ToString;
36:
37: /***********************************************************************************************************************
38: *
39: * @stereotype Finder
40: *
41: * @author Fabrizio Giudici
42: *
43: **********************************************************************************************************************/
44: @ToString
45: public class RepositoryPerformanceFinder extends RepositoryFinderSupport<Performance, PerformanceFinder>
46: implements PerformanceFinder
47: {
48: private static final long serialVersionUID = -5065032203985453428L;
49:
50: private static final String QUERY_PERFORMANCES = readSparql(RepositoryPerformanceFinder.class, "Performances.sparql");
51:
52: @Nonnull
53: private final Optional<Id> trackId;
54:
55: @Nonnull
56: private final Optional<Id> performerId;
57:
58: /*******************************************************************************************************************
59: *
60: * Default constructor.
61: *
62: ******************************************************************************************************************/
63: public RepositoryPerformanceFinder (@Nonnull final Repository repository)
64: {
65: this(repository, Optional.empty(), Optional.empty());
66:• }
67:
68: /*******************************************************************************************************************
69: *
70: * Clone constructor.
71: *
72: ******************************************************************************************************************/
73: public RepositoryPerformanceFinder (@Nonnull final RepositoryPerformanceFinder other,
74: @Nonnull final Object override)
75: {
76:• super(other, override);
77: final RepositoryPerformanceFinder source = getSource(RepositoryPerformanceFinder.class, other, override);
78: this.trackId = source.trackId;
79: this.performerId = source.performerId;
80:• }
81:
82: /*******************************************************************************************************************
83: *
84: * Override constructor.
85: *
86: ******************************************************************************************************************/
87: private RepositoryPerformanceFinder (@Nonnull final Repository repository,
88: @Nonnull final Optional<Id> trackId,
89: @Nonnull final Optional<Id> performerId)
90: {
91:• super(repository, "performance");
92: this.trackId = trackId;
93: this.performerId = performerId;
94:• }
95:
96: /*******************************************************************************************************************
97: *
98: * {@inheritDoc}
99: *
100: ******************************************************************************************************************/
101: @Override @Nonnull
102: public PerformanceFinder ofTrack (@Nonnull final Id trackId)
103: {
104: return clonedWith(new RepositoryPerformanceFinder(repository, Optional.of(trackId), performerId));
105: }
106:
107: /*******************************************************************************************************************
108: *
109: * {@inheritDoc}
110: *
111: ******************************************************************************************************************/
112: @Override @Nonnull
113: public PerformanceFinder performedBy (@Nonnull final Id performerId)
114: {
115: return clonedWith(new RepositoryPerformanceFinder(repository, trackId, Optional.of(performerId)));
116: }
117:
118: /*******************************************************************************************************************
119: *
120: * {@inheritDoc}
121: *
122: ******************************************************************************************************************/
123: @Override @Nonnull
124: protected QueryAndParameters prepareQuery()
125: {
126: return QueryAndParameters.withSparql(QUERY_PERFORMANCES)
127: .withParameter("track", trackId.map(this::iriFor))
128: .withParameter("artist", performerId.map(this::iriFor));
129: }
130: }