elog2labfolder/importing_from_elog.rst~
changeset 11 ccfe3c7fa0d2
parent 3 b71be85a294c
child 13 a21f3604f1db
equal deleted inserted replaced
3:b71be85a294c 11:ccfe3c7fa0d2
    15 	Attachment:
    15 	Attachment:
    16 	Encoding: HTML
    16 	Encoding: HTML
    17 	========================================
    17 	========================================
    18 	<p>Today Alex Paarmann and Marc Herzog are measuring in the wavelength range from 10 to 20 micron with a 0.5 mm thick GGG (Gadolinium Gallium Garnet, <a title="Gadolinium" href="http://en.wikipedia.org/wiki/Gadolinium">Gd</a><sub>3</sub><a title="Gallium" href="http://en.wikipedia.org/wiki/Gallium">Ga</a><sub>5</sub><a title="Oxygen" href="http://en.wikipedia.org/wiki/Oxygen">O</a><sub>12</sub>). Electron energy is set to 26 MeV.</p>
    18 	<p>Today Alex Paarmann and Marc Herzog are measuring in the wavelength range from 10 to 20 micron with a 0.5 mm thick GGG (Gadolinium Gallium Garnet, <a title="Gadolinium" href="http://en.wikipedia.org/wiki/Gadolinium">Gd</a><sub>3</sub><a title="Gallium" href="http://en.wikipedia.org/wiki/Gallium">Ga</a><sub>5</sub><a title="Oxygen" href="http://en.wikipedia.org/wiki/Oxygen">O</a><sub>12</sub>). Electron energy is set to 26 MeV.</p>
    19 
    19 
    20 This ASCII export looks like this in the ELOG webinterface:
    20 The entry shown above looks like this in the ELOG webinterface:
    21 
    21 
    22 .. image:: _static/elog_entry.png
    22 .. image:: _static/elog_entry.png
    23    :width: 100 %
    23    :width: 100 %
    24    :align: center
    24    :align: center
    25 
    25 
    26 What is noticeable is that the ELOG export comes with a "ö" instead of an "ö". Interestingly, if only entries done by Wieland are exported the export file has UTF-8 encoding which can actually print German "Umlaute" (ö, ä, ü). If all entries are exported the encoding changes to an encoding that cannot handle e.g. "ö". 
    26 What is noticeable is that the ELOG export comes with an "ö" instead of an "ö". Interestingly, if only entries done by Wieland are exported the export file has UTF-8 encoding which can actually print German "Umlaute" (ö, ä, ü). If, however, all entries are exported the encoding changes to an encoding that cannot handle e.g. "ö". 
       
    27 
       
    28 After importing the above ELOG entry into labfolder this entry appears like that:
       
    29 
       
    30 .. image:: _static/entry_after_import.png
       
    31    :width: 100 %
       
    32    :align: center
    27 
    33 
    28 
    34 
       
    35 Using python to import from ELOG to labfolder
       
    36 ---------------------------------------------
       
    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::
       
    39 
       
    40 	$ git clone https://github.molgen.mpg.de/weiher/elog2labfolder.git
       
    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.
       
    43 
       
    44 Alternatives to the manipulating the labfolder DB on MySQL level
       
    45 ----------------------------------------------------------------
       
    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:
       
    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.
       
    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*.
       
    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.
       
    54 
       
    55 The labfolder support
    29 
    56 
    30 
    57 
    31 
       
    32 
       
    33 
       
    34 
       
    35