View Javadoc
1   /*
2    * (c) Copyright 2006-2020 by rapiddweller GmbH & Volker Bergmann. All rights reserved.
3    *
4    * Redistribution and use in source and binary forms, with or without
5    * modification, is permitted under the terms of the
6    * GNU General Public License.
7    *
8    * For redistributing this software or a derivative work under a license other
9    * than the GPL-compatible Free Software License as defined by the Free
10   * Software Foundation or approved by OSI, you must first obtain a commercial
11   * license to this software product from rapiddweller GmbH & Volker Bergmann.
12   *
13   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14   * WITHOUT A WARRANTY OF ANY KIND. ALL EXPRESS OR IMPLIED CONDITIONS,
15   * REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
16   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
17   * HEREBY EXCLUDED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
18   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24   * POSSIBILITY OF SUCH DAMAGE.
25   */
26  
27  package com.rapiddweller.benerator;
28  
29  import com.rapiddweller.benerator.storage.AbstractStorageSystem;
30  import com.rapiddweller.common.Context;
31  import com.rapiddweller.format.DataSource;
32  import com.rapiddweller.model.data.DescriptorProvider;
33  import com.rapiddweller.model.data.Entity;
34  
35  import java.io.Closeable;
36  import java.io.Flushable;
37  
38  /**
39   * Abstract interface characterizing an Entity storage system.
40   * An implementation of this interface must inherit the class {@link AbstractStorageSystem}
41   * if it is needs to be forward compatible.<br/><br/>
42   * <br/>
43   * Created: 27.06.2007 23:02:21
44   *
45   * @author Volker Bergmann
46   * @since 0.4.0
47   */
48  public interface StorageSystem extends DescriptorProvider, Closeable, Flushable {
49  
50    /**
51     * Returns a name that identifies the database
52     */
53    @Override
54    String getId();
55  
56    /**
57     * Creates an iterator that provides all entities of given type.
58     *
59     * @param type     the type
60     * @param selector the selector
61     * @param context  the context
62     * @return the data source
63     */
64    DataSource<Entity> queryEntities(String type, String selector, Context context);
65  
66    /**
67     * Queries for entity ids
68     *
69     * @param type     the type
70     * @param selector the selector
71     * @param context  the context
72     * @return the data source
73     */
74    DataSource<?> queryEntityIds(String type, String selector, Context context);
75  
76    /**
77     * Creates an Iterable for repetitive iteration through the results of the specified query.
78     *
79     * @param selector the selector
80     * @param simplify the simplify
81     * @param context  the context
82     * @return the data source
83     */
84    DataSource<?> query(String selector, boolean simplify, Context context);
85  
86    /**
87     * Persists a new entity.
88     *
89     * @param entity the entity
90     */
91    void store(Entity entity);
92  
93    /**
94     * Updates an existing entity.
95     *
96     * @param entity the entity
97     */
98    void update(Entity entity);
99  
100   /**
101    * Executes a command on the storage system
102    *
103    * @param command the command
104    * @return the object
105    */
106   Object execute(String command);
107 
108   /**
109    * Assures that all data that has been {@link #store(Entity)}d, is send to the target system.
110    */
111   @Override
112   void flush();
113 
114   /**
115    * Closes the database.
116    */
117   @Override
118   void close();
119 
120 }