001 /** 002 * Copyright 2004-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 /* 017 * To change this template, choose Tools | Templates 018 * and open the template in the editor. 019 */ 020 package org.kuali.student.contract.model.util; 021 022 import java.io.PrintStream; 023 024 import org.kuali.student.contract.model.ServiceMethod; 025 import org.kuali.student.contract.model.ServiceMethodError; 026 import org.kuali.student.contract.model.ServiceMethodParameter; 027 028 /** 029 * 030 * @author nwright 031 */ 032 public class ServiceMethodDumper { 033 034 private ServiceMethod method; 035 private PrintStream out; 036 037 public ServiceMethodDumper(ServiceMethod method, PrintStream out) { 038 this.method = method; 039 this.out = out; 040 } 041 042 public void dump() { 043 out.println(method.getService() + "." + method.getName() + " - " + method.getDescription()); 044 for (ServiceMethodParameter param : method.getParameters()) { 045 out.println(" Param: " + param.getName() + " (" + param.getType() + ") " + param.getDescription() + " http://XXX" + param.getUrl()); 046 } 047 for (ServiceMethodError param : method.getErrors()) { 048 out.println(" Error: " + param.getType() + " - " + param.getDescription()); 049 } 050 out.println(" return: " + method.getReturnValue().getType() + " - " + method.getReturnValue(). 051 getDescription() + " http://XXX" + method.getReturnValue().getUrl()); 052 } 053 054 public void writeTabbedHeader() { 055 out.print("Service"); 056 out.print("\t"); 057 out.print("Key"); 058 out.print("\t"); 059 out.print("ShortName"); 060 out.print("\t"); 061 out.print("LongName"); 062 out.print("\t"); 063 out.print("Description"); 064 out.print("\t"); 065 out.print("url"); 066 out.println(""); 067 } 068 069 public void writeTabbedData() { 070 out.print(method.getService()); 071 out.print("\t"); 072 out.print("Method"); 073 out.print("\t"); 074 out.print(method.getName()); 075 out.print("\t"); 076 out.print(""); 077 out.print("\t"); 078 out.print(""); 079 out.print("\t"); 080 out.print(method.getUrl()); 081 out.println(); 082 083 out.print(method.getService()); 084 out.print("\t"); 085 out.print("Description"); 086 out.print("\t"); 087 out.print(method.getDescription()); 088 out.print("\t"); 089 out.print(""); 090 out.println(); 091 if (method.getParameters().size() == 0) { 092 out.print(method.getService()); 093 out.print("\t"); 094 out.print("Parameters"); 095 out.print("\t"); 096 out.print("None"); 097 out.print("\t"); 098 out.print("None"); 099 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 }