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

One-dimensionalization of data models #613

Merged
merged 7 commits into from
Oct 15, 2024
Merged

Conversation

LzLang
Copy link
Member

@LzLang LzLang commented Sep 5, 2024

Dear @BrapiCoordinatorSelby,

@VivianBass and I finished the editing of the schemas. Like we talked about, we added the relationshipType to every occurence of the attributes additionalInfo and externalReferences in every model. Also we flattend all models, so there shouldn`t be a nested model left or rather all models should be 1-dimensional. (As in Wittenberg, we proceeded here using separate models and associations).

In some models there were location specifications (such as ImageLocation in Image.json). These attributes were effectively just a copy of GeoJSON, although GeoJSON exists as an independent model. Accordingly, we have changed the attributes so that they form an association to GeoJSON: GeoJSON

"GeoJSON": {
	"title": "GeoJSON",
	"type": "object",
	"description": "One geometry as defined by GeoJSON (RFC 7946). All coordinates are decimal values on the WGS84 geographic coordinate reference system.\n\nCopied from RFC 7946 Section 3.1.1\n\nA position is an array of numbers. There MUST be two or more elements. The first two elements are longitude and latitude, or\neasting and northing, precisely in that order and using decimal numbers. Altitude or elevation MAY be included as an optional third element.",
	"properties": {
		"geometryDbId": {
			"description": "Unique identifier for the geometry",
			"type": [
				"null",
				"string"
			]
		},
		"geometry": {
			"description": "A geometry as defined by GeoJSON (RFC 7946). In this context, only Point or Polygon geometry are allowed.",
			"$ref": "GeoJSONGeometry.json#/$defs/GeoJSONGeometry"
		},
		"type": {
			"type": "string",
			"default": "Feature",
			"example": "Feature",
			"description": "The literal string \"Feature\""
		},
		"image": {
			"description": "Geometry associated with an image",
			"$ref": "../BrAPI-Phenotyping/Image.json#/$defs/Image",
			"relationshipType": "many-to-one",
			"referencedAttribute": "imageLocation"
		},
		"observation": {
			"description": "Geometry associated with an image",
			"$ref": "../BrAPI-Phenotyping/Observation.json#/$defs/Observation",
			"relationshipType": "many-to-one",
			"referencedAttribute": "geoCoordinates"
		},
		"observationUnit": {
			"description": "Geometry associated with an image",
			"$ref": "../BrAPI-Phenotyping/ObservationUnit.json#/$defs/ObservationUnitPosition",
			"relationshipType": "many-to-one",
			"referencedAttribute": "geoCoordinates"
		},
		"germplasmOrigin": {
			"description": "Geometry associated with an image",
			"$ref": "../BrAPI-Germplasm/Germplasm.json#/$defs/GermplasmOrigin",
			"relationshipType": "many-to-one",
			"referencedAttribute": "coordinates"
		}
	},
	"required": [
		"geometryDbId"
	]
}

New ImageLocation from Image.json:

"imageLocation": {
	"description": "One geometry as defined by GeoJSON (RFC 7946). All coordinates are decimal values on the WGS84 geographic coordinate reference system.\n\nCopied from RFC 7946 Section 3.1.1\n\nA position is an array of numbers. There MUST be two or more elements. The first two elements are longitude and latitude, or\neasting and northing, precisely in that order and using decimal numbers. Altitude or elevation MAY be included as an optional third element.",
	"relationshipType": "one-to-many",
	"referencedAttribute": "image",
	"items": {
		"$ref": "../BrAPI-Common/GeoJSON.json#/$defs/GeoJSON",
		"description": "A geometry as defined by GeoJSON (RFC 7946). In this context, only Point or Polygon geometry are allowed."
	},
	"title": "GeoJSON",
	"type": [
		"null",
		"array"
	]
}

Could you please check or changes, if there is something wrong or if you like us to change other things?

Thank you and best regards! :)

Dear @BrapiCoordinatorSelby,

@VivianBass and I finished the editing of the schemas.
Like we talked about, we added the `relationshipType` to every occurence of the attributes `additionalInfo` and `externalReferences` in every model.
Also we flattend all models, so there shouldn`t be a nested model left or rather all models should be 1-dimensional.
(As in Wittenberg, we proceeded here using separate models and associations).

