884 self.doexec(cnx, sql % attrs) |
884 self.doexec(cnx, sql % attrs) |
885 |
885 |
886 _handle_insert_entity_sql = doexec |
886 _handle_insert_entity_sql = doexec |
887 _handle_is_instance_of_sql = _handle_source_relation_sql = _handle_is_relation_sql |
887 _handle_is_instance_of_sql = _handle_source_relation_sql = _handle_is_relation_sql |
888 |
888 |
889 def add_info(self, cnx, entity, source, extid, complete): |
889 def add_info(self, cnx, entity, source, extid): |
890 """add type and source info for an eid into the system table""" |
890 """add type and source info for an eid into the system table""" |
891 with cnx.ensure_cnx_set: |
891 with cnx.ensure_cnx_set: |
892 # begin by inserting eid/type/source/extid into the entities table |
892 # begin by inserting eid/type/source/extid into the entities table |
893 if extid is not None: |
893 if extid is not None: |
894 assert isinstance(extid, str) |
894 assert isinstance(extid, str) |
911 if 'CWSource' in self.schema and source.eid is not None: # else, cw < 3.10 |
911 if 'CWSource' in self.schema and source.eid is not None: # else, cw < 3.10 |
912 self._handle_is_relation_sql(cnx, 'INSERT INTO cw_source_relation(eid_from,eid_to) VALUES (%s,%s)', |
912 self._handle_is_relation_sql(cnx, 'INSERT INTO cw_source_relation(eid_from,eid_to) VALUES (%s,%s)', |
913 (entity.eid, source.eid)) |
913 (entity.eid, source.eid)) |
914 # now we can update the full text index |
914 # now we can update the full text index |
915 if self.do_fti and self.need_fti_indexation(entity.cw_etype): |
915 if self.do_fti and self.need_fti_indexation(entity.cw_etype): |
916 if complete: |
|
917 entity.complete(entity.e_schema.indexable_attributes()) |
|
918 self.index_entity(cnx, entity=entity) |
916 self.index_entity(cnx, entity=entity) |
919 |
917 |
920 def update_info(self, cnx, entity, need_fti_update): |
918 def update_info(self, cnx, entity, need_fti_update): |
921 """mark entity as being modified, fulltext reindex if needed""" |
919 """mark entity as being modified, fulltext reindex if needed""" |
922 if self.do_fti and need_fti_update: |
920 if self.do_fti and need_fti_update: |
1179 # restore the entity |
1177 # restore the entity |
1180 action.changes['cw_eid'] = eid |
1178 action.changes['cw_eid'] = eid |
1181 sql = self.sqlgen.insert(SQL_PREFIX + etype, action.changes) |
1179 sql = self.sqlgen.insert(SQL_PREFIX + etype, action.changes) |
1182 self.doexec(cnx, sql, action.changes) |
1180 self.doexec(cnx, sql, action.changes) |
1183 # restore record in entities (will update fti if needed) |
1181 # restore record in entities (will update fti if needed) |
1184 self.add_info(cnx, entity, self, None, True) |
1182 self.add_info(cnx, entity, self, None) |
1185 self.repo.hm.call_hooks('after_add_entity', cnx, entity=entity) |
1183 self.repo.hm.call_hooks('after_add_entity', cnx, entity=entity) |
1186 return errors |
1184 return errors |
1187 |
1185 |
1188 def _undo_r(self, cnx, action): |
1186 def _undo_r(self, cnx, action): |
1189 """undo a relation removal""" |
1187 """undo a relation removal""" |