Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pj-core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.project
/.classpath
/.settings/
/target/
/bulldozer-temp.json
/bulldozer-state.json
/.factorypath
28 changes: 28 additions & 0 deletions pj-core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>pj-core</artifactId>

<parent>
<groupId>com.g2forge.project</groupId>
<artifactId>pj-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pj-project/pom.xml</relativePath>
</parent>

<dependencies>
<dependency>
<groupId>com.g2forge.gearbox</groupId>
<artifactId>gb-argparse</artifactId>
<version>${gearbox.version}</version>
</dependency>
<dependency>
<groupId>com.g2forge.gearbox</groupId>
<artifactId>gb-jira</artifactId>
<version>${gearbox.version}</version>
</dependency>
</dependencies>
</project>
11 changes: 3 additions & 8 deletions pj-create/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@

<dependencies>
<dependency>
<groupId>com.g2forge.gearbox</groupId>
<artifactId>gb-argparse</artifactId>
<version>${gearbox.version}</version>
</dependency>
<dependency>
<groupId>com.g2forge.gearbox</groupId>
<artifactId>gb-jira</artifactId>
<version>${gearbox.version}</version>
<groupId>com.g2forge.project</groupId>
<artifactId>pj-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
import com.g2forge.alexandria.java.type.ref.ITypeRef;
import com.g2forge.alexandria.log.HLog;
import com.g2forge.gearbox.jira.ExtendedJiraRestClient;
import com.g2forge.gearbox.jira.JIRAServer;
import com.g2forge.gearbox.jira.JiraAPI;
import com.g2forge.gearbox.jira.fields.KnownField;
import com.g2forge.project.plan.create.CreateIssue.CreateIssueBuilder;
import com.g2forge.project.plan.create.field.KnownField;
import com.google.common.base.Objects;

