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

OWL Relationship utility methods #1352

Merged
merged 1 commit into from
Dec 6, 2024
Merged
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 @@ -23,6 +23,10 @@
import com.b2international.snowowl.snomed.core.domain.RelationshipValue;
import com.b2international.snowowl.snomed.core.domain.SnomedConcept;
import com.b2international.snowowl.snomed.core.domain.SnomedRelationship;
import com.b2international.snowowl.snomed.datastore.StatementFragment;
import com.b2international.snowowl.snomed.datastore.StatementFragmentWithDestination;
import com.b2international.snowowl.snomed.datastore.StatementFragmentWithValue;
import com.b2international.snowowl.snomed.datastore.index.entry.SnomedOWLRelationshipDocument;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

Expand Down Expand Up @@ -204,6 +208,14 @@
}
}

public static SnomedOWLRelationship createFrom(final SnomedOWLRelationshipDocument r) {
if (r.hasValue()) {
return create(r.getTypeId(), r.getValueAsObject(), r.getRelationshipGroup());

Check warning on line 213 in snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/domain/refset/SnomedOWLRelationship.java

View check run for this annotation

Codecov / codecov/patch

snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/domain/refset/SnomedOWLRelationship.java#L213

Added line #L213 was not covered by tests
} else {
return create(r.getTypeId(), r.getDestinationId(), r.getRelationshipGroup());

Check warning on line 215 in snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/domain/refset/SnomedOWLRelationship.java

View check run for this annotation

Codecov / codecov/patch

snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/domain/refset/SnomedOWLRelationship.java#L215

Added line #L215 was not covered by tests
}
}

public static SnomedOWLRelationship create(final String typeId, final String destinationId, final int relationshipGroup) {
SnomedOWLRelationship owlRelationship = new SnomedOWLRelationship();

Expand All @@ -224,4 +236,38 @@
return owlRelationship;
}

@JsonIgnore
public StatementFragment toStatementFragment(final int groupOffset) {
final int adjustedGroup;
if (relationshipGroup == 0) {
adjustedGroup = relationshipGroup;
} else {
adjustedGroup = relationshipGroup + groupOffset;

Check warning on line 245 in snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/domain/refset/SnomedOWLRelationship.java

View check run for this annotation

Codecov / codecov/patch

snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/domain/refset/SnomedOWLRelationship.java#L243-L245

Added lines #L243 - L245 were not covered by tests
}

if (getDestinationId() != null) {
return new StatementFragmentWithDestination(
Long.parseLong(getTypeId()), // typeId
adjustedGroup, // adjustedGroup
0, // unionGroup
false, // universal
-1L, // statementId
-1L, // moduleId
false, // released
Long.parseLong(getDestinationId()), // destinationId
false); // destinationNegated

Check warning on line 258 in snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/domain/refset/SnomedOWLRelationship.java

View check run for this annotation

Codecov / codecov/patch

snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/domain/refset/SnomedOWLRelationship.java#L249-L258

Added lines #L249 - L258 were not covered by tests
} else {
return new StatementFragmentWithValue(
Long.parseLong(getTypeId()), // typeId
adjustedGroup, // adjustedGroup
0, // unionGroup
false, // universal
-1L, // statementId
-1L, // moduleId
false, // released
value.type(), // valueType
value.toRawValue()); // rawValue

Check warning on line 269 in snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/domain/refset/SnomedOWLRelationship.java

View check run for this annotation

Codecov / codecov/patch

snomed/com.b2international.snowowl.snomed.datastore/src/com/b2international/snowowl/snomed/core/domain/refset/SnomedOWLRelationship.java#L260-L269

Added lines #L260 - L269 were not covered by tests
}
}

}
Loading