Esempio n. 1
0
        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,
            });
        }
Esempio n. 2
0
        private static void propagateEdge(ModelClassNS.ModelClass modelStruct, string edgeId)
        {
            NetworkContainersNS.Edge edge        = modelStruct.graph.edges[edgeId];
            Layers.Layer             sourceLayer = modelStruct.layerDict.layers[edge.sourceVertexId];
            Layers.Layer             targetLayer = modelStruct.layerDict.layers[edge.targetVertexId];
            string sourceFieldName = sourceLayer.getValueNameOfPort(edge.sourcePortId);
            string targetFieldName = targetLayer.getValueNameOfPort(edge.targetPortId);

            bool edgeIsConsistent = targetLayer.compareFieldValue(targetFieldName, sourceLayer.getValueString(sourceFieldName));

            if (edgeIsConsistent)
            {
                edge.consistency = NetworkContainersNS.ConsistencyType.Consistent;
                return;
            }

            string validateFieldValue = targetLayer.validateFieldString(targetFieldName, sourceLayer.getValueString(sourceFieldName));

            if (validateFieldValue != null)
            {
                edge.consistency = NetworkContainersNS.ConsistencyType.Inconsistent;
                return;
            }

            Layers.LayersValidated validatedUpdate = targetLayer.validateSetFields(new Dictionary <string, string>()
            {
                { targetFieldName, sourceLayer.getValueString(sourceFieldName) },
            });
            if (validatedUpdate.errors.Count != 0)
            {
                edge.consistency = NetworkContainersNS.ConsistencyType.Inconsistent;
                return;
            }

            targetLayer.setFields(new Dictionary <string, string>()
            {
                { targetFieldName, sourceLayer.getValueString(sourceFieldName) },
            });
            edge.consistency = NetworkContainersNS.ConsistencyType.Consistent;
        }
Esempio n. 3
0
        public static ModelInfoReqResponses.GetPortInfoResponse dispatch(
            VersionedModelClassNS.VersionedModelClass versionedModel,
            JObject jobj
            )
        {
            string vertexId = jobj["vertexId"].ToString();
            string portId   = jobj["portId"].ToString();

            if (!versionedModel.getCurrent().graph.vertices.ContainsKey(vertexId))
            {
                return(new ModelInfoReqResponses.GetPortInfoResponseCouldNotFindPort());
            }
            if (!versionedModel.getCurrent().graph.vertices[vertexId].ports.ContainsKey(portId))
            {
                return(new ModelInfoReqResponses.GetPortInfoResponseCouldNotFindPort());
            }
            Layers.Layer layer = versionedModel.getCurrent().layerDict.layers[vertexId];

            string valueName  = layer.getValueNameOfPort(portId);
            string fieldValue = layer.getValueString(valueName);

            return(new ModelInfoReqResponses.GetPortInfoResponseCouldFindPort(fieldValue));
        }