X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.fileimport%2Fsrc%2Forg%2Fsimantics%2Ffileimport%2FIGenericFileImport.java;h=16df3ab457dd84b4b5217518b2b83c907a61f000;hb=664f37a026967c90a9a8a4ef3c5336ee426f67aa;hp=2de1cc7427dd5f03367b9ea310731011a7e701a8;hpb=96bb7ef9cbe42d82eb58306d8f9b62392cc29ba8;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.fileimport/src/org/simantics/fileimport/IGenericFileImport.java b/bundles/org.simantics.fileimport/src/org/simantics/fileimport/IGenericFileImport.java index 2de1cc742..16df3ab45 100644 --- a/bundles/org.simantics.fileimport/src/org/simantics/fileimport/IGenericFileImport.java +++ b/bundles/org.simantics.fileimport/src/org/simantics/fileimport/IGenericFileImport.java @@ -1,33 +1,53 @@ -package org.simantics.fileimport; - -import java.nio.file.Path; -import java.util.Map; -import java.util.Optional; - -/** - * @author Jani Simomaa - * - */ -public interface IGenericFileImport { - - /** - * Performs the import procedure for the given file - * - * @param file - * file to import - */ - Optional perform(Path file) throws Exception; - - /** - * @param resource - */ - void remove(String resource) throws Exception; - - /** - * Returns a key-value map for file extensions this importer can handle - * - * @return - */ - Map allowedExtensionsWithFilters(); - -} +package org.simantics.fileimport; + +import java.nio.file.Path; +import java.util.Map; +import java.util.Optional; + +import org.simantics.db.Resource; + +/** + * Base interface for performing file imports. + * + * Usually with Simantics products every file that will be imported will become + * a resource in the Simantics database. For these cases see {@link SimanticsResourceFileImport} + * + * @author Jani Simomaa + * + */ +public interface IGenericFileImport { + + /** + * Performs the import for the given file, using the default parent defined in the file-specific import implementation + * Calls perform(parent, file) with the defaultParent it finds + * + * @param file Path to file to import + * @return Optional string which will be the identifier of the imported file which can later be used for removing the imported entity + * @throws Exception + */ + Optional performWithDefaultParent(Path file) throws Exception; + + Optional perform(Resource parent, Path file) throws Exception; + + /** + * Remove the entity + * + * @param identifier String identifier which can be used to remove the imported entity + */ + void remove(String identifier) throws Exception; + + /** + * Returns a key-value map for file extensions this importer can handle + * + * @return Map allowed extensions this service can handle. Key is the extension e.g. .sharedLibrary and the value is the description of the extension + */ + Map allowedExtensionsWithFilters(); + + /** + * Choose the default parent resource in the specific implementations of the importer + * Can be null, in which case the default parent must always be provided from a selection UI or explicitly defined + * @return + */ + public abstract Resource defaultParentResource(); + +}