diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js index b880f5b85b9541ab6a143edfde3575a245b47031..229f60aca3aafc605726e8e448e00d4023f7a80f 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js @@ -433,8 +433,8 @@ function AdvancedSearchController(mainController, forceSearch) { this._sampleToSavedSearch = function(sample) { return { sample: sample, - name: sample.properties.NAME, - criteria: JSON.parse(sample.properties.CUSTOM_DATA.replace('<xml><![CDATA[', '').replace(']]></xml>', ''))['eln-lims-criteria'], + name: sample.properties['$NAME'], + criteria: JSON.parse(sample.properties['$SEARCH_QUERY.CUSTOM_DATA'].replace('<xml><![CDATA[', '').replace(']]></xml>', ''))['eln-lims-criteria'], }; } diff --git a/openbis_standard_technologies/dist/core-plugins/search-store/1/as/initialize-master-data.py b/openbis_standard_technologies/dist/core-plugins/search-store/1/as/initialize-master-data.py index 96c96d126ba19f31e4343a40652ea52fe2bfeb14..bf2f249601cf58c866ea9d2ff68c4b5d7c8217de 100644 --- a/openbis_standard_technologies/dist/core-plugins/search-store/1/as/initialize-master-data.py +++ b/openbis_standard_technologies/dist/core-plugins/search-store/1/as/initialize-master-data.py @@ -1,71 +1,82 @@ -''' -@copyright: -2016 ETH Zuerich, SIS - -@license: -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -''' +# +# Copyright 2014 ETH Zuerich, Scientific IT Services +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# MasterDataRegistrationTransaction Class +from ch.ethz.sis.openbis.generic.server.asapi.v3 import ApplicationServerApi +from ch.systemsx.cisd.openbis.generic.server import CommonServiceProvider +from ch.ethz.sis.openbis.generic.asapi.v3.dto.service.id import CustomASServiceCode +from ch.ethz.sis.openbis.generic.asapi.v3.dto.service import CustomASServiceExecutionOptions -import ch.systemsx.cisd.openbis.generic.server.jython.api.v1.DataType as DataType +# "======================== Helper Functions ========================" +import os +import sys +from collections import deque +from java.nio.file import Files, Paths +from java.io import File +from java.util import HashMap +from java.util import ArrayList -SAMPLE_TYPE_SEARCH_QUERY = "SEARCH_QUERY" -# we use XML to store the properties to avoid indexing of the fields -PROPERTY_TYPES = [ - { - 'code': 'NAME', - 'dataType': DataType.VARCHAR, - 'label': 'Name', - 'mandatory': True, - 'description': 'Human readable name', - 'shownEdit': True - }, - { - 'code': 'SEARCH_CRITERIA', - 'dataType': DataType.XML, - 'label': 'Search criteria', - 'mandatory': True, - 'description': 'V3 API search criteria', - 'shownEdit': False - }, - { - 'code': "FETCH_OPTIONS", - 'dataType': DataType.XML, - 'label': 'Fetch options', - 'mandatory': False, - 'description': 'V3 API fetch options', - 'shownEdit': False - }, - { - 'code': "CUSTOM_DATA", - 'dataType': DataType.XML, - 'label': 'Custom data', - 'mandatory': False, - 'description': 'Additional data in custom format', - 'shownEdit': False - } - ] +TYPES_FOLDER = "%s/master-data/" % [p for p in sys.path if p.find('core-plugins') >= 0][0] +SCRIPTS = os.path.join(TYPES_FOLDER, 'scripts') -tr = service.transaction() +def get_all_scripts(): + scripts = HashMap() + for rel_path, script in list_all_files(SCRIPTS): + scripts.put(rel_path, script) -sample_type = tr.getOrCreateNewSampleType(SAMPLE_TYPE_SEARCH_QUERY) -sample_type.setGeneratedCodePrefix("Q") + return scripts -for propert_type_def in PROPERTY_TYPES: - property_type = tr.getOrCreateNewPropertyType(propert_type_def['code'], propert_type_def['dataType']) - property_type.setLabel(propert_type_def['label']) - property_type.setDescription(propert_type_def['description']) - assignment = tr.assignPropertyType(sample_type, property_type) - assignment.setMandatory(propert_type_def['mandatory']) - assignment.setShownEdit(propert_type_def['shownEdit']) + +def list_xls_byte_arrays(): + xls = ArrayList() + for f in os.listdir(TYPES_FOLDER): + if f.endswith('.xls') or f.endswith('.xlsx'): + excel_file = open(os.path.join(TYPES_FOLDER, f)) + xls.add(excel_file.read()) + excel_file.close() + return xls + + +def list_all_files(source_root_path): + todo = [] + todo.append(File(source_root_path)) + while todo: + f = todo.pop() + if f.isDirectory(): + new_files = f.listFiles() + if new_files is not None: + todo.extend(f.listFiles()) + continue + if f.isFile(): + source_file = f.getAbsolutePath() + script_file = open(source_file) + script = script_file.read() + script_file.close() + file_path = source_file.replace(source_root_path, "") + if file_path.startswith("/"): + file_path = file_path[1:] + yield file_path, script + +# "======================== Helper Functions ========================" + +api = CommonServiceProvider.getApplicationContext().getBean(ApplicationServerApi.INTERNAL_SERVICE_NAME) +sessionToken = api.loginAsSystem() +props = CustomASServiceExecutionOptions().withParameter('xls', list_xls_byte_arrays()).withParameter('scripts', get_all_scripts()) +result = api.executeCustomASService(sessionToken, CustomASServiceCode("xls-import-api"), props); +print("======================== master-data xls ingestion result ========================") +print(result) +print("======================== master-data xls ingestion result ========================") diff --git a/openbis_standard_technologies/dist/core-plugins/search-store/1/as/master-data/data-model.xls b/openbis_standard_technologies/dist/core-plugins/search-store/1/as/master-data/data-model.xls new file mode 100644 index 0000000000000000000000000000000000000000..c88a9546574a5d7a0b484a2121c1d234e8d21b08 Binary files /dev/null and b/openbis_standard_technologies/dist/core-plugins/search-store/1/as/master-data/data-model.xls differ diff --git a/openbis_standard_technologies/dist/core-plugins/search-store/1/as/services/search-store/search-store.py b/openbis_standard_technologies/dist/core-plugins/search-store/1/as/services/search-store/search-store.py index 6b7556ca932d54b809f54118997dc6c452347840..17886edf9c8158e5b514d7f66cb26722cfce90ed 100644 --- a/openbis_standard_technologies/dist/core-plugins/search-store/1/as/services/search-store/search-store.py +++ b/openbis_standard_technologies/dist/core-plugins/search-store/1/as/services/search-store/search-store.py @@ -29,10 +29,10 @@ from ch.ethz.sis.openbis.generic.asapi.v3.dto.sample.delete import SampleDeletio SAMPLE_TYPE = 'SEARCH_QUERY' -PROP_NAME = 'NAME' -PROP_SEARCH_CRITERIA = 'SEARCH_CRITERIA' -PROP_FETCH_OPTIONS = 'FETCH_OPTIONS' -PROP_CUSTOM_DATA = 'CUSTOM_DATA' +PROP_NAME = '$NAME' +PROP_SEARCH_CRITERIA = '$SEARCH_QUERY.SEARCH_CRITERIA' +PROP_FETCH_OPTIONS = '$SEARCH_QUERY.FETCH_OPTIONS' +PROP_CUSTOM_DATA = '$SEARCH_QUERY.CUSTOM_DATA' PREFIX_XML = '<xml><![CDATA[' POSTFIX_XML = ']]></xml>'