Ejemplo n.º 1
0
        public String AsString()
        {
            // generate a string which may be used to present or identify the particular path.
            String retval  = "";
            int    counter = 0;

            foreach (Triple tt in this.tripleList)
            {
                String from = new OntologyName(tt.GetSubject()).GetLocalName();
                String via  = new OntologyName(tt.GetPredicate()).GetLocalName();
                String to   = new OntologyName(tt.GetObject()).GetLocalName();

                retval += "[" + from + "." + via + "] to ";

                // If "to" does not equal first class in next triple then put it in too
                if (counter == (this.tripleList.Count() - 1) || !(to.Equals(new OntologyName(this.tripleList[counter + 1].GetObject()).GetLocalName())))
                {
                    retval += to + " ";
                }
                counter++;
            }
            return(retval);
        }
Ejemplo n.º 2
0
        public String GenerateUserPathString(Node anchorNode, Boolean singleLoopFlag)
        {
            String anchorNodeName = anchorNode.GetSparqlID();
            String retval         = anchorNodeName + ": ";

            // handle the loop case:
            if (singleLoopFlag)
            {
                String classID   = new OntologyName(this.GetClass0Name(0)).GetLocalName();
                String attribute = new OntologyName(this.GetAttributeName(0)).GetLocalName();
                retval += anchorNode.GetSparqlID() + "-" + attribute + "->" + classID + "_NEW";
            }
            else
            {
                String first = new OntologyName(this.GetStartClassName()).GetLocalName();
                retval += first;
                if (!first.Equals(anchorNode.GetUri(true)))
                {
                    retval += "_NEW";
                }
                String last = first;

                for (int i = 0; i < this.GetLength(); i++)
                {
                    String class0 = new OntologyName(this.GetClass0Name(i)).GetLocalName();
                    String att    = new OntologyName(this.GetAttributeName(i)).GetLocalName();
                    String class1 = new OntologyName(this.GetAttributeName(i)).GetLocalName();
                    String sub0   = "";
                    String sub1   = "";

                    // mark connecting node on last hop of this generation.
                    if (i == (this.GetLength() - 1))
                    {
                        if (class0.Equals(last))
                        {
                            sub0 = anchorNode.GetSparqlID();
                        }
                        else
                        {
                            sub1 = anchorNode.GetSparqlID();
                        }
                    }

                    if (class0.Equals(last))
                    {
                        retval += "-" + att + "->";
                        retval += (!sub1.Equals("")) ? sub1 : class1;
                        last    = class1;
                    }
                    else
                    {
                        retval += "<-" + att + "-";
                        retval += (!sub0.Equals("")) ? sub0 : class0;
                        last    = class0;
                    }
                }
                if (!last.Equals(anchorNode.GetUri(true)))
                {
                    retval += "_NEW";
                }
            }

            return(retval);
        }