[TASK] Expanding the structure, getting the Mapper mechanisms ready and in place.
This commit is contained in:
1 parent
59e2543018
commit
b0a04b951e
10 files changed
+244
-33
No files matched your search
+2
-2
@@ -20,5 +20,5 @@ class PersonIdentityManager():
|
||||
def get_global_identities(self):
|
||||
return PersonGlobalIdentity.objects.all()
|
||||
|
||||
def get_mapped_identities_for_project(self, project):
|
||||
return CitaviProjectIdentity.objects.filter(project=project).all()
|
||||
def get_mapped_identities_for_project(self, project_instance):
|
||||
return CitaviProjectIdentity.objects.filter(project=project_instance).all()
|
||||
+8
-5
@@ -20,14 +20,14 @@ class PersonMapper():
|
||||
print "Len citavi persons: " + str(len(citavi_persons))
|
||||
print "Len mapped persons: " + str(len(mapped_persons))
|
||||
|
||||
if len(mapped_persons) == 0:
|
||||
return citavi_persons
|
||||
|
||||
# Prepare citavi_persons into a uuid->person dict, then eliminate mapped ones. This is ugly and a little slow.
|
||||
citavi_uuid_dict = {}
|
||||
for person in citavi_persons:
|
||||
citavi_uuid_dict[person.ID] = person
|
||||
|
||||
if len(mapped_persons) == 0:
|
||||
return citavi_uuid_dict
|
||||
|
||||
print len(citavi_uuid_dict)
|
||||
|
||||
for person in mapped_persons:
|
||||
@@ -42,11 +42,14 @@ class PersonMapper():
|
||||
def create_new_identity(self, project, person):
|
||||
self._person_identity_manager.create_identity(project, person.ID)
|
||||
|
||||
def get_person_by_uuid(self, project, uuid): #
|
||||
return self._citavi_project_manager.get_person_by_uuid(project.id, uuid)
|
||||
|
||||
def test():
|
||||
from frontend.models import Project
|
||||
project = Project.objects.get(id=1)
|
||||
p = PersonMapper()
|
||||
unmapped = p.get_unmapped_identities(project)
|
||||
print unmapped
|
||||
# for person in unmapped:
|
||||
# p.create_new_identity(project, person)
|
||||
for person in unmapped:
|
||||
p.create_new_identity(project, person)
|
||||
Reference in new issue
Block a user