From bd641fffff38abebdc49cdba7edbd016b10b4be3 Mon Sep 17 00:00:00 2001
From: yvesn <yvesn>
Date: Fri, 30 Jun 2017 12:19:21 +0000
Subject: [PATCH] SSDM-5275: getting list of non-RTF properties from settings
 sample so they don't get encoded with additional html tags

SVN: 38485
---
 .../reporting-plugins/eln-lims-api/script.py    | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py
index d83c5347b6b..19bb710e5f8 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py
@@ -34,6 +34,7 @@ from ch.systemsx.cisd.common.exceptions import UserFailureException
 
 from ch.ethz.sis import PlasmapperConnector
 
+import json
 import time
 import subprocess
 import os.path
@@ -136,6 +137,16 @@ def getProperties(tr, parameters):
 
 rtpropertiesToIgnore = ["FREEFORM_TABLE_STATE", "NAME", "SEQUENCE"];
 
+def updatePropertiesToIgnore(tr):
+	global rtpropertiesToIgnore;
+	sample = tr.getSample("/ELN_SETTINGS/GENERAL_ELN_SETTINGS");
+	if sample != None:
+		settingsJson = sample.getPropertyValue("ELN_SETTINGS");
+		if settingsJson != None:
+			settings = json.loads(settingsJson);
+			if "forcedDisableRTF" in settings:
+				rtpropertiesToIgnore = settings["forcedDisableRTF"];
+
 def isPropertyRichText(properties, propertyCode):
 	for property in properties:
 		if property.getCode() == propertyCode and property.getCode() not in rtpropertiesToIgnore:
@@ -209,21 +220,27 @@ def process(tr, parameters, tableBuilder):
 		isOk = insertUpdateProject(tr, parameters, tableBuilder);
 	
 	if method == "insertExperiment":
+		updatePropertiesToIgnore(tr);
 		isOk = insertUpdateExperiment(tr, parameters, tableBuilder);
 	if method == "updateExperiment":
+		updatePropertiesToIgnore(tr);
 		isOk = insertUpdateExperiment(tr, parameters, tableBuilder);
 	
 	if method == "copySample":
 		isOk = copySample(tr, parameters, tableBuilder);
 	if method == "insertSample":
+		updatePropertiesToIgnore(tr);
 		isOk = insertUpdateSample(tr, parameters, tableBuilder);
 	if method == "updateSample":
+		updatePropertiesToIgnore(tr);
 		isOk = insertUpdateSample(tr, parameters, tableBuilder);
 	if method == "moveSample":
 		isOk = moveSample(tr, parameters, tableBuilder);
 	if method == "insertDataSet":
+		updatePropertiesToIgnore(tr);
 		isOk = insertDataSet(tr, parameters, tableBuilder);
 	if method == "updateDataSet":
+		updatePropertiesToIgnore(tr);
 		isOk = updateDataSet(tr, parameters, tableBuilder);
 	
 	if method == "listFeatureVectorDatasetsPermIds":
-- 
GitLab