/** * Add the a recording to the selected sample starting in the first event year and ending in the * last year of the sample. * * @param recording */ public static void addRecordingFromFirstEventToEnd() { if (SampleController.getSelectedSampleIndex() > -1) { FHX2_Recording newRecording = new FHX2_Recording(); FHX2_Sample selectedSample = IOController.getFile() .getRequiredPart() .getSample(SampleController.getSelectedSampleIndex()); @SuppressWarnings("unchecked") ArrayList<FHX2_Event> events = (ArrayList<FHX2_Event>) selectedSample.getEvents().clone(); if (events.size() == 0) return; Collections.sort(events, new CompareEventYears()); FHX2_Event event = events.get(0); int firstyear = event.getEventYear(); int lastyear = selectedSample.getSampleLastYear(); // Handle year 0 if (firstyear == 0) firstyear++; if (lastyear == 0) lastyear--; newRecording.setStartYear(firstyear); newRecording.setEndYear(lastyear); selectedSample.addRecording(newRecording); } SampleController.setSelectedSampleIndex(SampleController.getSelectedSampleIndex()); }
/** Adds a new recording to the currently selected sample. */ public static void addNewRecording() { if (SampleController.getSelectedSampleIndex() > -1) { FHX2_Recording newRecording = null; FHX2_Sample selectedSample = IOController.getFile() .getRequiredPart() .getSample(SampleController.getSelectedSampleIndex()); if (selectedSample.getNumOfRecordings() > 0) { FHX2_Recording prevRecording = selectedSample.getRecording(selectedSample.getNumOfRecordings() - 1); int year = selectedSample.getNextAvailableRecordingYear(prevRecording.getEndYear() + 1); if (year != 0) { newRecording = new FHX2_Recording(year, year); } } else { int firstyear = selectedSample.getNextAvailableRecordingYear(); int lastyear = selectedSample.getSampleLastYear() - 1; if (firstyear != 0 && lastyear != 0) { newRecording = new FHX2_Recording(firstyear, lastyear); } } if (newRecording != null) { selectedSample.addRecording(newRecording); } } SampleController.setSelectedSampleIndex(SampleController.getSelectedSampleIndex()); }
@Test public void injectsPagedResourcesAssembler() { WebApplicationContext context = WebTestUtils.createApplicationContext(Config.class); SampleController controller = context.getBean(SampleController.class); assertThat(controller.assembler, is(notNullValue())); PagedResources<Resource<Person>> resources = controller.sample(new PageRequest(1, 1)); assertThat(resources.getLink(Link.REL_PREVIOUS), is(notNullValue())); assertThat(resources.getLink(Link.REL_NEXT), is(notNullValue())); }
@Test @SneakyThrows public void assertHandleNoClassLevelRequestMapping() { SampleController sampleController = new SampleController(); Method sampleMethod = sampleController.getClass().getMethod("sampleMethod"); HandlerMethod handlerMethod = new HandlerMethod(sampleController, sampleMethod); ControllerAdapter controllerAdapter = new ControllerAdapter(new Documentation(), handlerMethod, null); String controllerUri = controllerAdapter.getControllerUri(); assertThat(controllerUri, is(notNullValue())); }
/** * Removes a recording from the currently selected sample. * * @param index */ public static void deleteRecording(int index) { FHX2_Sample selectedSample = IOController.getFile() .getRequiredPart() .getSample(SampleController.getSelectedSampleIndex()); selectedSample.removeRecording(index); }
/** Delete all recordings from the currently selected sample but don't delete any events. */ public static void deleteAllRecordingsButNotEvents() { FHX2_Sample selectedSample = IOController.getFile() .getRequiredPart() .getSample(SampleController.getSelectedSampleIndex()); while (selectedSample.getNumOfRecordings() > 0) { selectedSample.removeRecording(0, true); } }
/** * Add the a recording to the selected sample starting in the first event year and ending in the * last year of the sample. * * @param recording */ public static void addRecordingFromBeginningToEnd() { if (SampleController.getSelectedSampleIndex() > -1) { FHX2_Recording newRecording = new FHX2_Recording(); FHX2_Sample selectedSample = IOController.getFile() .getRequiredPart() .getSample(SampleController.getSelectedSampleIndex()); int firstyear = selectedSample.getSampleFirstYear(); int lastyear = selectedSample.getSampleLastYear(); // Handle year 0 if (firstyear == 0) firstyear++; if (lastyear == 0) lastyear--; newRecording.setStartYear(firstyear); newRecording.setEndYear(lastyear); selectedSample.addRecording(newRecording); } SampleController.setSelectedSampleIndex(SampleController.getSelectedSampleIndex()); }