1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Dashboard
.Web
.Service
19 using System
.Xml
.XPath
;
21 using ThoughtWorks
.CruiseControl
.Remote
;
22 using ThoughtWorks
.CruiseControl
.Core
.Publishers
;
25 public enum DetailEnum
35 public class ContentTransformation
37 private readonly ICruiseManager cruiseManager
;
38 private readonly IBuildLogTransformer logTransformer
;
40 public ContentTransformation(ICruiseManager cruiseManager
, IBuildLogTransformer logTransformer
)
42 this.logTransformer
= logTransformer
;
43 this.cruiseManager
= cruiseManager
;
46 public String
GetSummary(String name
, String log
)
48 String xsl
= GetXslFullFileName("header.xsl");
50 String content
= cruiseManager
.GetLog(name
, log
);
52 XPathDocument document
= new XPathDocument(new StringReader(content
));
54 return logTransformer
.Transform(document
, xsl
);
57 public String
GetDetail(String name
, String log
, DetailEnum detail
)
61 if (detail
== DetailEnum
.Summary
)
63 return GetSummary(name
, log
);
65 else if (detail
== DetailEnum
.Compilation
)
67 xsl
= GetXslFullFileName("compile.xsl");
69 else if (detail
== DetailEnum
.Modifications
)
71 xsl
= GetXslFullFileName("modifications.xsl");
73 else if (detail
== DetailEnum
.UnitTestsDetail
)
75 xsl
= GetXslFullFileName("unittests.xsl");
77 else if (detail
== DetailEnum
.UnitTestsSummary
)
79 xsl
= GetXslFullFileName("AlternativeNUnitDetails.xsl");
82 String content
= cruiseManager
.GetLog(name
, log
);
84 XPathDocument document
= new XPathDocument(new StringReader(content
));
86 return logTransformer
.Transform(document
, xsl
);
89 private String
GetXslFullFileName(String xslFile
)
91 return Path
.Combine(AppDomain
.CurrentDomain
.BaseDirectory
, "xsl/" + xslFile
);