View Javadoc
1   /**
2    * Copyright 2004-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  /*
17   * To change this template, choose Tools | Templates
18   * and open the template in the editor.
19   */
20  package org.kuali.student.contract.model.util;
21  
22  import java.io.PrintStream;
23  
24  import org.kuali.student.contract.model.ServiceMethod;
25  import org.kuali.student.contract.model.ServiceMethodError;
26  import org.kuali.student.contract.model.ServiceMethodParameter;
27  
28  /**
29   *
30   * @author nwright
31   */
32  public class ServiceMethodDumper {
33  
34      private ServiceMethod method;
35      private PrintStream out;
36  
37      public ServiceMethodDumper(ServiceMethod method, PrintStream out) {
38          this.method = method;
39          this.out = out;
40      }
41  
42      public void dump() {
43          out.println(method.getService() + "." + method.getName() + " - " + method.getDescription());
44          for (ServiceMethodParameter param : method.getParameters()) {
45              out.println(" Param: " + param.getName() + " (" + param.getType() + ") " + param.getDescription() + " http://XXX" + param.getUrl());
46          }
47          for (ServiceMethodError param : method.getErrors()) {
48              out.println(" Error: " + param.getType() + " - " + param.getDescription());
49          }
50          out.println(" return: " + method.getReturnValue().getType() + " - " + method.getReturnValue().
51                  getDescription() + " http://XXX" + method.getReturnValue().getUrl());
52      }
53  
54      public void writeTabbedHeader() {
55          out.print("Service");
56          out.print("\t");
57          out.print("Key");
58          out.print("\t");
59          out.print("ShortName");
60          out.print("\t");
61          out.print("LongName");
62          out.print("\t");
63          out.print("Description");
64          out.print("\t");
65          out.print("url");
66          out.println("");
67      }
68  
69      public void writeTabbedData() {
70          out.print(method.getService());
71          out.print("\t");
72          out.print("Method");
73          out.print("\t");
74          out.print(method.getName());
75          out.print("\t");
76          out.print("");
77          out.print("\t");
78          out.print("");
79          out.print("\t");
80          out.print(method.getUrl());
81          out.println();
82  
83          out.print(method.getService());
84          out.print("\t");
85          out.print("Description");
86          out.print("\t");
87          out.print(method.getDescription());
88          out.print("\t");
89          out.print("");
90          out.println();
91          if (method.getParameters().size() == 0) {
92              out.print(method.getService());
93              out.print("\t");
94              out.print("Parameters");
95              out.print("\t");
96              out.print("None");
97              out.print("\t");
98              out.print("None");
99              out.print("\t");
100             out.print("No parameters");
101             out.print("\t");
102             out.print("");
103             out.println();
104         } else {
105             String parameters = "Parameters";
106             for (ServiceMethodParameter param : method.getParameters()) {
107                 out.print(method.getService());
108                 out.print("\t");
109                 out.print(parameters);
110                 parameters = "";
111                 out.print("\t");
112                 out.print(param.getType());
113                 out.print("\t");
114                 out.print(param.getName());
115                 out.print("\t");
116                 out.print(param.getDescription());
117                 out.print("\t");
118                 out.print(param.getUrl());
119                 out.println();
120             }
121         }
122 
123         out.print(method.getService());
124         out.print("\t");
125         out.print("Return");
126         out.print("\t");
127         out.print(method.getReturnValue().getType());
128         out.print("\t");
129         out.print(method.getReturnValue().getDescription());
130         out.print("\t");
131         out.print("");
132         out.print("\t");
133         out.print(method.getReturnValue().getUrl());
134         out.println();
135 
136         String errors = "Errors";
137         for (ServiceMethodError error : method.getErrors()) {
138             out.print(method.getService());
139             out.print("\t");
140             out.print(errors);
141             errors = "";
142             out.print("\t");
143             out.print(error.getType());
144             out.print("\t");
145             out.print(error.getDescription());
146             out.print("\t");
147             out.print("");
148             out.print("\t");
149             out.print("");
150             out.println();
151         }
152 
153         out.print(method.getService());
154         out.print("\t");
155         out.print("Capabilities");
156         out.print("\t");
157         out.print("");
158         out.print("\t");
159         out.print("");
160         out.print("\t");
161         out.print("");
162         out.print("\t");
163         out.print("");
164         out.println();
165 
166         out.print(method.getService());
167         out.print("\t");
168         out.print("Use Cases");
169         out.print("\t");
170         out.print("");
171         out.print("\t");
172         out.print("");
173         out.print("\t");
174         out.print("");
175         out.print("\t");
176         out.print("");
177         out.println();
178 
179         out.print(method.getService());
180         out.print("\t");
181         out.print("Comments/Feedback");
182         out.print("\t");
183         out.print("");
184         out.print("\t");
185         out.print("");
186         out.print("\t");
187         out.print("");
188         out.print("\t");
189         out.print("");
190         out.println();
191     }
192 }