Skip to content

Commit

Permalink
ConDec-446: Enable that manual classified elements in JIRA issue comm…
Browse files Browse the repository at this point in the history
…ents are added to active object dabase
  • Loading branch information
kleebaum committed Jan 26, 2019
1 parent 56b02d1 commit fd45d24
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public void destroy() throws Exception {

@EventListener
public void onIssueEvent(IssueEvent issueEvent) {
if(issueEvent == null){
return;
}
if (issueEvent == null) {
return;
}
this.issueEvent = issueEvent;
this.projectKey = issueEvent.getProject().getKey();

Expand Down Expand Up @@ -136,13 +136,16 @@ private void handleDeleteIssue() {

private void handleEditComment() {
// If locked, a REST service is currently manipulating the comment and should
// not be
// handled by this event listener.
// not be handled by this event listener.
if (!DecXtractEventListener.editCommentLock) {
JiraIssueCommentPersistenceManager.deleteAllSentencesOfComments(issueEvent.getComment());
if(ConfigPersistenceManager.isUseClassiferForIssueComments(this.projectKey)) {
new ClassificationManagerForJiraIssueComments().classifyAllCommentsOfJiraIssue(this.issueEvent.getIssue());
}
if (ConfigPersistenceManager.isUseClassiferForIssueComments(this.projectKey)) {
new ClassificationManagerForJiraIssueComments()
.classifyAllCommentsOfJiraIssue(this.issueEvent.getIssue());
} else {
MutableComment comment = getChangedComment();
new CommentSplitterImpl().getSentences(comment);
}
JiraIssueCommentPersistenceManager.createLinksForNonLinkedElementsForIssue(issueEvent.getIssue().getId());
} else {
LOGGER.debug("DecXtract event listener:\nEditing comment is still locked.");
Expand All @@ -155,9 +158,12 @@ private void handleDeleteComment() {
}

private void handleNewComment() {
if(ConfigPersistenceManager.isUseClassiferForIssueComments(this.projectKey)) {
new ClassificationManagerForJiraIssueComments().classifyAllCommentsOfJiraIssue(this.issueEvent.getIssue());
}
if (ConfigPersistenceManager.isUseClassiferForIssueComments(this.projectKey)) {
new ClassificationManagerForJiraIssueComments().classifyAllCommentsOfJiraIssue(this.issueEvent.getIssue());
} else {
MutableComment comment = getChangedComment();
new CommentSplitterImpl().getSentences(comment);
}
JiraIssueCommentPersistenceManager.createLinksForNonLinkedElementsForIssue(issueEvent.getIssue().getId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ private static boolean isSentenceQualifiedForBinaryClassification(Sentence sente

private List<Sentence> updateSentencesWithBinaryClassificationResult(List<Boolean> classificationResult,
List<Sentence> sentences) {
if (classificationResult.size() == 0) {
return sentences;
}
int i = 0;
for (Sentence sentence : sentences) {
if (isSentenceQualifiedForBinaryClassification(sentence)) {
//TODO Next line can cause bug check in live system
if(classificationResult.size() !=0) {
sentence.setRelevant(classificationResult.get(i));
sentence.setValidated(false);
JiraIssueCommentPersistenceManager.updateInDatabase(sentence);
i++;
}
sentence.setRelevant(classificationResult.get(i));
sentence.setValidated(false);
JiraIssueCommentPersistenceManager.updateInDatabase(sentence);
i++;
}
}
return sentences;
Expand Down Expand Up @@ -144,7 +144,6 @@ private List<Sentence> updateSentencesWithFineGrainedClassificationResult(List<K
for (Sentence sentence : sentences) {
if (isSentenceQualifiedForFineGrainedClassification(sentence)) {
sentence.setType(classificationResult.get(i));
System.out.println(sentence.getTypeAsString());
sentence.setSummary(null);
sentence.setValidated(false);
persistenceManager.updateDecisionKnowledgeElement(sentence, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ private static void setParameters(Sentence element, DecisionKnowledgeInCommentEn
databaseEntry.setCommentId(element.getCommentId());
databaseEntry.setType(element.getTypeAsString());
databaseEntry.setRelevant(element.isRelevant());
System.out.println(element.isValidated());
databaseEntry.setValidated(element.isValidated());
databaseEntry.setStartSubstringCount(element.getStartSubstringCount());
databaseEntry.setEndSubstringCount(element.getEndSubstringCount());
Expand Down Expand Up @@ -327,7 +326,6 @@ public boolean updateDecisionKnowledgeElement(Sentence element, ApplicationUser
sentence.setEndSubstringCount(sentence.getStartSubstringCount() + changedPartOfComment.length());
sentence.setType(element.getType());
sentence.setValidated(element.isValidated());
System.out.println(sentence.isValidated());
sentence.setRelevant(element.getType() != KnowledgeType.OTHER);

boolean isUpdated = updateInDatabase(sentence);
Expand Down

0 comments on commit fd45d24

Please sign in to comment.