In some models there were location specifications (such as ImageLocation in Image.json). These attributes were effectively just a copy of GeoJSON, although GeoJSON exists as an independent model.
Accordingly, we have changed the attributes so that they form an association to GeoJSON:
GeoJSON
```json
"GeoJSON": {
	"title": "GeoJSON",
	"type": "object",
	"description": "One geometry as defined by GeoJSON (RFC 7946). All coordinates are decimal values on the WGS84 geographic coordinate reference system.\n\nCopied from RFC 7946 Section 3.1.1\n\nA position is an array of numbers. There MUST be two or more elements. The first two elements are longitude and latitude, or\neasting and northing, precisely in that order and using decimal numbers. Altitude or elevation MAY be included as an optional third element.",
	"properties": {
		"geometryDbId": {
			"description": "Unique identifier for the geometry",
			"type": [
				"null",
				"string"
			]
		},
		"geometry": {
			"description": "A geometry as defined by GeoJSON (RFC 7946). In this context, only Point or Polygon geometry are allowed.",
			"$ref": "GeoJSONGeometry.json#/$defs/GeoJSONGeometry"
		},
		"type": {
			"type": "string",
			"default": "Feature",
			"example": "Feature",
			"description": "The literal string \"Feature\""
		},
		"image": {
			"description": "Geometry associated with an image",
			"$ref": "../BrAPI-Phenotyping/Image.json#/$defs/Image",
			"relationshipType": "many-to-one",
			"referencedAttribute": "imageLocation"
		},
		"observation": {
			"description": "Geometry associated with an image",
			"$ref": "../BrAPI-Phenotyping/Observation.json#/$defs/Observation",
			"relationshipType": "many-to-one",
			"referencedAttribute": "geoCoordinates"
		},
		"observationUnit": {
			"description": "Geometry associated with an image",
			"$ref": "../BrAPI-Phenotyping/ObservationUnit.json#/$defs/ObservationUnitPosition",
			"relationshipType": "many-to-one",
			"referencedAttribute": "geoCoordinates"
		},
		"germplasmOrigin": {
			"description": "Geometry associated with an image",
			"$ref": "../BrAPI-Germplasm/Germplasm.json#/$defs/GermplasmOrigin",
			"relationshipType": "many-to-one",
			"referencedAttribute": "coordinates"
		}
	},
	"required": [
		"geometryDbId"
	]
}
```

New `ImageLocation` from `Image.json`:
```json
"imageLocation": {
	"description": "One geometry as defined by GeoJSON (RFC 7946). All coordinates are decimal values on the WGS84 geographic coordinate reference system.\n\nCopied from RFC 7946 Section 3.1.1\n\nA position is an array of numbers. There MUST be two or more elements. The first two elements are longitude and latitude, or\neasting and northing, precisely in that order and using decimal numbers. Altitude or elevation MAY be included as an optional third element.",
	"relationshipType": "one-to-many",
	"referencedAttribute": "image",
	"items": {
		"$ref": "../BrAPI-Common/GeoJSON.json#/$defs/GeoJSON",
		"description": "A geometry as defined by GeoJSON (RFC 7946). In this context, only Point or Polygon geometry are allowed."
	},
	"title": "GeoJSON",
	"type": [
		"null",
		"array"
	]
}
```
Could you please check or changes, if there is something wrong or if you like us to change other things?

Thank you and best regards! :)
@daveneti
Copy link

daveneti commented Sep 6, 2024

Thanks @LzLang, I will check it out and run it through the schema validator.

I have a suggestion about the additions (not the re-organization part). Would if be possible to put this in a different branch, since these change the model? So keep the data-model-separation for v2.1? Alternatively we could merge the data model in to 2.1 branch and then create a new branch for 2.2 model changes?

