001    /*
002     * To change this template, choose Tools | Templates
003     * and open the template in the editor.
004     */
005    package org.kuali.student.contract.model.util;
006    
007    import java.io.PrintStream;
008    
009    import org.kuali.student.contract.model.ServiceMethod;
010    import org.kuali.student.contract.model.ServiceMethodError;
011    import org.kuali.student.contract.model.ServiceMethodParameter;
012    
013    /**
014     *
015     * @author nwright
016     */
017    public class ServiceMethodDumper {
018    
019        private ServiceMethod method;
020        private PrintStream out;
021    
022        public ServiceMethodDumper(ServiceMethod method, PrintStream out) {
023            this.method = method;
024            this.out = out;
025        }
026    
027        public void dump() {
028            out.println(method.getService() + "." + method.getName() + " - " + method.getDescription());
029            for (ServiceMethodParameter param : method.getParameters()) {
030                out.println(" Param: " + param.getName() + " (" + param.getType() + ") " + param.getDescription() + " http://XXX" + param.getUrl());
031            }
032            for (ServiceMethodError param : method.getErrors()) {
033                out.println(" Error: " + param.getType() + " - " + param.getDescription());
034            }
035            out.println(" return: " + method.getReturnValue().getType() + " - " + method.getReturnValue().
036                    getDescription() + " http://XXX" + method.getReturnValue().getUrl());
037        }
038    
039        public void writeTabbedHeader() {
040            out.print("Service");
041            out.print("\t");
042            out.print("Key");
043            out.print("\t");
044            out.print("ShortName");
045            out.print("\t");
046            out.print("LongName");
047            out.print("\t");
048            out.print("Description");
049            out.print("\t");
050            out.print("url");
051            out.println("");
052        }
053    
054        public void writeTabbedData() {
055            out.print(method.getService());
056            out.print("\t");
057            out.print("Method");
058            out.print("\t");
059            out.print(method.getName());
060            out.print("\t");
061            out.print("");
062            out.print("\t");
063            out.print("");
064            out.print("\t");
065            out.print(method.getUrl());
066            out.println();
067    
068            out.print(method.getService());
069            out.print("\t");
070            out.print("Description");
071            out.print("\t");
072            out.print(method.getDescription());
073            out.print("\t");
074            out.print("");
075            out.println();
076            if (method.getParameters().size() == 0) {
077                out.print(method.getService());
078                out.print("\t");
079                out.print("Parameters");
080                out.print("\t");
081                out.print("None");
082                out.print("\t");
083                out.print("None");
084                out.print("\t");
085                out.print("No parameters");
086                out.print("\t");
087                out.print("");
088                out.println();
089            } else {
090                String parameters = "Parameters";
091                for (ServiceMethodParameter param : method.getParameters()) {
092                    out.print(method.getService());
093                    out.print("\t");
094                    out.print(parameters);
095                    parameters = "";
096                    out.print("\t");
097                    out.print(param.getType());
098                    out.print("\t");
099                    out.print(param.getName());
100                    out.print("\t");
101                    out.print(param.getDescription());
102                    out.print("\t");
103                    out.print(param.getUrl());
104                    out.println();
105                }
106            }
107    
108            out.print(method.getService());
109            out.print("\t");
110            out.print("Return");
111            out.print("\t");
112            out.print(method.getReturnValue().getType());
113            out.print("\t");
114            out.print(method.getReturnValue().getDescription());
115            out.print("\t");
116            out.print("");
117            out.print("\t");
118            out.print(method.getReturnValue().getUrl());
119            out.println();
120    
121            String errors = "Errors";
122            for (ServiceMethodError error : method.getErrors()) {
123                out.print(method.getService());
124                out.print("\t");
125                out.print(errors);
126                errors = "";
127                out.print("\t");
128                out.print(error.getType());
129                out.print("\t");
130                out.print(error.getDescription());
131                out.print("\t");
132                out.print("");
133                out.print("\t");
134                out.print("");
135                out.println();
136            }
137    
138            out.print(method.getService());
139            out.print("\t");
140            out.print("Capabilities");
141            out.print("\t");
142            out.print("");
143            out.print("\t");
144            out.print("");
145            out.print("\t");
146            out.print("");
147            out.print("\t");
148            out.print("");
149            out.println();
150    
151            out.print(method.getService());
152            out.print("\t");
153            out.print("Use Cases");
154            out.print("\t");
155            out.print("");
156            out.print("\t");
157            out.print("");
158            out.print("\t");
159            out.print("");
160            out.print("\t");
161            out.print("");
162            out.println();
163    
164            out.print(method.getService());
165            out.print("\t");
166            out.print("Comments/Feedback");
167            out.print("\t");
168            out.print("");
169            out.print("\t");
170            out.print("");
171            out.print("\t");
172            out.print("");
173            out.print("\t");
174            out.print("");
175            out.println();
176        }
177    }