Search in sources :

Example 1 with RelationshipTermModel

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);
}
Also used : RelationshipTermModel(bio.terra.model.RelationshipTermModel) RelationshipModel(bio.terra.model.RelationshipModel)

Example 2 with RelationshipTermModel

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);
    }
}
Also used : RelationshipTermModel(bio.terra.model.RelationshipTermModel)

Example 3 with RelationshipTermModel

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" });
}
Also used : RelationshipTermModel(bio.terra.model.RelationshipTermModel) DatasetRequestModel(bio.terra.model.DatasetRequestModel) RelationshipModel(bio.terra.model.RelationshipModel) ErrorModel(bio.terra.model.ErrorModel) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

RelationshipTermModel (bio.terra.model.RelationshipTermModel)3 RelationshipModel (bio.terra.model.RelationshipModel)2 DatasetRequestModel (bio.terra.model.DatasetRequestModel)1 ErrorModel (bio.terra.model.ErrorModel)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1