示例#1
0
 def from_json(self, json_license):
     self.set_labels(json_license['labels'])
     self.set_permissions(frozenset(json_license['permissions']))
     self.set_obligations(frozenset(json_license['obligations']))
     self.set_prohibitions(frozenset(json_license['prohibitions']))
     datasets = []
     for dataset in json_license['datasets']:
         dataset_object = Dataset()
         dataset_object.from_json(dataset)
         datasets.append(dataset_object)
     self.set_datasets(datasets)
示例#2
0
def add_dataset(request, graph):
    json_dataset = json.loads(request.body)
    object_dataset = Dataset()
    object_dataset.from_json(json_dataset)
    neo_dataset = NeoFactory.NeoDataset(object_dataset, graph)
    object_dataset = ObjectFactory.objectDataset(neo_dataset)
    try:
        neo_dataset.save()
        response = HttpResponse(
            json.dumps(object_dataset.to_json()),
            content_type='application/json',
            status=201,
        )
    except UniqueProperty:
        response = HttpResponse(
            json.dumps(object_dataset.to_json()),
            content_type='application/json',
            status=409,
        )
    response['Access-Control-Allow-Origin'] = '*'
    return response
def objectDataset(neo_dataset):
    obj_dataset = Dataset()
    obj_dataset.set_label(neo_dataset.label)
    obj_dataset.set_uri(neo_dataset.uri)
    obj_dataset.set_description(neo_dataset.description)
    return obj_dataset