Ejemplo n.º 1
0
 def insert_object(self):
     """ Create a new mapping object """
     if self.dry_run or not self.value:
         return
     current_obj = self.row_converter.obj
     relationships = []
     mapping = None
     for obj in self.value:
         if current_obj.id:
             mapping = Relationship.find_related(current_obj, obj)
         if not self.unmap and not mapping:
             if not (self.mapping_object.__name__ == "Audit" and
                     not getattr(current_obj, "allow_map_to_audit", True)):
                 mapping = Relationship(source=current_obj, destination=obj)
                 relationships.append(mapping)
                 db.session.add(mapping)
             else:
                 self.add_warning(errors.SINGLE_AUDIT_RESTRICTION,
                                  mapped_type=obj.type,
                                  object_type=current_obj.type)
         elif self.unmap and mapping:
             if not (self.mapping_object.__name__ == "Audit"
                     and not getattr(current_obj, "allow_unmap_from_audit",
                                     True)):
                 db.session.delete(mapping)
             else:
                 self.add_warning(errors.UNMAP_AUDIT_RESTRICTION,
                                  mapped_type=obj.type,
                                  object_type=current_obj.type)
     db.session.flush()
     self.dry_run = True
Ejemplo n.º 2
0
 def insert_object(self):
   """ Create a new mapping object """
   if self.dry_run or not self.value:
     return
   current_obj = self.row_converter.obj
   relationships = []
   mapping = None
   for obj in self.value:
     if current_obj.id:
       mapping = Relationship.find_related(current_obj, obj)
     if not self.unmap and not mapping:
       if not (self.mapping_object.__name__ == "Audit" and
               not getattr(current_obj, "allow_map_to_audit", True)):
         mapping = Relationship(source=current_obj, destination=obj)
         relationships.append(mapping)
         db.session.add(mapping)
       else:
         self.add_warning(errors.SINGLE_AUDIT_RESTRICTION,
                          mapped_type=obj.type,
                          object_type=current_obj.type)
     elif self.unmap and mapping:
       if not (self.mapping_object.__name__ == "Audit" and
               not getattr(current_obj, "allow_unmap_from_audit", True)):
         db.session.delete(mapping)
       else:
         self.add_warning(errors.UNMAP_AUDIT_RESTRICTION,
                          mapped_type=obj.type,
                          object_type=current_obj.type)
   db.session.flush()
   self.dry_run = True
Ejemplo n.º 3
0
 def insert_object(self):
   """ Create a new mapping object """
   if self.dry_run or not self.value:
     return
   current_obj = self.row_converter.obj
   relationships = []
   mapping = None
   for obj in self.value:
     if current_obj.id:
       mapping = Relationship.find_related(current_obj, obj)
     if not self.unmap and not mapping:
       mapping = Relationship(source=current_obj, destination=obj)
       relationships.append(mapping)
       db.session.add(mapping)
     elif self.unmap and mapping:
       db.session.delete(mapping)
   db.session.flush()
   self.dry_run = True
Ejemplo n.º 4
0
 def insert_object(self):
   """ Create a new mapping object """
   if self.dry_run or not self.value:
     return
   current_obj = self.row_converter.obj
   relationships = []
   for obj in self.value:
     mapping = Relationship.find_related(current_obj, obj)
     if not self.unmap and not mapping:
       mapping = Relationship(source=current_obj, destination=obj)
       relationships.append(mapping)
       db.session.add(mapping)
     elif self.unmap and mapping:
       db.session.delete(mapping)
   db.session.flush()
   # it is safe to reuse this automapper since no other objects will be
   # created while creating automappings and cache reuse yields significant
   # performance boost
   automapper = AutomapperGenerator(use_benchmark=False)
   for relation in relationships:
     automapper.generate_automappings(relation)
   self.dry_run = True
Ejemplo n.º 5
0
 def insert_object(self):
   """ Create a new mapping object """
   if self.dry_run or not self.value:
     return
   current_obj = self.row_converter.obj
   relationships = []
   for obj in self.value:
     mapping = Relationship.find_related(current_obj, obj)
     if not self.unmap and not mapping:
       mapping = Relationship(source=current_obj, destination=obj)
       relationships.append(mapping)
       db.session.add(mapping)
     elif self.unmap and mapping:
       db.session.delete(mapping)
   db.session.flush()
   # it is safe to reuse this automapper since no other objects will be
   # created while creating automappings and cache reuse yields significant
   # performance boost
   automapper = AutomapperGenerator(use_benchmark=False)
   for relation in relationships:
     automapper.generate_automappings(relation)
   self.dry_run = True