View Javadoc

1   //
2   // $Revision: 5 $
3   // $LastChangedBy: mhanns $
4   // $Date: 2010-04-01 10:10:45 +0200 (Do, 01 Apr 2010) $
5   // $HeadURL:
6   // svn://localhost/winf-ps/trunk/repository/src/main/java/de/uni_leipzig/wifa/iwi/mr3/dao/ModelRepositoryDao.java
7   // $
8   //
9   
10  package de.uni_leipzig.wifa.iwi.mr3.dao;
11  
12  import java.util.Map;
13  
14  import org.eclipse.emf.ecore.EObject;
15  import org.eclipse.emf.ecore.resource.Resource;
16  
17  import de.uni_leipzig.wifa.iwi.mr3.common.Match;
18  import de.uni_leipzig.wifa.iwi.mr3.service.MRException;
19  
20  /**
21   * Model repository DAO.
22   */
23  public interface ModelRepositoryDao
24  {
25    /**
26     * Initialize the persitence media.
27     * <p>
28     * Make all stept to create an empty database. This action destroys any
29     * existing datastore.
30     */
31    void startUp();
32  
33    /**
34     * Lifecycle method.
35     * <p>
36     * Close all resources.
37     */
38    void shutDown();
39  
40    /**
41     * Load model by given namespace URI.
42     * <p>
43     * If no model will be found, the return value is <code>null</code>.
44     * 
45     * @param nsUri
46     *          Namespace URI
47     * @param registry
48     *          the registry for loaded elements
49     * @return Model
50     */
51    EObject load(final String nsUri, final Map<Object, EObject> registry);
52  
53    /**
54     * Save {@link Resource}.
55     * <p>
56     * The resource will be saved under it's nsURI. Any existing model can not be
57     * overwritten. In case of existence it must be deleted before saved.
58     * <p>
59     * Try {@link ModelRepositoryDao#modelExists(String)} to test whether the
60     * model still exists.
61     * 
62     * @param resource
63     *          EMF {@link Resource} to save
64     * @throws MRException
65     *           Application logic exception
66     */
67    void save(Resource resource) throws MRException;
68  
69    /**
70     * Check whether a model exists for the given namespace URI.
71     * 
72     * @param nsUri
73     *          Namespace URI to test
74     * @return <code>true</code> if a model exists inside the repository for the
75     *         given namespace URI, otherwise <code>false</code>
76     */
77    boolean modelExists(String nsUri);
78  
79    /**
80     * Remove the model from repository with the given namespace URI.
81     * <p>
82     * If no model with given namespace URI exists, no action will be taken.
83     * 
84     * @param nsUri
85     *          Namespace URI of model to delete
86     * @param cascading
87     *          Whether all the instance models shoud also deleted
88     * @throws MRException
89     *           Application logic exception
90     */
91    void delete(String nsUri, boolean cascading) throws MRException;
92  
93    /**
94     * Find all model instances of the model with the given nsURI.
95     * 
96     * @param metaNsUri
97     *          nsURI of meta model
98     * @return Array of instance model's nsURI.
99     */
100   String[] getInstanceModels(String metaNsUri);
101 
102   /**
103    * Finds all instances of given classifiers that contain given expression.
104    * 
105    * @param expression
106    *          the expression to search for
107    * @param classifiers
108    *          the classifiers to search in
109    * @param isRegEx
110    *          RegExp search
111    * @param isCaseSensitive
112    *          Case sensitive search
113    * @return the array of found models matching the given expression
114    */
115   Match[] find(String expression, String[] classifiers, final boolean isRegEx, final boolean isCaseSensitive);
116 }