Ejemplo n.º 1
0
        public Node(String name, List <PropertyItem> p, List <NodeItem> n, String URI, NodeGroup ng)
        {
            // create a basic node
            this.nodeName    = name;
            this.fullURIname = URI;
            if (n != null)
            {
                this.nodes = n;
            }
            if (p != null)
            {
                this.props = p;
            }

            this.nodeGroup = ng;

            // set the sparqlId
            this.sparqlID = BelmontUtil.GenerateSparqlID(name, this.nodeGroup.GetSparqlNameHash());
        }
Ejemplo n.º 2
0
        public Node(String name, List <PropertyItem> p, List <NodeItem> n, String classURI, List <String> subclassNames, NodeGroup ng, OntologyInfo inflateOInfo)
        {
            this.nodeName      = name;
            this.fullURIname   = classURI;
            this.subclassNames = new List <String>(subclassNames);
            if (n != null)
            {
                this.nodes = n;
            }
            if (p != null)
            {
                this.props = p;
            }

            this.nodeGroup = ng;
            this.InflateAndValidate(inflateOInfo);

            // set the sparqlId
            this.sparqlID = BelmontUtil.GenerateSparqlID(name, this.nodeGroup.GetSparqlNameHash());
        }
Ejemplo n.º 3
0
        public static JsonArray UpdateSparqlIdsForJSON(JsonArray jobj, int indexNum, Dictionary <String, String> changedHash, Dictionary <String, String> tempNameHash)
        {   // updates the names used in the json array given. this had to be divided into separate methods
            // NOTE: i am not sure that this method will work to perform our conversions. it works in the Java but small incompatibilities may be a dominating porblem here,
            JsonArray retval = jobj;

            String ID = retval.GetStringAt((uint)indexNum);

            if (changedHash.ContainsKey(ID))
            {
                // no op
            }
            else
            {
                String newId = BelmontUtil.GenerateSparqlID(ID, tempNameHash);
                if (!newId.Equals(ID))
                {
                    changedHash.Add(ID, newId); // when we come across the key ID when processing the new JSON, we will replace it with newId
                    tempNameHash.Add(newId, "0");

                    // there seems to be no efficient way to do this so we will just replace the specified one.
                    // by looping through and making our change....
                    retval = new JsonArray();

                    for (int i = 0; i < jobj.Count; i++)
                    {
                        if (i == indexNum)
                        {
                            retval.Add(JsonValue.CreateStringValue(newId));
                        }   // we found an instance of the proposed new one.
                        else
                        {   // add the old one.
                            retval.Add(JsonValue.CreateStringValue(jobj.GetStringAt((uint)i)));
                        }
                    }
                }
            }
            return(retval);
        }
Ejemplo n.º 4
0
        public static JsonObject UpdateSparqlIdsForJSON(JsonObject jobj, String indexname, Dictionary <String, String> changedHash, Dictionary <String, String> tempNamehash)
        {   // updates the names used in the json object given. this had to be divided into separate methods
            JsonObject retval = jobj;

            String ID = retval.GetNamedString(indexname);

            if (changedHash.ContainsKey(ID))
            {
                // no op
            }
            else
            {
                String newId = BelmontUtil.GenerateSparqlID(ID, tempNamehash);
                if (!newId.Equals(ID))
                {
                    changedHash.Add(ID, newId); // we want to make sure to replace the old one with the new one.
                    tempNamehash.Add(newId, "0");
                    retval.Remove(indexname);
                    retval.Add(indexname, JsonValue.CreateStringValue(newId));
                }
            }
            return(retval);
        }