dukeboard / kevoree-modeling-framework

Kevoree Modeling Framework
http://kevoree.org/kmf
GNU Lesser General Public License v3.0
37 stars 7 forks source link

delete() doesn't fully work #46

Closed maxleiko closed 10 years ago

maxleiko commented 10 years ago
import org.kevoree.impl.DefaultKevoreeFactory
import org.kevoree.*;
import org.kevoree.modeling.api.ModelSerializer;
import org.kevoree.serializer.JSONModelSerializer;
import org.kevoree.modeling.api.events.ModelElementListener;
import org.kevoree.modeling.api.events.ModelEvent;
import java.io.PrintWriter

fun main(args: Array<String>) {
    var factory : KevoreeFactory = DefaultKevoreeFactory();

    var model : ContainerRoot = factory.createContainerRoot();

    var node : ContainerNode = factory.createContainerNode();
    node.name = "node0";
    model.addNodes(node);

    var grp : Group = factory.createGroup();
    grp.name = "grp";
    model.addGroups(grp);
    grp.addSubNodes(node);

    var comp : ComponentInstance = factory.createComponentInstance();
    comp.name = "comp";
    node.addComponents(comp);

    var chan : Channel = factory.createChannel();
    chan.name = "chan";
    model.addHubs(chan);

    var port : Port = factory.createPort();
    port.name = "output";
    comp.addRequired(port);

    var binding : MBinding = factory.createMBinding();
    binding.hub = chan;
    binding.port = port;
    model.addMBindings(binding);

    node.addModelElementListener(object: ModelElementListener {
        override fun elementChanged(e: ModelEvent) {
            println(e.toString());
        }
    });

    node.delete();
//    chan.delete();

    var save : ModelSerializer = JSONModelSerializer();
    var modelStr : String = save.serialize(model)!!;
    var writer : PrintWriter = PrintWriter("model.json", "UTF-8");
    writer.write(modelStr);
    writer.close();
}

Saved model will still contain bindings to removed component Sample project

dukeboard commented 10 years ago

fixed in 1.10.0 and next Kevoree version , thx for the tricky but maxime :-)