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; 17 18 import java.io.OutputStream; 19 import java.util.Map; 20 21 import org.aludratest.impl.log4testing.AttachParameter; 22 import org.aludratest.impl.log4testing.AttachResult; 23 import org.aludratest.impl.log4testing.ElementName; 24 import org.aludratest.impl.log4testing.ElementType; 25 import org.aludratest.impl.log4testing.TechnicalArgument; 26 import org.aludratest.impl.log4testing.TechnicalLocator; 27 import org.aludratest.service.Interaction; 28 import org.databene.edifatto.EdiFormatSymbols; 29 import org.databene.edifatto.model.Interchange; 30 31 /** 32 * Parses and saves EDIFACT and X12 documents from and to streams. 33 * @author Volker Bergmann 34 */ 35 public interface EdifactFileInteraction extends Interaction { 36 37 /** Polls the file system until a file at the given path is found 38 * or a timeout occurs. 39 * @param elementType 40 * @param elementName 41 * @param filePath */ 42 void waitUntilExists( 43 @ElementType String elementType, 44 @ElementName String elementName, 45 @TechnicalLocator String filePath); 46 47 /** Polls the file system until no file is found at the given path. 48 * @param elementType 49 * @param elementName 50 * @param filePath */ 51 void waitUntilNotExists( 52 @ElementType String elementType, 53 @ElementName String elementName, 54 @TechnicalLocator String filePath); 55 56 /** Deletes a file 57 * @param elementType 58 * @param elementName 59 * @param filePath the path of the file to delete */ 60 void delete( 61 @ElementType String elementType, 62 @ElementName String elementName, 63 @TechnicalLocator String filePath); 64 65 /** Writes an EDIFACT or X12 interchange to an {@link OutputStream}. 66 * @param elementType 67 * @param elementName 68 * @param interchange the interchange to persist 69 * @param filePath the path of the file to write 70 * @param overwrite flag that indicates whether a pre-existing file may be overwritten */ 71 void writeInterchange( 72 @ElementType String elementType, 73 @ElementName String elementName, 74 @AttachParameter("Interchange") Interchange interchange, 75 @TechnicalLocator String filePath, 76 @TechnicalArgument boolean overwrite); 77 78 /** Creates an {@link Interchange} based on a template file and a variable tree 79 * @param elementType 80 * @param elementName 81 * @param templateUri the path of the template file 82 * @param symbols the symbols to use 83 * @param variables the variable tree 84 * @return a new Interchange containing the information from the variable tree */ 85 @AttachResult("Created Interchange") 86 Interchange createInterchange( 87 @ElementType String elementType, 88 @ElementName String elementName, 89 @TechnicalLocator String templateUri, 90 @TechnicalArgument EdiFormatSymbols symbols, 91 @TechnicalArgument Map<String, Object> variables); 92 93 /** Reads an {@link Interchange} from a file system. 94 * @param elementType 95 * @param elementName 96 * @param filePath the full path of the file to read 97 * @return an {@link Interchange} data structure 98 * that contains the EDI data mapped to a tree structure */ 99 @AttachResult("Read Interchange") 100 Interchange readInterchange( 101 @ElementType String elementType, 102 @ElementName String elementName, 103 @TechnicalLocator String filePath); 104 105 }