What do you think @BrapiCoordinatorSelby?

@daveneti
Copy link

daveneti commented Sep 6, 2024

@LzLang I got the following validation errors:
There were 5 errors validating the JSON Schema:
Validation Error : The required property 'progenyDbId' is not found in the list of properties of 'Progeny', expecting one of 'parentDbId, progenyGermplasm, parentType, pedigreeNode'
Validation Error : The required property 'description' is not found in the list of properties of 'EnvironmentParameters', expecting one of 'environmentParametersDbId, parameterName, parameterPUI, unit, unitPUI, value, valuePUI, study'
Validation Error : The required property 'crossDbId' is not found in the list of properties of 'CrossAttributes', expecting one of 'attributeDbId, crossAttributeName, crossAttributeValue, cross'
Validation Error : The required property 'storageDbId' is not found in the list of properties of 'StorageTypes', expecting one of 'storageDbID, code, description, germplasm'
Validation Error : The required property 'originDbId' is not found in the list of properties of 'GermplasmOrigin', expecting one of 'originDbID, coordinateUncertainty, coordinates, germplasm'

I will make the corrections and commit

Copy link

@daveneti daveneti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I notice a few model changes from single to array and use of Plural when Singular is appropriate.

"$defs": {
"Species": {
"properties": {
"specieDbId": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be speciesDbId

@@ -4,7 +4,15 @@
"properties": {
"additionalInfo": {
"description": "A free space containing any additional information related to a particular object. A data source may provide any JSON object, unrestricted by the BrAPI specification.",
"$ref": "../BrAPI-Common/AdditionalInfo.json#/$defs/AdditionalInfo"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the model, from a single to an array of AdditionalInfo, can this be put in v2.2? See in same changes in other entities.

"referencedAttribute": "study",
"items": {
"$ref": "../BrAPI-Core/Study.json#/$defs/ExperimentalDesign",
"description": "ExperimentalDesign"
},
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model change from a single ExperimentalDesign to an array of ExperimentalDesign. Not sure this is appropriate.

"type": [
"null",
"object"
"array"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model change from a single grow facility to array of growth facilities!

"type": [
"null",
"object"
"array"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model change from single lastUpdate to array of lastUpdates!

},
"title": "GeoJSON",
"type": [
"null",
"object"
"array"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model change from single to array

},
"title": "GeoJSON",
"type": [
"null",
"object"
"array"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model change from single to array

}
},
"type": "object"
"$ref": "../BrAPI-Phenotyping/OntologyReference.json#/$defs/DocumentationLinks",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be DocumentationLink

"relationshipType": "one-to-many",
"referencedAttribute": "scale",
"items": {
"$ref": "../BrAPI-Phenotyping/Scale.json#/$defs/ValidValues",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ValidValue

"primaryModel": false
}
},
"Categories": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Category

Copy link

@daveneti daveneti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added some more comments to previous review.

},
"Progeny": {
"properties": {
"parentDbId": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there should be an ID associated with a 'Progeny', since it is a Value Type and not an Entity. In any case it should be progenyDbId and not parentDbId.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to progenyDbId
Zendro is using the models for a data warehouse.
The problem we have is, that we need a primary key, which is why I added it.
If @asishallab don't mind I could remove it and add the primary key code side.

},
"Parents": {
"properties": {
"parentDbId": {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there should be an ID associated with a 'Parent', since it is a Value Type and not an Entity.

"parentType"
],
"type": "object"
"$ref": "../BrAPI-Germplasm/PedigreeNode.json#/$defs/Progeny",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the team GermplasmChild, since it is more specific.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you prefere, that we rename the whole "Progeny" Model to "GermplasmChild"?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please change :)

}
},
"required": [
"crossDbId"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Listed as required but is not a property of CrosssAttribute

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it accordingly to crossAttributeDbId

@LzLang
Copy link
Member Author

LzLang commented Sep 13, 2024

Thank you very much @daveneti for your review and corrections!
I didn't expect that we would have introduced so many new mistakes without realizing it.
Therefore thank you so much for correcting those!

I have a suggestion about the additions (not the re-organization part). Would if be possible to put this in a different branch, since these change the model? So keep the data-model-separation for v2.1? Alternatively we could merge the data model in to 2.1 branch and then create a new branch for 2.2 model changes?

Personally I don't see a problem with putting it in a different branch instaed of merching it.
My current status was that the goal is to generally one-dimensionalize the BrAPI models so that there are no more nested attributes/models.
However, I don't know what influence this change will have on other projects.
Nonetheless, I would like to sit down with Mr. Hallab again next week to discuss this and get his opinion and view on thise matter.

I have now noticed something else:
In some models, for example AdditionalInfo and TraitDataType, the “properties” have been removed.

{
    "$defs": {
        "TraitDataType": {
            "description": "<p>Class of the scale, entries can be</p>\n<p>\"Code\" -  This scale class is exceptionally used to express complex traits. Code is a nominal scale that combines the expressions of the different traits composing the complex trait. For example a severity trait might be expressed by a 2 digit and 2 character code. The first 2 digits are the percentage of the plant covered by a fungus and the 2 characters refer to the delay in development, e.g. \"75VD\" means \"75 %\" of the plant is infected and the plant is very delayed.</p>\n<p>\"Date\" - The date class is for events expressed in a time format, See ISO 8601</p>\n<p>\"Duration\" - The Duration class is for time elapsed between two events expressed in a time format, e.g. days, hours, months</p>\n<p>\"Nominal\" - Categorical scale that can take one of a limited and fixed number of categories. There is no intrinsic ordering to the categories</p>\n<p>\"Numerical\" - Numerical scales express the trait with real numbers. The numerical scale defines the unit e.g. centimeter, ton per hectare, branches</p>\n<p>\"Ordinal\" - Ordinal scales are scales composed of ordered categories</p>\n<p>\"Text\" - A free text is used to express the trait.</p>",
            "enum": [
                "Code",
                "Date",
                "Duration",
                "Nominal",
                "Numerical",
                "Ordinal",
                "Text"
            ],
            "type": "string",
            "example": "Numerical"
        }
    },
    "$id": "https://brapi.org/Specification/BrAPI-Schema/Components/Common/AdditionalInfo.json",
    "$schema": "http://json-schema.org/draft/2020-12/schema"
}

Is there a specific reason why these have been removed?
Personally, I think it would make sense to add them back for the sake of consistency.

Once again, thank you very much for your review.
I'll look over you review in detail and talk with @VivianBass about it :)

@daveneti
Copy link

Hi @LzLang

Thanks for your comment and changes. Yes, creating a new branch for v2.2 is a great idea, perhaps that can be done with the other 2.2 changes @BrapiCoordinatorSelby will add. I am not actually sure if there any many model changes. I think I might have been confused. If you can review my suggestions and make any changes, then we can review again to be sure. The comment you made about properties I will double check when get back to my computer.

@daveneti
Copy link

Hi @LzLang, back at my computer now.

For AdditionalInfo I did not see any properties on the original definition, only addtionalProperties, which is still there.
TraitDataType, is an enum, which do not have any properties.

Can you explain further your comment on theses please?

I can see in the example the id is incorrect. That looks Iike C&P error, I will correct that. It should be "$id": "https://brapi.org/Specification/BrAPI-Schema/Components/Common/TraitDataType.json"

I will add a check in the validator that looks for those mistakes.

@LzLang
Copy link
Member Author

LzLang commented Sep 15, 2024

Hey @daveneti,

For AdditionalInfo I did not see any properties on the original definition, only addtionalProperties, which is still there. TraitDataType, is an enum, which do not have any properties.

Sorry, for the confusion! This is a mistake on my part.
When we did the model separation in Wittenberg we created AditionalInfo as separated model.
In our version AdditionalInfo included the properties key, that cotained attributes like reverse association.
Due a fault on my side I never committed our changes officially, therefore there are no properties in the original model (when I wrote my comment, I forgot this and mixed it up).
In the current converter version, we work around this by adding the reverse associations in AdditionalInfo on the code side. Therefore we also needed the relationshipType in the respective models that had an association to AdditionalInfo.
For example, the association of Study.json:

"additionalInfo": {
	"description": "A free space containing any additional information related to a particular object. A data source may provide any JSON object, unrestricted by the BrAPI specification.",
	"$ref": "../BrAPI-Common/AdditionalInfo.json#/$defs/AdditionalInfo"
	"relationshipType": "one-to-many",
	"items": {
		"$ref": "../BrAPI-Common/AdditionalInfo.json#/$defs/AdditionalInfo",
		"description": "AdditionalInfo"
	},
	"type": [
		"null",
		"array"
	]
}

If @asishallab and @VivianBass have no objections, I think we can adopt the changes without further problems and use them as a basis for v2.2 and our own project.

@daveneti
Copy link

daveneti commented Sep 16, 2024

Thanks @LzLang

In the above 'additionalInfo' example, be careful you have the $ref to two places. I don't think it should be in the 'items', and the 'type' should be removed. Also I think the relationship will be one-to-one. E.g.

"additionalInfo": {
	"description": "A free space containing any additional information related to a particular object. A data source may provide any JSON object, unrestricted by the BrAPI specification.",
	"$ref": "../BrAPI-Common/AdditionalInfo.json#/$defs/AdditionalInfo"
	"relationshipType": "one-to-one"
}

Can you make all the changes in this branch, then I can review again, before merging into 'data-model-separation'. I will need to check again with the validator and then I can merge this modified 2.1 version into our extended versions. I don't think there are any model changes so this would be still be 2.1.

@LzLang
Copy link
Member Author

LzLang commented Sep 17, 2024

In the above 'additionalInfo' example, be careful you have the $ref to two places. I don't think it should be in the 'items', and the 'type' should be removed. Also I think the relationship will be one-to-one. E.g.

Thank you @daveneti for your advice, this simple slipped my eyes.
I will check the models again and see if this mistake occured just once or if I made this mistake in other models too.
While testing I noticed that I only added the relationshipType to additionalInfo and externalReferences, but there are other associations that don't have a relationshipType, therefore I would like to add those too.

Can you make all the changes in this branch, then I can review again, before merging into 'data-model-separation'.

Certainly!

I will need to check again with the validator and then I can merge this modified 2.1 version into our extended versions. I don't think there are any model changes so this would be still be 2.1.

There are some model changes, because there were some nested models left, which we one-dimensionalized.
However I can give you a list of the changed/new models, so we can decide what is the best course of action for merging.

Edit: I changed the models accordingly to your comments. I will check the models and make necessary changes (e.g. after renaming the model to it's singular form, I need to correct associations to this model).
After this I'll upload the models.

@LzLang
Copy link
Member Author

LzLang commented Sep 17, 2024

So far I changed the models accordingly to our conversation.
Also I added one-to-one relationship type to associations that were singular and missing a type.

For me, there are more problems with plural associations.
Study.json:

"dataLinks": {
	"description": "List of links to extra data files associated with this study. Extra data could include notes, images, and reference data.",
	"items": {
		"$ref": "DataLink.json#/$defs/DataLink"
	},
	"type": [
		"null",
		"array"
	]
}

Cross.json:

"parent1": {
	"$ref": "CrossParent.json#/$defs/CrossParent",
	"description": "the first parent used in the cross"
},
"parent2": {
	"$ref": "CrossParent.json#/$defs/CrossParent",
	"description": "the second parent used in the cross"
}

CrossingProject.json:

"potentialParents": {
	"description": "A list of all the potential parents in the crossing block, available in the crossing project\n<br/> If the parameter 'includePotentialParents' is false, the array 'potentialParents' should be empty, null, or excluded from the response object.",
	"items": {
		"$ref": "CrossParent.json#/$defs/CrossParent"
	},
	"type": [
		"null",
		"array"
	]
}

PlannedCross.json:

"parent1": {
	"$ref": "CrossParent.json#/$defs/CrossParent",
	"description": "the first parent used in the cross"
},
"parent2": {
	"$ref": "CrossParent.json#/$defs/CrossParent",
	"description": "the second parent used in the cross"
}

What relationshipType would you prefer for those associations?

Another thing I noticed while revising:
There isn't an uniform structure for 'one-to-many' and 'many-to-many' associations.
PlannedCross.json:
The informations are inside and outside of items

"crosses": {
	"title": "crosses",
	"description": "crosses",
	"referencedAttribute": "plannedCross",
	"relationshipType": "one-to-many",
	"items": {
		"$ref": "Cross.json#/$defs/Cross",
		"description": "Cross"
	},
	"type": [
		"null",
		"array"
	]
}

PedigreeNode.json:
The informations are all in items

"siblings": {
	"description": "A list of sibling germplasm references in the pedigree tree for this germplasm. These represent edges in the tree, connecting to other nodes.\n<br/> Siblings share at least one parent with the given germplasm. \n<br/> If the parameter 'includeSiblings' is set to false, then this array should be empty, null, or not present in the response.",
	"items": {
		"$ref": "Germplasm.json#/$defs/Germplasm",
		"description": "The ID which uniquely identifies a parent germplasm",
		"referencedAttribute": "siblingPedigreeNodes",
		"relationshipType": "many-to-one"
	},
	"type": [
		"null",
		"array"
	]
}

The first definition seems like the old one.
So would you prefere, that we change plural associations to the new definition?

@daveneti
Copy link

@LzLang Thanks for all your work, there is a lot to unpack there and consider.

On the question of which relationship type:
Study < datalinks > DataLink - The DataLink is not an entity, but a Value Type. It can no exist outside of a specific Study. So the relationship will be 'many-to-one'. Many data links associated with a single study
Cross < parent1 & parent2 > CrossParent - This is a straight 'one-to-one' relationship. BTW the schema validator assumes a 'one-to-one' relationship if the property references a single object or 'many-to-one' if the property references an array.
CrossingProject < potentialParents > CrossParent. A CrossParent is a value type, so although the relationship between a CrossingProject and it's potential parents is 'many-to-many', the relationship between CrossingProject and CrossParent is 'many-to-one'. BTW the relationship between CrossParent and Germplasm or ObservationUnit will be 'one-to-many'. So you could say 'many-to-one' + 'one-to-many' = 'many-to-many'
PlannedCross < parent1 & parent2 > CrossParent - This is the same as Cross < parent1 & parent2 > 'one-to-one'

You should add the relationship between CrossParent and Germplasm or ObservationUnit as 'one-to-many

Well spotted on the non-uniform placement of the referencedAttribute and relationshipType. I had not noticed these! I propose that these are associated with the property and not the items in a array. So the example for crosses in PlannedCross. The schema validator will only look for these in the property and not the items.

I will now review the PR.

@daveneti
Copy link

@LzLang Did you commit your changes? I did not see a new commit from you. Can you commit the changes to the branch and then I will review again.

If there are any model changes, we can put these in a separate branch. Putting the models in a separate top level definition if it does not change the cardinality of the relationship, is not a model change, so I think there are actually none or few model changes. Are there any additional properties or changes from one object to array or vice versa? I don't think there are any. I can do a final check on the PR once you have committed the changes.

@LzLang
Copy link
Member Author

LzLang commented Sep 19, 2024

@daveneti I made the changes we talked about and commited it-

Are there any additional properties or changes from one object to array or vice versa? I don't think there are any.

No, I don't think that we changed models in that way, or rather I reversed those changes according to your review.

So far I have made the changes we discussed.
At the moment I have refrained from adding the relationshipType, which we wrote about yesterday/today (but I will do so).
I also plan to go through the entire models again to make sure I haven't missed anything that could lead to errors in general or with Zendro (including minor errors or inconsistent definitions (e.g. the case with items)).
However, it would certainly be advantageous to create a separate PR here.

I will of course fix the errors/problems you find in the review as soon as possible.

We still have one question regarding GeoJSONGeometry:
This model uses “oneOf”, which Zendro does not natively support.
I would like to solve this problem on the code side (instead of changing anything in the model) by setting one of the two geometries as default with the possibility to optionally use the other geometry.
Which of the two geometries would you prefer as the “default”?

Sidenote: I'm currentyl helping my parents to move and I'm moving myself too, which is why my work on the models has been delayed somewhat.

@daveneti
Copy link

@LzLang Thanks for the changes, I will review now

For GeoJSONGeometry I don't have a suggestion. Perhaps @BrapiCoordinatorSelby has one? In the Schema tools generator for GraphQL I added a TypeResolver, that simply returned the first type to get the schema to generate. Ideally, we need to use a discriminator, which is the 'type'property. Since I was not generating a working API, it did not matter to me, which was default.

@AllArgsConstructor
private static class UnionTypeResolver implements TypeResolver {

    private GraphQLUnionType unionType;

    @Override
    public GraphQLObjectType getType(TypeResolutionEnvironment schemaName) {
        return (GraphQLObjectType) this.unionType.getTypes().get(0);
    }
}

@daveneti
Copy link

PS, @LzLang it would be great soon to compare the GraphQL schema you have developed and the one the Schema tools generates. I will add soon a CI build to generate it each time the model changes.

Copy link

@daveneti daveneti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LzLang @BrapiCoordinatorSelby I finished the review. I think there is a little bit more work to do. Mainly because of the addition of DbIds in some 'Value Types', which changes the model. Also the GermplasmParent, Progeny/GermplasmChild needs some discussion.

Specification/BrAPI-Schema/BrAPI-Core/DataLink.json Outdated Show resolved Hide resolved
Specification/BrAPI-Schema/BrAPI-Core/Study.json Outdated Show resolved Hide resolved
Specification/BrAPI-Schema/BrAPI-Phenotyping/Scale.json Outdated Show resolved Hide resolved
Specification/BrAPI-Schema/BrAPI-Phenotyping/Scale.json Outdated Show resolved Hide resolved
Specification/BrAPI-Schema/BrAPI-Phenotyping/Scale.json Outdated Show resolved Hide resolved
Specification/BrAPI-Schema/BrAPI-Phenotyping/Scale.json Outdated Show resolved Hide resolved
Specification/BrAPI-Schema/BrAPI-Phenotyping/Scale.json Outdated Show resolved Hide resolved
@daveneti
Copy link

@LzLang I finished the latest review. There are some minor changes that can be fixed easily and some more major questions that needs some input from @BrapiCoordinatorSelby that where in the original JSON Schema.

Copy link

@daveneti daveneti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LzLang I think there is only two remaining issue. Sorry it has taken so long!

  1. The issues are: Link from study to growth facility should be one-to-many, so the link should not be array.
  2. I think we can remove SourceGermplasm

I will make the changes in the branch directly, you can merge when you want. I will also run the validator.

@@ -2,13 +2,6 @@
"$defs": {
"SourceGermplasm": {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this link I would propose to drop SourceGermplasm directly. So in germplasm you would have in Reference and Reference Set

            "sourceGermplasm": {
                "description": "All known corresponding Germplasm",
                "relationshipType": "many-to-many",
                "referencedAttribute": "reference",
                "items": {
                    "$ref": "../BrAPI-Germplasm/Germplasm.json#/$defs/Germplasm",
                },
                "title": "SourceGermplasm",
                "type": [
                    "null",
                    "array"
                ]

Then you could add the back links in Germplasm

"referencedAttribute": "study",
"$ref": "../BrAPI-Core/Study.json#/$defs/GrowthFacility"
"items": {
Copy link

@daveneti daveneti Oct 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct before
"$ref": "../BrAPI-Core/Study.json#/$defs/GrowthFacility"
it was just the relationship type that was incorrect, which you corrected to 'many-to-one'

@@ -462,17 +455,17 @@
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure now, I think it is ok now :)

@LzLang LzLang merged commit e60eaaf into data-model-separation Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants