37 |
37 |
38 There is a GitHub project containing a python program for importing a raw (see the export example above) ELOG project. Get the project files by typing:: |
38 There is a GitHub project containing a python program for importing a raw (see the export example above) ELOG project. Get the project files by typing:: |
39 |
39 |
40 $ git clone https://github.molgen.mpg.de/weiher/elog2labfolder.git |
40 $ git clone https://github.molgen.mpg.de/weiher/elog2labfolder.git |
41 |
41 |
42 The script *elog2labfolder.py* is meant to be executed from remote, that is, not on the machine on which labfolder is running. A prerequisit is the python MySQLDB package because for a few methods the labfolder API cannot be used, instead, direct manipulation of the labfolder MySQL database is needed. The actual labfolder API is applied in the methodes collected in *myPythonAPIv1.py* and *myPythonAPIv2.py*. Mostly, API version 2 is used but adding text at the end of an entry can only be accomplished by using the version 1 API call. *getListOfAuthors.py* gives you a list of all authors in a raw ELOG export file. |
42 The script *elog2labfolder.py* is meant to be executed from remote, that is, not on the machine on which labfolder is running. A prerequisit is the python MySQLDB package because for a few methods the labfolder API cannot be used, instead, direct manipulation of the labfolder MySQL database is needed. The actual labfolder API is applied in the methodes collected in *myPythonAPIv1.py* and *myPythonAPIv2.py*. Mostly, API version 2 is used but adding text at the end of an entry can only be accomplished by using the version 1 API call. *getListOfAuthors.py* gives you a list of all authors that are mentioned in a raw ELOG export file. |
43 |
43 |
44 Alternatives to the manipulating the labfolder DB on MySQL level |
44 Alternatives to manipulating the labfolder DB on MySQL level |
45 ---------------------------------------------------------------- |
45 ------------------------------------------------------------ |
46 |
46 |
47 As mentioned previously: a few methods in the python API use a direct manipulation of the labfolder DB via MySQL queries. These methods are: |
47 As mentioned previously: a few methods in the python API use a direct manipulation of the labfolder DB via MySQL queries. These methods are: |
48 |
48 |
49 * *createUserAccount(email, author, entryContent, verboseOutput, cursor, db)*: If an author of an ELOG logbook entry has not yet a labolder account this account is created on the fly by setting a default (encrypted) password. This password is irrelevant because labfolder checks the entered password with the one from the LDAP server. Note: when setting a password in the DB labfolder's LDAP authentication needs to be disabled (FEATURE_LDAP_AUTHENTICATION=false) and enabled again after the setting process is finished. |
49 * *createUserAccount(email, author, entryContent, verboseOutput, cursor, db)*: If an author of an ELOG logbook entry does not yet have a labolder account this account is created on the fly by setting a default (encrypted) password. This password is irrelevant because labfolder checks the entered password with the one from the LDAP server. Note: when setting a password in the DB labfolder's LDAP authentication needs to be disabled (FEATURE_LDAP_AUTHENTICATION=false) beforehand and enabled again after the setting process is finished. |
50 |
50 |
51 * *updateAuthor(userID, blockID, cursor, db)*: Update the author of an entry. With the script *elog2labfolder.py* an entry is created with the author that is the person whose labfolder credentials are used to get the login token. Via this method the true author can be set to the passed in *userID*. |
51 * *updateAuthor(userID, blockID, cursor, db)*: Update the author of an entry. With the script *elog2labfolder.py* an entry is created with the author that is the person whose labfolder credentials are used to get the login token. Via this method the true author can be set to the passed in *userID*. |
52 |
52 |
53 * *updateDateAndTime(date, blockID, cursor, db)*: Similar to *updateAuthor()* this method sets the creation and modification date to the creation time and date of the entry to be imported. This is necessary because otherwise creation and modification date are the time and date of the import of the entry. |
53 * *updateDateAndTime(date, blockID, cursor, db)*: Similar to *updateAuthor()* this method sets the creation and modification date to the creation time and date of the entry to be imported. This is necessary because otherwise creation and modification date in labfolder are the time and date when the import took place. |
54 |
54 |
55 The labfolder support |
55 The labfolder support suggested the following alternative involving using the labfolder API: |
|
56 |
|
57 * User account: A user account can be created via the API 2 endpoint ``/auth/signup``. The password will be an encrypted dummy password. In order for this to work the LDAP authentication must be turned off when this endpoint is called. After the account creation LDAP authentication should be turned on again. Once the true user of this account logs in labfolder will ignore the dummy password and check the entered password against the password stored in LDAP. |
|
58 |
|
59 * Author: To create a labfolder entry by using the original entry's author needs a special work-around. **First, make sure to prevent labfolder users from accessing labfolder for the time of the import.** Then, manually change all user passwords in the DB to the same (encrypted) password. Switch off the LDAP authentication and restart labolder. Now, import entry by entry and get a new login token for each new entry. It is only possible to get login tokens for all users because they all have the same known password. If the author of the entry to be imported does not exist yet in the DB you need to create an account via the API 2 endpoint ``/auth/signup``. Now you reopen the access to the labfolder instance and switch on LDAP again restarting labfolder afterwards. The users can login using their FHI credentials no matter the "universal" password in the DB. If LDAP authentication is not turned on the users could do a password recovery on the login screen and re-set their password to their liking. |
|
60 |
|
61 * Date and time: Since you cannot change creation and modification time stamp of an entry via the API you could instead create custom dates during the import |
|
62 |
|
63 creation time wird das Datum bleiben, an dem der Eintrag importiert wurde; beim Import wird aber ein custom date angelegt, das z.B. "Original-Erstellungsdatum" heißt und als Datum das Erstellungsdatum aus Elog enthält (alle Einträge sind dann auch nach diesem Datum filterbar und durchsuchbar) |
56 |
64 |
57 |
65 |
|
66 |
|
67 |