Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Changed some method signatures to reduce code clutter. #190

Merged
merged 3 commits into from
Feb 21, 2024
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 @@ -97,7 +97,7 @@ public class MagmaCoreService {
public Set<ParticipantDetails> findParticipantDetails(final Individual individual1, final Individual individual2,
final KindOfAssociation kind, final PointInTime pointInTime) {

final Instant when = Instant.parse(pointInTime.value(HQDM.ENTITY_NAME).iterator().next().toString());
final Instant when = Instant.parse(pointInTime.oneValue(HQDM.ENTITY_NAME));

final QueryResultList queryResultList = database
.executeQuery(String.format(MagmaCoreServiceQueries.FIND_PARTICIPANT_DETAILS_QUERY, individual1.getId(),
Expand All @@ -113,7 +113,7 @@ public Set<ParticipantDetails> findParticipantDetails(final Individual individua
// Map them to ParticipantDetails objects.
.map(p -> {
// Get the Roles of the Participant.
final Set<Role> roles = p.value(HQDM.MEMBER_OF_KIND)
final Set<Role> roles = p.values(HQDM.MEMBER_OF_KIND)
.stream()
.map(o -> (IRI) o)
.map(roleIri -> database.get(roleIri))
Expand Down Expand Up @@ -171,12 +171,12 @@ public List<? extends Thing> findBySignValue(
final String value,
final PointInTime pointInTime) throws MagmaCoreException {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database
.executeQuery(String.format(MagmaCoreServiceQueries.FIND_BY_SIGN_VALUE_QUERY,
Expand Down Expand Up @@ -212,12 +212,12 @@ public List<? extends Thing> findByPartialSignValue(
final String value,
final PointInTime pointInTime) throws MagmaCoreException {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database
.executeQuery(String.format(MagmaCoreServiceQueries.FIND_BY_PARTIAL_SIGN_VALUE_CASE_INSENSITIVE_QUERY,
Expand Down Expand Up @@ -246,12 +246,12 @@ public List<? extends Thing> findByTypeClassAndSignPattern(
final IRI pattern,
final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database
.executeQuery(String.format(MagmaCoreServiceQueries.FIND_OBJECTS_BY_TYPE_CLASS_AND_SIGN_PATTERN,
Expand All @@ -278,12 +278,12 @@ public List<? extends Thing> findByTypeKindAndSignPattern(
final IRI pattern,
final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database
.executeQuery(String.format(MagmaCoreServiceQueries.FIND_OBJECTS_BY_TYPE_AND_SIGN_PATTERN,
Expand All @@ -305,12 +305,12 @@ public List<? extends Thing> findByTypeKindAndSignPattern(
*/
public List<? extends Thing> findByKindOfAssociation(final IRI kindOfAssociation, final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database
.executeQuery(String.format(MagmaCoreServiceQueries.FIND_BY_KIND_OF_ASSOCIATION,
Expand Down Expand Up @@ -352,12 +352,12 @@ public List<? extends Thing> findAssociated(final IRI item, final IRI kindOfAsso
*/
public List<? extends Thing> findAssociated(final IRI item, final IRI kindOfAssociation, final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database
.executeQuery(String.format(MagmaCoreServiceQueries.FIND_ASSOCIATED,
Expand All @@ -381,12 +381,12 @@ public List<? extends Thing> findAssociated(final IRI item, final IRI kindOfAsso
public List<? extends Thing> findByPartialSignAndClassCaseSensitive(final String text, final IRI classIri,
final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database
.executeQuery(
Expand All @@ -413,12 +413,12 @@ public List<? extends Thing> findByPartialSignAndClassCaseSensitive(final String
public List<? extends Thing> findByPartialSignAndClass(final String text, final IRI classIri,
final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database
.executeQuery(
Expand Down Expand Up @@ -448,12 +448,12 @@ public List<? extends Thing> findByPartialSignByActivityReferenceAndClass(final
final String text, final IRI classIri,
final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database.executeQuery(String.format(
MagmaCoreServiceQueries.FIND_MEMBERS_OF_CLASS_BY_ACTIVITY_AND_PARTIAL_SIGN_CASE_INSENSITIVE,
Expand Down Expand Up @@ -482,12 +482,12 @@ public List<? extends Thing> findByPartialSignByActivityReferenceAndClassCaseSen
final String text, final IRI classIri,
final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database.executeQuery(String.format(
MagmaCoreServiceQueries.FIND_MEMBERS_OF_CLASS_BY_ACTIVITY_AND_PARTIAL_SIGN_CASE_SENSITIVE,
Expand Down Expand Up @@ -516,12 +516,12 @@ public List<? extends Thing> findByPartialSignCompositionAndClassCaseSensitive(f
final String text, final IRI classIri,
final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database.executeQuery(String.format(
MagmaCoreServiceQueries.FIND_MEMBERS_OF_CLASS_BY_COMPOSITION_AND_PARTIAL_SIGN_CASE_SENSITIVE,
Expand Down Expand Up @@ -550,12 +550,12 @@ public List<? extends Thing> findByPartialSignCompositionAndClass(final IRI whol
final String text, final IRI classIri,
final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database.executeQuery(String.format(
MagmaCoreServiceQueries.FIND_MEMBERS_OF_CLASS_BY_COMPOSITION_AND_PARTIAL_SIGN_CASE_INSENSITIVE,
Expand All @@ -579,12 +579,12 @@ public List<? extends Thing> findByPartialSignCompositionAndClass(final IRI whol
*/
public List<SignPatternDto> findSignsForEntity(final IRI entityIri, final PointInTime pointInTime) {

final Set<Object> pointInTimeValues = pointInTime.value(HQDM.ENTITY_NAME);
if (pointInTimeValues == null || pointInTimeValues.isEmpty()) {
final String pointInTimeValue = pointInTime.oneValue(HQDM.ENTITY_NAME);
if (pointInTimeValue == null) {
return List.of();
}

final Instant when = Instant.parse(pointInTimeValues.iterator().next().toString());
final Instant when = Instant.parse(pointInTimeValue);

final QueryResultList queryResultList = database.executeQuery(String.format(
MagmaCoreServiceQueries.FIND_SIGNS_FOR_ENTITY, entityIri));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ public void testFindSuccess() {
// This query augments its object with HQDM.VALUE predicates for the current Sign values for the
// object.

final Set<Object> values = person.value(HQDM.VALUE_);
final Set<Object> values = person.values(HQDM.VALUE_);

assertNotNull(values);
assertEquals(1, values.size());

final Set<Object> names = person.value(HQDM.ENTITY_NAME);
final Set<Object> names = person.values(HQDM.ENTITY_NAME);
assertNotNull(names);
assertEquals(1, names.size());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void testFindSuccess() {

// This query augments its object with HQDM.VALUE predicates for the current Sign values for the
// object.
final Set<Object> values = person.value(HQDM.VALUE_);
final Set<Object> values = person.values(HQDM.VALUE_);
assertNotNull(values);
assertEquals(1, values.size());
assertEquals("person1", values.iterator().next().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ public void testFindBySignSuccess() throws MagmaCoreException {
assertEquals(SignPatternTestData.stateOfPerson1.getId(), personState1.getId());
assertEquals(SignPatternTestData.stateOfPerson2.getId(), personState2.getId());

final Set<Object> parent1 = personState1.value(HQDM.TEMPORAL_PART_OF);
final Set<Object> parent2 = personState2.value(HQDM.TEMPORAL_PART_OF);
final Set<Object> parent1 = personState1.values(HQDM.TEMPORAL_PART_OF);
final Set<Object> parent2 = personState2.values(HQDM.TEMPORAL_PART_OF);

// Check that the `temporal_part_of` relationship is correct.
assertEquals(1, parent1.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public final AbstractObjectBuilder member__Of(final Class clazz) {
*/
public AbstractObject build() throws HqdmException {
if (this.abstractObject.hasValue(HQDM.MEMBER__OF)
&& this.abstractObject.value(HQDM.MEMBER__OF).isEmpty()) {
&& this.abstractObject.values(HQDM.MEMBER__OF).isEmpty()) {
throw new HqdmException("Property Not Set: member__of");
}
return this.abstractObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,44 +332,44 @@ public final AcceptanceOfOfferBuilder temporal_Part_Of(final Individual individu
*/
public AcceptanceOfOffer build() throws HqdmException {
if (this.acceptanceOfOffer.hasValue(AGGREGATED_INTO)
&& this.acceptanceOfOffer.value(AGGREGATED_INTO).isEmpty()) {
&& this.acceptanceOfOffer.values(AGGREGATED_INTO).isEmpty()) {
throw new HqdmException("Property Not Set: aggregated_into");
}
if (this.acceptanceOfOffer.hasValue(BEGINNING)
&& this.acceptanceOfOffer.value(BEGINNING).isEmpty()) {
&& this.acceptanceOfOffer.values(BEGINNING).isEmpty()) {
throw new HqdmException("Property Not Set: beginning");
}
if (!this.acceptanceOfOffer.hasValue(CAUSES)) {
throw new HqdmException("Property Not Set: causes");
}
if (this.acceptanceOfOffer.hasValue(DETERMINES)
&& this.acceptanceOfOffer.value(DETERMINES).isEmpty()) {
&& this.acceptanceOfOffer.values(DETERMINES).isEmpty()) {
throw new HqdmException("Property Not Set: determines");
}
if (this.acceptanceOfOffer.hasValue(ENDING)
&& this.acceptanceOfOffer.value(ENDING).isEmpty()) {
&& this.acceptanceOfOffer.values(ENDING).isEmpty()) {
throw new HqdmException("Property Not Set: ending");
}
if (this.acceptanceOfOffer.hasValue(MEMBER__OF)
&& this.acceptanceOfOffer.value(MEMBER__OF).isEmpty()) {
&& this.acceptanceOfOffer.values(MEMBER__OF).isEmpty()) {
throw new HqdmException("Property Not Set: member__of");
}
if (this.acceptanceOfOffer.hasValue(MEMBER_OF)
&& this.acceptanceOfOffer.value(MEMBER_OF).isEmpty()) {
&& this.acceptanceOfOffer.values(MEMBER_OF).isEmpty()) {
throw new HqdmException("Property Not Set: member_of");
}
if (!this.acceptanceOfOffer.hasValue(MEMBER_OF_KIND)) {
throw new HqdmException("Property Not Set: member_of_kind");
}
if (this.acceptanceOfOffer.hasValue(PART__OF)
&& this.acceptanceOfOffer.value(PART__OF).isEmpty()) {
&& this.acceptanceOfOffer.values(PART__OF).isEmpty()) {
throw new HqdmException("Property Not Set: part__of");
}
if (!this.acceptanceOfOffer.hasValue(PART_OF)) {
throw new HqdmException("Property Not Set: part_of");
}
if (this.acceptanceOfOffer.hasValue(PART_OF_)
&& this.acceptanceOfOffer.value(PART_OF_).isEmpty()) {
&& this.acceptanceOfOffer.values(PART_OF_).isEmpty()) {
throw new HqdmException("Property Not Set: part_of_");
}
if (!this.acceptanceOfOffer.hasValue(PART_OF_POSSIBLE_WORLD)) {
Expand All @@ -379,11 +379,11 @@ public AcceptanceOfOffer build() throws HqdmException {
throw new HqdmException("Property Not Set: references");
}
if (this.acceptanceOfOffer.hasValue(TEMPORAL__PART_OF)
&& this.acceptanceOfOffer.value(TEMPORAL__PART_OF).isEmpty()) {
&& this.acceptanceOfOffer.values(TEMPORAL__PART_OF).isEmpty()) {
throw new HqdmException("Property Not Set: temporal__part_of");
}
if (this.acceptanceOfOffer.hasValue(TEMPORAL_PART_OF)
&& this.acceptanceOfOffer.value(TEMPORAL_PART_OF).isEmpty()) {
&& this.acceptanceOfOffer.values(TEMPORAL_PART_OF).isEmpty()) {
throw new HqdmException("Property Not Set: temporal_part_of");
}
return this.acceptanceOfOffer;
Expand Down
Loading
Loading