

def _reconcile_datasets(coordinator, objects, root, namespace):
    '\n  Reconcile datasets, datainputs, and dataoutputs.\n  datasets and tied to datainputs and dataoutputs.\n  Other dataset properties are set from XML tree.\n\n  ``coordinator`` is used for look ups and creating relevant objects.\n  ``objects`` should be transformed from XSLTs and loaded via django deserializers.\n  ``root`` is the element root of the coordinator (lxml).\n  ``namespace`` defines the XML coordinator namespace and schema version.\n  '
    namespaces = {
        'n': namespace,
    }
    datasets = {
        
    }
    datainputs = []
    dataoutputs = []
    coordinator.save()
    for obj in objects:
        obj.object.coordinator = coordinator
        if isinstance(obj.object, Dataset):
            obj.object.pk = None
            obj.object.save()
            dataset_elements = root.xpath(('//n:dataset[@name="%s"]' % obj.object.name), namespaces=namespaces)
            for dataset_element in dataset_elements:
                obj.object.start = oozie_to_django_datetime(dataset_element.get('initial-instance'))
            datasets[obj.object.name] = obj.object
            obj.object.save()
        elif isinstance(obj.object, DataInput):
            datainputs.append(obj.object)
        elif isinstance(obj.object, DataOutput):
            dataoutputs.append(obj.object)
    for datainput in datainputs:
        datainput_elements = root.xpath(('//n:data-in[@name="%s"]' % datainput.name), namespaces=namespaces)
        for datainput_element in datainput_elements:
            datainput.dataset = datasets[datainput_element.get('dataset')]
        datainput.pk = None
        datainput.save()
    for dataoutput in dataoutputs:
        dataoutput_elements = root.xpath(('//n:data-out[@name="%s"]' % dataoutput.name), namespaces=namespaces)
        for dataoutput_element in dataoutput_elements:
            dataoutput.dataset = datasets[dataoutput_element.get('dataset')]
        dataoutput.pk = None
        dataoutput.save()

dataset/ETHPy150Open cloudera/hue/apps/oozie/src/oozie/importlib/coordinators.py _reconcile_datasets/original