2 using System
.Collections
;
5 namespace Wv
.Schedulator
12 public Source(Schedulator s
, string name
)
16 s
.register_source(this);
19 // Return the web URL, if any, to view the given task. This can
20 // be used for hyperlinks in the web interface, and so on.
21 public virtual string view_url(string taskid
)
26 // When this is called, you have no guarantee that any particular
27 // objects already exist except for all Sources. Create Persons,
28 // Projects, FixFors, and (if you want) Tasks here.
29 public virtual void make_basic()
33 // Called when all non-task objects (Sources, Persons, Projects,
34 // FixFors) have been created, so you know you can refer to them
35 // from your tasks. Finish creating all your Tasks here.
37 // Unit testing: this can return an array of Task objects that
38 // represents the correct ordering of your tasks after Sort(). If
39 // you don't care, which is quite possible, just return null.
40 public virtual Task
[] make_tasks()
45 // Called when all Tasks have been created, but you might want to
46 // fixup some of their attributes.
48 // This is where you can, say, fill in the "parent" field if you
49 // want to refer to Tasks that were created by other Sources.
51 // You can also use this phase to override estimates on bugs
52 // produced by other Sources. Be careful with this, since if you
53 // get two Sources fighting over estimates, results will be
54 // undefined. (We use this to let you override Fogbugz estimates
55 // when FogBugz isn't flexible enough)
56 public virtual void cleanup_tasks()
60 // Called after the scheduling phase has run. If your plugin wants
61 // to look at the finished schedule or task list and record or
62 // analyze information, do it here.
63 public virtual void post_schedule()
69 public class SourceRegistry
71 WvLog log
= new WvLog("SourceRegistry");
72 Hashtable sources
= new Hashtable();
74 public delegate Source
Creator(Schedulator s
, string name
,
75 string prefix
, string suffix
);
77 public SourceRegistry()
79 register("test", TestSource
.create
);
80 register("string", StringSource
.create
);
81 register("file", StringSource
.create_from_file
);
82 register("fogbugz", FogBugzSource
.create
);
83 register("mantis", MantisSource
.create
);
84 register("googlecode", GoogleCodeSource
.create
);
85 register("logstr", LogSource
.create
);
86 register("log", LogSource
.create_from_file_id
);
87 register("results", ResultSource
.create
);
88 register("result", ResultSource
.create
);
91 public void register(string prefix
, Creator create
)
93 log
.print("registering {0}\n", prefix
);
94 sources
.Add(prefix
, create
);
97 public Source
create(Schedulator s
, string name
, string moniker
)
99 char[] splitchars
= {':'}
;
100 string[] list
= moniker
.Split(splitchars
, 2);
101 string prefix
= list
[0];
102 string suffix
= list
.Length
>1 ? list
[1] : "";
104 log
.print("create: prefix='{0}', suffix='{1}'\n", prefix
, suffix
);
106 if (!sources
.Contains(prefix
))
110 Creator func
= (Creator
)sources
[prefix
];
111 return func(s
, name
, prefix
, suffix
);