Skip to content
Snippets Groups Projects
Commit e8e2c451 authored by root's avatar root
Browse files

Latest: data registration works

parent e0d016f7
No related branches found
No related tags found
No related merge requests found
No preview for this file type
......@@ -40,7 +40,8 @@ class Dataset(StructuredNode):
"""
return {
'dataset_node_properties': {
'dataset_node_properties':
{
'uuid': self.uuid,
'fileTemplateName': self.fileTemplateName,
'userUuid': self.userUuid,
......
No preview for this file type
@csrf_exempt
def storeParseDataset(data):
"""
Creates nodes for each dataset with relative properties
"""
try:
logger.info('CHECK FUNCTION')
Dataset.create_or_update(uuid=data['uuid'],
userUuid=data['userUuid'],
crystalUuid=data['crystalUuid'],
currentPath=data['currentPath'],
generationPath=data['generationPath'],
fileTemplateName=data['fileTemplateName'],
blStartingDate=data['blStartingDate'],
beamlineName=data['beamlineName'],
facilityName=data['facilityName'])
logger.info('CREATE OR UPDATE')
# # dataset.save()
# # if dataset == None:
# # datasetNew = Dataset(uuid=data['uuid'],
# # userUuid=data['userUuid'],
# # crystalUuid=data['crystalUuid'],
# # currentPath=data['currentPath'],
# # generationPath=data['generationPath'],
# # fileTemplateName=data['fileTemplateName'],
# # blStartingDate=data['blStartingDate'],
# # beamlineName=data['beamlineName'],
# # facilityName=data['facilityName'])
# # datasetNew.save()
return JsonResponse({"Status": "INPUT REGISTERED"})
logger.info('RETURN')
except:
print(sys.exc_info()[0])
return ({"STATUS": "ERROR OCCURRED WHILE REGISTERING DATASET"})
\ No newline at end of file
......@@ -31,33 +31,36 @@ def storeInput(request):
json_data=json.loads(request.body)
json_data_dataset=json_data['dataset']
# json_data_storagehost=json_data['storageHost']
# json_data_user=json_data['user']
# json_data_construct=json_data['construct']
# json_data_computationhost=json_data['computationHost']
# json_data_datacollection=json_data['dataCollection']
# json_data_ocf=json_data['OCF']
json_data_storagehost=json_data['storageHost']
json_data_user=json_data['user']
json_data_construct=json_data['construct']
json_data_computationhost=json_data['computationHost']
json_data_datacollection=json_data['dataCollection']
json_data_ocf=json_data['construct']['OCF']
try:
# Register nodes
storeParseDataset(json_data_dataset)
# storeParseStorageHost(json_data_storagehost)
# storeParseUser(json_data_user)
# storeParseConstruct(json_data_construct)
# storeParseComputationHost(json_data_computationhost)
# storeParseDataCollection(json_data_datacollection)
# storeParseOCF(json_data_ocf)
storeParseStorageHost(json_data_storagehost)
storeParseUser(json_data_user)
storeParseConstruct(json_data_construct)
storeParseComputationHost(json_data_computationhost)
storeParseDataCollection(json_data_datacollection)
storeParseOCF(json_data_ocf)
# Register relationships
# connectConstructUser(json_data_construct, json_data_user)
# connectConstructStorageHost(json_data_construct, json_data_storagehost)
# connectConstructComputationHost(json_data_construct, json_data_computationhost)
# connectDatasetConstruct(json_data_dataset, json_data_construct)
# connectDatasetStorageHost(json_data_dataset, json_data_storagehost)
# connectDataCollectionDataset(json_data_datacollection, json_data_dataset)
connectConstructUser(json_data_construct, json_data_user)
connectConstructStorageHost(json_data_construct, json_data_storagehost)
connectConstructComputationHost(json_data_construct, json_data_computationhost)
connectDatasetConstruct(json_data_dataset, json_data_construct)
connectDatasetStorageHost(json_data_dataset, json_data_storagehost)
connectDataCollectionDataset(json_data_datacollection, json_data_dataset)
return JsonResponse({"Status": "INPUT SUCCESSFULLY REGISTERED"})
for input_ocf in json_data_ocf:
connectConstructOCF(json_data_construct, input_ocf)
return JsonResponse({"Status": "INPUT SUCCESSFULLY REGISTERED"})
except :
return JsonResponse({"Status":"ERROR OCCURRED"}, safe=False)
......@@ -69,7 +72,7 @@ def storeParseDataset(data):
"""
try:
dataset=Dataset.get_or_create(uuid=data['uuid'],
dataset=Dataset(uuid=data['uuid'],
userUuid=data['userUuid'],
crystalUuid=data['crystalUuid'],
currentPath=data['currentPath'],
......@@ -85,6 +88,22 @@ def storeParseDataset(data):
print(sys.exc_info()[0])
return ({"STATUS": "ERROR OCCURRED WHILE REGISTERING DATASET"})
# @csrf_exempt
# def storeParseDataset(data):
# """
# Creates nodes for each dataset with relative properties
# """
# try:
# # dataset=Dataset.create_or_update({"uuid": data['uuid']}, {"facilityName": data['facilityName']})
# Dataset.create_or_update(data.serialize)
# return dataset
# except:
# print(sys.exc_info()[0])
# return ({"STATUS": "ERROR OCCURRED WHILE REGISTERING DATASET"})
@csrf_exempt
def storeParseStorageHost(data):
......@@ -294,4 +313,20 @@ def connectDataCollectionDataset(data1, data2):
return JsonResponse({"STATUS": datacollection.generates.connect(dataset)}, safe=False)
except:
return JsonResponse({"STATUS": "ERROR OCCURRED WHILE CONNECTING DATA COLLECTION TO DATASET"}, safe=False)
\ No newline at end of file
return JsonResponse({"STATUS": "ERROR OCCURRED WHILE CONNECTING DATA COLLECTION TO DATASET"}, safe=False)
@csrf_exempt
def connectConstructOCF(data1, data2):
"""
Create a relationship between a construct and an ocf
"""
try:
construct=Construct.nodes.get(uuid=data1["uuid"])
ocf=OCF.nodes.get(uuid=data2["uuid"])
return JsonResponse({"STATUS": construct.has_ocf.connect(ocf)}, safe=False)
except:
return JsonResponse({"STATUS": "ERROR OCCURRED WHILE CONNECTING DATA COLLECTION TO DATASET"}, safe=False)
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