tmlab / majortom

The MaJorToM ( Merging Topic Maps Engine ) project was founded to develop a lightweight, merging and flexible Topic Maps engine satisfying different business use cases. The engine provides a couple of new features above to other engines based on the Topic Maps API version 2.0.
1 stars 1 forks source link

Clear Topic Map efficiently #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a topic map with names, variants, occurrences, including reification
2. try to delete everything in an efficient way
3. write a lot of code or fail

What is the expected output? What do you see instead?
a "clear" method on ITopicMap which does all the hard work in the right order

The code in RTM's TopicMap for that may be useful for copying:

    def clear
      # This is supported by some backends (e.g. Ontopia) and should be faster than the procedure below.
      if self.respond_to?(:wrapped) && self.wrapped.respond_to?(:clear)
        self.wrapped.clear
        return
      end

      set_reifier(nil)

      variants.to_a.each do |v|
        v.set_reifier(nil)
        v.remove
      end

      names.to_a.each do |n|
        n.set_reifier(nil)
        n.remove
      end

      occurrences.to_a.each do |o|
        o.set_reifier(nil)
        o.remove
      end

      roles.to_a.each do |r|
        r.set_reifier(nil)
        # Roles should not be removed here! They are removed when the association is removed
        #r.remove
      end

      associations.to_a.each do |a|
        a.set_reifier(nil)
        a.remove
      end

      types.to_a.each do |type|
        type.instances.to_a.each do |instance|
          instance.remove_type(type)
        end
      end

      topics.to_a.each do |t|
        t.remove
      end

    end

Original issue reported on code.google.com by bnjmn...@gmail.com on 27 Jul 2010 at 2:21

GoogleCodeExporter commented 9 years ago

Original comment by Sven.Kro...@googlemail.com on 28 Jul 2010 at 7:25

GoogleCodeExporter commented 9 years ago

Original comment by Sven.Kro...@googlemail.com on 28 Jul 2010 at 7:25

GoogleCodeExporter commented 9 years ago
This issue was closed by revision af5654a307.

Original comment by h.niederhausen@googlemail.com on 2 Aug 2010 at 3:01