Bladeren bron

removed some old transformations
changed compilation of concrete syntax metamodel: if an icon definition
was not found for a concrete class, or an icon definition is found for an
abstract class, an error is raised
AToMPM no longer crashes when an element with an unknown visual
representation is created. Instead, it gives an error

Simon Van Mierlo 9 jaren geleden
bovenliggende
commit
00701bc9db

+ 1 - 1
asworker.js

@@ -368,7 +368,7 @@ with AToMPM.  If not, see <http://www.gnu.org/licenses/>.
 		{
 			if( uri.match(/(.*)\..*Icons\.metamodel/) && 
 				 (res = _mmmk.
-						compileToIconDefinitionMetamodel(reqData['csm']))['$err'] )
+						compileToIconDefinitionMetamodel(reqData['csm'], reqData['asmm']))['$err'] )
 				__postInternalErrorMsg(resp,res['$err']);
 			else if( ! uri.match(/(.*)\..*Icons\.metamodel/) &&
 						(res = _mmmk.compileToMetamodel())['$err'] )

+ 40 - 18
csworker.js

@@ -1362,15 +1362,17 @@ with AToMPM.  If not, see <http://www.gnu.org/licenses/>.
 			var asuri   = matches[2]+(matches[3] || '')+'/'+matches[5]+'.type',
 				 csmm		= matches[1]+(matches[3] || ''),
 				 cstype	= matches[4],
-				 parser	= 
-					 _utils.jsonp(_mmmk.readMetamodels(csmm))['types'][cstype].
+                 types = _utils.jsonp(_mmmk.readMetamodels(csmm))['types'];
+            if (cstype in types) {
+				 var parser	= 
+					 types[cstype].
 					 	filter( 
 							function(attr) 
 							{
 								return attr['name']=='parser';
 							})[0]['default'],
-				 self		= this,
-				 actions = 
+				 self = this,
+				 actions  = 
 					[__successContinuable(),
 					 function()
 					 {
@@ -1417,13 +1419,18 @@ with AToMPM.  If not, see <http://www.gnu.org/licenses/>.
 									 asreqData);
 					 }];
 
-			_do.chain(actions)(
-					function(res) 	
-					{
-						__postMessage({'statusCode':202, 'respIndex':resp});
-					},
-					function(err) 	{__postInternalErrorMsg(resp,err);}
-			);
+                 _do.chain(actions)(
+                        function(res) 	
+                        {
+                            __postMessage({'statusCode':202, 'respIndex':resp});
+                        },
+                        function(err) 	{__postInternalErrorMsg(resp,err);}
+                 );
+            } else {
+                return __postBadReqErrorMsg(
+								resp,
+								'no concrete syntax definition found for '+cstype);
+            }
 		},
 
 
@@ -1798,16 +1805,31 @@ with AToMPM.  If not, see <http://www.gnu.org/licenses/>.
 			}
 			else
 			{
-				var genIconDef = uri.match(/(.*)\..*Icons\.metamodel/);
-					 actions 	= [
-							__wHttpReq(
-								'PUT',
-								uri+'?wid='+this.__aswid,
-								(genIconDef ? {'csm':_mmmk.read()} : undefined))];
+				var  genIconDef = uri.match(/(.*)\..*Icons\.metamodel/),
+                     matches   	 = uri.match(/\/GET(((.*\/).*)\..*Icons.metamodel)/),
+					 asmmPath  	 = './users'+matches[2]+'.metamodel',
+                     asmm       = undefined;
+                     aswid      = this.__aswid;
+					 var actions 	= [
+                            _fs.readFile(asmmPath,'utf8'),
+                            function(data) {
+                               asmm = _utils.jsonp(data);
+                               return __successContinuable();
+                            }];
 				_do.chain(actions)(
 						function() 
 						{
-							__postMessage({'statusCode':200, 'respIndex':resp});
+                            var requestActions = 
+                                [__wHttpReq(
+                                    'PUT',
+                                    uri+'?wid='+aswid,
+                                    (genIconDef ? {'csm':_mmmk.read(), 'asmm': asmm} : undefined))];
+                            _do.chain(requestActions)(
+                                function() {
+                                    __postMessage({'statusCode':200, 'respIndex':resp});
+                                },
+                                function(err) 	{__postInternalErrorMsg(resp,err);}
+                            );
 						},
 						function(err) 	{__postInternalErrorMsg(resp,err);}
 				);

+ 25 - 2
mmmk.js

@@ -962,7 +962,7 @@ with AToMPM.  If not, see <http://www.gnu.org/licenses/>.
 		4. return mm stringified (ensures no references to objects in this.model
 			are returned) */
 	'compileToIconDefinitionMetamodel' : 
-		function(csm)
+		function(csm, asmm)
 		{
 			var CS = '/Formalisms/__LanguageSyntax__/ConcreteSyntax/ConcreteSyntax';
 			try
@@ -1166,7 +1166,30 @@ with AToMPM.  If not, see <http://www.gnu.org/licenses/>.
 						mm.cardinalities[type] = [];
 						mm.types2parentTypes[type] = [];
 					});
