-
-
Notifications
You must be signed in to change notification settings - Fork 14
Feature/commit refactor #135
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
508f9b4
Refactor to use commitId instead of docId and adding munging of assoc…
HuiJun 60ebac5
Add commitId support for existing commits
HuiJun d2491c7
use bulk processor for elastic script update on branch create
fb1970f
Break up commits by size internally and move commit id setting
HuiJun 989188e
Assign id to commit id, if not set
HuiJun aa9fa37
Increase delay for commit indexing
HuiJun c7bdbb8
Increase delay for cameo tests
HuiJun bff1da4
Refactor to use commit object's id as commit id
HuiJun 9d507b9
Remove action attribute fix more commit id references
HuiJun 35538b5
Optimize element history and change fields to text instead of varchar
HuiJun 9aad069
Revert commitId elastic mapping
HuiJun 85dae16
Change length of fields and revert deleted test
HuiJun 5e60981
Add parameter support for projects endpoint
HuiJun 68cc229
Implement get project by org id in project repository and define orgI…
HuiJun 2126179
add test for get project by org,
01c4ecd
add test for getting nonexisting commit, fix optional return
8772ad3
Clean up copy method
HuiJun fce1b10
Merge branch 'feature/commitRefactor' of https://github.com/Open-MBEE…
HuiJun 54b27f2
fill in ref and project id for ref commits
1015cd1
Simplify existsById method for commits
HuiJun fb26f76
Merge branch 'feature/commitRefactor' of https://github.com/Open-MBEE…
HuiJun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -189,10 +189,11 @@ public ElementsResponse createOrUpdate(String projectId, String refId, ElementsR | |
| ContextHolder.setContext(projectId, refId); | ||
| boolean overwriteJson = Boolean.parseBoolean(params.get("overwrite")); | ||
| nodePostHelper.setPreserveTimestamps(Boolean.parseBoolean(params.get("preserveTimestamps"))); | ||
| String commitId = params.get("commitId"); | ||
|
|
||
| NodeChangeInfo info = nodePostHelper | ||
| .processPostJson(req.getElements(), overwriteJson, | ||
| createCommit(user, refId, projectId, req), this); | ||
| createCommit(user, refId, projectId, req, commitId), this); | ||
|
|
||
| commitChanges(info); | ||
|
|
||
|
|
@@ -220,16 +221,23 @@ protected void commitChanges(NodeChangeInfo info) { | |
| } | ||
| this.nodeIndex.removeFromRef(info.getOldDocIds()); | ||
|
|
||
| Commit commit = new Commit(); | ||
| commit.setBranchId(cmjs.getRefId()); | ||
| commit.setCommitType(CommitType.COMMIT); | ||
| commit.setCreator(cmjs.getCreator()); | ||
| commit.setDocId(cmjs.getId()); | ||
| commit.setTimestamp(now); | ||
| commit.setComment(cmjs.getComment()); | ||
|
|
||
| this.commitRepository.save(commit); | ||
| Optional<Commit> existing = this.commitRepository.findByCommitId(cmjs.getId()); | ||
| existing.ifPresentOrElse( | ||
| current -> { | ||
| this.logger.debug(String.format("Commit object %s already exists. Skipping record creation.", current.getCommitId())); | ||
| }, | ||
| () -> { | ||
| Commit commit = new Commit(); | ||
| commit.setCommitId(cmjs.getId()); | ||
| commit.setBranchId(cmjs.getRefId()); | ||
| commit.setCommitType(CommitType.COMMIT); | ||
| commit.setCreator(cmjs.getCreator()); | ||
| commit.setTimestamp(now); | ||
| commit.setComment(cmjs.getComment()); | ||
| this.commitRepository.save(commit); | ||
| }); | ||
| this.commitIndex.index(cmjs); | ||
|
|
||
| this.nodeRepository.getTransactionManager().commit(status); | ||
| } catch (Exception e) { | ||
| logger.error("commitChanges error: ", e); | ||
|
|
@@ -282,7 +290,7 @@ public ElementsResponse delete(String projectId, String refId, ElementsRequest r | |
| ContextHolder.setContext(projectId, refId); | ||
|
|
||
| NodeChangeInfo info = nodeDeleteHelper | ||
| .processDeleteJson(req.getElements(), createCommit(user, refId, projectId, req), | ||
| .processDeleteJson(req.getElements(), createCommit(user, refId, projectId, req, null), | ||
| this); | ||
| ElementsResponse response = new ElementsResponse(); | ||
|
|
||
|
|
@@ -294,13 +302,18 @@ public ElementsResponse delete(String projectId, String refId, ElementsRequest r | |
| } | ||
|
|
||
| private CommitJson createCommit(String creator, String refId, String projectId, | ||
| ElementsRequest req) { | ||
| ElementsRequest req, String commitId) { | ||
| CommitJson cmjs = new CommitJson(); | ||
| cmjs.setCreator(creator); | ||
| cmjs.setComment(req.getComment()); | ||
| cmjs.setSource(req.getSource()); | ||
| cmjs.setRefId(refId); | ||
| cmjs.setProjectId(projectId); | ||
|
|
||
| if (commitId != null && !commitId.isEmpty()) { | ||
| cmjs.setId(commitId); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there's somewhere else (initCommit)? that needs to be updated to check for existing id and generate docId |
||
| } | ||
|
|
||
| return cmjs; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can comment this function out for now so it doesn't show up in generated swagger