forked from j62/ctbrec
1
0
Fork 0

Rename Recorder.getModelsRecording to Recorder.getModels

This commit is contained in:
0xboobface 2019-02-05 14:44:21 +01:00
parent 2dd8100a97
commit 198a9c6893
7 changed files with 16 additions and 11 deletions

View File

@ -279,11 +279,11 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
} }
private void pauseAll(ActionEvent evt) { private void pauseAll(ActionEvent evt) {
new PauseAction(getTabPane(), recorder.getModelsRecording(), recorder).execute(); new PauseAction(getTabPane(), recorder.getModels(), recorder).execute();
} }
private void resumeAll(ActionEvent evt) { private void resumeAll(ActionEvent evt) {
new ResumeAction(getTabPane(), recorder.getModelsRecording(), recorder).execute(); new ResumeAction(getTabPane(), recorder.getModels(), recorder).execute();
} }
void initializeUpdateService() { void initializeUpdateService() {
@ -343,7 +343,7 @@ public class RecordedModelsTab extends Tab implements TabSelectionListener {
LOG.trace("Updating recorded models"); LOG.trace("Updating recorded models");
List<Recording> recordings = recorder.getRecordings(); List<Recording> recordings = recorder.getRecordings();
List<Model> onlineModels = recorder.getOnlineModels(); List<Model> onlineModels = recorder.getOnlineModels();
return recorder.getModelsRecording() return recorder.getModels()
.stream() .stream()
.map(m -> new JavaFxModel(m)) .map(m -> new JavaFxModel(m))
.peek(fxm -> { .peek(fxm -> {

View File

@ -253,7 +253,7 @@ public class ActionSettingsPanel extends TitledPane {
Label l = new Label("Models"); Label l = new Label("Models");
layout.add(l, 0, row); layout.add(l, 0, row);
modelSelectionPane = new ListSelectionPane<Model>(recorder.getModelsRecording(), Collections.emptyList()); modelSelectionPane = new ListSelectionPane<Model>(recorder.getModels(), Collections.emptyList());
layout.add(modelSelectionPane, 1, row++); layout.add(modelSelectionPane, 1, row++);
GridPane.setValignment(l, VPos.TOP); GridPane.setValignment(l, VPos.TOP);
GridPane.setHgrow(modelSelectionPane, Priority.ALWAYS); GridPane.setHgrow(modelSelectionPane, Priority.ALWAYS);

View File

@ -289,7 +289,7 @@ public class LocalRecorder implements Recorder {
} }
@Override @Override
public List<Model> getModelsRecording() { public List<Model> getModels() {
lock.lock(); lock.lock();
try { try {
return Collections.unmodifiableList(new ArrayList<>(models)); return Collections.unmodifiableList(new ArrayList<>(models));
@ -300,7 +300,7 @@ public class LocalRecorder implements Recorder {
@Override @Override
public List<Model> getOnlineModels() { public List<Model> getOnlineModels() {
return getModelsRecording() return getModels()
.stream() .stream()
.filter(m -> { .filter(m -> {
try { try {

View File

@ -42,7 +42,7 @@ public class OnlineMonitor extends Thread {
running = true; running = true;
while (running) { while (running) {
Instant begin = Instant.now(); Instant begin = Instant.now();
List<Model> models = recorder.getModelsRecording(); List<Model> models = recorder.getModels();
// remove models, which are not recorded anymore // remove models, which are not recorded anymore
for (Iterator<Model> iterator = states.keySet().iterator(); iterator.hasNext();) { for (Iterator<Model> iterator = states.keySet().iterator(); iterator.hasNext();) {

View File

@ -17,12 +17,17 @@ public interface Recorder {
public void switchStreamSource(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException, IllegalStateException; public void switchStreamSource(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException, IllegalStateException;
/** /**
* Returns, if a model is in the list of models to record. This does not reflect, if there currently is a recording running. The model might be offline * Returns true, if a model is in the list of models to record. This does not reflect, if there currently is a recording running. The model might be offline
* aswell. * aswell.
*/ */
public boolean isRecording(Model model); public boolean isRecording(Model model);
public List<Model> getModelsRecording(); /**
* Get the list of all models, which are tracked by ctbrec
*
* @return a List of Model objects, which might be empty
*/
public List<Model> getModels();
public List<Recording> getRecordings() throws IOException, InvalidKeyException, NoSuchAlgorithmException, IllegalStateException; public List<Recording> getRecordings() throws IOException, InvalidKeyException, NoSuchAlgorithmException, IllegalStateException;

View File

@ -138,7 +138,7 @@ public class RemoteRecorder implements Recorder {
} }
@Override @Override
public List<Model> getModelsRecording() { public List<Model> getModels() {
if(!lastSync.equals(Instant.EPOCH) && lastSync.isBefore(Instant.now().minusSeconds(60))) { if(!lastSync.equals(Instant.EPOCH) && lastSync.isBefore(Instant.now().minusSeconds(60))) {
throw new RuntimeException("Last sync was over a minute ago"); throw new RuntimeException("Last sync was over a minute ago");
} }

View File

@ -75,7 +75,7 @@ public class RecorderServlet extends AbstractCtbrecServlet {
case "list": case "list":
resp.getWriter().write("{\"status\": \"success\", \"msg\": \"List of models\", \"models\": ["); resp.getWriter().write("{\"status\": \"success\", \"msg\": \"List of models\", \"models\": [");
JsonAdapter<Model> modelAdapter = new ModelJsonAdapter(); JsonAdapter<Model> modelAdapter = new ModelJsonAdapter();
List<Model> models = recorder.getModelsRecording(); List<Model> models = recorder.getModels();
for (Iterator<Model> iterator = models.iterator(); iterator.hasNext();) { for (Iterator<Model> iterator = models.iterator(); iterator.hasNext();) {
Model model = iterator.next(); Model model = iterator.next();
resp.getWriter().write(modelAdapter.toJson(model)); resp.getWriter().write(modelAdapter.toJson(model));