Skip to content
Open
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
58 changes: 58 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
<artifactId>JIRATimeParser</artifactId>
<version>1.0-SNAPSHOT</version>

<repositories>
<repository>
<id>atlassian-public</id>
<url>https://maven.atlassian.com/repository/public</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
</repositories>

<dependencies>
<!--&lt;!&ndash; https://mvnrepository.com/artifact/org.apache.commons/commons-csv &ndash;&gt;-->
Expand All @@ -23,6 +38,49 @@
<artifactId>javacsv</artifactId>
<version>2.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.atlassian.jira/jira-rest-java-client-api -->
<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-api</artifactId>
<version>4.0.0</version>
</dependency>

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-rest-java-client-core</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.httpclient</groupId>
<artifactId>atlassian-httpclient-apache-httpcomponents</artifactId>
<version>0.11.0</version>
</dependency>
<dependency>
<groupId>com.atlassian.fugue</groupId>
<artifactId>fugue</artifactId>
<version>2.2.1</version>
</dependency>

<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.8</version>
</dependency>

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>

<dependency>
<groupId>com.atlassian.jira</groupId>
<artifactId>jira-api</artifactId>
<version>7.0.0</version>
<scope>provided</scope>
</dependency>




</dependencies>
Expand Down
211 changes: 204 additions & 7 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,216 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.*;

import com.csvreader.CsvReader;
import com.dudar.ConnectionData;
import com.dudar.JIRA_Accessor;

public class Main {
import javax.security.sasl.AuthenticationException;

import com.dudar.TicketDataRecord;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class Main extends Application{

public List<TicketDataRecord> records = new ArrayList<>();

public static void main (String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("JIRA Worklog Time Parser");

String url = "";
String user = "";
String pass = "";

Properties prop = new Properties();
try {
//load a properties file from class path, inside static method
prop.load(Main.class.getClassLoader().getResourceAsStream("credentials.properties"));

//get the property value and print it out
url = prop.getProperty("url");
user = prop.getProperty("user_name");
pass = prop.getProperty("user_pass");

}
catch (IOException ex) {
ex.printStackTrace();
}

GridPane grid = new GridPane();
grid.setAlignment(Pos.CENTER);
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(25, 25, 25, 25));

Text scenetitle = new Text("Welcome");
scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
grid.add(scenetitle, 0, 0, 2, 1);

Label jiraUrl = new Label("JIRA URL:");
grid.add(jiraUrl, 0, 1);

TextField urlTextField = new TextField();
urlTextField.setText(url);
grid.add(urlTextField, 1, 1);

Label userName = new Label("User Name:");
grid.add(userName, 0, 2);

TextField userTextField = new TextField();
userTextField.setText(user);
grid.add(userTextField, 1, 2);

Label pw = new Label("Password:");
grid.add(pw, 0, 3);

PasswordField pwBox = new PasswordField();
pwBox.setText(pass);
grid.add(pwBox, 1, 3);

Label usersLog = new Label("Name of users (separateed by comma):");
grid.add(usersLog, 0, 4);

TextField usersTextField = new TextField();
usersTextField.setText("Name of users (separateed by comma)");
grid.add(usersTextField, 1, 4);

Button btn_newWindows = new Button("Results");
HBox hbBtn = new HBox(10);
hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
hbBtn.getChildren().add(btn_newWindows);
btn_newWindows.setDisable(true);
grid.add(hbBtn, 0, 5);
btn_newWindows.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {
showResultsView(primaryStage);
}
});

Button btn = new Button("Get data");
hbBtn = new HBox(10);
hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
hbBtn.getChildren().add(btn);
grid.add(hbBtn, 1, 5);
btn.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {
System.out.println("Start");

JIRA_Accessor accessor = new JIRA_Accessor();

try {
records = accessor.getResponseResult(new ConnectionData(urlTextField.getText(), userTextField.getText(), pwBox.getText()), usersTextField.getText());
} catch (AuthenticationException e) {
e.printStackTrace();
}

System.out.println("Finish");
if(!records.isEmpty())
btn_newWindows.setDisable(false);
}
});

primaryStage.setScene(new Scene(grid, 660, 400));
primaryStage.setX(100);
primaryStage.setY(100);
primaryStage.show();
}

private void showResultsView(Stage primaryStage) {
final TableView table = new TableView();

Label secondLabel = new Label("I'm a Label on new Window");

StackPane secondaryLayout = new StackPane();
secondaryLayout.getChildren().add(secondLabel);

Scene secondScene = new Scene(secondaryLayout, 800, 600);

// New window (Stage)
Stage newWindow = new Stage();
newWindow.setTitle("Second Stage");
newWindow.setScene(secondScene);

// Specifies the modality for new window.
newWindow.initModality(Modality.APPLICATION_MODAL);

// Specifies the owner Window (parent) for new window
newWindow.initOwner(primaryStage);

// Set position of second window, related to primary window.
newWindow.setX(primaryStage.getX() + 10);
newWindow.setY(primaryStage.getY() + 10);

table.setEditable(true);

TableColumn authorNameCol = new TableColumn("Reporter");
TableColumn ticketNameCol = new TableColumn("Ticket Name");
TableColumn summaryCol = new TableColumn("Summary");
TableColumn hoursCol = new TableColumn("Hours");

table.getColumns().addAll(authorNameCol, ticketNameCol, summaryCol, hoursCol);

final ObservableList<TicketDataRecord> data1 = FXCollections.observableArrayList(
new TicketDataRecord("Jacob1", "ANS-1", "1h 15m", "1"),
new TicketDataRecord("Jacob2", "ANS-2", "Summary 2", "2h 15m"),
new TicketDataRecord("Jacob3", "ANS-3", "Summary 3", "3h 15m"),
new TicketDataRecord("Jacob4", "ANS-4", "Summary 4", "4h 15m"),
new TicketDataRecord("Jacob5", "ANS-5", "Summary 5", "5h 15m")
);

final ObservableList<TicketDataRecord> data = FXCollections.observableArrayList();
for(TicketDataRecord rec : records){
data.add(rec);
}

authorNameCol.setCellValueFactory(
new PropertyValueFactory<>("authorName")
);
ticketNameCol.setCellValueFactory(
new PropertyValueFactory<>("ticketNumber")
);
summaryCol.setCellValueFactory(
new PropertyValueFactory<>("ticketSummary")
);
hoursCol.setCellValueFactory(
new PropertyValueFactory<>("loggedHours")
);

table.setItems(data);

secondaryLayout.getChildren().add(table);

newWindow.show();
}

private static void doTheJob(String[] args) {
String pathToFile;
String pathToFileCreate;
String reportMonth;
Expand Down Expand Up @@ -136,8 +335,6 @@ public static void main (String[] args) {
pw.close();
System.out.println("Transformation completed!");
}


}

}
3 changes: 0 additions & 3 deletions src/main/java/TicketLoggedWork.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
import java.util.List;
import java.util.Map;

/**
* Created by Oleg_Dudar on 21-Nov-17.
*/
public class TicketLoggedWork {
String number;
String summary;
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/com/dudar/ConnectionData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.dudar;

public class ConnectionData {
private String url;
private String user;
private String pass;

public ConnectionData(String url, String user, String pass){
this.url = url;
this.user = user;
this.pass = pass;
}

public String getUrl(){
return this.url;
}

public String getUser(){
return this.user;
}

public String getPass(){
return this.pass;
}
}
Loading