Commit 8c68b3a1 authored by Fokkema's avatar Fokkema

Merge branch 'master' into feat/LOVD+.

parents bb54dd23 4a3d3cbb
......@@ -45,6 +45,7 @@ addons:
- mysql-server-5.6
- mysql-client-core-5.6
- mysql-client-5.6
- mutt
before_install:
- ./tests/travis/setup/setup_chrome.sh
......
......@@ -885,6 +885,9 @@ if (POST || $_FILES) { // || $_FILES is in use for the automatic loading of file
// Diagnostics: Find default gene we'll use for all VOTs, since the gene is always the same anyway.
$sDefaultGene = $_DB->query('SELECT geneid FROM ' . TABLE_TRANSCRIPTS . ' LIMIT 1')->fetchColumn();
}
// We need to check Genders of referenced mothers and fathers, so we need to know if the column is active.
$bGenderColumnActive = (bool) $_DB->query('SELECT COUNT(*) FROM ' . TABLE_ACTIVE_COLS . ' WHERE colid = ?',
array('Individual/Gender'))->fetchColumn();
......@@ -1813,37 +1816,44 @@ if (POST || $_FILES) { // || $_FILES is in use for the automatic loading of file
if ($aLine['panelid']) {
$bPanelInDB = isset($aParsed['Individuals']['ids'][(int) $aLine['panelid']]);
$bPanelInFile = isset($aParsed['Individuals']['data'][(int) $aLine['panelid']]);
if (!$bPanelInDB && !$bPanelInFile) {
// Individual does not exist and is not defined in the import file.
// Or the panel to which is referred is not yet parsed.
// It's assumed that in the import file panels are listed above individuals referring to them.
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): Individual "' . htmlspecialchars($aLine['panelid']) . '" does not exist in the database and is not defined (properly) in this import file.<BR>When referring to panels that are also defined in the import file, make sure they are defined above the individuals referring to them. Therefore, make sure that in the import file individual "' . htmlspecialchars($aLine['panelid']) . '" is defined above individual "' . htmlspecialchars($aLine['id']) . '".');
}
// It is not allowed to import a record where the panelid and id are the same.
// In theory, they could mean to link to the DB entry with this ID, but we're not going to risk that.
if ($aLine['panelid'] == $aLine['id']) {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): The \'Panel ID\' can not link to itself; this field is used to indicate to which panel this individual belongs.');
} elseif (!$bPanelInDB && !$bPanelInFile) {
// Individual does not exist and is not defined in the import file.
// Or the panel to which is referred is not yet parsed.
// It's assumed that in the import file panels are listed above individuals referring to them.
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): Individual "' . htmlspecialchars($aLine['panelid']) . '" does not exist in the database and is not defined (properly) in this import file.<BR>When referring to panels that are also defined in the import file, make sure they are defined above the individuals referring to them. Therefore, make sure that in the import file individual "' . htmlspecialchars($aLine['panelid']) . '" is defined above individual "' . htmlspecialchars($aLine['id']) . '".');
}
// A panel from the import file is preferred, as that describes the new
// panel size to which the new records must conform.
$nPanel = false;
// Find the referred panel in the file first, otherwise check the database.
$nPanelSize = false;
if ($bPanelInFile) {
$nPanel = $aParsed['Individuals']['data'][(int) $aLine['panelid']]['panel_size'];
$nPanelSize = $aParsed['Individuals']['data'][(int) $aLine['panelid']]['panel_size'];
} elseif ($bPanelInDB) {
$nPanel = $_DB->query('SELECT panel_size FROM ' . TABLE_INDIVIDUALS .
' WHERE id = ?', array($aLine['panelid']))->fetchColumn();
$nPanelSize = $_DB->query('SELECT panel_size FROM ' . TABLE_INDIVIDUALS . ' WHERE id = ?',
array($aLine['panelid']))->fetchColumn();
}
if ($nPanel !== false && $nPanel == 1) {
if ($nPanelSize == 1) {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): Panel ID "' . htmlspecialchars($aLine['panelid']) . '" refers to an individual, not a panel (group of individuals). If you want to configure that individual as a panel, set its \'Panel size\' field to a value higher than 1.');
} elseif ($nPanel !== false && $nPanel <= $aLine['panel_size']) {
} elseif ($nPanelSize !== false && $nPanelSize <= $aLine['panel_size']) {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): Panel size of Individual "' . htmlspecialchars($aLine['id']) . '" must be lower than the panel size of Individual "' . htmlspecialchars($aLine['panelid']) . '".');
}
}
foreach (array('fatherid', 'motherid') as $sParentalField) {
if ($aLine[$sParentalField]) {
// It is not allowed to import a record where the fatherid or motherid are the same as the individual id.
// In theory, they could mean to link to the DB entry with this ID, but we're not going to risk that.
if ($aLine[$sParentalField] == $aLine['id']) {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): The \'' . $sParentalField . '\' can not link to itself; this field is used to indicate which individual in the database is the parent of the given individual.');
continue; // Check next field.
}
$bParentInDB = isset($aParsed['Individuals']['ids'][(int) $aLine[$sParentalField]]);
$bParentInFile = isset($aParsed['Individuals']['data'][(int) $aLine[$sParentalField]]);
if (!$bParentInDB && !$bParentInFile) {
......@@ -1853,28 +1863,25 @@ if (POST || $_FILES) { // || $_FILES is in use for the automatic loading of file
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): Individual "' . htmlspecialchars($aLine[$sParentalField]) . '" does not exist in the database and is not defined (properly) in this import file.<BR>When referring to parents that are also defined in the import file, make sure they are defined above the children referring to them. Therefore, make sure that in the import file individual "' . htmlspecialchars($aLine[$sParentalField]) . '" is defined above individual "' . htmlspecialchars($aLine['id']) . '".');
}
// It is not allowed to import a record where the fatherid or motherid are the same as the individual id.
if ($aLine[$sParentalField] == $aLine['id']) {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): The \'' . $sParentalField . '\' can not link to itself; this field is used to indicate which individual in the database is the parent of the given individual.');
$zParentData = array();
if ($bParentInFile) {
$zParentData = $aParsed['Individuals']['data'][(int) $aLine[$sParentalField]];
} elseif ($bParentInDB) {
$zParentData = $_DB->query('SELECT ' . ($bGenderColumnActive? '' : '"" AS ') .
'`Individual/Gender`, panel_size FROM ' . TABLE_INDIVIDUALS . ' WHERE id = ?',
array($aLine[$sParentalField]))->fetchAssoc();
}
if ($_DB->query('SELECT ac.colid FROM ' . TABLE_ACTIVE_COLS . ' AS ac WHERE ac.colid = ?', array('Individual/Gender'))->fetchColumn()) {
$zParentData = array();
if ($bParentInDB) {
$zParentData = $_DB->query('SELECT `Individual/Gender`, panel_size FROM ' . TABLE_INDIVIDUALS . ' WHERE id = ?', array($aLine[$sParentalField]))->fetchAssoc();
} elseif ($bParentInFile) {
$zParentData = $aParsed['Individuals']['data'][(int) $aLine[$sParentalField]];
}
if (isset($zParentData['panel_size']) && $zParentData['panel_size'] > 1) {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): The ' . $sParentalField . ' "' . htmlspecialchars($aLine[$sParentalField]) . '" refers to an panel (group of individuals), not an individual. If you want to configure that panel as an individual, set its \'Panel size\' field to value 1.');
}
if (isset($zParentData['panel_size']) && $zParentData['panel_size'] > 1) {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): The ' . $sParentalField . ' "' . htmlspecialchars($aLine[$sParentalField]) . '" refers to an panel (group of individuals), not an individual. If you want to configure that panel as an individual, set its \'Panel size\' field to value 1.');
}
if (isset($zParentData['Individual/Gender']) && $sParentalField == 'fatherid' && $zParentData['Individual/Gender'] == 'F') {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): The ' . $sParentalField . ' "' . htmlspecialchars($aLine[$sParentalField]) . '" you entered does not refer to a male individual.');
} elseif (isset($zParentData['Individual/Gender']) && $sParentalField == 'motherid' && $zParentData['Individual/Gender'] == 'M') {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): The ' . $sParentalField . ' "' . htmlspecialchars($aLine[$sParentalField]) . '" you entered does not refer to a female individual.');
}
if (isset($zParentData['Individual/Gender']) && $sParentalField == 'fatherid'
&& $zParentData['Individual/Gender'] == 'F') {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): The ' . $sParentalField . ' "' . htmlspecialchars($aLine[$sParentalField]) . '" you entered does not refer to a male individual.');
} elseif (isset($zParentData['Individual/Gender']) && $sParentalField == 'motherid'
&& $zParentData['Individual/Gender'] == 'M') {
lovd_errorAdd('import', 'Error (' . $sCurrentSection . ', line ' . $nLine . '): The ' . $sParentalField . ' "' . htmlspecialchars($aLine[$sParentalField]) . '" you entered does not refer to a female individual.');
}
}
}
......
......@@ -3,12 +3,13 @@
*
* LEIDEN OPEN VARIATION DATABASE (LOVD)
*
* Created : 2016
* Modified : 2017-09-18
* For LOVD : 3.0-20
* Created : 2015-06-05
* Modified : 2019-08-29
* For LOVD : 3.0-22
*
* Copyright : 2016-2017 Leiden University Medical Center; http://www.LUMC.nl/
* Copyright : 2016-2019 Leiden University Medical Center; http://www.LUMC.nl/
* Programmers : M. Kroon <m.kroon@lumc.nl>
* Ivo F.A.C. Fokkema <I.F.A.C.Fokkema@LUMC.nl>
*
*
* This file is part of LOVD.
......@@ -45,12 +46,13 @@ class FalseInsertImportTest extends LOVDSeleniumWebdriverBaseTestCase
$element->click();
$element = $this->driver->findElement(WebDriverBy::xpath("//input[@value='Import file']"));
$element->click();
$element = $this->driver->findElement(WebDriverBy::linkText("Show 5 warnings"));
$element->click();
$bodyText = $this->driver->findElement(WebDriverBy::tagName("body"))->getText();
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Columns, line 9\): The field [\s\S]col_order[\s\S] must contain a positive integer, "abc" does not match\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Columns, line 9\): Incorrect value for field [\s\S]col_order[\s\S], which needs to be numeric, between 0 and 255\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Columns, line 9\): Incorrect value for field [\s\S]standard[\s\S], which should be 0 or 1\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Columns, line 9\): Select option #3 "yes\(\)[\s\S]* = Consanguineous parents" not understood\.[\s\S]*$/', $bodyText));
......@@ -72,9 +74,7 @@ class FalseInsertImportTest extends LOVDSeleniumWebdriverBaseTestCase
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Individuals, line 48\): Panel size of Individual "00000006" must be lower than the panel size of Individual "00000002"\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Individuals, line 49\): Individual "00000022" does not exist in the database and is not defined \(properly\) in this import file\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Individuals, line 49\): Individual "00000022" does not exist in the database and is not defined \(properly\) in this import file\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Individuals, line 50\): Individual "00000008" does not exist in the database and is not defined \(properly\) in this import file\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Individuals, line 50\): The [\s\S]fatherid[\s\S] can not link to itself; this field is used to indicate which individual in the database is the parent of the given individual\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Individuals, line 50\): Individual "00000008" does not exist in the database and is not defined \(properly\) in this import file\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Individuals, line 50\): The [\s\S]motherid[\s\S] can not link to itself; this field is used to indicate which individual in the database is the parent of the given individual\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Individuals, line 51\): The fatherid "00000002" refers to an panel \(group of individuals\), not an individual\. If you want to configure that panel as an individual, set its [\s\S]Panel size[\s\S] field to value 1\.[\s\S]*$/', $bodyText));
$this->assertTrue((bool)preg_match('/^[\s\S]*Error \(Individuals, line 51\): The motherid "00000002" refers to an panel \(group of individuals\), not an individual\. If you want to configure that panel as an individual, set its [\s\S]Panel size[\s\S] field to value 1\.[\s\S]*$/', $bodyText));
......
......@@ -39,7 +39,7 @@
"00000001" "" "" "00000022" "1" "00001" "9" "00001" "2015-06-03 11:30:26" "00001" "2015-06-03 11:30:26" "12345IVA" "{PMID:Fokkema et al (2011):21520333}" "No Remarks" "Still no remarks" ""
"00000002" "" "" "00000002" "11" "00001" "9" "00001" "2015-06-03 11:30:33" "" "" "12345IVA" "{PMID:Fokkema et al (2011):21520333}" "No Remarks" "Still no remarks" ""
"00000003" "00000003" "00000022" "00000001" "1" "00001" "9" "00001" "2015-06-03 11:30:41" "" "" "12345IVA" "{PMID:Fokkema et al (2011):21520333}" "No Remarks" "Still no remarks" "F"
"00000004" "" "00000002" "" "1" "00001" "9" "00001" "2015-06-03 11:30:48" "" "" "12345IVA" "{PMID:Fokkema et al (2011):21520333}" "No Remarks" "Still no remarks" "M"
"00000004" "00000003" "00000002" "" "1" "00001" "9" "00001" "2015-06-03 11:30:48" "" "" "12345IVA" "{PMID:Fokkema et al (2011):21520333}" "No Remarks" "Still no remarks" "M"
"00000005" "" "" "00000002" "1" "00001" "9" "00001" "2015-06-03 11:30:41" "" "" "12345IVA" "{PMID:Fokkema et al (2011):21520333}" "No Remarks" "Still no remarks" "F"
## Individuals_To_Diseases ## Do not remove or alter this header ##
......
......@@ -4,12 +4,19 @@
GLOB="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Loop through screenshot files (oldest to newest).
for file in `ls -1 -t -r ${GLOB}/test_results/error_screenshots/*.png`; do
for file in `ls -1 -t -r ${GLOB}/test_results/error_screenshots/ | grep -F .png`; do
echo "Uploading file: ${file}";
# Upload to transfer.sh, this command will output the URL on which the
# uploaded file can be reached.
curl --upload-file "${file}" https://transfer.sh
RETURN=`curl -s -H "Max-Days: 2" --upload-file "${GLOB}/test_results/error_screenshots/${file}" https://transfer.sh`;
echo $RETURN;
if [[ $RETURN == "Could not save metadata" ]];
then
# Transfer.sh service often fails.
echo "Transfer.sh failed, emailing file...";
mutt -s "Travis failure" -a "${GLOB}/test_results/error_screenshots/${file}" -- I.F.A.C.Fokkema@LUMC.nl < <(echo "Travis run failed. Screenshot attached.")
fi
rm -f "${file}"
rm -f "${GLOB}/test_results/error_screenshots/${file}"
done
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment