View Javadoc

1   /*
2    * Copyright 2010 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.osedu.org/licenses/ECL-2.0
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  package org.kuali.student.contract.writer.service;
17  
18  import java.util.List;
19  
20  import org.kuali.student.contract.model.ServiceContractModel;
21  import org.kuali.student.contract.model.ServiceMethod;
22  import org.kuali.student.contract.model.util.ModelFinder;
23  
24  /**
25   *
26   * @author nwright
27   */
28  public class EachMethodServiceWriterForOneService {
29  
30      private ServiceContractModel model;
31      private ModelFinder finder;
32      private String directory;
33      private String rootPackage;
34      private String servKey;
35  
36      public EachMethodServiceWriterForOneService(ServiceContractModel model,
37              String directory,
38              String rootPackage,
39              String servKey) {
40          this.model = model;
41          this.finder = new ModelFinder(model);
42          this.directory = directory;
43          this.rootPackage = rootPackage;
44          this.servKey = servKey;
45      }
46  
47      /**
48       * Write out the entire file
49       * @param out
50       */
51      public void write() {
52          List<ServiceMethod> methods = finder.getServiceMethodsInService(servKey);
53          if (methods.isEmpty()) {
54              System.out.println("No methods defined for servKey: " + servKey);
55              return;
56          }
57  
58          // the service method
59          System.out.println("Generating info interfaces");
60          for (ServiceMethod method : methods) {
61              System.out.println("Generating method for service " + method.getService() + "." + method.getName());
62              new EachMethodServiceWriterForOneMethod(model, directory, rootPackage, servKey, method).write();
63          }
64  
65      }
66  
67  }