|
50 | 50 | ElectricalRecordingStimulusType,
|
51 | 51 | ElectricalRecordingType,
|
52 | 52 | EntityType,
|
| 53 | + ExternalDataSource, |
53 | 54 | MeasurementStatistic,
|
54 | 55 | MeasurementUnit,
|
55 | 56 | PointLocation,
|
@@ -539,6 +540,22 @@ class Publication(Identifiable):
|
539 | 540 | __table_args__ = (Index("ix_publication_doi_normalized", func.lower(DOI), unique=True),)
|
540 | 541 |
|
541 | 542 |
|
| 543 | +class ExternalDataSourcePage(Identifiable, NameDescriptionVectorMixin): |
| 544 | + """Represents a web page on an external data source. |
| 545 | +
|
| 546 | + Attributes: |
| 547 | + id (uuid.UUID): Primary key. |
| 548 | + source_label (ExternalDataSource): Unique label for the data source, e.g. channelpedia. |
| 549 | + url (str): URL of the data source webpage, |
| 550 | + e.g. "https://channelpedia.epfl.ch/wikipages/189". |
| 551 | +
|
| 552 | + """ |
| 553 | + |
| 554 | + __tablename__ = EntityType.external_data_source_page.value |
| 555 | + source_label: Mapped[ExternalDataSource] |
| 556 | + url: Mapped[str] = mapped_column(String, index=True, unique=True) |
| 557 | + |
| 558 | + |
542 | 559 | class ScientificArtifact(Entity, SubjectMixin, LocationMixin, LicensedMixin):
|
543 | 560 | """Represents a scientific artifact entity in the database.
|
544 | 561 |
|
@@ -1290,6 +1307,53 @@ class ScientificArtifactPublicationLink(Identifiable):
|
1290 | 1307 | )
|
1291 | 1308 |
|
1292 | 1309 |
|
| 1310 | +class ScientificArtifactExternalDataSourcePageLink(Identifiable): |
| 1311 | + """Represents the association between a scientific artifact and an external data source page. |
| 1312 | +
|
| 1313 | + It enforces uniqueness on the combination of external data source page and scientific artifact, |
| 1314 | + ensuring that each artifact-database URL pair is unique. |
| 1315 | +
|
| 1316 | + Attributes: |
| 1317 | + external_data_source_page_id (UUID): Foreign key referencing |
| 1318 | + the associated external data source page. |
| 1319 | + scientific_artifact_id (UUID): Foreign key referencing the associated scientific artifact. |
| 1320 | + external_data_source_page (ExternalDataSourcePage): Relationship to the |
| 1321 | + external data source page model. |
| 1322 | + scientific_artifact (ScientificArtifact): Relationship to the ScientificArtifact model. |
| 1323 | +
|
| 1324 | + Table: |
| 1325 | + Unique constraint on (external_data_source_page_id, scientific_artifact_id). |
| 1326 | + """ |
| 1327 | + |
| 1328 | + __tablename__ = "scientific_artifact_external_data_source_page_link" |
| 1329 | + external_data_source_page_id: Mapped[UUID] = mapped_column( |
| 1330 | + ForeignKey("external_data_source_page.id"), index=True |
| 1331 | + ) |
| 1332 | + scientific_artifact_id: Mapped[UUID] = mapped_column( |
| 1333 | + ForeignKey("scientific_artifact.id"), index=True |
| 1334 | + ) |
| 1335 | + |
| 1336 | + # Relationships - assuming ScientificArtifact and ExternalDataSourcePage exist |
| 1337 | + external_data_source_page: Mapped["ExternalDataSourcePage"] = relationship( |
| 1338 | + "ExternalDataSourcePage", |
| 1339 | + foreign_keys=[external_data_source_page_id], |
| 1340 | + uselist=False, |
| 1341 | + ) |
| 1342 | + scientific_artifact: Mapped["ScientificArtifact"] = relationship( |
| 1343 | + "ScientificArtifact", |
| 1344 | + foreign_keys=[scientific_artifact_id], |
| 1345 | + uselist=False, |
| 1346 | + ) |
| 1347 | + |
| 1348 | + __table_args__ = ( |
| 1349 | + UniqueConstraint( |
| 1350 | + "external_data_source_page_id", |
| 1351 | + "scientific_artifact_id", |
| 1352 | + name="uq_saedspl_external_data_source_page_id_scientific_artifact_id", |
| 1353 | + ), |
| 1354 | + ) |
| 1355 | + |
| 1356 | + |
1293 | 1357 | class Circuit(ScientificArtifact, NameDescriptionVectorMixin):
|
1294 | 1358 | """Represents a neural circuit as a scientific artifact.
|
1295 | 1359 |
|
|
0 commit comments