-
+                
+                /* check whether all non-abstract types have an icon, and no abstract types have an icon */
+                var types = [],
+                    abstractTypes = [];
+                    
+                for (var idx in asmm["constraints"]) {
+                    var curr_constraint = asmm["constraints"][idx];
+                    if (curr_constraint["name"] == "noAbstractInstances") {
+                        abstractTypes.push(curr_constraint["targetType"]);
+                    }
+                }
+                
+                for (var curr_type in asmm["types"]) {
+                    if ((curr_type + 'Link' in mm["types"]) || (curr_type + 'Icon' in mm["types"])) {
+                        if (abstractTypes.indexOf(curr_type) >= 0) {
+                            return {'$err':'abstract type '+curr_type+' cannot have a visual representation'};
+                        }
+                    } else {
+                        if (abstractTypes.indexOf(curr_type) < 0) {
+                            return {'$err':'concrete type '+curr_type+' needs to have a visual representation'};
+                        }
+                    }
+                }
+                    
 				/* 4 */
 				return _utils.jsons(mm,null,"\t");
 			}

File diff suppressed because it is too large
+ 0 - 4546
users/(default)/Formalisms/Pacman/OpSem/T_Pacman_Move.model


File diff suppressed because it is too large
+ 0 - 1545
users/(default)/Formalisms/Pacman/OpSem/T_Pacman_Priority.model


+ 0 - 309
users/(default)/Formalisms/Pacman/OpSem/T_Pacman_Random.model

