Example #1
0
        public SqlPreCommand DeleteSqlSync(Entity ident, string comment = null)
        {
            var pre = OnPreDeleteSqlSync(ident);
            var collections = (from tml in this.TablesMList()
                               select new SqlPreCommandSimple("DELETE {0} WHERE {1} = {2} --{3}"
                                   .FormatWith(tml.Name, tml.BackReference.Name.SqlEscape(), ident.Id, comment ?? ident.ToString()))).Combine(Spacing.Simple);

            var main = new SqlPreCommandSimple("DELETE {0} WHERE {1} = {2} --{3}"
                    .FormatWith(Name, this.PrimaryKey.Name.SqlEscape(), ident.Id, comment ?? ident.ToString()));

            return SqlPreCommand.Combine(Spacing.Simple, pre, collections, main);
        }
 public string DeleteChanges(Entity entity, IDictionary<string, object> existingRecord)
 {
     var display = entity.ToString();
     var joinedKeyValue = "#" + entity.JoinedKeyValue;
     if (display != joinedKeyValue)
     {
         display += " ({0})".Fill(joinedKeyValue);
     }
     return "Deleted " + display;
 }
 public string CreateChanges(Entity entity)
 {
     var display = entity.ToString();
     var joinedKeyValue = "#" + entity.JoinedKeyValue;
     if (display != joinedKeyValue)
     {
         display += " ({0})".Fill(joinedKeyValue);
     }
     return "Created " + display;
 }
Example #4
0
        private void HandleReceiveEntity(Entity ent)
        {
            if (ent is Response)
                HandleResponse(ent as Response);
            else if (ent is Request)
                HandleRequest(ent as Request);
            else if (ent is Notice)
                HandleNotice(ent as Notice);
            else
                Console.WriteLine("TEBPProvicer received an invalid entity (ignored).");

            if (ent.RequiresAnswer && !ent.Responded)
                throw new NotSupportedException("The entity " + ent.ToString() + " has not been responded to.");
        }
Example #5
0
    static void RunTest(Store testlist, Entity test, bool shouldSucceed, int mode)
    {
        string inputpath = null, outputpath = null,
            inputformat = null, outputformat = null,
            inputbase = null, outputbase = null;

        if (mode == 0) {
            inputformat = "xml";
            outputformat = "n3";

            string uribase = "http://www.w3.org/2000/10/rdf-tests/rdfcore/";
            Resource input = testlist.SelectObjects(test, "http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#inputDocument")[0];
            inputbase = input.Uri;
            inputpath = input.Uri.Substring(uribase.Length);

            if (testlist.SelectObjects(test, "http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#outputDocument").Length > 0) {
                Resource output = testlist.SelectObjects(test, "http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#outputDocument")[0];
                outputpath = output.Uri.Substring(uribase.Length);
                outputbase = output.Uri;
            }
        } else if (mode == 1) {
            inputformat = "n3";
            outputformat = "n3";
            inputbase = "file:/home/syosi/cvs-trunk/WWW/2000/10/swap/test/n3parser.tests";

            string uribase = "http://www.example.org/";

            if (testlist.SelectObjects(test, "http://www.w3.org/2004/11/n3test#inputDocument").Length == 0) return;
            Resource input = testlist.SelectObjects(test, "http://www.w3.org/2004/11/n3test#inputDocument")[0];
            inputpath = input.Uri.Substring(uribase.Length);

            if (testlist.SelectObjects(test, "http://www.w3.org/2004/11/n3test#outputDocument").Length > 0) {
                Resource output = testlist.SelectObjects(test, "http://www.w3.org/2004/11/n3test#outputDocument")[0];
                outputpath = output.Uri.Substring(uribase.Length);
            }
        }

        string desc = test.ToString();
        try {
            desc += " " + ((Literal)testlist.SelectObjects(test, "http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#description")[0]).Value;
        } catch (Exception e) {
        }

        try {
            total++;

            RdfReader reader = RdfReader.Create(inputformat, Path.Combine(basepath, inputpath));
            reader.BaseUri = inputbase;

            MemoryStore inputmodel = new MemoryStore(reader);
            if (reader.Warnings.Count > 0) {
                string warnings = String.Join("; ", (string[])((ArrayList)reader.Warnings).ToArray(typeof(string)));
                throw new ParserException(warnings);
            }
            if (!shouldSucceed) {
                Console.WriteLine(desc + ": Should Not Have Passed **\n");
                badpass++;
                return;
            }

            if (shouldSucceed && outputpath != null) {
                RdfReader reader2 = RdfReader.Create(outputformat, Path.Combine(basepath, outputpath));
                reader2.BaseUri = outputbase;
                MemoryStore outputmodel = new MemoryStore(reader2);

                CompareModels(inputmodel, outputmodel);
            }
        } catch (System.IO.FileNotFoundException ex) {
            Console.WriteLine(inputpath + " Not Found");
            error++;
        } catch (System.IO.DirectoryNotFoundException ex) {
            Console.WriteLine(inputpath + " Not Found");
            error++;
        } catch (ParserException ex) {
            if (shouldSucceed) {
                Console.WriteLine(desc + ": " + ex.Message + " **");
                Console.WriteLine();
                badfail++;
            }
        }
    }
Example #6
0
 /// <summary>
 /// Prints the description for an individual entity on its own line.
 /// </summary>
 /// <param name="entity"></param>
 private static void PrintEntity( Entity entity )
 {
     Console.Out.WriteLine( entity.GetID() + " - " + entity.ToString() + " [" + entity.m_Type.ToString() + "]" );
 }
Example #7
0
		string GetUniqueName( Set<string> names, Entity entity )
		{
			string name = entity.Name;
			if( string.IsNullOrEmpty( name ) )
				name = entity.ToString();
			string uniqueName;
			for( int n = 1; ; n++ )
			{
				uniqueName = name;
				if( n != 1 )
					uniqueName += n.ToString();
				if( !names.Contains( uniqueName ) )
					break;
			}
			return uniqueName;
		}