Skip to content
Snippets Groups Projects
Commit 45670975 authored by mpukhliak's avatar mpukhliak
Browse files

Merge branch 'master' of https://sissource.ethz.ch/sispub/openbis

parents b237fa5a 0b1f72ef
No related branches found
No related tags found
No related merge requests found
Showing
with 58 additions and 52 deletions
......@@ -135,6 +135,7 @@ public class ELNCollectionTypeMigration {
}
private static List executeQuery(String SQL, String key, Object value) {
//System.out.println("SQL: " + SQL + " Key: " + key + " Value: " + value);
DAOFactory daoFactory = (DAOFactory) CommonServiceProvider.getApplicationContext().getBean(ComponentNames.DAO_FACTORY);
Session currentSession = daoFactory.getSessionFactory().getCurrentSession();
NativeQuery nativeQuery = currentSession.createNativeQuery(SQL);
......@@ -165,7 +166,8 @@ public class ELNCollectionTypeMigration {
for (String experimentCode:experimentsOfTypeCollection) {
Set<ExperimentType> experimentTypes = getExperimentTypes(new String[]{experimentCode});
if (!experimentTypes.isEmpty()) {
ExperimentType experimentType = getExperimentTypes(new String[]{experimentCode}).iterator().next();
//System.out.println("EXPERIMENT_CODE: " + experimentCode + " IS OF TYPE: " + experimentTypes.iterator().next().getCode());
ExperimentType experimentType = experimentTypes.iterator().next();
if (!experimentType.getCode().equals(COLLECTION)) {
// Property Type used
Set<PropertyType> propertyTypes = getPropertyTypes(experimentType);
......
......@@ -21,13 +21,17 @@ from ch.ethz.sis.openbis.generic.asapi.v3.dto.service import CustomASServiceExec
from ch.systemsx.cisd.openbis.generic.server.jython.api.v1.impl import MasterDataRegistrationHelper
import sys
from ch.systemsx.cisd.openbis.generic.server.hotfix import ELNCollectionTypeMigration
ELNCollectionTypeMigration.migrate()
helper = MasterDataRegistrationHelper(sys.path)
api = CommonServiceProvider.getApplicationContext().getBean(ApplicationServerApi.INTERNAL_SERVICE_NAME)
sessionToken = api.loginAsSystem()
props = CustomASServiceExecutionOptions().withParameter('xls', helper.listXlsByteArrays())\
.withParameter('xls_name', 'ELN-LIMS').withParameter('update_mode', 'UPDATE_IF_EXISTS')\
.withParameter('scripts', helper.getAllScripts())
result = api.executeCustomASService(sessionToken, CustomASServiceCode("xls-import-api"), props);
result = api.executeCustomASService(sessionToken, CustomASServiceCode("xls-import-api"), props)
print("======================== master-data xls ingestion result ========================")
print(result)
print("======================== master-data xls ingestion result ========================")
No preview for this file type
......@@ -2,4 +2,4 @@ label = Zenodo Exports API
class = ch.systemsx.cisd.openbis.dss.generic.server.plugins.jython.JythonIngestionService
script-path = zenodoExports.py
limit-data-size-megabytes=${zenodo-exports-api-limit-data-size-megabytes:4000}
zenodoUrl=${zenodo-exports-api-zenodoUrl:https://localhost}
\ No newline at end of file
zenodoUrl=${zenodo-exports-api-zenodoUrl:https://zenodo.org}
\ No newline at end of file
......@@ -121,11 +121,6 @@ def process(context, parameters):
entity_type_creation_operations, entity_creation_operations, entity_type_update_operations, entity_update_operations = CreationOrUpdateToOperationParser.parse(
creations)
print(entity_type_creation_operations)
print(entity_creation_operations)
print(entity_type_update_operations)
print(entity_update_operations)
entity_type_update_results = str(api.executeOperations(session_token, entity_type_update_operations,
SynchronousOperationExecutionOptions()).getResults())
entity_type_creation_results = str(api.executeOperations(session_token, entity_type_creation_operations,
......
......@@ -14,6 +14,8 @@ from ch.ethz.sis.openbis.generic.asapi.v3.dto.space.create import SpaceCreation
from ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.create import VocabularyCreation
from ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.create import VocabularyTermCreation
from ch.ethz.sis.openbis.generic.asapi.v3.dto.vocabulary.id import VocabularyPermId
from ch.ethz.sis.openbis.generic.asapi.v3.dto.project.id import ProjectIdentifier
from ch.ethz.sis.openbis.generic.asapi.v3.dto.experiment.id import ExperimentIdentifier
from java.lang import UnsupportedOperationException
from ch.systemsx.cisd.common.exceptions import UserFailureException
from utils.openbis_utils import is_internal_namespace, get_script_name_for
......@@ -271,7 +273,7 @@ class ExperimentDefinitionToCreationParser(object):
experiment_creation = ExperimentCreation()
experiment_creation.typeId = EntityTypePermId(definition.attributes.get(u'experiment type'))
experiment_creation.code = experiment_properties.get(u'code')
experiment_creation.projectId = CreationId(experiment_properties.get(u'project'))
experiment_creation.projectId = ProjectIdentifier(experiment_properties.get(u'project'))
creation_id = experiment_properties.get(u'code')
experiment_creation.creationId = CreationId(creation_id)
for prop, value in experiment_properties.items():
......@@ -308,9 +310,9 @@ class SampleDefinitionToCreationParser(object):
if u'space' in sample_properties and sample_properties.get(u'space') is not None:
sample_creation.spaceId = CreationId(sample_properties.get(u'space'))
if u'project' in sample_properties and sample_properties.get(u'project') is not None:
sample_creation.projectId = CreationId(sample_properties.get(u'project'))
sample_creation.projectId = ProjectIdentifier(sample_properties.get(u'project'))
if u'experiment' in sample_properties and sample_properties.get(u'experiment') is not None:
sample_creation.experimentId = CreationId(sample_properties.get(u'experiment'))
sample_creation.experimentId = ExperimentIdentifier(sample_properties.get(u'experiment'))
if u'parents' in sample_properties and sample_properties.get(u'parents') is not None:
parent_creation_ids = []
parents = sample_properties.get(u'parents').split('\n')
......
......@@ -28,12 +28,12 @@ class OpenbisDuplicatesHandler(object):
if existing_element.code == str(creation.spaceId):
creation.spaceId = existing_element.permId
break
if ExperimentDefinitionToCreationType in self.creations:
for creation in self.creations[ExperimentDefinitionToCreationType]:
for existing_element in self.existing_elements[ProjectDefinitionToCreationType]:
if existing_element.code == str(creation.projectId):
creation.projectId = existing_element.permId
break
# if ExperimentDefinitionToCreationType in self.creations:
# for creation in self.creations[ExperimentDefinitionToCreationType]:
# for existing_element in self.existing_elements[ProjectDefinitionToCreationType]:
# if existing_element.code == str(creation.projectId):
# creation.projectId = existing_element.permId
# break
if SampleDefinitionToCreationType in self.creations:
for creation in self.creations[SampleDefinitionToCreationType]:
if creation.spaceId is not None:
......@@ -41,16 +41,16 @@ class OpenbisDuplicatesHandler(object):
if existing_element.code == str(creation.spaceId):
creation.spaceId = existing_element.permId
break
if creation.projectId is not None:
for existing_element in self.existing_elements[ProjectDefinitionToCreationType]:
if existing_element.code == str(creation.projectId):
creation.projectId = existing_element.identifier
break
if creation.experimentId is not None:
for existing_element in self.existing_elements[ExperimentDefinitionToCreationType]:
if existing_element.code == str(creation.experimentId):
creation.experimentId = existing_element.permId
break
# if creation.projectId is not None:
# for existing_element in self.existing_elements[ProjectDefinitionToCreationType]:
# if existing_element.code == str(creation.projectId):
# creation.projectId = existing_element.identifier
# break
# if creation.experimentId is not None:
# for existing_element in self.existing_elements[ExperimentDefinitionToCreationType]:
# if existing_element.code == str(creation.experimentId):
# creation.experimentId = existing_element.permId
# break
rewritten_children = []
if creation.childIds is not None:
......
......@@ -38,7 +38,7 @@ class SampleCreationSampleChildrenParentSearchCriteria(object):
sample_code = identifier.sampleCode
search_criteria.withCode().thatEquals(sample_code)
if project_code is not None:
search_criteria.withProject().withCode().thatEquals(project_code)
search_criteria.withProject().withIdentifier().thatEquals(project_code)
else:
search_criteria.withoutProject()
......@@ -66,12 +66,15 @@ class SampleCreationSampleSearchCriteria(object):
if creation.code is not None:
search_criteria.withCode().thatEquals(creation.code)
if creation.experimentId is not None:
search_criteria.withExperiment().withCode().thatEquals(str(creation.experimentId))
search_criteria.withExperiment().withIdentifier().thatEquals(str(creation.experimentId))
else:
search_criteria.withoutExperiment()
if creation.projectId is not None:
search_criteria.withProject().withCode().thatEquals(str(creation.projectId))
space_code, project_code = str(creation.projectId)[1:].split('/')
project_search_criteria = search_criteria.withProject()
project_search_criteria.withCode().thatEquals(project_code)
project_search_criteria.withSpace().withCode().thatEquals(space_code)
else:
search_criteria.withoutProject()
......@@ -104,11 +107,12 @@ class ProjectFromPropertiesSearchCriteria(object):
self.search_criteria = search_criteria_class
def get_search_criteria(self, specific_creations):
project_codes = [dotdict({'code': str(creation.projectId)}) for creation in
specific_creations if
space_project = [tuple(str(creation.projectId)[1:].split('/')) for creation in specific_creations if
creation.projectId is not None]
project_codes = [dotdict({'code': project, 'spaceId': space}) for (space, project) in space_project]
if project_codes == []:
return None
default_search_criteria_builder = ProjectFromProjectCreationSearchCriteria(self.search_criteria)
return default_search_criteria_builder.get_search_criteria(project_codes)
......@@ -119,11 +123,11 @@ class ExperimentFromPropertiesSearchCriteria(object):
self.search_criteria = search_criteria_class
def get_search_criteria(self, specific_creations):
experiment_codes = [dotdict({'code': str(creation.experimentId)}) for creation in specific_creations if
experiment_codes = [dotdict({'identifier': str(creation.experimentId)}) for creation in specific_creations if
creation.experimentId is not None]
if not experiment_codes:
return None
default_search_criteria_builder = DefaultCreationElementSearchCriteria(self.search_criteria)
default_search_criteria_builder = ExperimentFromExperimentCreationSearchCriteria(self.search_criteria)
return default_search_criteria_builder.get_search_criteria(experiment_codes)
......@@ -155,6 +159,19 @@ class ProjectFromProjectCreationSearchCriteria(object):
return self.search_criteria
class ExperimentFromExperimentCreationSearchCriteria(object):
def __init__(self, search_criteria_class):
self.search_criteria = search_criteria_class()
def get_search_criteria(self, specific_creations):
for creation in specific_creations:
if creation.identifier:
self.search_criteria.withIdentifier().thatEquals(creation.identifier)
self.search_criteria.withOrOperator()
return self.search_criteria
class VocabularyTermCreationVocabularyTermSearchCriteria(object):
def __init__(self, search_criteria_class):
......
......@@ -278,39 +278,25 @@ class SearchEngine():
# explicitly mentioned in xls sheet, it is ok.
existing_elements[results_key].extend(existing_specific_elements)
print("DEBUGDEBUG")
print(existing_elements)
return existing_elements
def _get_existing_elements(self, search_criterias, **kwargs):
search_operation = kwargs['search_operation']
print("SSSOOOO")
fetch_options = kwargs['fetch_options']
print("FFFFFSSSOOOO")
if not search_criterias:
return None
search_criterias = search_criterias if type(search_criterias) == list else [search_criterias]
print("SCCSCSCSCS")
print(search_criterias)
operations = [search_operation(search_criteria, fetch_options) for search_criteria in search_criterias]
print("OOOOOOOOOO301")
print(operations)
return self._execute_search_operation(operations)
def _execute_search_operation(self, operations):
print(operations)
print("BRBRBRBRBRBRBRB")
print(self.api)
execution_results = self.api.executeOperations(self.session_token, operations,
SynchronousOperationExecutionOptions())
print("WWWWWWWWWW")
result_objects = []
print(operations)
print(execution_results)
print(execution_results.getResults())
print(execution_results.getResults()[0])
print(execution_results.getResults()[0].getSearchResult())
print(execution_results.getResults()[0].getSearchResult().getObjects())
for search_result in execution_results.getResults():
result_objects.extend(search_result.getSearchResult().getObjects())
print("PRINTED THINGS")
print(result_objects)
return result_objects
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment