-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
56 changed files
with
1,248 additions
and
1,170 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
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
package edu.tamu.app.cache; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import edu.tamu.app.cache.model.RemoteProject; | ||
|
||
public class RemoteProjectsCache extends AbstractCache<Map<Long, List<RemoteProject>>> { | ||
|
||
public RemoteProjectsCache() { | ||
set(new HashMap<Long, List<RemoteProject>>()); | ||
} | ||
|
||
} |
12 changes: 0 additions & 12 deletions
12
src/main/java/edu/tamu/app/cache/controller/RemoteProductsCacheController.java
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
src/main/java/edu/tamu/app/cache/controller/RemoteProjectsCacheController.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,12 @@ | ||
package edu.tamu.app.cache.controller; | ||
|
||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import edu.tamu.app.cache.service.RemoteProjectsScheduledCacheService; | ||
|
||
@RestController | ||
@RequestMapping("/projects/remote") | ||
public class RemoteProjectsCacheController extends AbstractCacheController<RemoteProjectsScheduledCacheService> { | ||
|
||
} |
6 changes: 3 additions & 3 deletions
6
...u/tamu/app/cache/model/RemoteProduct.java → ...u/tamu/app/cache/model/RemoteProject.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
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
90 changes: 0 additions & 90 deletions
90
src/main/java/edu/tamu/app/cache/service/RemoteProductsScheduledCacheService.java
This file was deleted.
Oops, something went wrong.
90 changes: 90 additions & 0 deletions
90
src/main/java/edu/tamu/app/cache/service/RemoteProjectsScheduledCacheService.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,90 @@ | ||
package edu.tamu.app.cache.service; | ||
|
||
import static edu.tamu.weaver.response.ApiStatus.SUCCESS; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import org.apache.log4j.Logger; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Service; | ||
|
||
import edu.tamu.app.cache.RemoteProjectsCache; | ||
import edu.tamu.app.cache.model.RemoteProject; | ||
import edu.tamu.app.model.RemoteProjectManager; | ||
import edu.tamu.app.model.repo.RemoteProjectManagerRepo; | ||
import edu.tamu.app.service.manager.RemoteProjectManagerBean; | ||
import edu.tamu.app.service.registry.ManagementBeanRegistry; | ||
import edu.tamu.weaver.response.ApiResponse; | ||
|
||
@Service | ||
public class RemoteProjectsScheduledCacheService extends AbstractScheduledCacheService<Map<Long, List<RemoteProject>>, RemoteProjectsCache> { | ||
|
||
private static final Logger logger = Logger.getLogger(RemoteProjectsScheduledCacheService.class); | ||
|
||
@Autowired | ||
private RemoteProjectManagerRepo remoteProjectManagerRepo; | ||
|
||
@Autowired | ||
private ManagementBeanRegistry managementBeanRegistry; | ||
|
||
public RemoteProjectsScheduledCacheService() { | ||
super(new RemoteProjectsCache()); | ||
} | ||
|
||
@Override | ||
@Scheduled(initialDelayString = "${app.cache.remote-projects.delay}", fixedDelayString = "${app.cache.remote-projects.interval}") | ||
public void schedule() { | ||
super.schedule(); | ||
} | ||
|
||
public void update() { | ||
logger.info("Caching remote projects..."); | ||
|
||
Map<Long, List<RemoteProject>> remoteProjects = new HashMap<Long, List<RemoteProject>>(); | ||
Optional<List<RemoteProjectManager>> remoteProjectManagers = Optional.ofNullable(remoteProjectManagerRepo.findAll()); | ||
|
||
if (remoteProjectManagers.isPresent()){ | ||
for (RemoteProjectManager remoteProjectManager : remoteProjectManagers.get()) { | ||
RemoteProjectManagerBean remoteProjectManagerBean = (RemoteProjectManagerBean) managementBeanRegistry | ||
.getService(remoteProjectManager.getName()); | ||
try { | ||
remoteProjects.put(remoteProjectManager.getId(), remoteProjectManagerBean.getRemoteProject()); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} | ||
|
||
set(remoteProjects); | ||
logger.info("Finished caching remote projects"); | ||
} | ||
|
||
public void broadcast() { | ||
logger.info("Broadcasting cached remote projects"); | ||
simpMessagingTemplate.convertAndSend("/channel/projects/remote", new ApiResponse(SUCCESS, get())); | ||
} | ||
|
||
public Optional<RemoteProject> getRemoteProject(Long remoteProjectManagerId, String scopeId) { | ||
Optional<RemoteProject> remoteProject = Optional.empty(); | ||
Optional<List<RemoteProject>> remoteProjects = Optional.ofNullable(get().get(remoteProjectManagerId)); | ||
if (remoteProjects.isPresent()) { | ||
for (RemoteProject rp : remoteProjects.get()) { | ||
if (rp.getId().equals(scopeId)) { | ||
remoteProject = Optional.of(rp); | ||
break; | ||
} | ||
} | ||
} | ||
return remoteProject; | ||
} | ||
|
||
@Override | ||
public int getOrder() { | ||
return 1; | ||
} | ||
|
||
} |
Oops, something went wrong.