Skip to content

Commit

Permalink
Added option to import MSDS from URLs
Browse files Browse the repository at this point in the history
Amount calcutation uses right density for container (if specific)
Correctly import experiments when using https://identifiers.org/sciflection:5ede4273-b26c-4ea4-adb7-3ce294ab3397
SVN garbage removed
  • Loading branch information
fr committed Jun 11, 2023
1 parent a2405ae commit d56b405
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 9,892 deletions.
12 changes: 11 additions & 1 deletion chooseAsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,22 @@
if ($url) {
require_once "lib_http.php";

if (!startswith($url, "http")) {
if (!isUrl($url)) {
// assume only uuid
$url=SCIFLECTION_URL."/performSearch?table=ElnReaction&UUID=".$url;
}

$parsed=parse_url($url);
if (IDENTIFIERS_ORG==$parsed["host"]) {
// get redirect URL and then append jsonRaw
$my_http_options=$default_http_options;
$my_http_options["follow_redirects"]=false;
$response=oe_http_get($url,$my_http_options);
if ($response && $response->isRedirect()) {
$url=$response->getHeader("location");
$parsed=parse_url($url);
}
}
$base_url=$parsed["scheme"]."://".$parsed["host"].ifnotempty(":",$parsed["port"]??"");
// get cookies
$response=oe_http_get($base_url,$default_http_options);
Expand Down
42 changes: 41 additions & 1 deletion import.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@
"n_20",
"mp_high",
"bp_high",
"default_safety_sheet_by",
"default_safety_sheet_url",
"alt_default_safety_sheet_by",
"alt_default_safety_sheet_url",
);
$cols_chemical_storage=array(
"amount", // incl unit
Expand All @@ -106,6 +110,10 @@
"add_multiple",
"migrate_id_cheminstor",
"comment_cheminstor",
"safety_sheet_by",
"safety_sheet_url",
"alt_safety_sheet_by",
"alt_safety_sheet_url",
);
$cols_supplier_offer=array(
"amount", // incl unit
Expand Down Expand Up @@ -211,6 +219,13 @@
$molecule["press_unit"]="bar";
}
break;
case "default_safety_sheet_url":
case "alt_default_safety_sheet_url":
$val=getValue($col_molecule,$cells);
if (isUrl($val)) {
$molecule[$col_molecule]="-".$val;
}
break;
default:
$molecule[$col_molecule]=getValue($col_molecule,$cells);
}
Expand All @@ -220,13 +235,23 @@
$molecule["storage_name"]=getValue("storage_name",$cells);
$molecule["order_date"]=getSQLFormatDate(getTimestampFromDate(getValue("order_date",$cells)));
$molecule["open_date"]=getSQLFormatDate(getTimestampFromDate(getValue("open_date",$cells)));

$chemical_storage["migrate_id_cheminstor"]=getValue("migrate_id_cheminstor",$cells);
$chemical_storage["comment_cheminstor"]=getValue("comment_cheminstor",$cells);
$chemical_storage["compartment"]=getValue("compartment",$cells);
$chemical_storage["description"]=getValue("description",$cells);
$chemical_storage["cat_no"]=getValue("cat_no",$cells);
$chemical_storage["lot_no"]=getValue("lot_no",$cells);
$chemical_storage["chemical_storage_barcode"]=getValue("chemical_storage_barcode",$cells);
$val=getValue("safety_sheet_url",$cells);
if (isUrl($val)) {
$chemical_storage["safety_sheet_url"]="-".$val;
}
$val=getValue("alt_safety_sheet_url",$cells);
if (isUrl($val)) {
$chemical_storage["alt_safety_sheet_url"]="-".$val;
}

$molecule["supplier"]=getValue("supplier",$cells);
$molecule["price"]=getNumber(getValue("price",$cells));
$molecule["price_currency"]=getValue("price_currency",$cells);
Expand Down Expand Up @@ -550,7 +575,22 @@
}
$fieldsArray[]=array("item" => "text", "text" => "<tr><td><b>".s("property")."</b></td><td><b>".s("column")." | ".s("fixed_value")."</b></td></tr>", );
}
$select_proto["text"]=s($col);
$langKey=$col;
switch ($col) {
case "default_safety_sheet_url":
case "alt_default_safety_sheet_url":
case "safety_sheet_url":
case "alt_safety_sheet_url":
$label="MSDS URL";
break;
case "alt_default_safety_sheet_by":
case "alt_safety_sheet_by":
$langKey="alt_safety_sheet";
// no break
default:
$label=s($langKey);
}
$select_proto["text"]=$label;
$select_proto["int_name"]="col_".$col;
$select_proto["value"]=$guessed_cols[$col]??null;
$fieldsArray[]=$select_proto;
Expand Down
Loading

0 comments on commit d56b405

Please sign in to comment.