]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.fileimport/src/org/simantics/fileimport/IGenericFileImport.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.fileimport / src / org / simantics / fileimport / IGenericFileImport.java
1 package org.simantics.fileimport;
2
3 import java.nio.file.Path;
4 import java.util.Map;
5 import java.util.Optional;
6
7 import org.simantics.db.Resource;
8
9 /**
10  * Base interface for performing file imports. 
11  * 
12  * Usually with Simantics products every file that will be imported will become 
13  * a resource in the Simantics database. For these cases see {@link SimanticsResourceFileImport}
14  * 
15  * @author Jani Simomaa
16  *
17  */
18 public interface IGenericFileImport {
19
20     /**
21      * Performs the import for the given file, using the default parent defined in the file-specific import implementation
22      * Calls perform(parent, file) with the defaultParent it finds
23      * 
24      * @param file Path to file to import
25      * @return Optional string which will be the identifier of the imported file which can later be used for removing the imported entity
26      * @throws Exception
27      */
28     Optional<String> performWithDefaultParent(Path file) throws Exception;
29     
30     Optional<Resource> perform(Resource parent, Path file) throws Exception;
31     
32     /**
33      * Remove the entity
34      * 
35      * @param identifier String identifier which can be used to remove the imported entity
36      */
37     void remove(String identifier) throws Exception;
38     
39     /**
40      * Returns a key-value map for file extensions this importer can handle
41      * 
42      * @return Map<String, String> allowed extensions this service can handle. Key is the extension e.g. <code>.sharedLibrary</code> and the value is the description of the extension
43      */
44     Map<String, String> allowedExtensionsWithFilters();
45
46     /**
47      * Choose the default parent resource in the specific implementations of the importer
48      * Can be null, in which case the default parent must always be provided from a selection UI or explicitly defined
49      * @return
50      */
51     public abstract Resource defaultParentResource();
52     
53 }