import io.atlassian.util.concurrent.Promise;
Expand All @@ -63,7 +63,7 @@
* The <code>INPUTFILE</code> must be a YAML file, which consists of a configuration one field of which is <code>issues</code>. The configuration must specify
* at least a <code>summary</code> for each issue, and optionally more. The fields of the issues in the YAML file are documented below. The configuration can
* also include, at the top level, an entry for any field marked "configurable" whose value will be used for any issue that does not specify a value explicitly.
* Please see {@link JIRAServer} for information on specifying the Jira server and user account.
* Please see {@link JiraAPI} for information on specifying the Jira server and user account.
*
* <table>
* <caption>Create issues issue properties and their descriptions</caption> <thead>
Expand Down Expand Up @@ -257,7 +257,7 @@ protected Map<String, BasicComponent> getProjectComponents(final ExtendedJiraRes

protected List<String> implementChanges(Server server, Changes changes) throws IOException, URISyntaxException, InterruptedException, ExecutionException {
HLog.getLogControl().setLogLevel(Level.INFO);
try (final ExtendedJiraRestClient client = JIRAServer.createFromPropertyInput(server == null ? null : server.getApi(), null).connect(true)) {
try (final ExtendedJiraRestClient client = JiraAPI.createFromPropertyInput(server == null ? null : server.getApi(), null).connect(true)) {
final Map<String, LinkType> linkTypes = new HashMap<>();
for (IssuelinksType linkType : client.getMetadataClient().getIssueLinkTypes().get()) {
linkTypes.put(linkType.getName(), new LinkType(linkType.getName(), false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import java.util.Map;

import com.g2forge.gearbox.jira.JIRAServer;
import com.g2forge.project.plan.create.field.Field;
import com.g2forge.project.plan.create.field.KnownField;
import com.g2forge.gearbox.jira.JiraAPI;
import com.g2forge.gearbox.jira.fields.Field;
import com.g2forge.gearbox.jira.fields.IFieldConfig;
import com.g2forge.gearbox.jira.fields.KnownField;

import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -14,7 +15,7 @@
@Data
@Builder
@AllArgsConstructor
public class Server {
public class Server implements IFieldConfig {
@Singular
protected final Map<KnownField, Field> fields;

Expand All @@ -23,5 +24,5 @@ public class Server {
@Singular
protected final Map<String, String> users;

protected final JIRAServer api;
protected final JiraAPI api;
}

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 3 additions & 8 deletions pj-plan/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@

<dependencies>
<dependency>
<groupId>com.g2forge.gearbox</groupId>
<artifactId>gb-argparse</artifactId>
<version>${gearbox.version}</version>
</dependency>
<dependency>
<groupId>com.g2forge.gearbox</groupId>
<artifactId>gb-jira</artifactId>
<version>${gearbox.version}</version>
<groupId>com.g2forge.project</groupId>
<artifactId>pj-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions pj-plan/src/main/java/com/g2forge/project/plan/Download.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.g2forge.alexandria.command.invocation.CommandInvocation;
import com.g2forge.alexandria.log.HLog;
import com.g2forge.gearbox.jira.ExtendedJiraRestClient;
import com.g2forge.gearbox.jira.JIRAServer;
import com.g2forge.gearbox.jira.JiraAPI;

import lombok.Builder;
import lombok.Data;
Expand Down Expand Up @@ -67,7 +67,7 @@ public IExit invoke(CommandInvocation<InputStream, PrintStream> invocation) thro
header.createCell(1).setCellValue("Summary");
}

try (final ExtendedJiraRestClient client = JIRAServer.load().connect(true)) {
try (final ExtendedJiraRestClient client = JiraAPI.load().connect(true)) {
final int max = 500;
int base = 0, rowNum = 1;
while (true) {
Expand Down
7 changes: 7 additions & 0 deletions pj-report/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/.project
/.classpath
/.settings/
/target/
/bulldozer-temp.json
/bulldozer-state.json
/.factorypath
23 changes: 23 additions & 0 deletions pj-report/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>pj-report</artifactId>

<parent>
<groupId>com.g2forge.project</groupId>
<artifactId>pj-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pj-project/pom.xml</relativePath>
</parent>

<dependencies>
<dependency>
<groupId>com.g2forge.project</groupId>
<artifactId>pj-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
89 changes: 89 additions & 0 deletions pj-report/src/main/java/com/g2forge/project/report/Billing.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.g2forge.project.report;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.URISyntaxException;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;

import org.slf4j.event.Level;

import com.atlassian.jira.rest.client.api.IssueRestClient;
import com.atlassian.jira.rest.client.api.domain.ChangelogGroup;
import com.atlassian.jira.rest.client.api.domain.ChangelogItem;
import com.atlassian.jira.rest.client.api.domain.Issue;
import com.g2forge.alexandria.command.command.IStandardCommand;
import com.g2forge.alexandria.command.exit.IExit;
import com.g2forge.alexandria.command.invocation.CommandInvocation;
import com.g2forge.alexandria.java.adt.name.IStringNamed;
import com.g2forge.alexandria.java.core.helpers.HCollection;
import com.g2forge.alexandria.log.HLog;
import com.g2forge.gearbox.argparse.ArgumentParser;
import com.g2forge.gearbox.jira.ExtendedJiraRestClient;
import com.g2forge.gearbox.jira.JiraAPI;
import com.g2forge.gearbox.jira.fields.KnownField;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class Billing implements IStandardCommand {
@Data
@Builder(toBuilder = true)
@AllArgsConstructor
protected static class Arguments {
protected final String issueKey;
}

public static void main(String[] args) throws Throwable {
IStandardCommand.main(args, new Billing());
}

protected void demoLogChanges(final String issueKey) throws InterruptedException, ExecutionException, IOException, URISyntaxException {
final Set<String> fields = HCollection.asList(KnownField.Status).stream().map(IStringNamed::getName).collect(Collectors.toSet());
try (final ExtendedJiraRestClient client = JiraAPI.load().connect(true)) {
final Issue issue = client.getIssueClient().getIssue(issueKey, HCollection.asList(IssueRestClient.Expandos.CHANGELOG)).get();
log.info("Created at {}", issue.getCreationDate());
for (ChangelogGroup changelogGroup : issue.getChangelog()) {
boolean printedGroupLabel = false;
for (ChangelogItem changelogItem : changelogGroup.getItems()) {
if ((fields == null) || fields.contains(changelogItem.getField())) {
if (!printedGroupLabel) {
log.info("{} {}", changelogGroup.getCreated(), changelogGroup.getAuthor().getDisplayName());
printedGroupLabel = true;
}
log.info("\t{}: {} -> {}", changelogItem.getField(), changelogItem.getFromString(), changelogItem.getToString());
}
}
}
}
}

@Override
public IExit invoke(CommandInvocation<InputStream, PrintStream> invocation) throws Throwable {
HLog.getLogControl().setLogLevel(Level.INFO);
final Arguments arguments = ArgumentParser.parse(Arguments.class, invocation.getArguments());

demoLogChanges(arguments.getIssueKey());

// Progressing: Input - API info, list of users
// TODO: Search for all relevant issues (anything updatedBy a relevant user in the given time range https://confluence.atlassian.com/jirasoftwareserver/advanced-searching-functions-reference-939938746.html, might have to search across all users)

// TODO: I/O - Start time and end time for the report, and the exact time we ran in
// TODO: Build a status history for an issue (Limit to the queried time range, Infer initial status from first status change, and create a timestamp of "now" for the end if needed)
// TODO: Input - working hours for a person (just start/stop times & days of week for now, add support for exceptions later)
// TODO: Input - mapping of issues to accounts (e.g. by epic, by component, etc)
// TODO: Construct a per-person timeline
// what accounts were they working on at all times (what issues, then group issues by account, two accounts can be double billed, or split)
// Reduce issue timeline to "active" statuses, and project those times against working hours
// Abstract the projection, so I can add filters/exceptions/days-off later
// TODO: Report on any times where a person was not billing to anything, but was working
// TODO: Report on any times an issue changed status outside working hours

return IStandardCommand.SUCCESS;
}
}
10 changes: 10 additions & 0 deletions pj-report/src/main/java/com/g2forge/project/report/Report.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.g2forge.project.report;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;

@Data
@Builder(toBuilder = true)
@AllArgsConstructor
public class Report {}
20 changes: 20 additions & 0 deletions pj-report/src/main/java/com/g2forge/project/report/Request.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.g2forge.project.report;

import java.util.List;

import com.g2forge.gearbox.jira.JiraAPI;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Singular;

@Data
@Builder(toBuilder = true)
@AllArgsConstructor
public class Request {
protected final JiraAPI api;

@Singular
protected final List<String> users;
}
2 changes: 2 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

<modules>
<module>pj-project</module>
<module>pj-core</module>
<module>pj-create</module>
<module>pj-plan</module>
<module>pj-report</module>
</modules>
</project>