public static NodeType GetNodeType(String typeName, IGraphModel model) { foreach(NodeType nodeType in model.NodeModel.Types) { if(nodeType.PackagePrefixedName == typeName) return nodeType; } return null; }
public static EdgeType GetEdgeType(String typeName, IGraphModel model) { foreach(EdgeType edgeType in model.EdgeModel.Types) { if(edgeType.PackagePrefixedName == typeName) return edgeType; } return null; }
public INamedGraph CreateNamedGraph(IGraphModel graphModel, string graphName, params String[] parameters) { String assemblyName = Assembly.GetAssembly(graphModel.GetType()).Location; int capacity = 0; if(parameters != null) foreach(String parameter in parameters) if(parameter.StartsWith("capacity=")) capacity = int.Parse(parameter.Substring("capacity=".Length)); return new LGSPNamedGraph(this, graphModel, graphName, assemblyName, capacity); }
/// <summary> /// Constructs an LGSPGraph object with the given model and backend, and an automatically generated name. /// </summary> /// <param name="grmodel">The graph model.</param> /// <param name="lgspBackend">The responsible backend object, needed for import from the sequences.</param> public LGSPGraph(IGraphModel grmodel, LGSPBackend lgspBackend) : this(grmodel, lgspBackend, GetNextGraphName()) { }
public static IDictionary FillSet(IDictionary setToCopyTo, string valueTypeName, object hopefullySetToCopy, IGraphModel model) { if (hopefullySetToCopy is IDictionary) { return(FillSet(setToCopyTo, valueTypeName, (IDictionary)hopefullySetToCopy, model)); } throw new Exception("Set copy constructor expects set as source."); }
public static EnumAttributeType GetEnumAttributeType(String typeName, IGraphModel model) { foreach(EnumAttributeType attrType in model.EnumAttributeTypes) { if(attrType.PackagePrefixedName == typeName) return attrType; } return null; }
/// <summary> /// Instantiates a new instance of LGSPMatcherGenerator with the given graph model. /// A PatternGraphAnalyzer must run before the matcher generator is used, /// so that the analysis data is written the pattern graphs of the matching patterns to generate code for. /// </summary> /// <param name="model">The model for which the matcher functions shall be generated.</param> public LGSPMatcherGenerator(IGraphModel model) { this.model = model; }
public ElementConverter(IGraphModel model) { _model = model; }
public static Dictionary <K, SetValueType> FillSet <K>(Dictionary <K, SetValueType> setToCopyTo, string valueTypeName, IDictionary setToCopy, IGraphModel model) { NodeType nodeType = TypesHelper.GetNodeType(valueTypeName, model); if (nodeType != null) { FillSetWithNode(setToCopyTo, nodeType, setToCopy); } else { EdgeType edgeType = TypesHelper.GetEdgeType(valueTypeName, model); if (edgeType != null) { FillSetWithEdge(setToCopyTo, edgeType, setToCopy); } else { Type varType = TypesHelper.GetType(valueTypeName, model); FillSetWithVar(setToCopyTo, varType, setToCopy); } } return(setToCopyTo); }
/// <summary> /// Constructs an LGSPNamedGraph object with the given model and capacity, and an automatically generated name. /// </summary> /// <param name="grmodel">The graph model.</param> /// <param name="capacity">The initial capacity for the name maps (performance optimization, use 0 if unsure).</param> public LGSPNamedGraph(IGraphModel grmodel, int capacity) : base(grmodel) { NameToElem = new Dictionary<String, IGraphElement>(capacity); ElemToName = new Dictionary<IGraphElement, String>(capacity); }
public List <SearcherDatabase> GetGraphVariablesSearcherDatabases(IGraphModel graphModel) { return(new List <SearcherDatabase>()); }
// Can't be on the property as we inherit a getter only GraphModel property. internal void SetGraphModel(IGraphModel graphModel) { m_GraphModel = graphModel; }
public CamelcaseLabelGraphModel(IGraphModel model) { _model = model; EdgesModel = new CamelcaseGraphElementModel(model.EdgesModel); VerticesModel = new CamelcaseGraphElementModel(model.VerticesModel); }
public AddVStep(IGraphModel model, object value) : base(model.VerticesModel, value) { }
public LowercaseGraphModel(IGraphModel model) { _model = model; EdgesModel = new LowercaseGraphElementModel(model.EdgesModel); VerticesModel = new LowercaseGraphElementModel(model.VerticesModel); }
public CamelcasePropertiesGraphModel(IGraphModel model) { _model = model; }
public AppMutationsGraphType(IGraphModel model, IEnumerable <ISchemaEntity> schemas) { foreach (var schema in schemas) { var appId = schema.AppId; var schemaId = schema.NamedId(); var schemaType = schema.TypeName(); var schemaName = schema.DisplayName(); var contentType = model.GetContentType(schema.Id); var inputType = new ContentDataInputGraphType(schema, schemaName, schemaType, model); AddField(new FieldType { Name = $"create{schemaType}Content", Arguments = ContentActions.Create.Arguments(inputType), ResolvedType = contentType, Resolver = ContentActions.Create.Resolver(appId, schemaId), Description = $"Creates an {schemaName} content." }); AddField(new FieldType { Name = $"update{schemaType}Content", Arguments = ContentActions.Update.Arguments(inputType), ResolvedType = contentType, Resolver = ContentActions.Update.Resolver(appId, schemaId), Description = $"Update an {schemaName} content by id." }); AddField(new FieldType { Name = $"upsert{schemaType}Content", Arguments = ContentActions.Upsert.Arguments(inputType), ResolvedType = contentType, Resolver = ContentActions.Upsert.Resolver(appId, schemaId), Description = $"Upsert an {schemaName} content by id." }); AddField(new FieldType { Name = $"patch{schemaType}Content", Arguments = ContentActions.Patch.Arguments(inputType), ResolvedType = contentType, Resolver = ContentActions.Patch.Resolver(appId, schemaId), Description = $"Patch an {schemaName} content by id." }); AddField(new FieldType { Name = $"change{schemaType}Content", Arguments = ContentActions.ChangeStatus.Arguments, ResolvedType = contentType, Resolver = ContentActions.ChangeStatus.Resolver(appId, schemaId), Description = $"Change a {schemaName} content." }); AddField(new FieldType { Name = $"delete{schemaType}Content", Arguments = ContentActions.Delete.Arguments, ResolvedType = EntitySavedGraphType.NonNull, Resolver = ContentActions.Delete.Resolver(appId, schemaId), Description = $"Delete an {schemaName} content." }); AddField(new FieldType { Name = $"publish{schemaType}Content", Arguments = ContentActions.ChangeStatus.Arguments, ResolvedType = contentType, Resolver = ContentActions.ChangeStatus.Resolver(appId, schemaId), Description = $"Publish a {schemaName} content.", DeprecationReason = $"Use 'change{schemaType}Content' instead" }); } Description = "The app mutations."; }
/// <summary> /// Constructs an LGSPGraph object with the given model, backend, and name. /// </summary> /// <param name="grmodel">The graph model.</param> /// <param name="lgspBackend">The responsible backend object, needed for import from the sequences.</param> /// <param name="grname">The name for the graph.</param> public LGSPGraph(IGraphModel grmodel, LGSPBackend lgspBackend, String grname) : this(grmodel, grname) { backend = lgspBackend; }
public GremlinQueryLanguageTest() { this._model = GraphModel.FromAssembly(Assembly.GetExecutingAssembly(), typeof(Vertex), typeof(Edge), GraphElementNamingStrategy.Simple); }
/// <summary> /// Copy constructor helper. /// </summary> /// <param name="dataSource">The LGSPGraph object to get the data from</param> /// <param name="newName">Name of the copied graph.</param> /// <param name="oldToNewMap">A map of the old elements to the new elements after cloning, /// just forget about it if you don't need it.</param> private void Copy(LGSPGraph dataSource, String newName, out IDictionary<IGraphElement, IGraphElement> oldToNewMap) { model = dataSource.model; name = newName; InitializeGraph(); model.CreateAndBindIndexSet(this); if(dataSource.backend != null) { backend = dataSource.backend; modelAssemblyName = dataSource.modelAssemblyName; } oldToNewMap = new Dictionary<IGraphElement, IGraphElement>(); for(int i = 0; i < dataSource.nodesByTypeHeads.Length; i++) { for(LGSPNode head = dataSource.nodesByTypeHeads[i], node = head.lgspTypePrev; node != head; node = node.lgspTypePrev) { LGSPNode newNode = (LGSPNode) node.Clone(); AddNodeWithoutEvents(newNode, node.lgspType.TypeID); oldToNewMap[node] = newNode; } } for(int i = 0; i < dataSource.edgesByTypeHeads.Length; i++) { for(LGSPEdge head = dataSource.edgesByTypeHeads[i], edge = head.lgspTypePrev; edge != head; edge = edge.lgspTypePrev) { LGSPEdge newEdge = (LGSPEdge) edge.Clone((INode) oldToNewMap[edge.lgspSource], (INode) oldToNewMap[edge.lgspTarget]); AddEdgeWithoutEvents(newEdge, newEdge.lgspType.TypeID); oldToNewMap[edge] = newEdge; } } /* TODO: remove when cloning of graph variables was implemented * foreach(KeyValuePair<IGraphElement, LinkedList<Variable>> kvp in dataSource.ElementMap) { IGraphElement newElem = oldToNewMap[kvp.Key]; foreach(Variable var in kvp.Value) SetVariableValue(var.Name, newElem); }*/ model.FillIndexSetAsClone(this, dataSource, oldToNewMap); statistics = new LGSPGraphStatistics(this.Model); statistics.Copy(dataSource); }
public static String DefaultValueString(String typeName, IGraphModel model) { switch (typeName) { case "SByte": return "0"; case "Int16": return "0"; case "Int32": return "0"; case "Int64": return "0L"; case "Boolean": return "false"; case "Single": return "0.0f"; case "Double": return "0.0"; case "String": return "\"\""; } switch (typeName) { case "byte": return "0"; case "short": return "0"; case "int": return "0"; case "long": return "0L"; case "bool": return "false"; case "float": return "0.0f"; case "double": return "0.0"; case "string": return "\"\""; case "object": return "null"; } if(typeName == "boolean") return "false"; if(typeName.StartsWith("GRGEN_MODEL.")) typeName = typeName.Substring(12); if(typeName.Contains(".ENUM_")) typeName = typeName.Substring(0, typeName.IndexOf(".ENUM_")) + "::" + typeName.Substring(typeName.IndexOf(".ENUM_")+6); if(typeName.StartsWith("ENUM_")) typeName = typeName.Substring(5); foreach(EnumAttributeType enumAttrType in model.EnumAttributeTypes) { if(enumAttrType.PackagePrefixedName == typeName) return "(GRGEN_MODEL." + (enumAttrType.Package!=null ? enumAttrType.Package+"." : "") + "ENUM_" + enumAttrType.Name + ")0"; } return "null"; // object or graph or node type or edge type }
/// <summary> /// Constructs an LGSPNamedGraph object. /// Deprecated. /// </summary> /// <param name="lgspBackend">The responsible backend object.</param> /// <param name="grmodel">The graph model.</param> /// <param name="grname">The name for the graph.</param> /// <param name="modelassemblyname">The name of the model assembly.</param> /// <param name="capacity">The initial capacity for the name maps (performance optimization, use 0 if unsure).</param> public LGSPNamedGraph(LGSPBackend lgspBackend, IGraphModel grmodel, String grname, String modelassemblyname, int capacity) : base(lgspBackend, grmodel, grname, modelassemblyname) { NameToElem = new Dictionary<String, IGraphElement>(capacity); ElemToName = new Dictionary<IGraphElement, String>(capacity); }
/// <summary> /// Returns type with correct namespace prefix for the type given /// </summary> public static string XgrsTypeToCSharpType(string type, IGraphModel model) { if(type == "Node") return "GRGEN_LIBGR.INode"; if(type == "AEdge" || type == "Edge" || type == "UEdge") return "GRGEN_LIBGR.IEdge"; if(type == "short" || type == "int" || type == "long" || type == "bool" || type == "string" || type == "float" || type == "double" || type == "object") return type; if(type == "byte") return "sbyte"; if(type == "boolean") return "bool"; if(type.StartsWith("set<") || type.StartsWith("map<")) return "Dictionary<" + XgrsTypeToCSharpType(ExtractSrc(type), model) + "," + XgrsTypeToCSharpType(ExtractDst(type), model) + ">"; if(type.StartsWith("array<")) return "List<" + XgrsTypeToCSharpType(ExtractSrc(type), model) + ">"; if(type.StartsWith("deque<")) return "GRGEN_LIBGR.Deque<" + XgrsTypeToCSharpType(ExtractSrc(type), model) + ">"; if(type.StartsWith("match<")) return "Rule_" + ExtractSrc(type) + ".IMatch_" + ExtractSrc(type); if(type == "SetValueType") return "GRGEN_LIBGR.SetValueType"; if(type == "graph") return "GRGEN_LIBGR.IGraph"; foreach(EnumAttributeType enumAttrType in model.EnumAttributeTypes) { if (enumAttrType.PackagePrefixedName == type) return "GRGEN_MODEL." + (enumAttrType.Package!=null ? enumAttrType.Package+"." : "") + "ENUM_" + enumAttrType.Name; } if(type.Contains("::")) { String packageName = type.Substring(0, type.IndexOf(':')); String typeName = type.Substring(type.LastIndexOf(':')+1); return "GRGEN_MODEL." + packageName + ".I" + typeName; } return "GRGEN_MODEL.I" + type; }
/// <summary> /// Constructs an LGSPNamedGraph object with the given model, backend, name, and capacity. /// </summary> /// <param name="grmodel">The graph model.</param> /// <param name="backend">The backend.</param> /// <param name="grname">The name for the graph.</param> /// <param name="capacity">The initial capacity for the name maps (performance optimization, use 0 if unsure).</param> public LGSPNamedGraph(IGraphModel grmodel, LGSPBackend backend, String grname, int capacity) : base(grmodel, backend, grname) { NameToElem = new Dictionary<String, IGraphElement>(capacity); ElemToName = new Dictionary<IGraphElement, String>(capacity); }
public static bool IsEnumType(string typename, IGraphModel model) { foreach(EnumAttributeType enumAttrType in model.EnumAttributeTypes) { if(enumAttrType.PackagePrefixedName == typename) return true; } return false; }
public static object DefaultValue(String typeName, IGraphModel model) { switch (typeName) { case "SByte": return 0; case "Int16": return 0; case "Int32": return 0; case "Int64": return 0L; case "Boolean": return false; case "Single": return 0.0f; case "Double": return 0.0; case "String": return ""; } switch (typeName) { case "byte": return 0; case "short": return 0; case "int": return 0; case "long": return 0L; case "bool": return false; case "float": return 0.0f; case "double": return 0.0; case "string": return ""; case "object": return null; } if(typeName == "boolean") return false; if(typeName.StartsWith("ENUM_")) typeName = typeName.Substring(5); foreach(EnumAttributeType enumAttrType in model.EnumAttributeTypes) { if (enumAttrType.PackagePrefixedName == typeName) return Enum.Parse(enumAttrType.EnumType, Enum.GetName(enumAttrType.EnumType, 0)); } return null; // object or graph or node type or edge type }
/// <summary> /// Imports the first graph not being of type "gxl-1.0" from a GXL file /// with the given filename. /// Any errors will be reported by exception. /// </summary> /// <param name="importFilename">The filename of the file to be imported, /// the model specification part will be ignored.</param> /// <param name="backend">The backend to use to create the graph.</param> /// <param name="graphModel">The graph model to be used, /// it must be conformant to the model used in the file to be imported.</param> /// <param name="actions">Receives the actions object in case a .grg model is given.</param> public static IGraph Import(String importFilename, IBackend backend, IGraphModel graphModel, out IActions actions) { return(Import(new StreamReader(importFilename), backend, graphModel, out actions)); }
public static String XgrsTypeOfConstant(object constant, IGraphModel model) { if(constant == null) return ""; if(constant.GetType().IsGenericType) { if(constant.GetType().Name == "Dictionary`2") { Type keyType; Type valueType; ContainerHelper.GetDictionaryTypes(constant, out keyType, out valueType); if(valueType == typeof(de.unika.ipd.grGen.libGr.SetValueType)) return "set<" + DotNetTypeToXgrsType(keyType.Name, keyType.FullName) + ">"; else return "map<" + DotNetTypeToXgrsType(keyType.Name, keyType.FullName) + "," + DotNetTypeToXgrsType(valueType.Name, valueType.FullName) + ">"; } else if(constant.GetType().Name == "List`1") { Type valueType; ContainerHelper.GetListType(constant.GetType(), out valueType); return "array<" + DotNetTypeToXgrsType(valueType.Name, valueType.FullName) + ">"; } else //if(constant.GetType().Name == "Deque`1") { Type valueType; ContainerHelper.GetListType(constant.GetType(), out valueType); return "deque<" + DotNetTypeToXgrsType(valueType.Name, valueType.FullName) + ">"; } } object typeinsteadofobject = NodeOrEdgeTypeIfNodeOrEdge(constant); return DotNetTypeToXgrsType(typeinsteadofobject.GetType().Name, typeinsteadofobject.GetType().FullName); }
/// <summary> /// Returns the types to which the operands must be casted to, /// assuming a string operator. /// Returns "" if the type can only be determined at runtime. /// Returns "-" in case of a type error and/or if no operator working on strings can be applied. /// </summary> public static string BalanceString(string left, string right, IGraphModel model) { if(left == "string" || right == "string") return "string"; if(left == "" || right == "") return ""; return "-"; }
public static bool IsSameOrSubtype(string xgrsTypeSameOrSub, string xgrsTypeBase, IGraphModel model) { if(xgrsTypeSameOrSub == "" || xgrsTypeBase == "") return true; if(xgrsTypeSameOrSub.StartsWith("set<")) { if(!xgrsTypeBase.StartsWith("set<")) return false; return ExtractSrc(xgrsTypeSameOrSub) == ExtractSrc(xgrsTypeBase); } else if(xgrsTypeSameOrSub.StartsWith("map<")) { if(!xgrsTypeBase.StartsWith("map<")) return false; return ExtractSrc(xgrsTypeSameOrSub) == ExtractSrc(xgrsTypeBase) && ExtractDst(xgrsTypeSameOrSub) == ExtractDst(xgrsTypeBase); } else if(xgrsTypeSameOrSub.StartsWith("array<")) { if(!xgrsTypeBase.StartsWith("array<")) return false; return ExtractSrc(xgrsTypeSameOrSub) == ExtractSrc(xgrsTypeBase); } else if(xgrsTypeSameOrSub.StartsWith("deque<")) { if(!xgrsTypeBase.StartsWith("deque<")) return false; return ExtractSrc(xgrsTypeSameOrSub) == ExtractSrc(xgrsTypeBase); } else if(xgrsTypeSameOrSub.StartsWith("match<")) { if(!xgrsTypeBase.StartsWith("match<")) return false; return ExtractSrc(xgrsTypeSameOrSub) == ExtractSrc(xgrsTypeBase); } else if(xgrsTypeSameOrSub == "short" || xgrsTypeSameOrSub == "int" || xgrsTypeSameOrSub == "long" || xgrsTypeSameOrSub == "float" || xgrsTypeSameOrSub == "double" || xgrsTypeSameOrSub == "string" || xgrsTypeSameOrSub == "object" || xgrsTypeSameOrSub == "graph") return xgrsTypeSameOrSub==xgrsTypeBase; else if (xgrsTypeSameOrSub == "byte" || xgrsTypeSameOrSub == "sbyte") return xgrsTypeBase == "byte" || xgrsTypeBase == "sbyte"; else if (xgrsTypeSameOrSub == "bool" || xgrsTypeSameOrSub == "boolean") return xgrsTypeBase=="bool" || xgrsTypeBase=="boolean"; foreach(EnumAttributeType enumAttrType in model.EnumAttributeTypes) { if(enumAttrType.PackagePrefixedName == xgrsTypeSameOrSub) return xgrsTypeSameOrSub == xgrsTypeBase; } foreach(NodeType leftNodeType in model.NodeModel.Types) { if(leftNodeType.PackagePrefixedName == xgrsTypeSameOrSub) { foreach(NodeType rightNodeType in model.NodeModel.Types) { if(rightNodeType.PackagePrefixedName == xgrsTypeBase) { return leftNodeType.IsA(rightNodeType); } } } } foreach(EdgeType leftEdgeType in model.EdgeModel.Types) { if(leftEdgeType.PackagePrefixedName == xgrsTypeSameOrSub) { foreach(EdgeType rightEdgeType in model.EdgeModel.Types) { if(rightEdgeType.PackagePrefixedName == xgrsTypeBase) { return leftEdgeType.IsA(rightEdgeType); } } } } foreach(ExternalType leftExternalType in model.ExternalTypes) { if(leftExternalType.Name == xgrsTypeSameOrSub) { foreach(ExternalType rightExternalType in model.ExternalTypes) { if(rightExternalType.Name == xgrsTypeBase) { return leftExternalType.IsA(rightExternalType); } } } } return false; }
/// <summary> /// Returns the types to which the operands must be casted to, /// assuming an external type equality or ordering operator. /// Returns "" if the type can only be determined at runtime. /// Returns "-" in case of a type error and/or if no operator working on external types can be applied. /// </summary> public static string BalanceExternalType(string left, string right, IGraphModel model) { if(left == right) return left; if(left == "" || right == "") return ""; if(TypesHelper.IsSameOrSubtype(left, right, model) && TypesHelper.IsExternalTypeIncludingObjectType(right, model)) return right; if(TypesHelper.IsSameOrSubtype(right, left, model) && TypesHelper.IsExternalTypeIncludingObjectType(left, model)) return left; return "-"; }
public static bool IsExternalTypeIncludingObjectType(string typename, IGraphModel model) { for(int i=0; i<model.ExternalTypes.Length; ++i) { if(model.ExternalTypes[i].Name == typename) return true; } return false; }
public static string NotEqualStatic(string leftValue, string rightValue, string balancedType, string leftType, string rightType, IGraphModel model) { // byte and short are only used for storing, no computations are done with them // enums are handled via int, node and edges are handled via reference equality if(balancedType == "int") { return "((int)"+leftValue+" != "+"(int)"+rightValue+")"; } else if(balancedType == "long") { return "((long)"+leftValue+" != "+"(long)"+rightValue+")"; } else if(balancedType == "float") { return "((float)"+leftValue+" != "+"(float)"+rightValue+")"; } else if(balancedType == "double") { return "((double)"+leftValue+" != "+"(double)"+rightValue+")"; } else if(balancedType == "boolean") { return "((bool)"+leftValue+" != "+"(bool)"+rightValue+")"; } else if(balancedType == "string") { return "((string)"+leftValue+" != "+"(string)"+rightValue+")"; } else if(balancedType == "graph") { return "!GRGEN_LIBGR.GraphHelper.Equal((GRGEN_LIBGR.IGraph)" + leftValue + ", (GRGEN_LIBGR.IGraph)" + rightValue + ")"; } else if(balancedType.StartsWith("set<")) { return "GRGEN_LIBGR.ContainerHelper.NotEqualIDictionary((IDictionary)"+leftValue+", (IDictionary)"+rightValue+")"; } else if(balancedType.StartsWith("map<")) { return "GRGEN_LIBGR.ContainerHelper.NotEqualIDictionary((IDictionary)"+leftValue+", (IDictionary)"+rightValue+")"; } else if(balancedType.StartsWith("array<")) { return "GRGEN_LIBGR.ContainerHelper.NotEqualIList((IList)"+leftValue+", (IList)"+rightValue+")"; } else if(balancedType.StartsWith("deque<")) { return "GRGEN_LIBGR.ContainerHelper.NotEqualDeque((Deque)" + leftValue + ", (Deque)" + rightValue + ")"; } else if(TypesHelper.IsExternalTypeIncludingObjectType(balancedType, model)) { return "!graph.Model.IsEqual((object)" + leftValue + ", (object)" + rightValue + ")"; } else { return "!Object.Equals("+leftValue+", "+rightValue+")"; } }
/// <summary> /// Constructs the sequence generator /// </summary> public LGSPSequenceGenerator(LGSPGrGen gen, IGraphModel model, Dictionary<String, List<IFilter>> rulesToFilters, Dictionary<String, List<String>> filterFunctionsToInputTypes, Dictionary<String, List<String>> rulesToInputTypes, Dictionary<String, List<String>> rulesToOutputTypes, Dictionary<String, List<String>> rulesToTopLevelEntities, Dictionary<String, List<String>> rulesToTopLevelEntityTypes, Dictionary<String, List<String>> sequencesToInputTypes, Dictionary<String, List<String>> sequencesToOutputTypes, Dictionary<String, List<String>> proceduresToInputTypes, Dictionary<String, List<String>> proceduresToOutputTypes, Dictionary<String, bool> proceduresToIsExternal, Dictionary<String, List<String>> functionsToInputTypes, Dictionary<String, String> functionsToOutputType, Dictionary<String, bool> functionsToIsExternal) { this.gen = gen; this.model = model; this.rulesToFilters = rulesToFilters; this.filterFunctionsToInputTypes = filterFunctionsToInputTypes; this.rulesToInputTypes = rulesToInputTypes; this.rulesToOutputTypes = rulesToOutputTypes; this.rulesToTopLevelEntities = rulesToTopLevelEntities; this.rulesToTopLevelEntityTypes = rulesToTopLevelEntityTypes; this.sequencesToInputTypes = sequencesToInputTypes; this.sequencesToOutputTypes = sequencesToOutputTypes; this.proceduresToInputTypes = proceduresToInputTypes; this.proceduresToOutputTypes = proceduresToOutputTypes; this.proceduresToIsExternal = proceduresToIsExternal; this.functionsToInputTypes = functionsToInputTypes; this.functionsToOutputType = functionsToOutputType; this.functionsToIsExternal = functionsToIsExternal; // extract rule names from domain of rule names to input types map ruleNames = new String[rulesToInputTypes.Count]; int i = 0; foreach(KeyValuePair<String, List<String>> ruleToInputTypes in rulesToInputTypes) { ruleNames[i] = ruleToInputTypes.Key; ++i; } // extract sequence names from domain of sequence names to input types map sequenceNames = new String[sequencesToInputTypes.Count]; i = 0; foreach(KeyValuePair<String, List<String>> sequenceToInputTypes in sequencesToInputTypes) { sequenceNames[i] = sequenceToInputTypes.Key; ++i; } // extract procedure names from domain of procedure names to input types map procedureNames = new String[proceduresToInputTypes.Count]; i = 0; foreach(KeyValuePair<String, List<String>> procedureToInputTypes in proceduresToInputTypes) { procedureNames[i] = procedureToInputTypes.Key; ++i; } // extract function names from domain of function names to input types map functionNames = new String[functionsToInputTypes.Count]; i = 0; foreach(KeyValuePair<String, List<String>> functionToInputTypes in functionsToInputTypes) { functionNames[i] = functionToInputTypes.Key; ++i; } // extract function output types from range of function names to output types map functionOutputTypes = new String[functionsToOutputType.Count]; i = 0; foreach(KeyValuePair<String, String> functionToOutputType in functionsToOutputType) { functionOutputTypes[i] = functionToOutputType.Value; ++i; } // extract filter function names from domain of filter functions to input types filterFunctionNames = new String[filterFunctionsToInputTypes.Count]; i = 0; foreach(KeyValuePair<String, List<String>> filterFunctionToInputType in filterFunctionsToInputTypes) { filterFunctionNames[i] = filterFunctionToInputType.Key; ++i; } // create the environment for (type) checking the compiled sequences after parsing env = new SequenceCheckingEnvironmentCompiled( ruleNames, sequenceNames, procedureNames, functionNames, rulesToFilters, filterFunctionsToInputTypes, rulesToInputTypes, rulesToOutputTypes, rulesToTopLevelEntities, rulesToTopLevelEntityTypes, sequencesToInputTypes, sequencesToOutputTypes, proceduresToInputTypes, proceduresToOutputTypes, proceduresToIsExternal, functionsToInputTypes, functionsToOutputType, functionsToIsExternal, model); }
// todo クラス化 private Tuple<IEnumerable<IGraphPoint>, IEnumerable<IGraphPoint>> MakePiChartModel(IGraphModel stacked) { var days = stacked.Pv.Concat(stacked.Ev).Concat(stacked.Ac).Select(x => x.Day).Distinct(); var pis = from d in days let pv = stacked.Pv.Where(x => x.Day == d).Select(x => x.Value).FirstOrDefault() let ev = stacked.Ev.Where(x => x.Day == d).Select(x => x.Value).FirstOrDefault() let ac = stacked.Ac.Where(x => x.Day == d).Select(x => x.Value).FirstOrDefault() select new { d, spi = ev / pv, cpi = ev / ac }; var spis = pis.Select(x => new GraphPoint { Day = x.d, Value = double.IsNaN(x.spi) ? 0.0 : x.spi }).ToArray(); var cpis = pis.Select(x => new GraphPoint { Day = x.d, Value = double.IsNaN(x.cpi) ? 0.0 : x.cpi }).ToArray(); var points = spis .Concat(cpis).ToArray(); if (points.Any() == false) { return null; } return Tuple.Create(spis.OfType<IGraphPoint>(), cpis.OfType<IGraphPoint>()); }
/// <summary> /// Constructs an LGSPGraph object with the given model and an automatically generated name. /// </summary> /// <param name="grmodel">The graph model.</param> public LGSPGraph(IGraphModel grmodel) : this(grmodel, GetNextGraphName()) { }
// constructor for compiled sequences public SequenceCheckingEnvironmentCompiled(String[] ruleNames, String[] sequenceNames, String[] procedureNames, String[] functionNames, Dictionary<String, List<IFilter>> rulesToFilters, Dictionary<String, List<String>> filterFunctionsToInputTypes, Dictionary<String, List<String>> rulesToInputTypes, Dictionary<String, List<String>> rulesToOutputTypes, Dictionary<String, List<String>> rulesToTopLevelEntities, Dictionary<String, List<String>> rulesToTopLevelEntityTypes, Dictionary<String, List<String>> sequencesToInputTypes, Dictionary<String, List<String>> sequencesToOutputTypes, Dictionary<String, List<String>> proceduresToInputTypes, Dictionary<String, List<String>> proceduresToOutputTypes, Dictionary<String, bool> proceduresToIsExternal, Dictionary<String, List<String>> functionsToInputTypes, Dictionary<String, String> functionsToOutputType, Dictionary<String, bool> functionsToIsExternal, IGraphModel model) { this.ruleNames = ruleNames; this.sequenceNames = sequenceNames; this.procedureNames = procedureNames; this.functionNames = functionNames; this.rulesToFilters = rulesToFilters; this.filterFunctionsToInputTypes = filterFunctionsToInputTypes; this.rulesToInputTypes = rulesToInputTypes; this.rulesToOutputTypes = rulesToOutputTypes; this.rulesToTopLevelEntities = rulesToTopLevelEntities; this.rulesToTopLevelEntityTypes = rulesToTopLevelEntityTypes; this.sequencesToInputTypes = sequencesToInputTypes; this.sequencesToOutputTypes = sequencesToOutputTypes; this.proceduresToInputTypes = proceduresToInputTypes; this.proceduresToOutputTypes = proceduresToOutputTypes; this.proceduresToIsExternal = proceduresToIsExternal; this.functionsToInputTypes = functionsToInputTypes; this.functionsToOutputType = functionsToOutputType; this.functionsToIsExternal = functionsToIsExternal; this.model = model; }
/// <summary> /// Constructs an LGSPGraph object with the given model and name. /// </summary> /// <param name="grmodel">The graph model.</param> /// <param name="grname">The name for the graph.</param> public LGSPGraph(IGraphModel grmodel, String grname) : this(grname) { InitializeGraph(grmodel); }
/// <summary> /// Creates an interpretation plan builder for the given scheduled search plan. /// Only a limited amount of search operations is supported, the ones needed for isomorphy checking. /// </summary> /// <param name="ssp">the scheduled search plan to build an interpretation plan for</param> /// <param name="spg">the search plan graph for determining the pattern element needed for attribute checking</param> /// <param name="model">the model over which the patterns are to be searched</param> public InterpretationPlanBuilder(ScheduledSearchPlan ssp, SearchPlanGraph spg, IGraphModel model) { this.ssp = ssp; this.spg = spg; this.model = model; }
/// <summary> /// Constructs an LGSPGraph object. /// Deprecated. /// </summary> /// <param name="lgspBackend">The responsible backend object.</param> /// <param name="grmodel">The graph model.</param> /// <param name="grname">The name for the graph.</param> /// <param name="modelassemblyname">The name of the model assembly.</param> public LGSPGraph(LGSPBackend lgspBackend, IGraphModel grmodel, String grname, String modelassemblyname) : this(grmodel, grname) { backend = lgspBackend; modelAssemblyName = modelassemblyname; }
/// <summary> /// Imports a graph from the given file. /// The format is determined by the file extension. /// Any errors will be reported by exception. /// </summary> /// <param name="importFilename">The filename of the file to be imported, /// the model specification part will be ignored.</param> /// <param name="backend">The backend to use to create the graph.</param> /// <param name="graphModel">The graph model to be used, /// it must be conformant to the model used in the file to be imported.</param> /// <param name="actions">Receives the actions object in case a .grg model is given.</param> /// <returns>The imported graph. /// The .grs/.grsi importer returns an INamedGraph. If you don't need it: create an LGSPGraph from it and throw the named graph away. /// (the naming requires about the same amount of memory the raw graph behind it requires).</returns> public static IGraph Import(String importFilename, IBackend backend, IGraphModel graphModel, out IActions actions) { if(importFilename.EndsWith(".gxl", StringComparison.InvariantCultureIgnoreCase)) return GXLImport.Import(importFilename, backend, graphModel, out actions); else if (importFilename.EndsWith(".grs", StringComparison.InvariantCultureIgnoreCase) || importFilename.EndsWith(".grsi", StringComparison.InvariantCultureIgnoreCase)) return GRSImport.Import(importFilename, backend, graphModel, out actions); else throw new NotSupportedException("File format not supported"); }
/// <summary> /// Initializes the graph with the given model. /// </summary> /// <param name="grmodel">The model for this graph.</param> protected void InitializeGraph(IGraphModel grmodel) { model = grmodel; if(statistics.graphModel == null) statistics.graphModel = grmodel; modelAssemblyName = Assembly.GetAssembly(grmodel.GetType()).Location; InitializeGraph(); grmodel.CreateAndBindIndexSet(this); }
public void Initialize(IGraphModel model, ISchemaEntity schema, IComplexGraphType contentDataType) { var schemaType = schema.TypeName(); var schemaName = schema.DisplayName(); Name = $"{schemaType}Dto"; AddField(new FieldType { Name = "id", ResolvedType = AllTypes.NonNullGuid, Resolver = Resolve(x => x.Id), Description = $"The id of the {schemaName} content." }); AddField(new FieldType { Name = "version", ResolvedType = AllTypes.NonNullInt, Resolver = Resolve(x => x.Version), Description = $"The version of the {schemaName} content." }); AddField(new FieldType { Name = "created", ResolvedType = AllTypes.NonNullDate, Resolver = Resolve(x => x.Created), Description = $"The date and time when the {schemaName} content has been created." }); AddField(new FieldType { Name = "createdBy", ResolvedType = AllTypes.NonNullString, Resolver = Resolve(x => x.CreatedBy.ToString()), Description = $"The user that has created the {schemaName} content." }); AddField(new FieldType { Name = "lastModified", ResolvedType = AllTypes.NonNullDate, Resolver = Resolve(x => x.LastModified), Description = $"The date and time when the {schemaName} content has been modified last." }); AddField(new FieldType { Name = "lastModifiedBy", ResolvedType = AllTypes.NonNullString, Resolver = Resolve(x => x.LastModifiedBy.ToString()), Description = $"The user that has updated the {schemaName} content last." }); AddField(new FieldType { Name = "status", ResolvedType = AllTypes.NonNullStatusType, Resolver = Resolve(x => x.Status), Description = $"The the status of the {schemaName} content." }); AddField(new FieldType { Name = "url", ResolvedType = AllTypes.NonNullString, Resolver = model.ResolveContentUrl(schema), Description = $"The url to the the {schemaName} content." }); if (contentDataType.Fields.Any()) { AddField(new FieldType { Name = "data", ResolvedType = new NonNullGraphType(contentDataType), Resolver = Resolve(x => x.Data), Description = $"The data of the {schemaName} content." }); AddField(new FieldType { Name = "dataDraft", ResolvedType = contentDataType, Resolver = Resolve(x => x.DataDraft), Description = $"The draft data of the {schemaName} content." }); } Description = $"The structure of a {schemaName} content type."; }