From 1292e3fc5c8438e9d97ccc457cf2fc41ec40bfb6 Mon Sep 17 00:00:00 2001 From: Sarthak Kapoor Date: Wed, 14 Aug 2024 18:34:59 +0200 Subject: [PATCH] Add `AddPolymerizationReactions` section --- .../schema_packages/polymerization.py | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/nomad_polymerization_reactions/schema_packages/polymerization.py b/src/nomad_polymerization_reactions/schema_packages/polymerization.py index ff4e812..451b500 100644 --- a/src/nomad_polymerization_reactions/schema_packages/polymerization.py +++ b/src/nomad_polymerization_reactions/schema_packages/polymerization.py @@ -16,6 +16,7 @@ from nomad.datamodel.metainfo.annotations import ELNAnnotation, ELNComponentEnum from nomad.datamodel.metainfo.basesections import ( Activity, + BaseSection, CompositeSystem, PubChemPureSubstanceSection, PublicationReference, @@ -125,4 +126,43 @@ class PolymerizationReactionReference(SectionReference): ) +class AddPolymerizationReactions(BaseSection, Schema): + """ + A section to add polymerization reaction entries in the current upload. + Each entry is also referenced in this section. + """ + + zip_file = Quantity( + type=str, + description='Zip file containing one JSON for each polymerization reaction.', + a_eln=ELNAnnotation( + component=ELNComponentEnum.FileEditQuantity, + ), + ) + polymerization_reactions = SubSection( + section_def=PolymerizationReactionReference, + repeats=True, + description='References to polymerization reaction entries.', + ) + reprocess = Quantity( + type=bool, + description='Reprocess the zip file to generate entries.', + a_eln=ELNAnnotation( + component=ELNComponentEnum.BoolEditQuantity, + ), + default=True, + ) + + def normalize(self, archive: 'EntryArchive', logger: 'BoundLogger') -> None: + logger.info( + 'AddPolymerizationReactions.normalize', parameter=configuration.parameter + ) + super().normalize(archive, logger) + if self.zip_file and self.reprocess: + ## create entry archives with overwriting + ## use generate archive from json + ## add the entry to the polymerization_reactions reference list + self.reprocess = False + + m_package.__init_metainfo__()