Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with Exploration tool #1588

Merged
merged 1 commit into from
Jan 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 12 additions & 9 deletions refinery/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,21 @@ def update_data_set_index(data_set):


@skip
def add_data_set_to_neo4j(dataset_uuid, user_id):
def add_data_set_to_neo4j(dataset, user_id):

"""Add a node in Neo4J for a dataset and give the owner read access.
Note: Neo4J manages read access only.
"""

logger.info(
'Add dataset (uuid: %s) to Neo4J and give read access to user ' +
'(id: %s)', dataset_uuid, user_id
'(id: %s)', dataset.uuid, user_id
)

graph = py2neo.Graph(urljoin(settings.NEO4J_BASE_URL, 'db/data'))

# Get annotations of the data_set
annotations = get_data_set_annotations(dataset_uuid)
annotations = get_data_set_annotations(dataset.uuid)
annotations = normalize_annotation_ont_ids(annotations)

try:
Expand All @@ -80,13 +81,13 @@ def add_data_set_to_neo4j(dataset_uuid, user_id):

statement_name = (
"MATCH (term:Class {name:{ont_id}}) "
"MERGE (ds:DataSet {uuid:{ds_uuid}}) "
"MERGE (ds:DataSet {id:{ds_id},uuid:{ds_uuid}}) "
"MERGE ds-[:`annotated_with`]->term"
)

statement_uri = (
"MATCH (term:Class {uri:{uri}}) "
"MERGE (ds:DataSet {uuid:{ds_uuid}}) "
"MERGE (ds:DataSet {id:{ds_id},uuid:{ds_uuid}}) "
"MERGE ds-[:`annotated_with`]->term"
)

Expand All @@ -96,7 +97,8 @@ def add_data_set_to_neo4j(dataset_uuid, user_id):
statement_uri,
{
'uri': annotation['value_uri'],
'ds_uuid': annotation['data_set_uuid']
'ds_id': dataset.id,
'ds_uuid': dataset.uuid
}
)
else:
Expand All @@ -108,7 +110,8 @@ def add_data_set_to_neo4j(dataset_uuid, user_id):
':' +
annotation['value_accession']
),
'ds_uuid': annotation['data_set_uuid']
'ds_id': dataset.id,
'ds_uuid': dataset.uuid
}
)

Expand All @@ -129,7 +132,7 @@ def add_data_set_to_neo4j(dataset_uuid, user_id):
tx.append(
statement,
{
'ds_uuid': dataset_uuid,
'ds_uuid': dataset.uuid,
'user_id': user_id
}
)
Expand All @@ -142,7 +145,7 @@ def add_data_set_to_neo4j(dataset_uuid, user_id):
"""
logger.error(
'Failed to add read access to data set (uuid: %s) for user '
'(uuid: %s) to Neo4J. Exception: %s', dataset_uuid, user_id, e
'(uuid: %s) to Neo4J. Exception: %s', dataset.uuid, user_id, e
)


Expand Down
6 changes: 4 additions & 2 deletions refinery/data_set_manager/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
from django.core.management import call_command

from core.models import DataSet, FileStoreItem, ExtendedGroup
from core.utils import update_data_set_index, add_data_set_to_neo4j
from core.utils import update_data_set_index, add_data_set_to_neo4j, \
update_annotation_sets_neo4j
from file_store.models import FileExtension
from .isa_tab_parser import IsaTabParser
from .models import Investigation, Node, \
Expand Down Expand Up @@ -385,7 +386,8 @@ def create_dataset(investigation_uuid, username, identifier=None, title=None,
dataset.save()
# Finally index data set
update_data_set_index(dataset)
add_data_set_to_neo4j(dataset.uuid, user.id)
add_data_set_to_neo4j(dataset, user.id)
update_annotation_sets_neo4j()
return dataset.uuid
return None

Expand Down