protected static String buildExpectedStatesDescription( List<? extends PhdProcessStateType> possibleNextStates) { if (possibleNextStates.isEmpty()) { return BundleUtil.getString( Bundle.PHD, Locale.getDefault(), "message.phd.process.state.none"); } StringBuilder builder = new StringBuilder(); for (PhdProcessStateType expectedState : possibleNextStates) { Locale locale = Locale.getDefault(); builder.append(expectedState.getLocalizedName(locale)).append(", "); } builder.delete(builder.length() - 2, builder.length()); return builder.toString(); }
private void checkStateDate(DateTime stateDate, final PhdProcessStateType type) { Collection<? extends PhdProcessState> orderedStates = getProcess().getOrderedStates(); for (PhdProcessState phdProcessState : orderedStates) { if (phdProcessState == this) { continue; } if (phdProcessState.getStateDate() != null && phdProcessState.getStateDate().isAfter(stateDate)) { String newStateDate = stateDate.toString("dd/MM/yyyy") + " - " + type.getLocalizedName(); String actualStateDate = phdProcessState.getStateDate().toString("dd/MM/yyyy") + " - " + phdProcessState.getType().getLocalizedName(); throw new PhdDomainOperationException( "error.PhdProcessState.state.date.is.previous.of.actual.state.on.process", newStateDate, actualStateDate); } } }