1 package org.simantics.fileimport;
3 import java.nio.file.Path;
5 import java.util.Optional;
7 import org.simantics.db.Resource;
10 * Base interface for performing file imports.
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}
15 * @author Jani Simomaa
18 public interface IGenericFileImport {
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
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
28 Optional<String> performWithDefaultParent(Path file) throws Exception;
30 Optional<Resource> perform(Resource parent, Path file) throws Exception;
35 * @param identifier String identifier which can be used to remove the imported entity
37 void remove(String identifier) throws Exception;
40 * Returns a key-value map for file extensions this importer can handle
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
44 Map<String, String> allowedExtensionsWithFilters();
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
51 public abstract Resource defaultParentResource();