@Ignore @Test public void should_set_harmonicLoopWeights_for_bar() throws CloneNotSupportedException { int barIndex = 1; ProgressionUnit currentProgressionUnit = progressionUnitSetup().get(1); ProgressionUnit previousProgressionUnit = progressionUnitSetup().get(0); ExecutorService executorPool = Executors.newFixedThreadPool(4); harmonicLoopWeighter.setHarmonicLoopWeight(LoopPositions.POSITION_TWO, currentProgressionUnit, previousProgressionUnit, null); WeightClass rythmicalWeight = currentProgressionUnit.getProgressionUnitBars().get(barIndex).getHarmonicLoopOptions().get(LoopPositions.POSITION_ONE).getRhythmicWeight(); assertThat(rythmicalWeight).isEqualTo(WeightClass.GOOD); WeightClass eqWeight = currentProgressionUnit.getProgressionUnitBars().get(barIndex).getHarmonicLoopOptions().get(LoopPositions.POSITION_ONE).getEqWeight(); assertThat(eqWeight).isNotNull(); rythmicalWeight = currentProgressionUnit.getProgressionUnitBars().get(barIndex).getHarmonicLoopOptions().get(LoopPositions.POSITION_TWO).getRhythmicWeight(); assertThat(rythmicalWeight).isEqualTo(WeightClass.GOOD); eqWeight = currentProgressionUnit.getProgressionUnitBars().get(barIndex).getHarmonicLoopOptions().get(LoopPositions.POSITION_TWO).getEqWeight(); assertThat(eqWeight).isNotNull(); rythmicalWeight = currentProgressionUnit.getProgressionUnitBars().get(barIndex).getHarmonicLoopOptions().get(LoopPositions.POSITION_THREE).getRhythmicWeight(); assertThat(rythmicalWeight).isEqualTo(WeightClass.GOOD); eqWeight = currentProgressionUnit.getProgressionUnitBars().get(barIndex).getHarmonicLoopOptions().get(LoopPositions.POSITION_THREE).getEqWeight(); assertThat(eqWeight).isNotNull(); }
public boolean setHarmonicLoopWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit, Iterable<AnalyticsHorizontal> analyticsHorizontals) { ProgressionUnitBar progressionUnitBar = currentProgressionUnit.getProgressionUnitBars().get(indexToWeight); for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) { WeightClass rWeight = rhythmWeighter.calculateRhythmicWeight(progressionUnitBar.getHarmonicLoop(), progressionUnitBar.getHarmonicLoopOptions().get(i)); progressionUnitBar.getHarmonicLoopOptions().get(i).setRhythmicWeight(rWeight); } assignTimeSeriesWeight(indexToWeight, currentProgressionUnit, priorProgressionUnit); assignThemeWeight(indexToWeight, currentProgressionUnit, priorProgressionUnit); Collection<HarmonicLoopEqWeightTask> taskList = new ArrayList<>(); for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) { HarmonicLoopEqWeightTask task = new HarmonicLoopEqWeightTask(progressionUnitBar.getBeatLoop().getId(), progressionUnitBar.getHarmonicLoopOptions().get(i).getId(), bypassEqRatings, apiUser, apiPassword); taskList.add(task); } Application.logger.debug("LOG: Harmonic TaskList SIZE: " + taskList.size()); ExecutorService executorPool = ExecutorPoolFactory.getPool(); Application.logger.debug("LOG: EXECUTOR : CREATING"); Application.logger.debug("LOG: TIME: " + DateTime.now()); try { List<Future<WeightTaskResponse>> invokedTasks = executorPool.invokeAll(taskList); List<WeightTaskResponse> weightTaskResponses = new ArrayList<>(); for (Future<WeightTaskResponse> task : invokedTasks) { try { weightTaskResponses.add(task.get()); task.get(THREAD_TIMEOUT, TimeUnit.SECONDS).getWeightClass(); } catch (TimeoutException tException) { Application.logger.debug("LOG: ERROR!! : TIMEOUT EXCEPTION : HL WEIGHTING!!"); } catch (InterruptedException ie) { Application.logger.debug("LOG: ERROR!! : INTERRUPT EXCEPTION : HL WEIGHTING!!"); } } assignWeights(progressionUnitBar, weightTaskResponses); } catch (Exception e) { Application.logger.debug("LOG: ERROR!! : HL WEIGHTING!! ", e); } executorPool.shutdownNow(); try { while (!executorPool.awaitTermination(10, TimeUnit.SECONDS)) { Application.logger.debug("LOG: Awaiting completion of threads."); } Application.logger.debug("LOG: EXECUTOR : SHUTDOWN SUCCESS"); } catch (InterruptedException e) { Application.logger.debug("LOG: ERROR AWAITING THREAD SHUTDOWN : ", e); } return true; }
HarmonicLoopWeighter { public boolean setHarmonicLoopWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit, Iterable<AnalyticsHorizontal> analyticsHorizontals) { ProgressionUnitBar progressionUnitBar = currentProgressionUnit.getProgressionUnitBars().get(indexToWeight); for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) { WeightClass rWeight = rhythmWeighter.calculateRhythmicWeight(progressionUnitBar.getHarmonicLoop(), progressionUnitBar.getHarmonicLoopOptions().get(i)); progressionUnitBar.getHarmonicLoopOptions().get(i).setRhythmicWeight(rWeight); } assignTimeSeriesWeight(indexToWeight, currentProgressionUnit, priorProgressionUnit); assignThemeWeight(indexToWeight, currentProgressionUnit, priorProgressionUnit); Collection<HarmonicLoopEqWeightTask> taskList = new ArrayList<>(); for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) { HarmonicLoopEqWeightTask task = new HarmonicLoopEqWeightTask(progressionUnitBar.getBeatLoop().getId(), progressionUnitBar.getHarmonicLoopOptions().get(i).getId(), bypassEqRatings, apiUser, apiPassword); taskList.add(task); } Application.logger.debug("LOG: Harmonic TaskList SIZE: " + taskList.size()); ExecutorService executorPool = ExecutorPoolFactory.getPool(); Application.logger.debug("LOG: EXECUTOR : CREATING"); Application.logger.debug("LOG: TIME: " + DateTime.now()); try { List<Future<WeightTaskResponse>> invokedTasks = executorPool.invokeAll(taskList); List<WeightTaskResponse> weightTaskResponses = new ArrayList<>(); for (Future<WeightTaskResponse> task : invokedTasks) { try { weightTaskResponses.add(task.get()); task.get(THREAD_TIMEOUT, TimeUnit.SECONDS).getWeightClass(); } catch (TimeoutException tException) { Application.logger.debug("LOG: ERROR!! : TIMEOUT EXCEPTION : HL WEIGHTING!!"); } catch (InterruptedException ie) { Application.logger.debug("LOG: ERROR!! : INTERRUPT EXCEPTION : HL WEIGHTING!!"); } } assignWeights(progressionUnitBar, weightTaskResponses); } catch (Exception e) { Application.logger.debug("LOG: ERROR!! : HL WEIGHTING!! ", e); } executorPool.shutdownNow(); try { while (!executorPool.awaitTermination(10, TimeUnit.SECONDS)) { Application.logger.debug("LOG: Awaiting completion of threads."); } Application.logger.debug("LOG: EXECUTOR : SHUTDOWN SUCCESS"); } catch (InterruptedException e) { Application.logger.debug("LOG: ERROR AWAITING THREAD SHUTDOWN : ", e); } return true; } }
HarmonicLoopWeighter { public boolean setHarmonicLoopWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit, Iterable<AnalyticsHorizontal> analyticsHorizontals) { ProgressionUnitBar progressionUnitBar = currentProgressionUnit.getProgressionUnitBars().get(indexToWeight); for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) { WeightClass rWeight = rhythmWeighter.calculateRhythmicWeight(progressionUnitBar.getHarmonicLoop(), progressionUnitBar.getHarmonicLoopOptions().get(i)); progressionUnitBar.getHarmonicLoopOptions().get(i).setRhythmicWeight(rWeight); } assignTimeSeriesWeight(indexToWeight, currentProgressionUnit, priorProgressionUnit); assignThemeWeight(indexToWeight, currentProgressionUnit, priorProgressionUnit); Collection<HarmonicLoopEqWeightTask> taskList = new ArrayList<>(); for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) { HarmonicLoopEqWeightTask task = new HarmonicLoopEqWeightTask(progressionUnitBar.getBeatLoop().getId(), progressionUnitBar.getHarmonicLoopOptions().get(i).getId(), bypassEqRatings, apiUser, apiPassword); taskList.add(task); } Application.logger.debug("LOG: Harmonic TaskList SIZE: " + taskList.size()); ExecutorService executorPool = ExecutorPoolFactory.getPool(); Application.logger.debug("LOG: EXECUTOR : CREATING"); Application.logger.debug("LOG: TIME: " + DateTime.now()); try { List<Future<WeightTaskResponse>> invokedTasks = executorPool.invokeAll(taskList); List<WeightTaskResponse> weightTaskResponses = new ArrayList<>(); for (Future<WeightTaskResponse> task : invokedTasks) { try { weightTaskResponses.add(task.get()); task.get(THREAD_TIMEOUT, TimeUnit.SECONDS).getWeightClass(); } catch (TimeoutException tException) { Application.logger.debug("LOG: ERROR!! : TIMEOUT EXCEPTION : HL WEIGHTING!!"); } catch (InterruptedException ie) { Application.logger.debug("LOG: ERROR!! : INTERRUPT EXCEPTION : HL WEIGHTING!!"); } } assignWeights(progressionUnitBar, weightTaskResponses); } catch (Exception e) { Application.logger.debug("LOG: ERROR!! : HL WEIGHTING!! ", e); } executorPool.shutdownNow(); try { while (!executorPool.awaitTermination(10, TimeUnit.SECONDS)) { Application.logger.debug("LOG: Awaiting completion of threads."); } Application.logger.debug("LOG: EXECUTOR : SHUTDOWN SUCCESS"); } catch (InterruptedException e) { Application.logger.debug("LOG: ERROR AWAITING THREAD SHUTDOWN : ", e); } return true; } @Autowired  HarmonicLoopWeighter(IRhythmWeighter rhythmWeighter, HarmonicLoopTimeseriesClassifier harmonicLoopTimeseriesClassifier, @Value("${bypass_eq_ratings}") boolean bypassEqRatings); }
HarmonicLoopWeighter { public boolean setHarmonicLoopWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit, Iterable<AnalyticsHorizontal> analyticsHorizontals) { ProgressionUnitBar progressionUnitBar = currentProgressionUnit.getProgressionUnitBars().get(indexToWeight); for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) { WeightClass rWeight = rhythmWeighter.calculateRhythmicWeight(progressionUnitBar.getHarmonicLoop(), progressionUnitBar.getHarmonicLoopOptions().get(i)); progressionUnitBar.getHarmonicLoopOptions().get(i).setRhythmicWeight(rWeight); } assignTimeSeriesWeight(indexToWeight, currentProgressionUnit, priorProgressionUnit); assignThemeWeight(indexToWeight, currentProgressionUnit, priorProgressionUnit); Collection<HarmonicLoopEqWeightTask> taskList = new ArrayList<>(); for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) { HarmonicLoopEqWeightTask task = new HarmonicLoopEqWeightTask(progressionUnitBar.getBeatLoop().getId(), progressionUnitBar.getHarmonicLoopOptions().get(i).getId(), bypassEqRatings, apiUser, apiPassword); taskList.add(task); } Application.logger.debug("LOG: Harmonic TaskList SIZE: " + taskList.size()); ExecutorService executorPool = ExecutorPoolFactory.getPool(); Application.logger.debug("LOG: EXECUTOR : CREATING"); Application.logger.debug("LOG: TIME: " + DateTime.now()); try { List<Future<WeightTaskResponse>> invokedTasks = executorPool.invokeAll(taskList); List<WeightTaskResponse> weightTaskResponses = new ArrayList<>(); for (Future<WeightTaskResponse> task : invokedTasks) { try { weightTaskResponses.add(task.get()); task.get(THREAD_TIMEOUT, TimeUnit.SECONDS).getWeightClass(); } catch (TimeoutException tException) { Application.logger.debug("LOG: ERROR!! : TIMEOUT EXCEPTION : HL WEIGHTING!!"); } catch (InterruptedException ie) { Application.logger.debug("LOG: ERROR!! : INTERRUPT EXCEPTION : HL WEIGHTING!!"); } } assignWeights(progressionUnitBar, weightTaskResponses); } catch (Exception e) { Application.logger.debug("LOG: ERROR!! : HL WEIGHTING!! ", e); } executorPool.shutdownNow(); try { while (!executorPool.awaitTermination(10, TimeUnit.SECONDS)) { Application.logger.debug("LOG: Awaiting completion of threads."); } Application.logger.debug("LOG: EXECUTOR : SHUTDOWN SUCCESS"); } catch (InterruptedException e) { Application.logger.debug("LOG: ERROR AWAITING THREAD SHUTDOWN : ", e); } return true; } @Autowired  HarmonicLoopWeighter(IRhythmWeighter rhythmWeighter, HarmonicLoopTimeseriesClassifier harmonicLoopTimeseriesClassifier, @Value("${bypass_eq_ratings}") boolean bypassEqRatings); boolean setHarmonicLoopWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit, Iterable<AnalyticsHorizontal> analyticsHorizontals); void assignThemeWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit); void assignTimeSeriesWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit); void assignWeights(ProgressionUnitBar progressionUnitBar, List<WeightTaskResponse> weightTaskResponses); }
HarmonicLoopWeighter { public boolean setHarmonicLoopWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit, Iterable<AnalyticsHorizontal> analyticsHorizontals) { ProgressionUnitBar progressionUnitBar = currentProgressionUnit.getProgressionUnitBars().get(indexToWeight); for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) { WeightClass rWeight = rhythmWeighter.calculateRhythmicWeight(progressionUnitBar.getHarmonicLoop(), progressionUnitBar.getHarmonicLoopOptions().get(i)); progressionUnitBar.getHarmonicLoopOptions().get(i).setRhythmicWeight(rWeight); } assignTimeSeriesWeight(indexToWeight, currentProgressionUnit, priorProgressionUnit); assignThemeWeight(indexToWeight, currentProgressionUnit, priorProgressionUnit); Collection<HarmonicLoopEqWeightTask> taskList = new ArrayList<>(); for (int i = 0; i < progressionUnitBar.getHarmonicLoopOptions().size(); i++) { HarmonicLoopEqWeightTask task = new HarmonicLoopEqWeightTask(progressionUnitBar.getBeatLoop().getId(), progressionUnitBar.getHarmonicLoopOptions().get(i).getId(), bypassEqRatings, apiUser, apiPassword); taskList.add(task); } Application.logger.debug("LOG: Harmonic TaskList SIZE: " + taskList.size()); ExecutorService executorPool = ExecutorPoolFactory.getPool(); Application.logger.debug("LOG: EXECUTOR : CREATING"); Application.logger.debug("LOG: TIME: " + DateTime.now()); try { List<Future<WeightTaskResponse>> invokedTasks = executorPool.invokeAll(taskList); List<WeightTaskResponse> weightTaskResponses = new ArrayList<>(); for (Future<WeightTaskResponse> task : invokedTasks) { try { weightTaskResponses.add(task.get()); task.get(THREAD_TIMEOUT, TimeUnit.SECONDS).getWeightClass(); } catch (TimeoutException tException) { Application.logger.debug("LOG: ERROR!! : TIMEOUT EXCEPTION : HL WEIGHTING!!"); } catch (InterruptedException ie) { Application.logger.debug("LOG: ERROR!! : INTERRUPT EXCEPTION : HL WEIGHTING!!"); } } assignWeights(progressionUnitBar, weightTaskResponses); } catch (Exception e) { Application.logger.debug("LOG: ERROR!! : HL WEIGHTING!! ", e); } executorPool.shutdownNow(); try { while (!executorPool.awaitTermination(10, TimeUnit.SECONDS)) { Application.logger.debug("LOG: Awaiting completion of threads."); } Application.logger.debug("LOG: EXECUTOR : SHUTDOWN SUCCESS"); } catch (InterruptedException e) { Application.logger.debug("LOG: ERROR AWAITING THREAD SHUTDOWN : ", e); } return true; } @Autowired  HarmonicLoopWeighter(IRhythmWeighter rhythmWeighter, HarmonicLoopTimeseriesClassifier harmonicLoopTimeseriesClassifier, @Value("${bypass_eq_ratings}") boolean bypassEqRatings); boolean setHarmonicLoopWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit, Iterable<AnalyticsHorizontal> analyticsHorizontals); void assignThemeWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit); void assignTimeSeriesWeight(Integer indexToWeight, ProgressionUnit currentProgressionUnit, ProgressionUnit priorProgressionUnit); void assignWeights(ProgressionUnitBar progressionUnitBar, List<WeightTaskResponse> weightTaskResponses);  }