-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexey Belostotskiy
committed
Oct 3, 2019
1 parent
05b0bae
commit 5c2bfdc
Showing
10 changed files
with
287 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
16 changes: 16 additions & 0 deletions
16
src/main/java/ru/mail/jira/plugins/groovy/api/entity/AuditLogIssueRelation.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ru.mail.jira.plugins.groovy.api.entity; | ||
|
||
import net.java.ao.Entity; | ||
import net.java.ao.schema.Indexed; | ||
import net.java.ao.schema.NotNull; | ||
import net.java.ao.schema.Table; | ||
|
||
@Table("AUDIT_ISSUE_REL") | ||
public interface AuditLogIssueRelation extends Entity { | ||
@NotNull | ||
AuditLogEntry getAuditLog(); | ||
|
||
@NotNull | ||
@Indexed | ||
Long getIssueId(); | ||
} |
This file contains 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 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
14 changes: 14 additions & 0 deletions
14
...ain/java/ru/mail/jira/plugins/groovy/impl/repository/querydsl/QAuditLogIssueRelation.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package ru.mail.jira.plugins.groovy.impl.repository.querydsl; | ||
|
||
import com.atlassian.pocketknife.spi.querydsl.EnhancedRelationalPathBase; | ||
import com.querydsl.core.types.dsl.NumberPath; | ||
|
||
public class QAuditLogIssueRelation extends EnhancedRelationalPathBase<QAuditLogIssueRelation> { | ||
public final NumberPath<Integer> ID = createIntegerCol("ID").asPrimaryKey().build(); | ||
public final NumberPath<Integer> AUDIT_LOG_ID = createIntegerCol("AUDIT_LOG_ID").build(); | ||
public final NumberPath<Long> ISSUE_ID = createLongCol("ISSUE_ID").build(); | ||
|
||
public QAuditLogIssueRelation() { | ||
super(QAuditLogIssueRelation.class, "AO_2FC5DA_AUDIT_ISSUE_REL"); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
.../java/ru/mail/jira/plugins/groovy/impl/upgrade/Upgrade001CreateAuditLogIssueRelation.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package ru.mail.jira.plugins.groovy.impl.upgrade; | ||
|
||
import com.atlassian.activeobjects.external.ActiveObjects; | ||
import com.atlassian.plugin.spring.scanner.annotation.export.ExportAsService; | ||
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; | ||
import com.atlassian.sal.api.message.Message; | ||
import com.atlassian.sal.api.upgrade.PluginUpgradeTask; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Component; | ||
import ru.mail.jira.plugins.groovy.api.entity.AuditLogEntry; | ||
import ru.mail.jira.plugins.groovy.api.repository.AuditLogRepository; | ||
import ru.mail.jira.plugins.groovy.util.Const; | ||
|
||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
@Component | ||
@ExportAsService(PluginUpgradeTask.class) | ||
public class Upgrade001CreateAuditLogIssueRelation implements PluginUpgradeTask { | ||
private final ActiveObjects activeObjects; | ||
private final AuditLogRepository auditLogRepository; | ||
|
||
@Autowired | ||
public Upgrade001CreateAuditLogIssueRelation( | ||
@ComponentImport ActiveObjects activeObjects, | ||
AuditLogRepository auditLogRepository | ||
) { | ||
this.activeObjects = activeObjects; | ||
this.auditLogRepository = auditLogRepository; | ||
} | ||
|
||
@Override | ||
public int getBuildNumber() { | ||
return 100; | ||
} | ||
|
||
@Override | ||
public String getShortDescription() { | ||
return "Created relation between audit log entry and Jira issues"; | ||
} | ||
|
||
@Override | ||
public Collection<Message> doUpgrade() throws Exception { | ||
for (AuditLogEntry auditLogEntry : activeObjects.find(AuditLogEntry.class)) { | ||
auditLogRepository.createRelations(auditLogEntry); | ||
} | ||
|
||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public String getPluginKey() { | ||
return Const.PLUGIN_KEY; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/ru/mail/jira/plugins/groovy/servlet/IssuePanelContextProvider.java
This file contains 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package ru.mail.jira.plugins.groovy.servlet; | ||
|
||
import com.atlassian.jira.issue.Issue; | ||
import com.atlassian.jira.plugin.webfragment.contextproviders.AbstractJiraContextProvider; | ||
import com.atlassian.jira.plugin.webfragment.model.JiraHelper; | ||
import com.atlassian.jira.user.ApplicationUser; | ||
import com.google.common.collect.ImmutableMap; | ||
import ru.mail.jira.plugins.groovy.api.repository.AuditLogRepository; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
public class IssuePanelContextProvider extends AbstractJiraContextProvider { | ||
private final AuditLogRepository auditLogRepository; | ||
|
||
public IssuePanelContextProvider( | ||
AuditLogRepository auditLogRepository | ||
) { | ||
this.auditLogRepository = auditLogRepository; | ||
} | ||
|
||
@Override | ||
public Map getContextMap( | ||
ApplicationUser applicationUser, JiraHelper jiraHelper | ||
) { | ||
Map<String, Object> params = jiraHelper.getContextParams(); | ||
|
||
Issue issue = (Issue) params.get("issue"); | ||
|
||
if (issue == null) { | ||
return ImmutableMap.of("changes", Collections.emptyList()); | ||
} | ||
|
||
return ImmutableMap.of( | ||
"changes", auditLogRepository.getRelated(issue.getId()) | ||
); | ||
} | ||
} |
This file contains 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 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.