@@ -1,309 +0,0 @@
-{
-	"csm": {
-		"nodes": {
-			"0": {
-				"typename": {
-					"type": "string",
-					"value": "ExhaustRandomIcon"
-				},
-				"position": {
-					"type": "list<double>",
-					"value": [
-						"593",
-						"253"
-					]
-				},
-				"orientation": {
-					"type": "double",
-					"value": 0
-				},
-				"scale": {
-					"type": "list<double>",
-					"value": [
-						1,
-						1
-					]
-				},
-				"mapper": {
-					"type": "code",
-					"value": ""
-				},
-				"parser": {
-					"type": "code",
-					"value": ""
-				},
-				"$contents": {
-					"type": "map<string,*>",
-					"value": {
-						"nodes": {
-							"37": {
-								"width": {
-									"type": "double",
-									"value": "200"
-								},
-								"height": {
-									"type": "double",
-									"value": "100"
-								},
-								"cornerRadius": {
-									"type": "double",
-									"value": "10"
-								},
-								"style": {
-									"type": "map<string,string>",
-									"value": {
-										"stroke": "#000000",
-										"stroke-dasharray": "",
-										"fill": "#ffffff",
-										"fill-opacity": 0.75,
-										"font-size": "20px",
-										"stroke-width": 1,
-										"arrow-start": "none",
-										"arrow-end": "none"
-									}
-								},
-								"mapper": {
-									"type": "code",
-									"value": ""
-								},
-								"parser": {
-									"type": "code",
-									"value": ""
-								},
-								"$type": "/Formalisms/__LanguageSyntax__/ConcreteSyntax/ConcreteSyntax/Rectangle",
-								"position": {
-									"type": "list<double>",
-									"value": [
-										0,
-										-1
-									]
-								},
-								"orientation": {
-									"type": "double",
-									"value": 0
-								},
-								"scale": {
-									"type": "list<double>",
-									"value": [
-										1,
-										1
-									]
-								}
-							},
-							"38": {
-								"segments": {
-									"type": "string",
-									"value": "m0,0 l10,15 l-5,0 l0,35 l5,0 l-10,15 l-10,-15 l5,0 l0-35 l-5,0z"
-								},
-								"style": {
-									"type": "map<string,string>",
-									"value": {
-										"stroke": "#3CB371",
-										"stroke-dasharray": "",
-										"fill": "#3CB371",
-										"fill-opacity": 1,
-										"font-size": "20px",
-										"stroke-width": 1,
-										"arrow-start": "none",
-										"arrow-end": "none"
-									}
-								},
-								"mapper": {
-									"type": "code",
-									"value": ""
-								},
-								"parser": {
-									"type": "code",
-									"value": ""
-								},
-								"$type": "/Formalisms/__LanguageSyntax__/ConcreteSyntax/ConcreteSyntax/Path",
-								"position": {
-									"type": "list<double>",
-									"value": [
-										211,
-										18
-									]
-								},
-								"orientation": {
-									"type": "double",
-									"value": 0
-								},
-								"scale": {
-									"type": "list<double>",
-									"value": [
-										1,
-										1
-									]
-								}
-							},
-							"39": {
-								"distance": {
-									"type": "double",
-									"value": 0
-								},
-								"alignment": {
-									"type": "ENUM(\"top\",\"bottom\",\"center\")",
-									"value": "center"
-								},
-								"$type": "/Formalisms/__LanguageSyntax__/ConcreteSyntax/ConcreteSyntax/RightOf",
-								"position": {
-									"type": "list<double>",
-									"value": [
-										197.4989985080956,
-										45.99899850809555
-									]
-								},
-								"orientation": {
-									"type": "double",
-									"value": 0
-								},
-								"scale": {
-									"type": "list<double>",
-									"value": [
-										1,
-										1
-									]
-								},
-								"link-style": {
-									"type": "map<string,string>",
-									"value": {
-										"stroke": "#ff0000",
-										"stroke-dasharray": "",
-										"stroke-opacity": 1,
-										"arrow-start": "none",
-										"arrow-end": "classic-wide-long"
-									}
-								}
-							},
-							"40": {
-								"textContent": {
-									"type": "string",
-									"value": "R_PacMoveLeft"
-								},
-								"style": {
-									"type": "map<string,string>",
-									"value": {
-										"stroke": "#000000",
-										"stroke-dasharray": "",
-										"fill": "#ffffff",
-										"fill-opacity": 0.75,
-										"font-size": "13px",
-										"stroke-width": 1,
-										"arrow-start": "none",
-										"arrow-end": "none"
-									}
-								},
-								"mapper": {
-									"type": "code",
-									"value": "var filenames = getAttr('filenames').map(\n\t\t\t\tfunction(f)\n\t\t\t\t{\n\t\t\t\t\treturn f.match(/.*\\/(.*)\\.model/)[1];\n\t\t\t\t});\n\n({'textContent': filenames.join('\\n')})"
-								},
-								"parser": {
-									"type": "code",
-									"value": ""
-								},
-								"$type": "/Formalisms/__LanguageSyntax__/ConcreteSyntax/ConcreteSyntax/Text",
-								"position": {
-									"type": "list<double>",
-									"value": [
-										4,
-										-3
-									]
-								},
-								"orientation": {
-									"type": "double",
-									"value": 0
-								},
-								"scale": {
-									"type": "list<double>",
-									"value": [
-										1,
-										1
-									]
-								}
-							},
-							"41": {
-								"$type": "/Formalisms/__LanguageSyntax__/ConcreteSyntax/ConcreteSyntax/Contain",
-								"position": {
-									"type": "list<double>",
-									"value": [
-										12.890662583693938,
-										4.548997593600802
-									]
-								},
-								"orientation": {
-									"type": "double",
-									"value": 0
-								},
-								"scale": {
-									"type": "list<double>",
-									"value": [
-										1,
-										1
-									]
-								},
-								"link-style": {
-									"type": "map<string,string>",
-									"value": {
-										"stroke": "#00ffff",
-										"stroke-dasharray": "",
-										"stroke-opacity": 0.1,
-										"arrow-start": "none",
-										"arrow-end": "classic-wide-long"
-									}
-								}
-							}
-						},
-						"edges": [
-							{
-								"src": "38",
-								"dest": 39
-							},
-							{
-								"src": 39,
-								"dest": "37"
-							},
-							{
-								"src": "37",
-								"dest": 41
-							},
-							{
-								"src": 41,
-								"dest": "40"
-							}
-						]
-					}
-				},
-				"$asuri": {
-					"type": "string",
-					"value": "/Formalisms/__Transformations__/Transformation/Transformation/ExhaustRandom/0.instance"
-				},
-				"$type": "/Formalisms/__Transformations__/Transformation/Transformation.defaultIcons/ExhaustRandomIcon"
-			}
-		},
-		"edges": [],
-		"metamodels": [
-			"/Formalisms/__Transformations__/Transformation/Transformation.defaultIcons"
-		]
-	},
-	"asm": {
-		"nodes": {
-			"0": {
-				"filenames": {
-					"type": "list<string>",
-					"value": [
-						"/Formalisms/Pacman/OpSem/R_PacMoveLeft.model"
-					]
-				},
-				"isStart": {
-					"type": "boolean",
-					"value": true
-				},
-				"$type": "/Formalisms/__Transformations__/Transformation/Transformation/ExhaustRandom"
-			}
-		},
-		"edges": [],
-		"metamodels": [
-			"/Formalisms/__Transformations__/Transformation/Transformation"
-		]
-	}
-}