Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Validation problems.
Validation problems. [message #555184] Wed, 25 August 2010 18:16 Go to next message
José Miguel P. is currently offline José Miguel P.Friend
Messages: 66
Registered: March 2010
Member

Hello!!

First to all, thanks you for your time.

I'm using EVL for validate my model and it's working perfect when I create the model. The problem is when I change some object from a container to other.

I have a meta-class called "Zone"
class Zone extends Element, Set{
   
}

class Set {
  val Host[*] hosts;
  val Server[*] servers;
}

class Element extends Traficable {
  attr IpType[1] ip;
}


and other meta-class called "Host"
class Host extends Element {
  
}

Well, I have a restriccion, An IP from a Host must to be a valid IP in his Zone.

When I create for example the next model:

+------------------------+
| ZONE1 : 192.168.1.0/24 |
+------------------------+
|			 |
| +----------------+     |
| |HOST:192.168.1.1|   	 |
| |		   |	 |
| +----------------+     |
+------------------------+

+------------------------+
| ZONE2 : 10.10.0.0/18   |
+------------------------+
|			 |
|                        |
|                	 |
|                	 |
|                        |
+------------------------+


The validation works ok. The last model is correct, but, When I change HOST from ZONE1 to ZONE2 (the next situation)

+------------------------+
| ZONE1 : 192.168.1.0/24 |
+------------------------+
|			 |
|                        |
|                	 |
|                	 |
|                        |
+------------------------+

+------------------------+
| ZONE2 : 10.10.0.0/18   |
+------------------------+
|			 |
| +----------------+     |
| |HOST:192.168.1.1|   	 |
| |		   |	 |
| +----------------+     |
+------------------------+


I can check that the model have changed, however, the validation don't give any error and the last situation is not correct.


The problem is only when I change elements, if I remove the host in ZONE1 and I create other in ZONE2 whit the IP 192.168.1.1 the validation gives the error.

Somebody can help me? Why is this happening?

Thanks you.

Jose Miguel.
Re: Validation problems. [message #555265 is a reply to message #555184] Thu, 26 August 2010 07:12 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Jose,

How do you navigate from the host to the zone? Perhaps the code still
navigates to the previous one?

Seeing the evl code could help in solving the problem.

Hallvard

On 25.08.10 20.16, Jose Miguel wrote:
> Hello!!
> First to all, thanks you for your time.
>
> I'm using EVL for validate my model and it's working perfect when I
> create the model. The problem is when I change some object from a
> container to other.
>
> I have a meta-class called "Zone"
>
> class Zone extends Element, Set{
> }
>
> class Set {
> val Host[*] hosts;
> val Server[*] servers;
> }
>
> class Element extends Traficable {
> attr IpType[1] ip;
> }
>
>
> and other meta-class called "Host"
>
> class Host extends Element {
>
> }
>
> Well, I have a restriccion, An IP from a Host must to be a valid IP in
> his Zone.
>
> When I create for example the next model:
>
> +------------------------+
> | ZONE1 : 192.168.1.0/24 |
> +------------------------+
> | |
> | +----------------+ |
> | |HOST:192.168.1.1| |
> | | | |
> | +----------------+ |
> +------------------------+
>
> +------------------------+
> | ZONE2 : 10.10.0.0/18 |
> +------------------------+
> | |
> | |
> | |
> | |
> | |
> +------------------------+
>
> The validation works ok. The last model is correct, but, When I change
> HOST from ZONE1 to ZONE2 (the next situation)
>
>
> +------------------------+
> | ZONE1 : 192.168.1.0/24 |
> +------------------------+
> | |
> | |
> | |
> | |
> | |
> +------------------------+
>
> +------------------------+
> | ZONE2 : 10.10.0.0/18 |
> +------------------------+
> | |
> | +----------------+ |
> | |HOST:192.168.1.1| |
> | | | |
> | +----------------+ |
> +------------------------+
>
> I can check that the model have changed, however, the validation don't
> give any error and the last situation is not correct.
>
>
> The problem is only when I change elements, if I remove the host in
> ZONE1 and I create other in ZONE2 whit the IP 192.168.1.1 the validation
> gives the error.
>
> Somebody can help me? Why is this happening?
> Thanks you.
>
> Jose Miguel.
Re: Validation problems. [message #555404 is a reply to message #555265] Thu, 26 August 2010 14:04 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Jose Miguel,

Sorry to hear you're having a problem with the validation language. I think a little more detail would be helpful in debugging this problem. Could you show us the following?

1) The EVL code.

2) The XMI of two models: one that works, and one that doesn't

Cheers,
Louis.

[Updated on: Thu, 26 August 2010 14:05]

Report message to a moderator

Re: Validation problems. [message #555602 is a reply to message #555404] Fri, 27 August 2010 09:53 Go to previous messageGo to next message
José Miguel P. is currently offline José Miguel P.Friend
Messages: 66
Registered: March 2010
Member

Hi Hallvard and Louis.

Thanks you very much again!!

The validation works perfect Louis, it's only in this condition when no work, I thinks you haven't understedn me before, I will try explain it again. Sorry for my bad English Sad

The situation is the folowing.

First. I create this model using the editor:
+------------------------+
| ZONE1 : 192.168.1.0/24 |
+------------------------+
|			 |
| +----------------+     |
| |HOST:192.168.1.1|   	 |
| |		   |	 |
| +----------------+     |
+------------------------+

+------------------------+
| ZONE2 : 10.10.0.0/18   |
+------------------------+
|			 |
|                        |
|                	 |
|                	 |
|                        |
+------------------------+

And when validate, the validation works perfect. No erros, so it working ok.

Second. I move HOST from ZONE1 to ZONE2 using the mouse clicking and draging from ZONE1 to ZONE2. So I get this situation:
+------------------------+
| ZONE1 : 192.168.1.0/24 |
+------------------------+
|			 |
|                        |
|                	 |
|                	 |
|                        |
+------------------------+

+------------------------+
| ZONE2 : 10.10.0.0/18   |
+------------------------+
|			 |
| +----------------+     |
| |HOST:192.168.1.1|   	 |
| |		   |	 |
| +----------------+     |
+------------------------+


And when I validate, the validation is not working, because it don't give me any error and this is not a correct situation. Hallvard, This is the form I navigate from the host to the zone.


Well, Here you are the EVL code for this restriccion.

constraint IPOK{
	
		guard {
			var zone = self.getZone();
			return zone.isTypeOf(Zone) and zone.ip.isDefined() and self.ip.isDefined();
		}
		
		check{
			var zone = self.getZone();
			var p := new Native ('FirewallsPolicy.tools.validation');
			return p.ipOK(zone.ip,self.ip);	
		}
		
		message: "Ip invalid for the Zone"
	
		fix{
		
			title : 'Write a different IP/CIDR for ' + self.eClass().name
			
			do {
			  var user_ip := UserInput.prompt("Write the IP of "+self.eClass().name+" "+self.name);
			  if (user_ip.matches("((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(/[0-3]?[0-9])?)")){
			  	self.ip := user_ip;
			  }else{
			  	UserInput.inform("Wrong IP");
			  }
          	}
		
		}
	}



Here you are the XMI for the model working.

Graphical.
<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:fws="fws" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmi:id="_5Kl-YLG-Ed-Mzacp-zjg9w" type="Fws" name="default.fws_diagram" measurementUnit="Pixel">
  <children xmi:type="notation:Shape" xmi:id="_5jQWALG-Ed-Mzacp-zjg9w" type="2001" fontName="Sans">
    <children xmi:type="notation:DecorationNode" xmi:id="_5jRkILG-Ed-Mzacp-zjg9w" type="5004"/>
    <children xmi:type="notation:BasicCompartment" xmi:id="_5jRkIbG-Ed-Mzacp-zjg9w" type="7001">
      <children xmi:type="notation:Shape" xmi:id="_LQAEkLG_Ed-Mzacp-zjg9w" type="3001" fontName="Sans">
        <children xmi:type="notation:DecorationNode" xmi:id="_LQAroLG_Ed-Mzacp-zjg9w" type="5001">
          <layoutConstraint xmi:type="notation:Location" xmi:id="_LQArobG_Ed-Mzacp-zjg9w" y="5"/>
        </children>
        <element xmi:type="fws:Host" href="default.fws#//@sets.0/@hosts.0"/>
        <layoutConstraint xmi:type="notation:Bounds" xmi:id="_LQAEkbG_Ed-Mzacp-zjg9w" x="44" y="8"/>
      </children>
    </children>
    <children xmi:type="notation:BasicCompartment" xmi:id="_5jRkIrG-Ed-Mzacp-zjg9w" type="7002"/>
    <styles xmi:type="notation:HintedDiagramLinkStyle" xmi:id="_5jQ9ELG-Ed-Mzacp-zjg9w"/>
    <element xmi:type="fws:Zone" href="default.fws#//@sets.0"/>
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="_5jQ9EbG-Ed-Mzacp-zjg9w" x="270" y="60"/>
  </children>
  <children xmi:type="notation:Shape" xmi:id="__TVeQLG-Ed-Mzacp-zjg9w" type="2001" fontName="Sans">
    <children xmi:type="notation:DecorationNode" xmi:id="__TXTcLG-Ed-Mzacp-zjg9w" type="5004"/>
    <children xmi:type="notation:BasicCompartment" xmi:id="__TXTcbG-Ed-Mzacp-zjg9w" type="7001"/>
    <children xmi:type="notation:BasicCompartment" xmi:id="__TXTcrG-Ed-Mzacp-zjg9w" type="7002"/>
    <styles xmi:type="notation:HintedDiagramLinkStyle" xmi:id="__TVeQbG-Ed-Mzacp-zjg9w"/>
    <element xmi:type="fws:Zone" href="default.fws#//@sets.1"/>
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="__TVeQrG-Ed-Mzacp-zjg9w" x="265" y="305"/>
  </children>
  <styles xmi:type="notation:DiagramStyle" xmi:id="_5Kl-YbG-Ed-Mzacp-zjg9w"/>
  <element xmi:type="fws:Diagram" href="default.fws#/"/>
</notation:Diagram>

Model generated.
<?xml version="1.0" encoding="UTF-8"?>
<fws:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fws="fws">
  <sets xsi:type="fws:Zone" name="ZONA1" ip="192.168.1.0/24">
    <hosts name="HOST" ip="192.168.1.1"/>
  </sets>
  <sets xsi:type="fws:Zone" name="ZONA2" ip="10.10.0.0/18"/>
</fws:Diagram>


The you are the XMI for the model not working.
<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:fws="fws" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmi:id="_5Kl-YLG-Ed-Mzacp-zjg9w" type="Fws" name="default.fws_diagram" measurementUnit="Pixel">
  <children xmi:type="notation:Shape" xmi:id="_5jQWALG-Ed-Mzacp-zjg9w" type="2001" fontName="Sans">
    <children xmi:type="notation:DecorationNode" xmi:id="_5jRkILG-Ed-Mzacp-zjg9w" type="5004"/>
    <children xmi:type="notation:BasicCompartment" xmi:id="_5jRkIbG-Ed-Mzacp-zjg9w" type="7001"/>
    <children xmi:type="notation:BasicCompartment" xmi:id="_5jRkIrG-Ed-Mzacp-zjg9w" type="7002"/>
    <styles xmi:type="notation:HintedDiagramLinkStyle" xmi:id="_5jQ9ELG-Ed-Mzacp-zjg9w"/>
    <element xmi:type="fws:Zone" href="default.fws#//@sets.0"/>
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="_5jQ9EbG-Ed-Mzacp-zjg9w" x="270" y="60"/>
  </children>
  <children xmi:type="notation:Shape" xmi:id="__TVeQLG-Ed-Mzacp-zjg9w" type="2001" fontName="Sans">
    <children xmi:type="notation:DecorationNode" xmi:id="__TXTcLG-Ed-Mzacp-zjg9w" type="5004"/>
    <children xmi:type="notation:BasicCompartment" xmi:id="__TXTcbG-Ed-Mzacp-zjg9w" type="7001">
      <children xmi:type="notation:Shape" xmi:id="_LQAEkLG_Ed-Mzacp-zjg9w" type="3001" fontName="Sans">
        <children xmi:type="notation:DecorationNode" xmi:id="_LQAroLG_Ed-Mzacp-zjg9w" type="5001">
          <layoutConstraint xmi:type="notation:Location" xmi:id="_LQArobG_Ed-Mzacp-zjg9w" y="5"/>
        </children>
        <element xmi:type="fws:Host" href="default.fws#//@sets.1/@hosts.0"/>
        <layoutConstraint xmi:type="notation:Bounds" xmi:id="_LQAEkbG_Ed-Mzacp-zjg9w" x="45" y="13"/>
      </children>
    </children>
    <children xmi:type="notation:BasicCompartment" xmi:id="__TXTcrG-Ed-Mzacp-zjg9w" type="7002"/>
    <styles xmi:type="notation:HintedDiagramLinkStyle" xmi:id="__TVeQbG-Ed-Mzacp-zjg9w"/>
    <element xmi:type="fws:Zone" href="default.fws#//@sets.1"/>
    <layoutConstraint xmi:type="notation:Bounds" xmi:id="__TVeQrG-Ed-Mzacp-zjg9w" x="265" y="305"/>
  </children>
  <styles xmi:type="notation:DiagramStyle" xmi:id="_5Kl-YbG-Ed-Mzacp-zjg9w"/>
  <element xmi:type="fws:Diagram" href="default.fws#/"/>
</notation:Diagram>

The model generated is the following
<?xml version="1.0" encoding="UTF-8"?>
<fws:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fws="fws">
  <sets xsi:type="fws:Zone" name="ZONA1" ip="192.168.1.0/24"/>
  <sets xsi:type="fws:Zone" name="ZONA2" ip="10.10.0.0/18">
    <hosts name="HOST" ip="192.168.1.1"/>
  </sets>
</fws:Diagram>




I hope this information was sufficient. If you need something more, request to me.

Thanks you very much for you time and help.

Thanks a lot.


Jose Miguel.
Re: Validation problems. [message #555613 is a reply to message #555602] Fri, 27 August 2010 11:14 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Jose Miguel,

Thanks for the details - I recreated the validation script and models in my workspace. I have some more questions:

How is the getZone() method implemented? Here's what I used in the EVL script:

operation Host getZone() : Zone {
  return Zone.all.selectOne(z|z.hosts.includes(self));
}


How and when is the EVL script being executed? Is it definitely the case that the GMF editor has saved the model to disk before EVL is executed?

Cheers,
Louis.
Re: Validation problems. [message #555699 is a reply to message #555613] Fri, 27 August 2010 17:16 Go to previous messageGo to next message
José Miguel P. is currently offline José Miguel P.Friend
Messages: 66
Registered: March 2010
Member

Hi Louis:

My method getZone is a litter different because it get the zone for any element in the diagram. Only for Zone, yours will be valid. Here you are my getZone method, perhaps it can be helpful for you.

/*
* Returned the Zone(Zone,Internet or Firewall) of the Element (Host/Server/....)
*/
operation Any getZone() : Any {
	if (self.isTypeOf(Zone) or self.isTypeOf(Firewall) or self.isTypeOf(Internet)){
		return self;
	}
				
	for (z in Zone) {
		if (z.hosts.includes(self)){
			return z;
		}
		
		if (z.servers.includes(self)){
			return z;
		}else{
			for (p in z.servers){
				//TODO: Check!!
				if (p.services.includes(self)){
					return z;
				}
			}
		} 
		
	}
	var int := Internet;
	for (z in int) {
		if (z.hosts.includes(self)){
			return z;
		}	
		if (z.servers.includes(self)){
			return z;
		}else{
			for (p in z.servers){
				if (p.services.includes(self)){
					return z;
				}
			}
		}
		if (z.services.includes(self)){
			return z;
		}
	}
	var fw := Firewall;
	for (z in fw) {
		if (z.services.includes(self)){
			return z;
		}
	}
}


In the last version the validation was executed when the model was saved, but I have tried some things and in my current workspace the validation is executed only manually, using Edit -> Validate.

Thanks you again! Wink
Re: Validation problems. [message #556284 is a reply to message #555699] Tue, 31 August 2010 15:27 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Jose Miguel,

Sorry for the late reply, I've been away from the Internet during a national holiday here in the UK.

I've been investigating the problem further today. I'm trying to recreate this bug, but have not succeeded Sad I tried using the getZone operation from your previous message, but that doesn't recreate the bug for me.

I created a small GMF editor using EuGENia and a simple EVL script, both are below. My metamodel comprises Nodes and Students. Nodes contain Students. Nodes and Students both have names. My validation has a (silly) check to ensure that every Student has the same name as the Node in which it is contained.

In a new diagram, I created two Nodes (named 'foo' and 'bar') and a Student (named 'foo'). Then I:


  1. Placed the Student 'foo' inside the Node 'foo'. I ran Edit | Validate, and no errors (as expected).
  2. Moved the Student 'foo' to be inside the Node 'bar'. I ran Edit | Validate, and one error (as expected).
  3. Moved the Student 'foo' back to the Node 'foo'. I ran Edit | Validate, and no errors (as expected).


I'm moving the Student between Nodes by clicking and dragging the Student in the GMF editor. I had to resize the Nodes to make the compartments large enough to house a Student. I'm not saving the contents of the GMF editor between invocations of Edit | Validate.

So it seems that I can't recreate the bug Sad Am I doing something differently to the process you're using?

Cheers,
Louis.


EuGENia for my GMF editor:

@namespace(uri="icons", prefix="icons")

@gmf(foo="bar")
package icons;

@gmf.diagram(foo="bar")
class Root {
	val Node[*] nodes;   
}

@gmf.node(label="name")
class Node {
  attr String name;
  @gmf.compartment(foo="bar")
  val Student[*] students;
}

@gmf.node(label="name")
class Student {
  attr String name;
}



EVL for my validation:

context Student {
	constraint NamesMatch {
		check: self.getNode().name = self.name
		message: 'The student \'' + self.name + '\' must be contained within a node of the same name.'
	}
}

operation Student getNode() : Node {
	return Node.all.selectOne(n|n.students.includes(self));
}



And the plugin.xml that specifies the EVL extension point:

<plugin>

   <extension point="org.eclipse.emf.ecore.generated_package">
      <package
            uri="icons"
            class="icons.IconsPackage"/>
   </extension>
   <extension
         point="org.eclipse.epsilon.evl.emf.validation">
      <constraintsBinding
            constraints="model/Icons.evl"
            modelName="Model"
            namespaceURI="icons">
      </constraintsBinding>
   </extension>

</plugin>

Re: Validation problems. [message #556314 is a reply to message #556284] Tue, 31 August 2010 17:53 Go to previous messageGo to next message
José Miguel P. is currently offline José Miguel P.Friend
Messages: 66
Registered: March 2010
Member

Hello Louis:

Don't worry, Thanks you for reply Wink

I have checked your example and really it's working ok.

Then I have looked my code again, and I have seen the bug. The bug was into my validation tool. I call to Java for some tasks and there was the bug.

Sorry for doing lost your time Sad. and Thanks you very much for your help.

Thanks so much Louis.
Re: Validation problems. [message #556451 is a reply to message #556314] Wed, 01 September 2010 11:57 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Jose Miguel,

No problem. I'm glad to hear that you found and fixed the bug. Do let us know if you have any further questions or feedback.

Cheers,
Louis.

Re: Validation problems. [message #593225 is a reply to message #555265] Thu, 26 August 2010 14:04 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Jose,

Sorry to hear you're having a problem with the validation language. I think a little more detail would be helpful in debugging this problem. Could you show us the following?

1) The EVL code.

2) The XMI of two models: one that works, and one that doesn't

Cheers,
Louis.
Re: Validation problems. [message #593255 is a reply to message #593225] Fri, 27 August 2010 09:53 Go to previous messageGo to next message
José Miguel P. is currently offline José Miguel P.Friend
Messages: 66
Registered: March 2010
Member

Hi Hallvard and Louis.

Thanks you very much again!!

The validation works perfect Louis, it's only in this condition when no work, I thinks you haven't understedn me before, I will try explain it again. Sorry for my bad English :(

The situation is the folowing.

First. I create this model using the editor:

+------------------------+
| ZONE1 : 192.168.1.0/24 |
+------------------------+
| |
| +----------------+ |
| |HOST:192.168.1.1| |
| | | |
| +----------------+ |
+------------------------+

+------------------------+
| ZONE2 : 10.10.0.0/18 |
+------------------------+
| |
| |
| |
| |
| |
+------------------------+

And when validate, the validation works perfect. No erros, so it working ok.

Second. I move HOST from ZONE1 to ZONE2 using the mouse clicking and draging from ZONE1 to ZONE2. So I get this situation:

+------------------------+
| ZONE1 : 192.168.1.0/24 |
+------------------------+
| |
| |
| |
| |
| |
+------------------------+

+------------------------+
| ZONE2 : 10.10.0.0/18 |
+------------------------+
| |
| +----------------+ |
| |HOST:192.168.1.1| |
| | | |
| +----------------+ |
+------------------------+

And when I validate, the validation is not working, because it don't give me any error and this is not a correct situation. Hallvard, This is the form I navigate from the host to the zone.


Well, Here you are the EVL code for this restriccion.


constraint IPOK{

guard {
var zone = self.getZone();
return zone.isTypeOf(Zone) and zone.ip.isDefined() and self.ip.isDefined();
}

check{
var zone = self.getZone();
var p := new Native ('FirewallsPolicy.tools.validation');
return p.ipOK(zone.ip,self.ip);
}

message: "Ip invalid for the Zone"

fix{

title : 'Write a different IP/CIDR for ' + self.eClass().name

do {
var user_ip := UserInput.prompt("Write the IP of "+self.eClass().name+" "+self.name);
if (user_ip.matches(" ((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0- 9]|[01]?[0-9][0-9]?)\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]? )\\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(/[0-3]?[0-9])?) ")){
self.ip := user_ip;
}else{
UserInput.inform("Wrong IP");
}
}

}
}


Here you are the XMI for the model working.

Graphical.

<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:fws="fws" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmi:id="_5Kl-YLG-Ed-Mzacp-zjg9w" type="Fws" name="default.fws_diagram" measurementUnit="Pixel">
<children xmi:type="notation:Shape" xmi:id="_5jQWALG-Ed-Mzacp-zjg9w" type="2001" fontName="Sans">
<children xmi:type="notation:DecorationNode" xmi:id="_5jRkILG-Ed-Mzacp-zjg9w" type="5004"/>
<children xmi:type="notation:BasicCompartment" xmi:id="_5jRkIbG-Ed-Mzacp-zjg9w" type="7001">
<children xmi:type="notation:Shape" xmi:id="_LQAEkLG_Ed-Mzacp-zjg9w" type="3001" fontName="Sans">
<children xmi:type="notation:DecorationNode" xmi:id="_LQAroLG_Ed-Mzacp-zjg9w" type="5001">
<layoutConstraint xmi:type="notation:Location" xmi:id="_LQArobG_Ed-Mzacp-zjg9w" y="5"/>
</children>
<element xmi:type="fws:Host" href="default.fws#//@sets.0/@hosts.0"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_LQAEkbG_Ed-Mzacp-zjg9w" x="44" y="8"/>
</children>
</children>
<children xmi:type="notation:BasicCompartment" xmi:id="_5jRkIrG-Ed-Mzacp-zjg9w" type="7002"/>
<styles xmi:type="notation:HintedDiagramLinkStyle" xmi:id="_5jQ9ELG-Ed-Mzacp-zjg9w"/>
<element xmi:type="fws:Zone" href="default.fws#//@sets.0"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_5jQ9EbG-Ed-Mzacp-zjg9w" x="270" y="60"/>
</children>
<children xmi:type="notation:Shape" xmi:id="__TVeQLG-Ed-Mzacp-zjg9w" type="2001" fontName="Sans">
<children xmi:type="notation:DecorationNode" xmi:id="__TXTcLG-Ed-Mzacp-zjg9w" type="5004"/>
<children xmi:type="notation:BasicCompartment" xmi:id="__TXTcbG-Ed-Mzacp-zjg9w" type="7001"/>
<children xmi:type="notation:BasicCompartment" xmi:id="__TXTcrG-Ed-Mzacp-zjg9w" type="7002"/>
<styles xmi:type="notation:HintedDiagramLinkStyle" xmi:id="__TVeQbG-Ed-Mzacp-zjg9w"/>
<element xmi:type="fws:Zone" href="default.fws#//@sets.1"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="__TVeQrG-Ed-Mzacp-zjg9w" x="265" y="305"/>
</children>
<styles xmi:type="notation:DiagramStyle" xmi:id="_5Kl-YbG-Ed-Mzacp-zjg9w"/>
<element xmi:type="fws:Diagram" href="default.fws#/"/>
</notation:Diagram>

Model generated.

<?xml version="1.0" encoding="UTF-8"?>
<fws:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fws="fws">
<sets xsi:type="fws:Zone" name="ZONA1" ip="192.168.1.0/24">
<hosts name="HOST" ip="192.168.1.1"/>
</sets>
<sets xsi:type="fws:Zone" name="ZONA2" ip="10.10.0.0/18"/>
</fws:Diagram>


The you are the XMI for the model not working.

<?xml version="1.0" encoding="UTF-8"?>
<notation:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:fws="fws" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmi:id="_5Kl-YLG-Ed-Mzacp-zjg9w" type="Fws" name="default.fws_diagram" measurementUnit="Pixel">
<children xmi:type="notation:Shape" xmi:id="_5jQWALG-Ed-Mzacp-zjg9w" type="2001" fontName="Sans">
<children xmi:type="notation:DecorationNode" xmi:id="_5jRkILG-Ed-Mzacp-zjg9w" type="5004"/>
<children xmi:type="notation:BasicCompartment" xmi:id="_5jRkIbG-Ed-Mzacp-zjg9w" type="7001"/>
<children xmi:type="notation:BasicCompartment" xmi:id="_5jRkIrG-Ed-Mzacp-zjg9w" type="7002"/>
<styles xmi:type="notation:HintedDiagramLinkStyle" xmi:id="_5jQ9ELG-Ed-Mzacp-zjg9w"/>
<element xmi:type="fws:Zone" href="default.fws#//@sets.0"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_5jQ9EbG-Ed-Mzacp-zjg9w" x="270" y="60"/>
</children>
<children xmi:type="notation:Shape" xmi:id="__TVeQLG-Ed-Mzacp-zjg9w" type="2001" fontName="Sans">
<children xmi:type="notation:DecorationNode" xmi:id="__TXTcLG-Ed-Mzacp-zjg9w" type="5004"/>
<children xmi:type="notation:BasicCompartment" xmi:id="__TXTcbG-Ed-Mzacp-zjg9w" type="7001">
<children xmi:type="notation:Shape" xmi:id="_LQAEkLG_Ed-Mzacp-zjg9w" type="3001" fontName="Sans">
<children xmi:type="notation:DecorationNode" xmi:id="_LQAroLG_Ed-Mzacp-zjg9w" type="5001">
<layoutConstraint xmi:type="notation:Location" xmi:id="_LQArobG_Ed-Mzacp-zjg9w" y="5"/>
</children>
<element xmi:type="fws:Host" href="default.fws#//@sets.1/@hosts.0"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="_LQAEkbG_Ed-Mzacp-zjg9w" x="45" y="13"/>
</children>
</children>
<children xmi:type="notation:BasicCompartment" xmi:id="__TXTcrG-Ed-Mzacp-zjg9w" type="7002"/>
<styles xmi:type="notation:HintedDiagramLinkStyle" xmi:id="__TVeQbG-Ed-Mzacp-zjg9w"/>
<element xmi:type="fws:Zone" href="default.fws#//@sets.1"/>
<layoutConstraint xmi:type="notation:Bounds" xmi:id="__TVeQrG-Ed-Mzacp-zjg9w" x="265" y="305"/>
</children>
<styles xmi:type="notation:DiagramStyle" xmi:id="_5Kl-YbG-Ed-Mzacp-zjg9w"/>
<element xmi:type="fws:Diagram" href="default.fws#/"/>
</notation:Diagram>

The model generated is the following

<?xml version="1.0" encoding="UTF-8"?>
<fws:Diagram xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fws="fws">
<sets xsi:type="fws:Zone" name="ZONA1" ip="192.168.1.0/24"/>
<sets xsi:type="fws:Zone" name="ZONA2" ip="10.10.0.0/18">
<hosts name="HOST" ip="192.168.1.1"/>
</sets>
</fws:Diagram>



I hope this information was sufficient. If you need something more, request to me.

Thanks you very much for you time and help.

Thanks a lot.


Jose Miguel.
Re: Validation problems. [message #593285 is a reply to message #593255] Fri, 27 August 2010 11:14 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Jose Miguel,

Thanks for the details - I recreated the validation script and models in my workspace. I have some more questions:

How is the getZone() method implemented? Here's what I used in the EVL script:

operation Host getZone() : Zone {
return Zone.all.selectOne(z|z.hosts.includes(self));
}

How and when is the EVL script being executed? Is it definitely the case that the GMF editor has saved the model to disk before EVL is executed?

Cheers,
Louis.
Re: Validation problems. [message #593332 is a reply to message #555613] Fri, 27 August 2010 17:16 Go to previous messageGo to next message
José Miguel P. is currently offline José Miguel P.Friend
Messages: 66
Registered: March 2010
Member

Hi Louis:

My method getZone is a litter different because it get the zone for any element in the diagram. Only for Zone, yours will be valid. Here you are my getZone method, perhaps it can be helpful for you.


/*
* Returned the Zone(Zone,Internet or Firewall) of the Element (Host/Server/....)
*/
operation Any getZone() : Any {
if (self.isTypeOf(Zone) or self.isTypeOf(Firewall) or self.isTypeOf(Internet)){
return self;
}

for (z in Zone) {
if (z.hosts.includes(self)){
return z;
}

if (z.servers.includes(self)){
return z;
}else{
for (p in z.servers){
//TODO: Check!!
if (p.services.includes(self)){
return z;
}
}
}

}
var int := Internet;
for (z in int) {
if (z.hosts.includes(self)){
return z;
}
if (z.servers.includes(self)){
return z;
}else{
for (p in z.servers){
if (p.services.includes(self)){
return z;
}
}
}
if (z.services.includes(self)){
return z;
}
}
var fw := Firewall;
for (z in fw) {
if (z.services.includes(self)){
return z;
}
}
}

In the last version the validation was executed when the model was saved, but I have tried some things and in my current workspace the validation is executed only manually, using Edit -> Validate.

Thanks you again! ;)
Re: Validation problems. [message #593360 is a reply to message #593332] Tue, 31 August 2010 15:27 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Jose Miguel,

Sorry for the late reply, I've been away from the Internet during a national holiday here in the UK.

I've been investigating the problem further today. I'm trying to recreate this bug, but have not succeeded :( I tried using the getZone operation from your previous message, but that doesn't recreate the bug for me.

I created a small GMF editor using EuGENia and a simple EVL script, both are below. My metamodel comprises Nodes and Students. Nodes contain Students. Nodes and Students both have names. My validation has a (silly) check to ensure that every Student has the same name as the Node in which it is contained.

In a new diagram, I created two Nodes (named 'foo' and 'bar') and a Student (named 'foo'). Then I:


Placed the Student 'foo' inside the Node 'foo'. I ran Edit | Validate, and no errors (as expected).
Moved the Student 'foo' to be inside the Node 'bar'. I ran Edit | Validate, and one error (as expected).
Moved the Student 'foo' back to the Node 'foo'. I ran Edit | Validate, and no errors (as expected).


I'm moving the Student between Nodes by clicking and dragging the Student in the GMF editor. I had to resize the Nodes to make the compartments large enough to house a Student. I'm not saving the contents of the GMF editor between invocations of Edit | Validate.

So it seems that I can't recreate the bug :( Am I doing something differently to the process you're using?

Cheers,
Louis.


EuGENia for my GMF editor:

@namespace(uri="icons", prefix="icons")

@gmf(foo="bar")
package icons;

@gmf.diagram(foo="bar")
class Root {
val Node[*] nodes;
}

@gmf.node(label="name")
class Node {
attr String name;
@gmf.compartment(foo="bar")
val Student[*] students;
}

@gmf.node(label="name")
class Student {
attr String name;
}


EVL for my validation:

context Student {
constraint NamesMatch {
check: self.getNode().name = self.name
message: 'The student \'' + self.name + '\' must be contained within a node of the same name.'
}
}

operation Student getNode() : Node {
return Node.all.selectOne(n|n.students.includes(self));
}


And the plugin.xml that specifies the EVL extension point:

<plugin>

<extension point="org.eclipse.emf.ecore.generated_package">
<package
uri="icons"
class="icons.IconsPackage"/>
</extension>
<extension
point="org.eclipse.epsilon.evl.emf.validation">
<constraintsBinding
constraints="model/Icons.evl"
modelName="Model"
namespaceURI="icons">
</constraintsBinding>
</extension>

</plugin>
Re: Validation problems. [message #593376 is a reply to message #593360] Tue, 31 August 2010 17:53 Go to previous messageGo to next message
José Miguel P. is currently offline José Miguel P.Friend
Messages: 66
Registered: March 2010
Member

Hello Louis:

Don't worry, Thanks you for reply ;)

I have checked your example and really it's working ok.

Then I have looked my code again, and I have seen the bug. The bug was into my validation tool. I call to Java for some tasks and there was the bug.

Sorry for doing lost your time :(. and Thanks you very much for your help.

Thanks so much Louis.
Re: Validation problems. [message #593407 is a reply to message #556314] Wed, 01 September 2010 11:57 Go to previous message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Jose Miguel,

No problem. I'm glad to hear that you found and fixed the bug. Do let us know if you have any further questions or feedback.

Cheers,
Louis.
Previous Topic:[Epsilon - EOL] Cloning model elements
Next Topic:[EWL] Use data from different models/files
Goto Forum:
  


Current Time: Fri Apr 19 18:43:19 GMT 2024

Powered by FUDForum. Page generated in 0.04237 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top