public static ResponseJson.LayerData getLayerJsonData( ModelClassNS.ModelClass modelStruct, string layerId ) { Layers.Layer layer = modelStruct.layerDict.layers[layerId]; var ports = new Dictionary <string, ResponseJson.LayerPortData>(); var fields = new Dictionary <string, ResponseJson.LayerFieldData>(); foreach (string portName in layer.getPortNames()) { ports[portName] = new ResponseJson.LayerPortData { valueName = layer.getValueNameOfPort(portName), }; } List <string> occupiedValueNames = modelStruct.edgesByVertex[layerId].edgesIn.Select((string edgeId) => { return(modelStruct.layerDict.layers[layerId].getValueNameOfPort(modelStruct.graph.edges[edgeId].targetPortId)); }).ToList(); foreach (string fieldName in layer.getValueNames()) { bool fieldOccupiedByEdge = occupiedValueNames.Contains(fieldName); fields[fieldName] = new ResponseJson.LayerFieldData { value = layer.getValueString(fieldName), fieldIsReadonly = fieldOccupiedByEdge || layer.getValueIsReadonly(fieldName) }; } return(new ResponseJson.LayerData { ports = ports, fields = fields, }); }
public static ModelInfoReqResponses.ValidateLayerFieldsResponse dispatch( VersionedModelClassNS.VersionedModelClass versionedModel, JObject jobj ) { Dictionary <string, string> fieldValues = new Dictionary <string, string>(); foreach (var fieldEntry in (jobj["fieldValues"] as JObject).Properties()) { fieldValues[fieldEntry.Name] = fieldEntry.Value.ToString(); } string layerId = jobj["layerId"].ToString(); if (!versionedModel.getCurrent().layerDict.layers.ContainsKey(layerId)) { return(new ModelInfoReqResponses.ValidateLayerFieldsResponseLayerNonexistentError()); } Layers.Layer layer = versionedModel.getCurrent().layerDict.layers[layerId]; foreach (var fieldEntry in fieldValues) { if (!layer.getValueNames().Contains(fieldEntry.Key)) { return(new ModelInfoReqResponses.ValidateLayerFieldsResponseFieldNonexistent(fieldEntry.Key)); } } var validated = ModelUtilsNS.ModelUtils.validateLayerFields( versionedModel.getCurrent(), layerId, fieldValues ); return(new ModelInfoReqResponses.ValidateLayerFieldsResponseNoError(validated.errors, validated.warnings)); }