Skip to content
Snippets Groups Projects
datacollection_model.py 1.13 KiB
Newer Older
root's avatar
root committed
# Import libraries
from neomodel import StructuredNode, StringProperty, IntegerProperty,UniqueIdProperty, RelationshipTo
root's avatar
root committed
from uuid import uuid4
root's avatar
root committed
# Import models
root's avatar
root committed
from api.models.dataset_model import Dataset
root's avatar
root committed
class DataCollection(StructuredNode):
root's avatar
root committed
	
	"""
	Defines node properties and relationships
	Provides data serializer
	"""

	# Properties
root's avatar
root committed
	uuid=StringProperty(unique_index=True, default=uuid4)
root's avatar
root committed
	imagesNumber=IntegerProperty()
	flux=StringProperty()
root's avatar
root committed
	resolution=StringProperty()
	wavelength=IntegerProperty()
	transmission=IntegerProperty()
root's avatar
root committed
	exposureTime=IntegerProperty()
	detectorDistance=IntegerProperty()
	beamlineName=StringProperty()
root's avatar
root committed
	# Relationships
	generates=RelationshipTo(Dataset, 'GENERATES')
root's avatar
root committed
	@property
	def serialize(self):
root's avatar
root committed
		"""
		Serializer for node properties
		"""
		
		return {
			'node_properties': {
root's avatar
root committed
				"uuid": self.uuid,
root's avatar
root committed
				"imagesNumber": self.imagesNumber,
root's avatar
root committed
				"flux": self.flux,
				"resolution": self.resolution,
				"wavelength": self.wavelength,
				"transmission": self.transmission,
root's avatar
root committed
				"exposureTime": self.exposureTime,
				"detectorDistance": self.detectorDistance ,
				"beamlineName": self.beamlineName,
root's avatar
root committed
			},
		}