mivot_validator.instance_checking package

Subpackages

Submodules

mivot_validator.instance_checking.inheritance_checker module

Created on 30 May 2023

@author: julien abid

class mivot_validator.instance_checking.inheritance_checker.InheritanceChecker(tree)[source]

Bases: object

classdocs

check_inheritance(first_class, second_class)[source]

Check if two classes are in inheritance relation

get_inheritance(class_name)[source]

Get the inheritance of an inheritance tree for a given class

inherits_from(actual_class, parent_class)[source]

Return True if actual_class inherits from parent_class

mivot_validator.instance_checking.instance_checker module

Created on 21 Feb 2023

@author: laurentmichel

exception mivot_validator.instance_checking.instance_checker.CheckFailedException[source]

Bases: Exception

class mivot_validator.instance_checking.instance_checker.InstanceChecker[source]

Bases: object

API operating the validation of mapped instances against the VODML definition

  • all ATTRIBUTE/COLLECTION/INSTANCE children of the mapped instance must be referenced in the VODML with the same dmrole and the same dmtype.

  • The dmtype checking takes into account the inheritance

  • The mapped instances must not necessary host all the components declared in the VODML

  • All the components hosted by the mapped instances must be compliant with the VODML

The VODML files are stored locally for the moment

static check_instance_validity(instance_etree, session)[source]

Public method. The only one meant to be used from from outside Checks that instance_etree is compliant with the model it refers to

Parameters:

instance_etree (etree) – MIVOT instance to be checked

Return type:

a documented exception ins case of failure

inheritence_tree = {}
static reset()[source]

Reset the static inheritence tree cache Mainly used by tests that run the static class several time in one process

mivot_validator.instance_checking.instance_checker.raise_check_failed_exception(message, tree_element)[source]
Parameters:
  • message (string) – Exception message

  • tree_element (Element (XML)) – XML element where the error occured

mivot_validator.instance_checking.instance_snippet_builder module

Created on 21 Apr 2023

use the snippet_builder to build a concrete MIVOT view of the class model_name:class_name of the model serialized in provided generic MIVOT snippet

@author: julien abid

class mivot_validator.instance_checking.instance_snippet_builder.BColors[source]

Bases: object

Color codes for terminal output

BOLD = '\x1b[1m'
ENDC = '\x1b[0m'
GRAY = '\x1b[37m'
OKBLUE = '\x1b[94m'
OKCYAN = '\x1b[96m'
OKGREEN = '\x1b[92m'
RED = '\x1b[31m'
UNDERLINE = '\x1b[4m'
WARNING = '\x1b[93m'
class mivot_validator.instance_checking.instance_snippet_builder.InstanceSnippetBuilder(vodmlid, output_name, session, concrete_list=None)[source]

Bases: object

Build a concrete MIVOT view of the class model_name:class_name of the model serialized in provided generic MIVOT snippet

add_abstract_classes(model)[source]

Add the abstract classes to the list

ask_for_collection(actual_collection, instance_count, parent_key)[source]

Ask the user if he wants to add another property in the collection

Parameters:
  • actual_collection – the context of the property

  • instance_count – the number of instance in the collection

  • parent_key – the parent key of the property

build()[source]

Build the concrete MIVOT snippet

static clean(xml_file)[source]

Remove all empty collection in the xml file

static get_dm_role(line)[source]

Get the dmrole from the line :return: the dmrole

static get_dm_type(line)[source]

Get the dmtype from the line :return: the dmtype

get_instance(model_name, class_name)[source]

Get the instance of the class class_name of the model model_name :return: the instance path

insert_dm_roles(xml_file, dmroles)[source]

Insert the dmroles in the concrete MIVOT snippet

output_result()[source]

Write the concrete MIVOT snippet in the output directory

populate_choices(els, parent_key)[source]

Make an input with choices from the list

static remove_instance(xml_file, dmtype)[source]

