Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FRI-127 #328

Merged
merged 2 commits into from
Oct 12, 2021
Merged

FRI-127 #328

merged 2 commits into from
Oct 12, 2021

Conversation

dmcgihtsdo
Copy link
Contributor

@dmcgihtsdo dmcgihtsdo commented Oct 6, 2021

FRI-127 is concerned with returning certain criteria from authoring-acceptance-gateway whenever a snowstorm branch is flagged as having had content added via a batch process.

Snowstorm will set the appropriate flag whenever the import function is run or when updating/creating Concepts in bulk. This flag will later be picked up by authoring-acceptance-gateway.

This feature is spanned across several services. Please see below all pull requests.

Snowstorm

Reporting Engine

Authoring Acceptance Gateway

@dmcgihtsdo dmcgihtsdo requested a review from kaicode October 6, 2021 13:58
@dmcgihtsdo dmcgihtsdo self-assigned this Oct 6, 2021
Comment on lines +200 to +209
public Branch setAuthorFlag(String branchPath, SetAuthorFlag setAuthorFlag) {
Branch branch = branchService.findBranchOrThrow(branchPath);

Metadata metadata = branch.getMetadata();
Map<String, String> authFlagMap = metadata.getMapOrCreate(AUTHOR_FLAGS_METADATA_KEY);
authFlagMap.put(setAuthorFlag.getName(), String.valueOf(setAuthorFlag.isValue()));
metadata.putMap(AUTHOR_FLAGS_METADATA_KEY, authFlagMap);

return branchService.updateMetadata(branchPath, metadata);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic was previously in BranchController, however I needed it in another place (ConceptService).

I originally tried injecting the controller to the service, but that caused a circular dependency so I moved the logic to a separate service class.

Comment on lines -156 to +161
Branch branch = branchService.findBranchOrThrow(branchPath);

String name = setAuthorFlag.getName();
String value = String.valueOf(setAuthorFlag.isValue());
if (name == null || name.isEmpty()) {
throw new IllegalArgumentException("Name for author flag not present");
}

Metadata metadata = branch.getMetadata();
Map<String, String> authFlagMap = metadata.getMapOrCreate(AUTHOR_FLAGS_METADATA_KEY);
authFlagMap.put(name, value);
metadata.putMap(AUTHOR_FLAGS_METADATA_KEY, authFlagMap);

return getBranchPojo(branchService.updateMetadata(branchPath, metadata));
return getBranchPojo(sBranchService.setAuthorFlag(branchPath, setAuthorFlag));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been updated to use the new service method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved to a service class as it was needed in several places. After speaking with @kaicode , the code was no longer needed in the second place (still required in the controller). However, I've kept the change as it minimises the logic in the controller.

Comment on lines 175 to 178

Map<String, String> authFlagMap = metadata.getMapOrCreate(AUTHOR_FLAGS_METADATA_KEY);
authFlagMap.put(BATCH_CHANGE_KEY, "true");
metadata.putMap(AUTHOR_FLAGS_METADATA_KEY, authFlagMap);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When importing, the flag will be set on the branch.

Comment on lines +175 to +181

boolean codeSystem = codeSystemService.findByBranchPath(branchPath).isPresent();
if (!codeSystem) {
Map<String, String> authFlagMap = metadata.getMapOrCreate(AUTHOR_FLAGS_METADATA_KEY);
authFlagMap.put(BATCH_CHANGE_KEY, "true");
metadata.putMap(AUTHOR_FLAGS_METADATA_KEY, authFlagMap);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kaicode , I have added this codeSystem condition check after our chat.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flag will now only be set when not importing at the CodeSystem level.

Copy link
Member

@kaicode kaicode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@dmcgihtsdo dmcgihtsdo merged commit e9c5887 into develop Oct 12, 2021
@dmcgihtsdo dmcgihtsdo deleted the feature/FRI-127 branch October 12, 2021 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants