Skip to content

Commit

Permalink
active sprint cache service
Browse files Browse the repository at this point in the history
  • Loading branch information
wwelling committed Jun 27, 2018
1 parent 1c6e7f6 commit 6fde87d
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 34 deletions.
3 changes: 2 additions & 1 deletion src/main/java/edu/tamu/app/ProjectApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
* Web server initialization.
*
*/
@EnableScheduling
@SpringBootApplication
@ComponentScan(basePackages = { "edu.tamu.*" })
public class ProjectApplication extends SpringBootServletInitializer {
Expand Down
27 changes: 0 additions & 27 deletions src/main/java/edu/tamu/app/model/response/RemoteSprint.java

This file was deleted.

53 changes: 53 additions & 0 deletions src/main/java/edu/tamu/app/service/ScheduledCacheService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package edu.tamu.app.service;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import edu.tamu.app.model.Project;
import edu.tamu.app.model.RemoteProjectManager;
import edu.tamu.app.model.cache.Sprint;
import edu.tamu.app.model.repo.ProjectRepo;
import edu.tamu.app.service.managing.RemoteProjectManagerBean;
import edu.tamu.app.service.registry.ManagementBeanRegistry;

@Service
public class ScheduledCacheService {

@Autowired
private ProjectRepo projectRepo;

@Autowired
private ManagementBeanRegistry managementBeanRegistry;

private final List<Sprint> activeSprints = new ArrayList<Sprint>();

@Scheduled(fixedRate = 10000)
private void cacheAllProjectsActiveSprints() {
System.out.println("Caching project's active sprints...");
List<Project> projects = projectRepo.findAll();
List<Sprint> activeSprints = new ArrayList<Sprint>();
projects.forEach(project -> {
Optional<RemoteProjectManager> versionManagementSoftware = Optional.ofNullable(project.getRemoteProjectManager());
if (versionManagementSoftware.isPresent()) {
RemoteProjectManagerBean versionManagementSoftwareBean = (RemoteProjectManagerBean) managementBeanRegistry.getService(versionManagementSoftware.get().getName());
activeSprints.addAll(versionManagementSoftwareBean.getActiveRemoteSprintsByProject(project.getScopeId()));
}
});
setActiveSprints(activeSprints);
}

public synchronized void setActiveSprints(List<Sprint> activeSprints) {
this.activeSprints.clear();
this.activeSprints.addAll(activeSprints);
}

public synchronized List<Sprint> getActiveSprints() {
return activeSprints;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import com.fasterxml.jackson.databind.JsonNode;

import edu.tamu.app.model.cache.Sprint;
import edu.tamu.app.model.request.FeatureRequest;
import edu.tamu.app.model.response.RemoteProject;
import edu.tamu.app.model.response.RemoteSprint;
import edu.tamu.app.service.registry.ManagementBean;

public interface RemoteProjectManagerBean extends ManagementBean {
Expand All @@ -15,7 +15,7 @@ public interface RemoteProjectManagerBean extends ManagementBean {

public RemoteProject getRemoteProjectByScopeId(String scopeId);

public List<RemoteSprint> getActiveRemoteSprintsByProject(String projectScopeId);
public List<Sprint> getActiveRemoteSprintsByProject(String projectScopeId);

public JsonNode push(FeatureRequest request);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package edu.tamu.app.service.managing;

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

Expand All @@ -8,9 +9,9 @@
import com.fasterxml.jackson.databind.JsonNode;

import edu.tamu.app.model.ManagementService;
import edu.tamu.app.model.cache.Sprint;
import edu.tamu.app.model.request.FeatureRequest;
import edu.tamu.app.model.response.RemoteProject;
import edu.tamu.app.model.response.RemoteSprint;
import edu.tamu.app.rest.BasicAuthRestTemplate;
import edu.tamu.app.service.TemplateService;
import edu.tamu.app.utility.VersionOneJsonNodeUtility;
Expand Down Expand Up @@ -43,9 +44,12 @@ public RemoteProject getRemoteProjectByScopeId(String scopeId) {
}

@Override
public List<RemoteSprint> getActiveRemoteSprintsByProject(String projectScopeId) {
// TODO Auto-generated method stub
return null;
public List<Sprint> getActiveRemoteSprintsByProject(String projectScopeId) {
List<Sprint> activeSprints = new ArrayList<Sprint>();

System.out.println(projectScopeId);

return activeSprints;
}

@Override
Expand Down

0 comments on commit 6fde87d

Please sign in to comment.