Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implemented MagmaCoreObjectDatabase Queries #6

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public interface MagmaCoreDatabase {
List<Thing> findByPredicateIri(IRI predicateIri, IRI objectIri);

/**
* Find object(s) that have a specific predicate associated with them.
* Find object(s) that have a specific HQDM-defined predication.
*
* @param predicateIri IRI of the predicate being queried.
* @param predicateIri IRI of the HQDM relationship type being queried.
* @return The object(s).
*/
List<Thing> findByPredicateIriOnly(HqdmIri predicateIri);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ public List<Thing> findByPredicateIri(final IRI predicateIri, final IRI objectIr
*/
@Override
public List<Thing> findByPredicateIriOnly(final HqdmIri predicateIri) {
throw new RuntimeException("findByPredicateIRIOnly not yet implemented.");
return objects.values().stream()
.filter(object -> object.hasValue(predicateIri))
.collect(Collectors.toList());
}

/**
Expand All @@ -103,9 +105,7 @@ public List<Thing> findByPredicateIriOnly(final HqdmIri predicateIri) {
@Override
public List<Thing> findByPredicateIriAndStringValue(final IRI predicateIri,
final String value) {
return objects
.values()
.stream()
return objects.values().stream()
.filter(object -> object.hasThisStringValue(predicateIri, value))
.collect(Collectors.toList());
}
Expand All @@ -116,8 +116,9 @@ public List<Thing> findByPredicateIriAndStringValue(final IRI predicateIri,
@Override
public List<Thing> findByPredicateIriAndStringCaseInsensitive(final IRI predicateIri,
final String value) {
throw new RuntimeException(
"findByPredicateIRIAndStringCaseInsensitive not yet implemented.");
return objects.values().stream()
.filter(object -> object.hasThisStringValueIgnoreCase(predicateIri, value))
.collect(Collectors.toList());
}

/**
Expand Down