Skip to content
Snippets Groups Projects

ENH: No automatic name for mass-imported File entities

Merged Daniel Hornung requested to merge f-no-automatic-file-naming into dev
5 unresolved threads
4 files
+ 20
10
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -60,7 +60,7 @@ import org.caosdb.server.utils.Utils;
@@ -60,7 +60,7 @@ import org.caosdb.server.utils.Utils;
loadOnDefault = false,
loadOnDefault = false,
stage = TransactionStage.INIT,
stage = TransactionStage.INIT,
description =
description =
"For expert users only! Risk of creating spam records!\nValue of this flag might be any directory on the servers local file system which is part of the server's back-end file storage. This job will insert every readable, nonhidden file in said directory into the database and link the file with a symlink. This is useful to add a huge amount of files without actully copying them to the back-end file storage. If you call this job on a directory more than once every file that was recently added to the source directory is inserted. Every yet known file is left untouched. \nOptional parameter -e EXCLUDE: A regular expression of files which are to be ignored. \n Optional parameter -i INCLUDE: a regular expression of files which are to be included. By default, all files are included. The -e takes precedence. \nOptional parameter -p PREFIX: Stores all new files into the directory PREFIX in the server's file system.\nOptional parameter --force-allow-symlinks: Simlinks in your data are a source of problems for the database. Therefore, simlinks are ignored by default. This option allows symlinks (but still generates simlink warnings). \nPrepend/Dry run: Call this flag with a retrieve transaction (HTTP GET) and it will only count all files and list them without actually inserting them.")
"For expert users only! Risk of creating spam records!\nValue of this flag may be any directory on the servers local file system which is part of the server's back-end file storage. This job will insert every readable, nonhidden file in said directory into the database and link the file with a symlink. This is useful to add a huge amount of files without actually copying them to the back-end file storage. If you call this job on a directory more than once every file that was recently added to the source directory is inserted. Every already known file is left untouched. \nOptional parameter -e EXCLUDE: A regular expression of files which are to be ignored. \n Optional parameter -i INCLUDE: a regular expression of files which are to be included. By default, all files are included. The -e takes precedence. \nOptional parameter -p PREFIX: Stores all new files into the directory PREFIX in the server's file system.\nOptional parameter --force-allow-symlinks: Symlinks in your data are a source of problems for the database. Therefore, simlinks are ignored by default. This option allows symlinks (but still generates simlink warnings). \nPrepend/Dry run: Call this flag with a retrieve transaction (HTTP GET) and it will only count all files and list them without actually inserting them.")
Please register or sign in to reply
public class InsertFilesInDir extends FlagJob {
public class InsertFilesInDir extends FlagJob {
private File tmp = null;
private File tmp = null;
@@ -95,6 +95,11 @@ public class InsertFilesInDir extends FlagJob {
@@ -95,6 +95,11 @@ public class InsertFilesInDir extends FlagJob {
return ret;
return ret;
}
}
 
/**
 
* Parse the value string and store the content in this Job.
 
*
 
* @return The path to the source directory as given by the flag parameter.
 
*/
public String parseValue(String value) {
public String parseValue(String value) {
String ret = value;
String ret = value;
@@ -217,7 +222,7 @@ public class InsertFilesInDir extends FlagJob {
@@ -217,7 +222,7 @@ public class InsertFilesInDir extends FlagJob {
} else {
} else {
i++;
i++;
final String targetPath = root + sub.getName();
final String targetPath = root + sub.getName();
final EntityInterface newFileEntity = createInsertFileEntity(sub.getName());
final EntityInterface newFileEntity = createInsertFileEntity();
final long size = sub.length();
final long size = sub.length();
final FileProperties fp = new FileProperties(null, targetPath, size);
final FileProperties fp = new FileProperties(null, targetPath, size);
newFileEntity.setFileProperties(fp);
newFileEntity.setFileProperties(fp);
@@ -266,14 +271,13 @@ public class InsertFilesInDir extends FlagJob {
@@ -266,14 +271,13 @@ public class InsertFilesInDir extends FlagJob {
* Create a new InsertEntity (if this is an actual run) or a new RetrieveEntity (in dry-run mode)
* Create a new InsertEntity (if this is an actual run) or a new RetrieveEntity (in dry-run mode)
* with {@link Role.File}.
* with {@link Role.File}.
*
*
* @param name the file name
* @return new File entity
* @return new File entity
*/
*/
private EntityInterface createInsertFileEntity(String name) {
private EntityInterface createInsertFileEntity() {
if (getTransaction() instanceof WriteTransactionInterface) {
if (getTransaction() instanceof WriteTransactionInterface) {
return new InsertEntity(name, Role.File);
return new InsertEntity((String) null, Role.File);
}
}
EntityInterface result = new RetrieveEntity(name);
EntityInterface result = new RetrieveEntity((String) null);
Please register or sign in to reply
result.setRole(Role.File);
result.setRole(Role.File);
return result;
return result;
}
}
Loading