class Udf(models.Model): """ UDF = User Defined Field For example, say we wanted to start tracking ‘challenge problem #’ with an experiment. Instead of creating a new column in experiment, we could define a udf (udf_def) and it’s associated value (val) type, in this case say: text. Then we could allow the user (API) to create a specific instance of that udf_def, and associate it with a specific experiment, where the experiment_uuid is the ref_udf_uuid. """ uuid = RetUUIDField(primary_key=True, db_column='udf_uuid') udf_def = models.ForeignKey('UdfDef', models.DO_NOTHING, blank=True, null=True, db_column='udf_def_uuid', related_name='udf_udf_def') description = models.CharField(max_length=255, null=True) udf_value = ValField(max_length=255, db_column='udf_val') udf_val_edocument = models.ForeignKey('Edocument', models.DO_NOTHING, blank=True, null=True, db_column='udf_val_edocument_uuid', related_name='udf_udf_val_edocument') ref_udf = RetUUIDField(db_column='ref_udf_uuid') add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_udf' def __str__(self): return "{}".format(self.description)
class Note(models.Model): uuid = RetUUIDField(primary_key=True, db_column='note_uuid') notetext = models.TextField(blank=True, null=True, verbose_name='Note Text') add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) actor = models.ForeignKey('Actor', models.DO_NOTHING, db_column='actor_uuid', related_name='note_actor') actor_description = models.CharField(max_length=255, blank=True, null=True, editable=False) """ note_x_uuid = models.ForeignKey('Note_x', models.DO_NOTHING, blank=True, null=True, editable=False, db_column='note_x_uuid', related_name='note_note_x') """ ref_note_uuid = RetUUIDField(blank=True, null=True) class Meta: managed = False db_table = 'vw_note' def __str__(self): return "{}".format(self.notetext)
class WorkflowActionSet(models.Model): uuid = RetUUIDField(primary_key=True, db_column='workflow_action_set_uuid') description = models.CharField(max_length=255, blank=True, null=True) workflow = models.ForeignKey('Workflow', models.DO_NOTHING, blank=True, null=True, db_column='workflow_uuid', related_name='workflow_action_set_workflow') action_def = models.ForeignKey('ActionDef', models.DO_NOTHING, blank=True, null=True, db_column='action_def_uuid', related_name='workflow_action_set_action_def') start_date = models.DateTimeField() end_date = models.DateTimeField() duration = models.FloatField() repeating = models.BigIntegerField() parameter_def = models.ForeignKey('ParameterDef', models.DO_NOTHING, blank=True, null=True, db_column='parameter_def_uuid', related_name='workflow_action_set_parameter_def') parameter_val_nominal = CustomArrayField(ValField(), blank=True, null=True, db_column='parameter_val') calculation = models.ForeignKey('Calculation', models.DO_NOTHING, blank=True, null=True, db_column='calculation_uuid', related_name='workflow_action_set_calculation') source_material = ArrayField(RetUUIDField(blank=True, null=True), db_column='source_material_uuid') destination_material = ArrayField(RetUUIDField(blank=True, null=True), db_column='destination_material_uuid') actor = models.ForeignKey('Actor', on_delete=models.DO_NOTHING, db_column='actor_uuid', blank=True, null=True, editable=False, related_name='workflow_action_set_actor') status = models.ForeignKey('Status', on_delete=models.DO_NOTHING, db_column='status_uuid', blank=True, null=True, editable=False, related_name='workflow_action_set_status') add_date = models.DateTimeField(auto_now_add=True, db_column='add_date') mod_date = models.DateTimeField(auto_now=True, db_column='mod_date') class Meta: managed = False db_table = 'vw_workflow_action_set'
class WorkflowObject(models.Model): uuid = RetUUIDField(primary_key=True, db_column='workflow_object_uuid') workflow = models.ForeignKey('Workflow', models.DO_NOTHING, blank=True, null=True, db_column='workflow_uuid', related_name='workflow_object_workflow') action = models.ForeignKey('Action', models.DO_NOTHING, blank=True, null=True, db_column='action_uuid', related_name='workflow_object_action') condition = models.ForeignKey('Condition', models.DO_NOTHING, blank=True, null=True, db_column='condition_uuid', related_name='workflow_object_condition') object_uuid = models.CharField(max_length=255, blank=True, null=True, editable=False) object_type = models.CharField(max_length=255, blank=True, null=True, editable=False) object_description = models.CharField(max_length=255, blank=True, null=True, editable=False) object_def_description = models.CharField(max_length=255, blank=True, null=True, editable=False) add_date = models.DateTimeField(auto_now_add=True, db_column='add_date') mod_date = models.DateTimeField(auto_now=True, db_column='mod_date') class Meta: managed = False db_table = 'vw_workflow_object'
class Material(models.Model): uuid = RetUUIDField(primary_key=True, db_column='material_uuid') description = models.CharField(max_length=255, blank=True, null=True) consumable = models.BooleanField(blank=True, null=True) composite_flg = models.BooleanField(blank=True, null=True) material_types = models.ManyToManyField('MaterialType', through='MaterialTypeAssign', related_name='material_material_types') material_class = models.CharField(max_length=64, choices=MATERIAL_CLASS_CHOICES) actor = models.ForeignKey('Actor', models.DO_NOTHING, blank=True, null=True, db_column='actor_uuid', related_name='material_actor') actor_description = models.CharField(max_length=255, blank=True, null=True, editable=False) status = models.ForeignKey('Status', on_delete=models.DO_NOTHING, blank=True, null=True, db_column='status_uuid', related_name='material_status') property = models.ManyToManyField('Property', through='MaterialProperty', related_name='material_property') status_description = models.CharField( max_length=255, blank=True, null=True, editable=False) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_material' def __str__(self): return "{}".format(self.description)
class ConditionDef(models.Model): uuid = RetUUIDField( primary_key=True, db_column='condition_def_uuid') description = models.CharField(max_length=255, blank=True, null=True, db_column='description', editable=False) calculation_def = models.ManyToManyField('CalculationDef', through='ConditionCalculationDefAssign') actor = models.ForeignKey('Actor', on_delete=models.DO_NOTHING, db_column='actor_uuid', blank=True, null=True, editable=False, related_name='condition_def_actor') actor_description = models.CharField(max_length=255, blank=True, null=True, db_column='actor_description', editable=False) status = models.ForeignKey('Status', on_delete=models.DO_NOTHING, db_column='status_uuid', blank=True, null=True, editable=False, related_name='condition_def_status') add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_condition_def'
class BillOfMaterials(models.Model): uuid = RetUUIDField(primary_key=True, db_column='bom_uuid') description = models.CharField(max_length=255, blank=True, null=True) experiment = models.ForeignKey('Experiment', on_delete=models.DO_NOTHING, blank=True, null=True, db_column='experiment_uuid', related_name='bom_experiment') experiment_description = models.CharField( max_length=255, blank=True, null=True) actor = models.ForeignKey('Actor', on_delete=models.DO_NOTHING, db_column='actor_uuid', blank=True, null=True, editable=False, related_name='bom_actor') status = models.ForeignKey('Status', on_delete=models.DO_NOTHING, db_column='status_uuid', blank=True, null=True, editable=False, related_name='bom_status') add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_bom'
class Organization(models.Model): uuid = RetUUIDField(primary_key=True, db_column='organization_uuid') description = models.CharField(max_length=255) full_name = models.CharField(max_length=255) short_name = models.CharField(max_length=255, blank=True, null=True) address1 = models.CharField(max_length=255, blank=True, null=True) address2 = models.CharField(max_length=255, blank=True, null=True) city = models.CharField(max_length=255, blank=True, null=True) state_province = models.CharField(max_length=3, blank=True, null=True) zip = models.CharField(max_length=255, blank=True, null=True) country = models.CharField(max_length=255, blank=True, null=True) website_url = models.CharField(max_length=255, blank=True, null=True) phone = models.CharField(max_length=255, blank=True, null=True) parent = models.ForeignKey('self', models.DO_NOTHING, blank=True, null=True, db_column='parent_uuid', related_name='organization_parent') parent_org_full_name = models.CharField(max_length=255, blank=True, null=True) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_organization' def __str__(self): return "{}".format(self.full_name)
class Experiment(models.Model): uuid = RetUUIDField(primary_key=True, db_column='experiment_uuid') ref_uid = models.CharField(max_length=255, db_column='ref_uid') description = models.CharField(max_length=255, db_column='description') parent = models.ForeignKey('TypeDef', db_column='parent_uuid', on_delete=models.DO_NOTHING, blank=True, null=True, related_name='experiment_parent') owner = models.ForeignKey('Actor', db_column='owner_uuid', on_delete=models.DO_NOTHING, blank=True, null=True, related_name='experiment_owner') workflow = models.ManyToManyField('Workflow', through='ExperimentWorkflow', related_name='experiment_workflow') owner_description = models.CharField( max_length=255, db_column='owner_description') operator = models.ForeignKey('Actor', db_column='operator_uuid', on_delete=models.DO_NOTHING, blank=True, null=True, related_name='experiment_operator') operator_description = models.CharField( max_length=255, db_column='operator_description') lab = models.ForeignKey('Actor', db_column='lab_uuid', on_delete=models.DO_NOTHING, blank=True, null=True, related_name='experiment_lab') lab_description = models.CharField( max_length=255, db_column='lab_description') status = models.ForeignKey( 'Status', on_delete=models.DO_NOTHING, db_column='status_uuid', blank=True, null=True, related_name='experiment_status') status_description = models.CharField( max_length=255, blank=True, null=True, db_column='status_description', editable=False) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) def __str__(self): return f'{self.description}' class Meta: managed = False db_table = 'vw_experiment'
class Systemtool(models.Model): uuid = RetUUIDField(primary_key=True, db_column='systemtool_uuid') systemtool_name = models.CharField(max_length=255, null=True) description = models.CharField(max_length=255, blank=True, null=True) vendor_organization = models.ForeignKey( 'Organization', models.DO_NOTHING, db_column='vendor_organization_uuid', related_name='systemtool_vendor_organization') organization_fullname = models.CharField(max_length=255, blank=True, null=True) systemtool_type = models.ForeignKey( 'SystemtoolType', models.DO_NOTHING, db_column='systemtool_type_uuid', related_name='systemtool_systemtool_type') systemtool_type_description = models.CharField(max_length=255, blank=True, null=True) model = models.CharField(max_length=255, blank=True, null=True) serial = models.CharField(max_length=255, blank=True, null=True) ver = models.CharField(max_length=255, null=True) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_systemtool' def __str__(self): return "{}".format(self.systemtool_name)
class BomCompositeMaterial(models.Model): uuid = RetUUIDField(primary_key=True, db_column='bom_material_composite_uuid') description = models.CharField(max_length=255, blank=True, null=True) bom_material = models.ForeignKey('BomMaterial', on_delete=models.DO_NOTHING, blank=True, null=True, db_column='bom_material_uuid', related_name='bom_composite_material_bom_material') bom_material_description = models.CharField(max_length=255, blank=True, null=True) composite_material = models.ForeignKey('CompositeMaterial', on_delete=models.DO_NOTHING, blank=True, null=True, db_column='material_composite_uuid', related_name='bom_composite_material_composite_material') component = models.ForeignKey('Material', on_delete=models.DO_NOTHING, blank=True, null=True, db_column='component_uuid', related_name='bom_composite_material_component') material_description = models.CharField(max_length=255, blank=True, null=True) actor = models.ForeignKey('Actor', on_delete=models.DO_NOTHING, db_column='actor_uuid', blank=True, null=True, editable=False, related_name='bom_composite_material_actor') status = models.ForeignKey('Status', on_delete=models.DO_NOTHING, db_column='status_uuid', blank=True, null=True, editable=False, related_name='bom_composite_material_status') add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_bom_material_composite'
class ExperimentParameter(models.Model): """Note: this is currently broken but unused. Consider it deprecated""" uuid = RetUUIDField(primary_key=True, db_column='parameter_uuid') parameter_value_nominal = CustomArrayField(ValField(), blank=True, null=True) parameter_value_actual = CustomArrayField(ValField(), blank=True, null=True) parameter_def_description = models.CharField( max_length=255, db_column='parameter_def_description', editable=False) object = models.ForeignKey('WorkflowObject', on_delete=models.DO_NOTHING, db_column='object_uuid', blank=True, null=True, related_name='experiment_parameter_object', editable=False) object_description = models.CharField(blank=True, null=True, max_length=255, db_column='object_description', editable=False) workflow_object = models.CharField(blank=True, null=True, max_length=255, db_column='workflow_object', editable=False) workflow_seq = models.IntegerField(blank=True, null=True) workflow_description = models.CharField(blank=True, null=True, max_length=255, db_column='workflow', editable=False) experiment_description = models.CharField(blank=True, null=True, max_length=255, db_column='experiment', editable=False) experiment = models.ForeignKey('Experiment', on_delete=models.DO_NOTHING, db_column='experiment_uuid', blank=True, null=True, related_name='experiment_parameter_experiment', editable=False) class Meta: managed = False db_table = 'vw_experiment_parameter'
class ActionParameterDef(models.Model): uuid = RetUUIDField( primary_key=True, db_column='action_parameter_def_x_uuid') action_def = models.ForeignKey('ActionDef', on_delete=models.DO_NOTHING, db_column='action_def_uuid', blank=True, null=True, editable=False, related_name='action_parameter_def_action_def') description = models.CharField(max_length=255, blank=True, null=True, db_column='description', editable=False) actor = models.ForeignKey('Actor', on_delete=models.DO_NOTHING, db_column='actor_uuid', blank=True, null=True, editable=False, related_name='action_parameter_def_actor') actor_description = models.CharField(max_length=255, blank=True, null=True, db_column='actor_description', editable=False) status = models.ForeignKey('Status', on_delete=models.DO_NOTHING, db_column='status_uuid', blank=True, null=True, editable=False, related_name='action_parameter_def_status') status_description = models.CharField(max_length=255, blank=True, null=True, db_column='status_description', editable=False) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) parameter_def = models.ForeignKey('ParameterDef', on_delete=models.DO_NOTHING, db_column='parameter_def_uuid', blank=True, null=True, editable=False, related_name='action_parameter_def_parameter_def') parameter_description = models.CharField(max_length=255, blank=True, null=True, db_column='parameter_description', editable=False) parameter_val_type = models.ForeignKey('TypeDef', db_column='parameter_val_type_uuid', on_delete=models.DO_NOTHING, blank=True, null=True, related_name='action_parameter_def_parameter_val_type') class Meta: managed = False db_table = 'vw_action_parameter_def'
class PropertyDef(models.Model): uuid = RetUUIDField(primary_key=True, db_column='property_def_uuid') description = models.CharField(max_length=255, blank=True, null=True, db_column='description') property_def_class = models.CharField(max_length=64, choices=PROPERTY_DEF_CLASS_CHOICES) short_description = models.CharField(max_length=255, blank=True, null=True, db_column='short_description') val_type = models.ForeignKey('TypeDef', db_column='val_type_uuid', on_delete=models.DO_NOTHING, blank=True, null=True, related_name='property_def_val_type') val_unit = models.CharField(max_length=255, blank=True, null=True, db_column='valunit') unit_type = models.CharField(max_length=255, blank=True, null=True, db_column='property_def_unit_type') actor = models.ForeignKey('Actor', on_delete=models.DO_NOTHING, db_column='actor_uuid', blank=True, null=True, editable=False, related_name='property_def_actor') actor_description = models.CharField(max_length=255, blank=True, null=True, db_column='actor_description', editable=False) status = models.ForeignKey('Status', on_delete=models.DO_NOTHING, blank=True, null=True, db_column='status_uuid', related_name='property_def_status') status_description = models.CharField(max_length=255, blank=True, null=True, db_column='status_description', editable=False) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_property_def' def __str__(self): return "{}".format(self.description)
class TagAssign(models.Model): uuid = RetUUIDField(primary_key=True, db_column='tag_x_uuid') ref_tag = RetUUIDField(db_column='ref_tag_uuid') tag = models.ForeignKey('Tag', models.DO_NOTHING, blank=True, null=True, db_column='tag_uuid', related_name='tag_assign_tag') add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_tag_assign' def __str__(self): return "{}".format(self.uuid)
class Note_x(models.Model): uuid = RetUUIDField(primary_key=True, db_column='note_x_uuid') ref_note = RetUUIDField(db_column='ref_note_uuid') note = models.ForeignKey('Note', models.DO_NOTHING, blank=True, null=True, editable=False, db_column='note_uuid', related_name='note_x_note') add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'note_x' def __str__(self): return "{}".format(self.note_uuid)
class Status(models.Model): uuid = RetUUIDField(primary_key=True, db_column='status_uuid') description = models.CharField(max_length=255, null=True) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_status' def __str__(self): return "{}".format(self.description)
class MaterialType(models.Model): uuid = RetUUIDField(primary_key=True, db_column='material_type_uuid') description = models.TextField(blank=True, null=True) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_material_type' def __str__(self): return "{}".format(self.description)
class MaterialRefnameDef(models.Model): uuid = RetUUIDField( primary_key=True, db_column='material_refname_def_uuid') description = models.CharField(max_length=255, blank=True, null=True) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_material_refname_def' def __str__(self): return "{}".format(self.description)
class TagType(models.Model): uuid = RetUUIDField(primary_key=True, db_column='tag_type_uuid') type = models.CharField(max_length=255, null=True) description = models.CharField(max_length=255, blank=True, null=True) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_tag_type' def __str__(self): return "{}".format(self.type)
class SystemtoolType(models.Model): #systemtool_type_id = models.BigAutoField() uuid = RetUUIDField(primary_key=True, db_column='systemtool_type_uuid') description = models.CharField(max_length=255, blank=True, null=True) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_systemtool_type' def __str__(self): return self.description
class WorkflowType(models.Model): uuid = RetUUIDField(primary_key=True, db_column='workflow_type_uuid') description = models.CharField(max_length=255, blank=True, null=True, db_column='description') add_date = models.DateTimeField(auto_now_add=True, db_column='add_date') mod_date = models.DateTimeField(auto_now=True, db_column='mod_date') class Meta: managed = False db_table = 'vw_workflow_type'
class CalculationDef(models.Model): uuid = RetUUIDField(primary_key=True, db_column='calculation_def_uuid') short_name = models.CharField(max_length=255, blank=True, null=True) calc_definition = models.CharField(max_length=255, blank=True, null=True) description = models.CharField(max_length=1023, blank=True, null=True) parameter_def = models.ManyToManyField( 'ParameterDef', through='CalculationParameterDefAssign', related_name='calculation_def_parameter_def') in_source = models.ForeignKey('CalculationDef', models.DO_NOTHING, db_column='in_source_uuid', related_name='calculation_def_in_source') in_type = models.ForeignKey('TypeDef', models.DO_NOTHING, db_column='in_type_uuid', related_name='calculation_def_in_type') in_opt_source = models.ForeignKey( 'CalculationDef', models.DO_NOTHING, db_column='in_opt_source_uuid', related_name='calculation_def_in_opt_source') in_opt_type = models.ForeignKey('TypeDef', models.DO_NOTHING, db_column='in_opt_type_uuid', related_name='calculation_def_in_opt_type') out_type = models.ForeignKey('TypeDef', models.DO_NOTHING, blank=True, null=True, db_column='out_type_uuid', related_name='calculation_def_out_type') systemtool = models.ForeignKey('Systemtool', models.DO_NOTHING, db_column='systemtool_uuid', related_name='calculation_def_systemtool') actor = models.ForeignKey('Actor', models.DO_NOTHING, blank=True, null=True, db_column='actor_uuid', related_name='calculation_def_actor') add_date = models.DateTimeField(auto_now_add=True, db_column='add_date') mod_date = models.DateTimeField(auto_now=True, db_column='mod_date') class Meta: managed = False db_table = 'vw_calculation_def' def __str__(self): return "{}".format(self.description)
class Measure(models.Model): uuid = RetUUIDField(primary_key=True, db_column='measure_uuid') measure_type = models.ForeignKey('MeasureType', on_delete=models.DO_NOTHING, db_column='measure_type_uuid', blank=True, null=True, related_name='measure_measure_type') ref_measure = models.ForeignKey('Measure', on_delete=models.DO_NOTHING, db_column='ref_measure_uuid', blank=True, null=True, related_name='measure_ref_measure') description = models.CharField( max_length=255, blank=True, null=True, ) measure_def = models.ForeignKey('MeasureDef', db_column='measure_def_uuid', on_delete=models.DO_NOTHING) measure_value = ValField(max_length=255, ) actor_uuid = models.ForeignKey('Actor', on_delete=models.DO_NOTHING, db_column='actor_uuid', blank=True, null=True, related_name='measure_actor') actor_description = models.CharField(max_length=255, blank=True, null=True, editable=False) status_uuid = models.ForeignKey('Status', on_delete=models.DO_NOTHING, db_column='status_uuid', blank=True, null=True, related_name='measure_status') status_description = models.CharField(max_length=255, blank=True, null=True, editable=False) add_date = models.DateTimeField(auto_now_add=True, db_column='add_date') mod_date = models.DateTimeField(auto_now=True, db_column='mod_date') class Meta: managed = False db_table = 'vw_measure'
class Condition(models.Model): # todo: link to condition calculation uuid = RetUUIDField(primary_key=True, db_column='condition_uuid') condition_calculation = models.ForeignKey('ConditionCalculationDefAssign', models.DO_NOTHING, db_column='condition_calculation_def_x_uuid', related_name='condition_condition_calculation') condition_description = models.CharField(max_length=255, blank=True, null=True, editable=False) condition_def = models.ForeignKey('ConditionDef', models.DO_NOTHING, db_column='condition_def_uuid', related_name='condition_condition_def') calculation_description = models.CharField(max_length=255, blank=True, null=True, editable=False) # TODO: Fix in_val and out_val on Postgres to return strings not JSON! in_val = ValField(max_length=255, blank=True, null=True) out_val = ValField(max_length=255, blank=True, null=True) actor = models.ForeignKey('Actor', on_delete=models.DO_NOTHING, db_column='actor_uuid', blank=True, null=True, editable=False, related_name='condition_actor') actor_description = models.CharField(max_length=255, blank=True, null=True, db_column='actor_description', editable=False) status = models.ForeignKey('Status', on_delete=models.DO_NOTHING, db_column='status_uuid', blank=True, null=True, editable=False, related_name='condition_status') status_description = models.CharField(max_length=255, blank=True, null=True, db_column='status_description', editable=False) add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_condition'
class Workflow(models.Model): uuid = RetUUIDField(primary_key=True, db_column='workflow_uuid') #step = models.ManyToManyField( # 'WorkflowStep', through='WorkflowStep', related_name='workflow_step') description = models.CharField(max_length=255, blank=True, null=True, db_column='description') parent = models.ForeignKey('Workflow', models.DO_NOTHING, blank=True, null=True, db_column='parent_uuid', related_name='workflow_parent') workflow_type = models.ForeignKey('WorkflowType', models.DO_NOTHING, blank=True, null=True, db_column='workflow_type_uuid', related_name='workflow_workflow_type') workflow_type_description = models.CharField(max_length=255, blank=True, null=True, editable=False) actor = models.ForeignKey('Actor', on_delete=models.DO_NOTHING, db_column='actor_uuid', blank=True, null=True, related_name='workflow_actor') actor_description = models.CharField(max_length=255, blank=True, null=True, db_column='actor_description', editable=False) status = models.ForeignKey('Status', on_delete=models.DO_NOTHING, db_column='status_uuid', blank=True, null=True, related_name='workflow_status') status_description = models.CharField(max_length=255, blank=True, null=True, db_column='status_description', editable=False) add_date = models.DateTimeField(auto_now_add=True, db_column='add_date') mod_date = models.DateTimeField(auto_now=True, db_column='mod_date') class Meta: managed = False db_table = 'vw_workflow'
class ExperimentWorkflow(models.Model): # note: omitted much detail here because should be nested under # experiment, no need for redundancy. uuid = RetUUIDField(primary_key=True, db_column='experiment_workflow_uuid') experiment = models.ForeignKey('Experiment', db_column='experiment_uuid', on_delete=models.DO_NOTHING, blank=True, null=True, related_name='experiment_workflow_experiment') experiment_ref_uid = models.CharField(max_length=255) experiment_description = models.CharField(max_length=255) experiment_workflow_seq = models.IntegerField() workflow = models.ForeignKey('Workflow', db_column='workflow_uuid', on_delete=models.DO_NOTHING, blank=True, null=True, related_name='experiment_workflow_workflow') workflow_type_uuid = models.ForeignKey('WorkflowType', db_column='workflow_type_uuid', on_delete=models.DO_NOTHING, blank=True, null=True) class Meta: managed = False db_table = 'vw_experiment_workflow'
def get_action_parameter_querysets(exp_uuid): related_exp = 'workflow__experiment_workflow_workflow__experiment' related_exp_wf = 'workflow__experiment_workflow_workflow' q1 = ActionParameter.objects.filter(**{ f'{related_exp}': exp_uuid }).annotate(object_description=F('action_description')).annotate( object_uuid=F('uuid') ).annotate(parameter_value=F('parameter_val_nominal')).annotate( experiment_uuid=F(f'{related_exp}__uuid')).annotate( experiment_description=F(f'{related_exp}__description')).annotate( workflow_seq=F(f'{related_exp_wf}__experiment_workflow_seq') ).filter(workflow_action_set__isnull=True).prefetch_related( f'{related_exp}') q2 = WorkflowActionSet.objects.filter( **{ f'{related_exp}': exp_uuid, 'parameter_val_nominal__isnull': False }).annotate(object_description=F('description')).annotate( object_uuid=F('uuid')).annotate( parameter_def_description=F('parameter_def__description') ).annotate(parameter_uuid=Value(None, RetUUIDField())).annotate( parameter_value=F('parameter_val_nominal')).annotate( experiment_uuid=F(f'{related_exp}__uuid')).annotate( experiment_description=F(f'{related_exp}__description') ).annotate(workflow_seq=F( f'{related_exp_wf}__experiment_workflow_seq') ).prefetch_related(f'{related_exp}') q3 = WorkflowActionSet.objects.filter( calculation__isnull=False, workflow__experiment_workflow_workflow__experiment=exp_uuid ).annotate(object_description=F('description')).annotate( object_uuid=F('uuid') ).annotate(parameter_def_description=F( 'calculation__calculation_def__parameter_def__description' )).annotate( parameter_uuid=F('calculation__calculation_def__parameter_def__uuid') ).annotate(parameter_value=F( 'calculation__calculation_def__parameter_def__default_val' )).annotate(experiment_uuid=F(f'{related_exp}__uuid')).annotate( experiment_description=F(f'{related_exp}__description')).annotate( workflow_seq=F(f'{related_exp_wf}__experiment_workflow_seq') ).prefetch_related('workflow__experiment_workflow_workflow__experiment' ).distinct('parameter_uuid') return q1, q2, q3
class MeasureDef(models.Model): uuid = RetUUIDField(primary_key=True, db_column='measure_def_uuid') default_measure_type = models.ForeignKey( 'MeasureType', models.DO_NOTHING, blank=True, null=True, db_column='default_measure_type_uuid', related_name='measure_def_default_measure_type') description = models.CharField(max_length=255, blank=True, null=True, db_column='description') default_measure_value = ValField(max_length=255, ) property_def = models.ForeignKey( 'PropertyDef', models.DO_NOTHING, blank=True, null=True, db_column='property_def_uuid', related_name='measure_def_default_measure_type') actor = models.ForeignKey('Actor', on_delete=models.DO_NOTHING, db_column='actor_uuid', blank=True, null=True, editable=False, related_name='measure_def_actor') status = models.ForeignKey('Status', on_delete=models.DO_NOTHING, db_column='status_uuid', blank=True, null=True, editable=False, related_name='measure_def_status') add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) def __str__(self): return f'{self.description}' class Meta: managed = False db_table = 'vw_measure_def'
class ActionParameterDefAssign(models.Model): uuid = RetUUIDField( primary_key=True, db_column='action_parameter_def_x_uuid') parameter_def = models.ForeignKey('ParameterDef', on_delete=models.DO_NOTHING, blank=True, null=True, db_column='parameter_def_uuid', related_name='action_parameter_def_assign_parameter_def') action_def = models.ForeignKey('ActionDef', on_delete=models.DO_NOTHING, blank=True, null=True, db_column='action_def_uuid', related_name='action_parameter_def_assign_action_def') add_date = models.DateTimeField(auto_now_add=True) mod_date = models.DateTimeField(auto_now=True) class Meta: managed = False db_table = 'vw_action_parameter_def_assign'