View Javadoc
1   /*
2    * Copyright (C) 2010-2014 Hamburg Sud and the contributors.
3    *
4    * Licensed under the Apache 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.apache.org/licenses/LICENSE-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.aludratest.service.edifactfile.edifatto;
17  
18  import org.aludratest.content.edifact.edifatto.EdifattoContent;
19  import org.aludratest.service.AbstractAludraService;
20  import org.aludratest.service.edifactfile.EdifactFileCondition;
21  import org.aludratest.service.edifactfile.EdifactFileInteraction;
22  import org.aludratest.service.edifactfile.EdifactFileService;
23  import org.aludratest.service.edifactfile.EdifactFileVerification;
24  import org.aludratest.service.file.FileService;
25  
26  /** 
27   * Default implementation of the EdifactService 
28   * which employs Edifatto for EDIFACR/X12 processing.
29   * @author Volker Bergmann
30   */
31  public class EdifattoFileService extends AbstractAludraService implements EdifactFileService {
32      
33      private FileService fileService;
34      
35      /** The action object that implements all EdifactService action interfaces */
36      private EdifattoFileAction action;
37      
38      /** Initializes the service */
39      @Override
40      public void initService() {
41          this.fileService = aludraServiceContext.getNonLoggingService(FileService.class);
42          this.action = new EdifattoFileAction(new EdifattoContent(), fileService);
43      }
44      
45      
46      // AludraService interface implementation ----------------------------------
47      
48      /** Provides a description of the service */
49      @Override
50      public String getDescription() {
51          return getClass().getSimpleName();
52      }
53      
54      /** Provides an object to parses and save EDIFACT and X12 documents from and to streams. */
55      @Override
56      public EdifactFileInteraction perform() {
57          return action;
58      }
59      
60      /** Provides an object to verify EDIFACT or X12 documents. */
61      @Override
62      public EdifactFileVerification verify() {
63          return action;
64      }
65      
66      /** Provides an object for performing queries on EDIFACT or X12 interchanges 
67       *  and analyze their differences. */
68      @Override
69      public EdifactFileCondition check() {
70          return action;
71      }
72      
73      @Override
74      public FileService getFileService() {
75          return fileService;
76      }
77      
78      /** Closes the service */
79      @Override
80      public void close() {
81          // nothing to do
82      }
83  
84  }