equal
deleted
inserted
replaced
689 if eschema.final: |
689 if eschema.final: |
690 instschema.del_entity_type(etype) |
690 instschema.del_entity_type(etype) |
691 else: |
691 else: |
692 eschema = self.fs_schema.eschema(etype) |
692 eschema = self.fs_schema.eschema(etype) |
693 confirm = self.verbosity >= 2 |
693 confirm = self.verbosity >= 2 |
|
694 groupmap = self.group_mapping() |
694 # register the entity into CWEType |
695 # register the entity into CWEType |
695 self.rqlexecall(ss.eschema2rql(eschema, self.group_mapping()), ask_confirm=confirm) |
696 self.rqlexecall(ss.eschema2rql(eschema, groupmap), ask_confirm=confirm) |
696 # add specializes relation if needed |
697 # add specializes relation if needed |
697 self.rqlexecall(ss.eschemaspecialize2rql(eschema), ask_confirm=confirm) |
698 self.rqlexecall(ss.eschemaspecialize2rql(eschema), ask_confirm=confirm) |
698 # register entity's attributes |
699 # register entity's attributes |
699 for rschema, attrschema in eschema.attribute_definitions(): |
700 for rschema, attrschema in eschema.attribute_definitions(): |
700 # ignore those meta relations, they will be automatically added |
701 # ignore those meta relations, they will be automatically added |
703 if not rschema.type in instschema: |
704 if not rschema.type in instschema: |
704 # need to add the relation type and to commit to get it |
705 # need to add the relation type and to commit to get it |
705 # actually in the schema |
706 # actually in the schema |
706 self.cmd_add_relation_type(rschema.type, False, commit=True) |
707 self.cmd_add_relation_type(rschema.type, False, commit=True) |
707 # register relation definition |
708 # register relation definition |
708 self.rqlexecall(ss.rdef2rql(rschema, etype, attrschema.type), |
709 self.rqlexecall(ss.rdef2rql(rschema, etype, attrschema.type, |
|
710 groupmap=groupmap), |
709 ask_confirm=confirm) |
711 ask_confirm=confirm) |
710 # take care to newly introduced base class |
712 # take care to newly introduced base class |
711 # XXX some part of this should probably be under the "if auto" block |
713 # XXX some part of this should probably be under the "if auto" block |
712 for spschema in eschema.specialized_by(recursive=False): |
714 for spschema in eschema.specialized_by(recursive=False): |
713 try: |
715 try: |
764 rtypeadded = True |
766 rtypeadded = True |
765 # register relation definition |
767 # register relation definition |
766 # remember this two avoid adding twice non symetric relation |
768 # remember this two avoid adding twice non symetric relation |
767 # such as "Emailthread forked_from Emailthread" |
769 # such as "Emailthread forked_from Emailthread" |
768 added.append((etype, rschema.type, targettype)) |
770 added.append((etype, rschema.type, targettype)) |
769 self.rqlexecall(ss.rdef2rql(rschema, etype, targettype), |
771 self.rqlexecall(ss.rdef2rql(rschema, etype, targettype, |
|
772 groupmap=groupmap), |
770 ask_confirm=confirm) |
773 ask_confirm=confirm) |
771 for rschema in eschema.object_relations(): |
774 for rschema in eschema.object_relations(): |
772 rtypeadded = rschema.type in instschema or rschema.type in added |
775 rtypeadded = rschema.type in instschema or rschema.type in added |
773 for targetschema in rschema.subjects(etype): |
776 for targetschema in rschema.subjects(etype): |
774 # ignore relations where the targeted type is not in the |
777 # ignore relations where the targeted type is not in the |
784 self.cmd_add_relation_type(rschema.type, False, commit=True) |
787 self.cmd_add_relation_type(rschema.type, False, commit=True) |
785 rtypeadded = True |
788 rtypeadded = True |
786 elif (targettype, rschema.type, etype) in added: |
789 elif (targettype, rschema.type, etype) in added: |
787 continue |
790 continue |
788 # register relation definition |
791 # register relation definition |
789 self.rqlexecall(ss.rdef2rql(rschema, targettype, etype), |
792 self.rqlexecall(ss.rdef2rql(rschema, targettype, etype, |
|
793 groupmap=groupmap), |
790 ask_confirm=confirm) |
794 ask_confirm=confirm) |
791 if commit: |
795 if commit: |
792 self.commit() |
796 self.commit() |
793 |
797 |
794 def cmd_drop_entity_type(self, etype, commit=True): |
798 def cmd_drop_entity_type(self, etype, commit=True): |
846 assert len(objtypes) == 1 |
850 assert len(objtypes) == 1 |
847 objtype = objtypes[0] |
851 objtype = objtypes[0] |
848 props = rschema.rproperties( |
852 props = rschema.rproperties( |
849 rschema.subjects(objtype)[0], objtype) |
853 rschema.subjects(objtype)[0], objtype) |
850 assert props |
854 assert props |
851 self.rqlexecall(ss.rdef2rql(rschema, etype, objtype, props), |
855 self.rqlexecall(ss.rdef2rql(rschema, etype, objtype, props, |
|
856 groupmap=self.group_mapping()), |
852 ask_confirm=self.verbosity>=2) |
857 ask_confirm=self.verbosity>=2) |
853 |
858 |
854 if commit: |
859 if commit: |
855 self.commit() |
860 self.commit() |
856 |
861 |
878 schema definition file |
883 schema definition file |
879 """ |
884 """ |
880 rschema = self.fs_schema.rschema(rtype) |
885 rschema = self.fs_schema.rschema(rtype) |
881 if not rtype in self.repo.schema: |
886 if not rtype in self.repo.schema: |
882 self.cmd_add_relation_type(rtype, addrdef=False, commit=True) |
887 self.cmd_add_relation_type(rtype, addrdef=False, commit=True) |
883 self.rqlexecall(ss.rdef2rql(rschema, subjtype, objtype, groupmap=self.group_mapping()), |
888 self.rqlexecall(ss.rdef2rql(rschema, subjtype, objtype, |
|
889 groupmap=self.group_mapping()), |
884 ask_confirm=self.verbosity>=2) |
890 ask_confirm=self.verbosity>=2) |
885 if commit: |
891 if commit: |
886 self.commit() |
892 self.commit() |
887 |
893 |
888 def cmd_drop_relation_definition(self, subjtype, rtype, objtype, commit=True): |
894 def cmd_drop_relation_definition(self, subjtype, rtype, objtype, commit=True): |