Remove the instance of a class containing given dmtype and all its children

mivot_validator.instance_checking.instance_snippet_builder.add_value(dict_obj, key, value)[source]

Adds a key-value pair to the dictionary. If the key already exists in the dictionary, it will associate multiple values with that key instead of overwritting its value

mivot_validator.instance_checking.instance_snippet_builder.remove_value(dict_obj, key, value)[source]

Removes a value from a key that has multiple values associated with it. If the key only has one value associated with it, it will remove the key from the dictionary

mivot_validator.instance_checking.instance_snippet_builder.setup_elements(graph, dmtype, abstract_list)[source]

Sets up the elements of the graph

mivot_validator.instance_checking.model_snippets_builder module

Created on 19 Apr 2023

use a modified version of the snippet builder to generate snippets for all the objectTypes of a VODML model

@author: julien abid

class mivot_validator.instance_checking.model_snippets_builder.ModelBuilder(vodml_path, session)[source]

Bases: Builder

Class to generate snippets for all the objectTypes and dataTypes of a VODML model

Parameters:
  • vodml_path – path to the VODML model

  • output_dir – path to the output directory

build()[source]

Build one snippet for all the dataType/objectType which are not abstract, found in the VODML model

build_object(ele, role, root, aggregate)[source]

Build a MIVOT instance from a VOMDL element

Ele:

VODML representation of the class to be mapped

Role:

VODML role to be affected to the built instance

Aggregate:

If False, all components found out in the VODML element are added to the enclosing instance (in that case of inheritance reconstruction) . Otherwise, those components are enclosed in an INSTANCE (composition case)

mivot_validator.instance_checking.snippet_builder module

Created on 22 Dec 2022

@author: laurentmichel

class mivot_validator.instance_checking.snippet_builder.Builder(model_name, class_name, session, verbose=False)[source]

Bases: object

Build a MIVOT view of the class model_name:class_name of the model serialized in the provided VOMDL file

CACHE = {}
RECORD = ''
RECORD_ON = True
addAttribute(ele)[source]

add one attribute to the current snippet (can a complex data type or not) if the multiplicity is one:one attribute is added, a COLLECTION otherwise :ele: ATTRIBUTE VODML element

addComposition(ele)[source]

insert in the current snippet the VOMDL element matching the VODML composition element :ele: VODML element of the composition

addExtend(ele)[source]

add to the current snippet the super class components :ele: EXTEND VODML element

addReference(ele)[source]

insert in the current snippet the VOMDL element matching the VODML reference element :ele: VODML element of the reference

build()[source]

Build one snippet for the dataType/objectType found in the VODML block and matching the searched class

build_object(ele, role, root, aggregate)[source]

Build a MIVOT instance from a VOMDL element

Ele:

VODML representation of the class to be mapped

Role:

VODML role to be affected to the built instance

Root:

If true the INSTANCE is not a component of an enclosing object. The snippet file must be initialized

Aggregate:

If False, all components found out in the VODML element are added to the enclosing instance (in that case of inheritance reconstruction). Otherwise, those components are enclosed in an INSTANCE (composition case)

get_concrete_type_by_ref(abstract_vodmlid, role, aggregate, extend)[source]
get_object_by_ref(vodmlid, role, aggregate, extend=False)[source]
get_vodmlid(vodmlid)[source]

returns the full qualified VODMLid

include_file(filename)[source]

Snippet aggregation: no longer used

is_abstract(ele)[source]

Tells whether the datatype ele is abstract or not

write_out(string, record=False)[source]

Write out the element given as string into the current snippet

class mivot_validator.instance_checking.snippet_builder.Constraints(model_name, verbose=False)[source]

Bases: object

Place holder for the constraints detected in the model Contraints consist in forcing a certain sub-type for a certain role There are stored in a dict {role: type}

add_constraint(ele)[source]
get_contraint(const_key)[source]
get_superclass_contraint(const_key)[source]

Module contents