Class ExportImportUtils
java.lang.Object
org.qubership.atp.mia.ei.component.ExportImportUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Map<UUID, ProjectDirectory> createMapIdToExistingDirectory(ProjectConfiguration projectConfiguration) To quickly map between UUID and ProjectDirector, maps directory id -> ProjectDirectory.static Map<UUID, ProjectFile> createMapIdToExistingFile(ProjectConfiguration projectConfiguration) To quickly map between UUID and ProjectFile, maps directory id -> ProjectFile.static Map<UUID, Map<String, ProjectDirectory>> createMapParentIdToDirectoryNames(ProjectConfiguration projectConfiguration) Map to quickly handle conflict with names in same folder.static Map<UUID, Map<String, ProjectFile>> createMapParentIdToFileNames(ProjectConfiguration projectConfiguration) Map to quickly handle conflict with names in same folder.static StringgenerateCopyEntryName(String name) In case of file name conflicts this method provide unique name for existing file.static UUIDgetFolderId(ProjectDirectory directory) Get sourceId ofProjectDirectory, if not present gets id.static <K,V> Map <V, K> reverseMap(Map<K, V> originalMap) Reverses key and values in map, key becomes value and value becomes key.
-
Constructor Details
-
ExportImportUtils
public ExportImportUtils()
-
-
Method Details
-
getFolderId
Get sourceId ofProjectDirectory, if not present gets id.- Parameters:
directory- - directory to get id from.- Returns:
- sourceId or id or null.
-
generateCopyEntryName
In case of file name conflicts this method provide unique name for existing file. e.g. File1.txt -> File1.txt_ConflictImport_1732861570280- Parameters:
name- - current name to modify.- Returns:
- modified name with some suffix and current UNIX timestamp.
-
createMapIdToExistingDirectory
public static Map<UUID,ProjectDirectory> createMapIdToExistingDirectory(ProjectConfiguration projectConfiguration) To quickly map between UUID and ProjectDirector, maps directory id -> ProjectDirectory. Map contains sourceId and id at the same time in case if they differ, Sometimes conflicts can occur between sourceId and id, e.g. Given: Directory1 id=1 sourceId=2 Directory2 id=2 sourceId=2 Then we have map with: 1 -> Directory1 2 -> Directory2- Parameters:
projectConfiguration- - ProjectConfiguration.- Returns:
- Map.
-
createMapParentIdToDirectoryNames
public static Map<UUID,Map<String, createMapParentIdToDirectoryNamesProjectDirectory>> (ProjectConfiguration projectConfiguration) Map to quickly handle conflict with names in same folder. folder id -> Map(folder name -> ProjectDirectory) UUID -> Map(String -> ProjectDirectory) e.g. Given: need to create directory2 inside directory1, need to check whether directory1 already contains a subdirectory named directory2. Using the UUID of directory1, access a Map (generated by this method) that returnsMap<String, ProjectDirectory>where the keys represent the folder names within directory1. If the key for directory2 exists, a duplicate is detected.- Parameters:
projectConfiguration- ProjectConfiguration.- Returns:
- Map of maps.
-
createMapParentIdToFileNames
public static Map<UUID,Map<String, createMapParentIdToFileNamesProjectFile>> (ProjectConfiguration projectConfiguration) Map to quickly handle conflict with names in same folder. folder id -> Map(name -> ProjectFile) UUID -> Map(String -> ProjectFile) e.g. Given: need to create file.txt inside directory1, need to check whether directory1 already contains a file named file.txt. Using the UUID of directory1, access a Map (generated by this method) that returnsMap<String, ProjectFile>where the keys represent the folder names within directory1. If the key for file.txt exists, a duplicate is detected.- Parameters:
projectConfiguration- ProjectConfiguration.- Returns:
- Map of maps.
-
createMapIdToExistingFile
public static Map<UUID,ProjectFile> createMapIdToExistingFile(ProjectConfiguration projectConfiguration) To quickly map between UUID and ProjectFile, maps directory id -> ProjectFile. Map contains sourceId and id at the same time in case if they differ, Sometimes conflicts can occur between sourceId and id, e.g. Given: Directory1 id=1 sourceId=2 Directory2 id=2 sourceId=2 Then we have map with: 1 -> Directory1 2 -> Directory2- Parameters:
projectConfiguration- ProjectConfiguration.- Returns:
- Map.
-
reverseMap
Reverses key and values in map, key becomes value and value becomes key.- Parameters:
originalMap- map.- Returns:
- reversed map.
-