use of bio.terra.model.RelationshipTermModel in project jade-data-repo by DataBiosphere.
the class SnapshotService method makeRelationshipModelFromRelationship.
private RelationshipModel makeRelationshipModelFromRelationship(Relationship relationship) {
RelationshipTermModel fromModel = new RelationshipTermModel().table(relationship.getFromTable().getName()).column(relationship.getFromColumn().getName());
RelationshipTermModel toModel = new RelationshipTermModel().table(relationship.getToTable().getName()).column(relationship.getToColumn().getName());
return new RelationshipModel().name(relationship.getName()).from(fromModel).to(toModel);
}
use of bio.terra.model.RelationshipTermModel in project jade-data-repo by DataBiosphere.
the class DatasetRequestValidator method validateRelationship.
private void validateRelationship(RelationshipModel relationship, Errors errors, SchemaValidationContext context) {
RelationshipTermModel fromTerm = relationship.getFrom();
if (fromTerm != null) {
validateRelationshipTerm(fromTerm, errors, context);
}
RelationshipTermModel toTerm = relationship.getTo();
if (toTerm != null) {
validateRelationshipTerm(toTerm, errors, context);
}
String relationshipName = relationship.getName();
if (relationshipName != null) {
context.addRelationship(relationshipName);
}
}
use of bio.terra.model.RelationshipTermModel in project jade-data-repo by DataBiosphere.
the class DatasetValidationsTest method testInvalidRelationshipTermTableColumn.
@Test
public void testInvalidRelationshipTermTableColumn() throws Exception {
// participant_id is part of the sample table, not participant
RelationshipTermModel mismatchedTerm = new RelationshipTermModel().table("participant").column("participant_id");
RelationshipModel mismatchedRelationship = new RelationshipModel().name("participant_sample").from(mismatchedTerm).to(buildSampleTerm());
DatasetRequestModel req = buildDatasetRequest();
req.getSchema().relationships(Collections.singletonList(mismatchedRelationship));
ErrorModel errorModel = expectBadDatasetCreateRequest(req);
checkValidationErrorModel(errorModel, new String[] { "InvalidRelationshipTermTableColumn" });
}
Aggregations