View Javadoc

1   /**
2    * Copyright 2004-2013 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  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.impl.ServiceContractModelPescXsdLoader;
23  import org.kuali.student.contract.model.util.ModelFinder;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  
27  /**
28   *
29   * @author nwright
30   */
31  public class EachMethodServiceWriterForOneService {
32      
33      private static Logger log = LoggerFactory.getLogger(EachMethodServiceWriterForOneService.class);
34  
35      private ServiceContractModel model;
36      private ModelFinder finder;
37      private String directory;
38      private String rootPackage;
39      private String servKey;
40  
41      public EachMethodServiceWriterForOneService(ServiceContractModel model,
42              String directory,
43              String rootPackage,
44              String servKey) {
45          this.model = model;
46          this.finder = new ModelFinder(model);
47          this.directory = directory;
48          this.rootPackage = rootPackage;
49          this.servKey = servKey;
50      }
51  
52      /**
53       * Write out the entire file
54       * @param out
55       */
56      public void write() {
57          List<ServiceMethod> methods = finder.getServiceMethodsInService(servKey);
58          if (methods.isEmpty()) {
59              log.warn("No methods defined for servKey: " + servKey);
60              return;
61          }
62  
63          // the service method
64          log.info("Generating info interfaces");
65          for (ServiceMethod method : methods) {
66              log.info("Generating method for service " + method.getService() + "." + method.getName());
67              new EachMethodServiceWriterForOneMethod(model, directory, rootPackage, servKey, method).write();
68          }
69  
70      }
71  
72  }