Skip to content

Commit

Permalink
Merge 5a6e3b0 into e95ef35
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling committed Aug 22, 2018
2 parents e95ef35 + 5a6e3b0 commit 1cb3f8c
Show file tree
Hide file tree
Showing 157 changed files with 6,463 additions and 2,751 deletions.
125 changes: 124 additions & 1 deletion README.md
Expand Up @@ -13,4 +13,127 @@ $ mvn clean spring-boot:run
### Production
```bash
$ mvn clean package -DskipTests -Dproduction
```
```

## Rest API

| **Title** | **Projects** |
| :------------------- | :------------------------------------------------------------------------------------------ |
| **Description** | Returns a list of all projects. |
| **URL** | ```/projects``` |
| **Method** | **GET** |
| **URL Parameters** | |
| **Success Response** | **Code:** 200 OK<br/>**Content Type:** application/json<br/> |
| **Sample Request** | ```/projects``` |
| **Notes** | These are managed projects for this service and not projects from a remote project manager. |

```json
{
"meta": {
"status": ApiStatus,
"action": ApiAction,
"message": String,
"id": String
},
"payload": {
"ArrayList<Project>": [
{
"id": Long,
"name": String,
"scopeId": String,
"remoteProjectManager": {
"id": Long,
"name": String,
"type": String
}
}
]
}
}
```

<hr />

| **Title** | **Active Sprints** |
| :------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Description** | Returns a list of all active sprints based on associated remote project manager projects. |
| **URL** | ```/sprints/active``` |
| **Method** | **GET** |
| **URL Parameters** | |
| **Success Response** | **Code:** 200 OK<br/>**Content Type:** application/json<br/>**Schema:** |
| **Sample Request** | ```/sprints/active``` |
| **Notes** | Currently, VersionOne is the only remote project manager implemented. VersionOne sprints are based on a timebox which is a sprint schedule in the UI. Projects can share the same sprint schedule and will appear to be the same sprint in this response. |

```json
{
"meta": {
"status": ApiStatus,
"action": ApiAction,
"message": String,
"id": String
},
"payload": {
"ArrayList<Sprint>": [
{
"id": String,
"name": String,
"project": String,
"cards": [
{
"id": String,
"number": String,
"type": String,
"status": String,
"name": String,
"description": String,
"estimate": Float,
"assignees": [
{
"id": String,
"name": String,
"avatar": String
}
]
}
]
}
]
}
}
```

<hr />

| **Title** | **Projects Stats** |
| :------------------- | :------------------------------------------------------------------------------------------------------------------ |
| **Description** | Returns a list of all projects with statistics gathered from their associated remote project manager projects. |
| **URL** | ```/projects/stats``` |
| **Method** | **GET** |
| **URL Parameters** | |
| **Success Response** | **Code:** 200 OK<br/>**Content Type:** application/json |
| **Sample Request** | ```/projects/stats``` |
| **Notes** | |

```json
{
"meta": {
"status": ApiStatus,
"action": ApiAction,
"message": String,
"id": String
},
"payload": {
"ArrayList<ProjectStats>": [
{
"id": String,
"name": String,
"requestCount": Interger,
"issueCount": Interger,
"featureCount": Interger,
"defectCount": Interger,
"backlogItemCount": Interger
}
]
}
}
```
10 changes: 6 additions & 4 deletions pom.xml
Expand Up @@ -51,7 +51,7 @@
<artifactId>validation</artifactId>
<version>2.0.0-RC5-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>edu.tamu.weaver</groupId>
<artifactId>email</artifactId>
Expand All @@ -64,6 +64,11 @@
<version>2.0.0-RC5-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand Down Expand Up @@ -125,7 +130,6 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<quiet>true</quiet>
<instrumentation>
Expand All @@ -145,7 +149,6 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.8</version>
<executions>
<execution>
<id>prepare-agent</id>
Expand All @@ -158,7 +161,6 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.3.0</version>
<configuration>
<repoToken></repoToken>
</configuration>
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/edu/tamu/app/ProjectApplication.java
Expand Up @@ -9,7 +9,6 @@

/**
* Web server initialization.
*
*/
@EnableScheduling
@SpringBootApplication
Expand All @@ -21,7 +20,6 @@ public class ProjectApplication extends SpringBootServletInitializer {
*
* @param args
* String[]
*
*/
public static void main(String[] args) {
SpringApplication.run(ProjectApplication.class, args);
Expand All @@ -32,9 +30,7 @@ public static void main(String[] args) {
*
* @param application
* SpringApplicationBuilder
*
* @return SpringApplicationBuilder
*
*/
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/edu/tamu/app/ProjectInitialization.java
@@ -1,26 +1,39 @@
package edu.tamu.app;

import java.util.Arrays;
import java.util.HashSet;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import edu.tamu.app.model.repo.VersionManagementSoftwareRepo;
import edu.tamu.app.model.CardType;
import edu.tamu.app.model.repo.CardTypeRepo;
import edu.tamu.app.model.repo.RemoteProjectManagerRepo;
import edu.tamu.app.service.registry.ManagementBeanRegistry;

@Component
@Profile("!test")
public class ProjectInitialization implements CommandLineRunner {

@Autowired
private ManagementBeanRegistry managementBeanRegistry;

@Autowired
private VersionManagementSoftwareRepo versionManagementSoftwareRepo;
private RemoteProjectManagerRepo remoteProjectManagerRepo;

@Autowired
private CardTypeRepo cardTypeRepo;

@Override
public void run(String... args) throws Exception {
versionManagementSoftwareRepo.findAll().forEach(versionManagementSoftware -> {
remoteProjectManagerRepo.findAll().forEach(versionManagementSoftware -> {
managementBeanRegistry.register(versionManagementSoftware);
});
if (cardTypeRepo.findByIdentifier("Feature") == null) {
cardTypeRepo.create(new CardType("Feature", new HashSet<String>(Arrays.asList(new String[] { "Story" }))));
}
}

}
Expand Up @@ -4,7 +4,7 @@

import org.springframework.stereotype.Service;

import edu.tamu.app.enums.Role;
import edu.tamu.app.model.Role;
import edu.tamu.app.model.User;
import edu.tamu.app.model.repo.UserRepo;
import edu.tamu.weaver.auth.model.Credentials;
Expand All @@ -20,26 +20,7 @@ public synchronized User updateUserByCredentials(Credentials credentials) {

User user = null;

if (!optionalUser.isPresent()) {

Role role = Role.ROLE_USER;

if (credentials.getRole() == null) {
credentials.setRole(role.toString());
}

String shibUin = credentials.getUin();

for (String uin : admins) {
if (uin.equals(shibUin)) {
role = Role.ROLE_ADMIN;
credentials.setRole(role.toString());
}
}

user = userRepo.create(credentials.getUin(), credentials.getEmail(), credentials.getFirstName(), credentials.getLastName(), role);

} else {
if (optionalUser.isPresent()) {
user = optionalUser.get();

boolean changed = false;
Expand All @@ -65,27 +46,44 @@ public synchronized User updateUserByCredentials(Credentials credentials) {
}

if (credentials.getRole() == null) {

user.setRole(Role.valueOf(credentials.getRole()));
user.setRole(getDefaultRole(credentials));
changed = true;
}

if (changed) {
user = userRepo.save(user);
}

} else {
user = userRepo.create(credentials.getUin(), credentials.getEmail(), credentials.getFirstName(), credentials.getLastName(), getDefaultRole(credentials));
}

credentials.setRole(user.getRole().toString());
credentials.setUin(user.getUsername());

return user;

}

@Override
public String getAnonymousRole() {
return Role.ROLE_ANONYMOUS.toString();
}

private Role getDefaultRole(Credentials credentials) {
Role role = Role.ROLE_USER;

if (credentials.getRole() == null) {
credentials.setRole(role.toString());
}

String shibUin = credentials.getUin();

for (String uin : admins) {
if (uin.equals(shibUin)) {
role = Role.ROLE_ADMIN;
credentials.setRole(role.toString());
}
}
return role;
}

}
15 changes: 15 additions & 0 deletions src/main/java/edu/tamu/app/cache/AbstractCache.java
@@ -0,0 +1,15 @@
package edu.tamu.app.cache;

public abstract class AbstractCache<T> implements Cache<T> {

private T cache;

public synchronized T get() {
return cache;
}

public synchronized void set(T cache) {
this.cache = cache;
}

}
14 changes: 14 additions & 0 deletions src/main/java/edu/tamu/app/cache/ActiveSprintsCache.java
@@ -0,0 +1,14 @@
package edu.tamu.app.cache;

import java.util.ArrayList;
import java.util.List;

import edu.tamu.app.cache.model.Sprint;

public class ActiveSprintsCache extends AbstractCache<List<Sprint>> {

public ActiveSprintsCache() {
set(new ArrayList<Sprint>());
}

}
9 changes: 9 additions & 0 deletions src/main/java/edu/tamu/app/cache/Cache.java
@@ -0,0 +1,9 @@
package edu.tamu.app.cache;

public interface Cache<T> {

public T get();

public void set(T cache);

}
14 changes: 14 additions & 0 deletions src/main/java/edu/tamu/app/cache/ProjectsStatsCache.java
@@ -0,0 +1,14 @@
package edu.tamu.app.cache;

import java.util.ArrayList;
import java.util.List;

import edu.tamu.app.cache.model.ProjectStats;

public class ProjectsStatsCache extends AbstractCache<List<ProjectStats>> {

public ProjectsStatsCache() {
set(new ArrayList<ProjectStats>());
}

}

0 comments on commit 1cb3f8c

Please sign in to comment.