Skip to content

Commit

Permalink
Add externalIds to Activity #823
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Feb 27, 2024
1 parent a1d5a0b commit 90e4b10
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
14 changes: 14 additions & 0 deletions grails-app/domain/au/org/ala/ecodata/Activity.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ class Activity {
projectActivityId index: true
bulkImportId index: true
version false
externalIds index:true
}

static hasMany = [externalIds:ExternalId]

ObjectId id
String activityId
String status = 'active'
Expand All @@ -54,6 +57,7 @@ class Activity {
String bulkImportId
Date startDate
Date endDate
List<ExternalId> externalIds

/** The type of activity performed. This field must match the name of an ActivityForm */
String type
Expand Down Expand Up @@ -127,6 +131,16 @@ class Activity {
formVersion nullable: true
verificationStatus nullable: true, inList: ['not applicable', 'not approved', 'not verified', 'under review' , 'approved']
bulkImportId nullable: true
externalIds nullable: true
}

static Activity findByExternalId(String externalId) {
where {
externalIds {
externalId == externalId
}
status != Status.DELETED
}.find()
}

}
3 changes: 2 additions & 1 deletion grails-app/domain/au/org/ala/ecodata/ExternalId.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class ExternalId implements Comparable {

enum IdType {
INTERNAL_ORDER_NUMBER, TECH_ONE_CODE, WORK_ORDER, GRANT_AWARD, GRANT_OPPORTUNITY, RELATED_PROJECT,
MONITOR_PROTOCOL_INTERNAL_ID, MONITOR_PROTOCOL_GUID, TECH_ONE_CONTRACT_NUMBER, MONITOR_PLOT_GUID, UNSPECIFIED }
MONITOR_PROTOCOL_INTERNAL_ID, MONITOR_PROTOCOL_GUID, TECH_ONE_CONTRACT_NUMBER, MONITOR_PLOT_GUID,
MONITOR_MINTED_COLLECTION_ID, UNSPECIFIED }

static constraints = {
}
Expand Down
5 changes: 3 additions & 2 deletions grails-app/services/au/org/ala/ecodata/ParatooService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class ParatooService {



private static Map mapActivity(Map surveyData, Map activity, ParatooProtocolConfig config) {
private static Map mapActivity(String mintedCollectionId, Map surveyData, Map activity, ParatooProtocolConfig config) {
activity.startDate = config.getStartDate(surveyData)
activity.endDate = config.getEndDate(surveyData)
activity.type = ''// map activity type from protocol
Expand All @@ -210,7 +210,7 @@ class ParatooService {
data: surveyData
]
activity.outputs = [output]
activity
activity.externalIds = [new ExternalId(idType:ExternalId.IdType.MONITOR_MINTED_COLLECTION_ID, externalId: mintedCollectionId)]
}

private ParatooProtocolConfig getProtocolConfig(String protocolId) {
Expand Down Expand Up @@ -371,6 +371,7 @@ class ParatooService {
form.publicationStatus = PublicationStatus.PUBLISHED
form.description = protocol.attributes.description
form.tags = tags
form.externalIds
}

private ParatooProject mapProject(Project project, AccessLevel accessLevel, List<Site> sites) {
Expand Down

0 comments on commit 90e4b10

Please sign in to comment.