Merge branch 'master' of gitea.azcona-becker.net:beckermj/mocha
This commit is contained in:
commit
0df920491c
@ -51,10 +51,10 @@ class MochaShell (REPLApplication):
|
|||||||
|
|
||||||
def print_instance_list(self, instances : list):
|
def print_instance_list(self, instances : list):
|
||||||
print("")
|
print("")
|
||||||
print("instance key global identifier ")
|
print("instance key global identifier comment ")
|
||||||
print("--------------- --------------------------------------")
|
print("--------------- -------------------------------------- -------------------------")
|
||||||
for inst in instances:
|
for inst in instances:
|
||||||
print(str(inst.get_instance_key()).ljust(16) + str(inst.get_global_identifier()))
|
print(str(inst.get_instance_key()).ljust(16) + str(inst.get_global_identifier()) + " " + self.oms.get_instance_text(inst))
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
def print_instance_list_with_attribute_values(self, instances : list, oms : Oms, refobj : InstanceReference):
|
def print_instance_list_with_attribute_values(self, instances : list, oms : Oms, refobj : InstanceReference):
|
||||||
|
|||||||
@ -103,6 +103,42 @@ class Oms:
|
|||||||
def get_tenant_by_name(self, tenant_name : str) -> TenantReference:
|
def get_tenant_by_name(self, tenant_name : str) -> TenantReference:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_related_instances(self, inst : InstanceReference, rel : InstanceReference) -> list[InstanceReference]:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_related_instance(self, inst : InstanceReference, rel : InstanceReference) -> InstanceReference | None:
|
||||||
|
rels = self.get_related_instances(inst, rel)
|
||||||
|
if len(rels) == 0:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return rels[0]
|
||||||
|
|
||||||
|
def assign_attribute(self, instance : InstanceReference, attribute : InstanceReference, value : str):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def assign_relationship(self, instance : InstanceReference, relationship : InstanceReference, related_instances : InstanceReference|list):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def get_instance_text(self, inst : InstanceReference) -> str:
|
||||||
|
# first see if we have a parent class with `Class.instance labeled by Executable returning Attribute`
|
||||||
|
pclasz = self.get_parent_class(inst)
|
||||||
|
if pclasz is not None:
|
||||||
|
rel = self.get_instance_by_global_identifier(KnownRelationshipGuids.Class__instances_labeled_by__Executable_returning_Attribute)
|
||||||
|
relinst = self.get_related_instance(pclasz, rel)
|
||||||
|
if relinst is not None:
|
||||||
|
text = "EXEC:" + str(relinst.get_instance_key()) # self.execute(relinst)
|
||||||
|
return text
|
||||||
|
|
||||||
|
|
||||||
|
# if all else fails, try getting the `Name` attribute
|
||||||
|
attr = self.get_instance_by_global_identifier(KnownAttributeGuids.Name)
|
||||||
|
text = self.get_attribute_value(inst, attr)
|
||||||
|
|
||||||
|
if text is None:
|
||||||
|
text = ""
|
||||||
|
|
||||||
|
return text
|
||||||
|
|
||||||
def _create_instance_of(self, class_inst : InstanceReference, global_identifier : Guid = None):
|
def _create_instance_of(self, class_inst : InstanceReference, global_identifier : Guid = None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -222,6 +258,7 @@ class Oms:
|
|||||||
ik_MaximumValue = self.create_instance_of(ik_NumericAttribute, KnownAttributeGuids.MaximumValue)
|
ik_MaximumValue = self.create_instance_of(ik_NumericAttribute, KnownAttributeGuids.MaximumValue)
|
||||||
self.set_attribute_value(ik_MaximumValue, att_Name, "Maximum Value")
|
self.set_attribute_value(ik_MaximumValue, att_Name, "Maximum Value")
|
||||||
|
|
||||||
|
self.set_attribute_value(ik_Class, att_Name, "Class")
|
||||||
self.update_class_instances()
|
self.update_class_instances()
|
||||||
|
|
||||||
def update_relationship(self, relationship : InstanceReference, src_class : InstanceReference, type : str, dst_class : InstanceReference, singular: bool, sibling_relationship : InstanceReference):
|
def update_relationship(self, relationship : InstanceReference, src_class : InstanceReference, type : str, dst_class : InstanceReference, singular: bool, sibling_relationship : InstanceReference):
|
||||||
|
|||||||
@ -118,6 +118,9 @@ class MySQLDatabaseOms(DatabaseOms):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_related_instances(self, inst : InstanceReference, rel : InstanceReference) -> list[InstanceReference]:
|
||||||
|
pass
|
||||||
|
|
||||||
def get_tenant_by_name(self, tenant_name : str) -> TenantReference:
|
def get_tenant_by_name(self, tenant_name : str) -> TenantReference:
|
||||||
mycur = self.db.cursor()
|
mycur = self.db.cursor()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user