From 31a92e645eeaf9914cd7ed08fdf6fe4240e400c5 Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Thu, 24 Sep 2015 12:26:21 +0000
Subject: [PATCH] SSDM-2495 : Adding v3 client API to ELN (Last stable version
 before making fundamental changes)

SVN: 34693
---
 .../eln-lims/html/js/server/ServerFacade.js   | 11 +++++++++
 .../reporting-plugins/newbrowserapi/script.py | 23 +++++++++++++++++--
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
index 6dc43c9ee9a..7920cc6ab52 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
@@ -574,6 +574,7 @@ function ServerFacade(openbisServer) {
 //				require(["util/Json"], function(Json){
 //					Json.fromJson(jsonParsed).done(function(data) {
 //						var samples = data.objects;
+//						callbackFunction(samples);
 //					}).fail(function() {
 //						alert("V3 dropbox search failed to be parsed.");
 //					});
@@ -905,6 +906,15 @@ function ServerFacade(openbisServer) {
 	//
 	// Free Text Search
 	//
+//	this.searchWithText = function(freeText, callbackFunction)
+//	{
+//		this.searchSamples({
+//			"anyField" : freeText,
+//			"withProperties" : true,
+//			"withOrOperator" : true
+//		}, callbackFunction);
+//	}
+	
 	this.searchWithText = function(freeText, callbackFunction)
 	{
 		var _this = this;
@@ -989,6 +999,7 @@ function ServerFacade(openbisServer) {
 		
 		return sampleCriteria;
 	}
+	
 	//
 	// Search Domains
 	//
diff --git a/plasmid/source/core-plugins/eln-lims/1/dss/reporting-plugins/newbrowserapi/script.py b/plasmid/source/core-plugins/eln-lims/1/dss/reporting-plugins/newbrowserapi/script.py
index 6a07391ba85..f8bf905b47d 100644
--- a/plasmid/source/core-plugins/eln-lims/1/dss/reporting-plugins/newbrowserapi/script.py
+++ b/plasmid/source/core-plugins/eln-lims/1/dss/reporting-plugins/newbrowserapi/script.py
@@ -493,9 +493,12 @@ def searchSamples(tr, parameters, tableBuilder, sessionId):
 	###############
 	############### V3 Search
 	###############
+	fechOptions = parameters;
+	
+	# FreeText
+	anyField = fechOptions.get("anyField");
 	
 	# Attributes
-	fechOptions = parameters;
 	samplePermId = fechOptions.get("samplePermId");
 	sampleIdentifier = fechOptions.get("sampleIdentifier");
 	sampleCode = fechOptions.get("sampleCode");
@@ -517,9 +520,19 @@ def searchSamples(tr, parameters, tableBuilder, sessionId):
 
 	#Search Setup
 	criterion = SampleSearchCriterion();
-	criterion.withAndOperator();
 	fetchOptions = SampleFetchOptions();
 	
+	#Operator
+	withOrOperator = fechOptions.get("withOrOperator");
+	if withOrOperator:
+		criterion.withOrOperator();
+	else:
+		criterion.withAndOperator();
+	
+	#Free Text
+	if anyField is not None:
+		criterion.withAnyField().thatContains(anyField);
+	
 	#Attributes
 	if samplePermId is not None:
 		criterion.withPermId().thatEquals(samplePermId);
@@ -554,6 +567,12 @@ def searchSamples(tr, parameters, tableBuilder, sessionId):
 	if withDescendants:
 		fetchOptions.withChildren(fetchOptions);
 	
+	#Standard Fetch Options, always use
+	fetchOptions.withType();
+	fetchOptions.withSpace();
+	fetchOptions.withRegistrator();
+	fetchOptions.withModifier();
+	
 	###############
 	###############
 	###############
-- 
GitLab