Skip to content

Commit

Permalink
Merge pull request #250 from chrisala/master
Browse files Browse the repository at this point in the history
Added 2 editor emails and a 2nd grant manager email to the project im…
  • Loading branch information
chrisala committed Jun 19, 2015
2 parents d16a8e5 + 2ffd133 commit d05a138
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ImportService {
def grailsApplication
def userService
def documentService
def roleEditor = "editor"
def roleAdmin = "admin"
def roleGrantManager = "caseManager"

Expand Down Expand Up @@ -1252,9 +1253,12 @@ class ImportService {
if (!projectDetails.error) {

def adminEmail = projectDetails.project.remove('adminEmail')
def grantManagerEmail = projectDetails.project.remove('grantManagerEmail')
def grantManagerEmail = projectDetails.project.remove('grantManagerEmail')
def grantManagerEmail2 = projectDetails.project.remove('grantManagerEmail2')
def applicantEmail = projectDetails.project.remove('applicantEmail')
def adminEmail2 = projectDetails.project.remove('adminEmail2')
def editorEmail = projectDetails.project.remove('editorEmail')
def editorEmail2 = projectDetails.project.remove('editorEmail2')

def result = importProject(projectDetails.project, false) // Do not overwrite existing projects because of the impacts to sites / activities etc.

Expand All @@ -1269,6 +1273,10 @@ class ImportService {
addUser(applicantEmail, roleAdmin, projectId, projectDetails.errors)
addUser(adminEmail2, roleAdmin, projectId, projectDetails.errors)
addUser(grantManagerEmail, roleGrantManager, projectId, projectDetails.errors)
addUser(grantManagerEmail2, roleGrantManager, projectId, projectDetails.errors)
addUser(editorEmail, roleEditor, projectId, projectDetails.errors)
addUser(editorEmail2, roleEditor, projectId, projectDetails.errors)


def sites = projectDetails.sites
sites.each { site ->
Expand Down
7 changes: 5 additions & 2 deletions src/groovy/au/org/ala/fieldcapture/GmsMapper.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.text.SimpleDateFormat
*/
class GmsMapper {

public static final List GMS_COLUMNS = ['PROGRAM_NM', 'ROUND_NM', 'APP_ID', 'EXTERNAL_ID', 'APP_NM', 'APP_DESC', 'START_DT', 'FINISH_DT', 'FUNDING', 'APPLICANT_NAME', 'ORG_TRADING_NAME', 'APPLICANT_EMAIL', 'AUTHORISEDP_CONTACT_TYPE', 'AUTHORISEDP_EMAIL', 'GRANT_MGR_EMAIL', 'DATA_TYPE', 'ENV_DATA_TYPE', 'PGAT_PRIORITY', 'PGAT_GOAL_CATEGORY', 'PGAT_GOALS', 'PGAT_OTHER_DETAILS','PGAT_PRIMARY_ACTIVITY','PGAT_ACTIVITY_DELIVERABLE_GMS_CODE','PGAT_ACTIVITY_DELIVERABLE','PGAT_ACTIVITY_TYPE','PGAT_ACTIVITY_UNIT','PGAT_UOM', 'UNITS_COMPLETED']
public static final List GMS_COLUMNS = ['PROGRAM_NM', 'ROUND_NM', 'APP_ID', 'EXTERNAL_ID', 'APP_NM', 'APP_DESC', 'START_DT', 'FINISH_DT', 'FUNDING', 'APPLICANT_NAME', 'ORG_TRADING_NAME', 'APPLICANT_EMAIL', 'AUTHORISEDP_CONTACT_TYPE', 'AUTHORISEDP_EMAIL', 'GRANT_MGR_EMAIL', 'GRANT_MGR_EMAIL_2','DATA_TYPE', 'ENV_DATA_TYPE', 'PGAT_PRIORITY', 'PGAT_GOAL_CATEGORY', 'PGAT_GOALS', 'PGAT_OTHER_DETAILS','PGAT_PRIMARY_ACTIVITY','PGAT_ACTIVITY_DELIVERABLE_GMS_CODE','PGAT_ACTIVITY_DELIVERABLE','PGAT_ACTIVITY_TYPE','PGAT_ACTIVITY_UNIT','PGAT_UOM', 'UNITS_COMPLETED', 'EDITOR_EMAIL', 'EDITOR_EMAIL_2']

// These identify the data contained in the row.
static final LOCATION_DATA_TYPE = 'Location Data'
Expand Down Expand Up @@ -60,9 +60,12 @@ class GmsMapper {
FUNDING:[name:'funding', type:'decimal'],
AUTHORISEDP_EMAIL:[name:'adminEmail', type:'email'],
GRANT_MGR_EMAIL:[name:'grantManagerEmail', type:'email'],
GRANT_MGR_EMAIL_2:[name:'grantManagerEmail2', type:'email'],
SERVICE_PROVIDER:[name:'serviceProviderName', type:'string'],
APPLICANT_EMAIL:[name:'applicantEmail', type:'email'],
ADMIN_EMAIL:[name:'adminEmail2', type:'email']
ADMIN_EMAIL:[name:'adminEmail2', type:'email'],
EDITOR_EMAIL:[name:'editorEmail', type:'email'],
EDITOR_EMAIL_2:[name:'editorEmail2', type:'email']
]

def siteMapping = [
Expand Down
15 changes: 11 additions & 4 deletions test/unit/au/org/ala/fieldcapture/GmsMapperSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GmsMapperSpec extends Specification {
when:
def projectDetails = gmsMapper.mapProject(rows)

then:
then: "Project details are mapped correctly"
def expectedStartDate = '2014-10-12T13:00:00+0000'
def expectedEndDate = '2015-03-22T13:00:00+0000'
def project = projectDetails.project
Expand All @@ -50,12 +50,12 @@ class GmsMapperSpec extends Specification {
0 == project.funding
'not approved' == project.planStatus

// TODO check timeline!

// TODO check timeline
and: "sites are mapped correctly"
def sites = projectDetails.sites
// Ignoring for the moment, not sure how to handle the kml transformation, probably out of scope of the mapper.


and: "activities are mapped correctly"
// Input data contains 4 output targets which can be mapped to 3 activities
def activities = projectDetails.activities
3 == activities.size()
Expand All @@ -70,6 +70,7 @@ class GmsMapperSpec extends Specification {

}

and: "output targets are mapped correctly"
// output targets
def outputTargets = project.outputTargets
4 == outputTargets.size()
Expand All @@ -84,6 +85,12 @@ class GmsMapperSpec extends Specification {

}

and: "emails are mapped correctly"
project.editorEmail == "[email protected]"
project.editorEmail2 == "[email protected]"
project.grantManagerEmail == "[email protected]"
project.grantManagerEmail2 == "[email protected]"

}

/**
Expand Down
2 changes: 2 additions & 0 deletions test/unit/au/org/ala/fieldcapture/ImportServiceSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ class ImportServiceSpec extends Specification {
def importService
def projectServiceStub = Stub(ProjectService)
def activitiesModel = JSON.parse(new InputStreamReader(getClass().getResourceAsStream('/resources/activities-model.json')))
def userService = Mock(UserService)

def setup() {
importService = new ImportService()
importService.cacheService = new CacheService()
importService.projectService = projectServiceStub
importService.userService = userService

def metadataServiceStub = Stub(MetadataService)
metadataServiceStub.activitiesModel() >> activitiesModel
Expand Down
Loading

0 comments on commit d05a138

Please sign in to comment.