List of usage examples for org.joda.time LocalDate toString
public String toString(String pattern)
From source file:energy.usef.dso.workflow.validate.gridsafetyanalysis.DsoGridSafetyAnalysisCoordinator.java
License:Apache License
/** * This method handles the GridSafetyAnalysisEvent. This Event creates GridSafetyAnalysis / CongestionPoint. * * @param event The {@link GridSafetyAnalysisEvent} that triggers the process. *///w ww. jav a 2 s . c o m @Asynchronous public void startGridSafetyAnalysis( @Observes(during = TransactionPhase.AFTER_COMPLETION) GridSafetyAnalysisEvent event) throws BusinessValidationException { LOGGER.info(LOG_COORDINATOR_START_HANDLING_EVENT, event); eventValidationService.validateEventPeriodTodayOrInFuture(event); String entityAddress = event.getCongestionPointEntityAddress(); LocalDate period = event.getPeriod(); // PrognosisDto List, one for each participant List<PtuPrognosis> prognosisList = findLastPrognoses(period, entityAddress); WorkflowContext inContext = prepareInContext(event, prognosisList); Long timeout = configDso.getLongProperty(ConfigDsoParam.DSO_GRID_SAFETY_ANALYSIS_EXPIRATION_IN_MINUTES); CompletableFuture<WorkflowContext> completableFuture = CompletableFuture .supplyAsync(() -> callPluggableBusinessComponent(inContext)); if (timeout != null && timeout > 0) { completableFuture = concurrentUtil.within(completableFuture, Duration.ofMinutes(timeout), String.format("Grid Safety Analysis for %s on %s timed out after ", entityAddress, period.toString("yyyy-MM-dd"))); } completableFuture.whenCompleteAsync((result, throwable) -> { LOGGER.info("Processing Grid Gafety Analysis for {}", result.getValue(IN.CONGESTION_POINT_ENTITY_ADDRESS.name())); WorkflowUtil.validateContext(DSO_CREATE_GRID_SAFETY_ANALYSIS.name(), result, CreateGridSafetyAnalysisStepParameter.OUT.values()); GridSafetyAnalysisDto dto = result.get( CreateGridSafetyAnalysisStepParameter.OUT.GRID_SAFETY_ANALYSIS.name(), GridSafetyAnalysisDto.class); storeGridSafetyEventManager.fire(new StoreGridSafetyAnalysisEvent(entityAddress, period, dto)); }).exceptionally(throwable -> { LOGGER.error(throwable.getMessage()); return null; }); LOGGER.info(LOG_COORDINATOR_FINISHED_HANDLING_EVENT, event); }
From source file:es.usc.citius.servando.calendula.activities.CalendarActivity.java
License:Open Source License
private boolean showPickupsInfo(final LocalDate date) { final List<PickupInfo> from = DB.pickups().findByFrom(date, true); if (!from.isEmpty()) { TextView title = ((TextView) bottomSheet.findViewById(R.id.bottom_sheet_title)); LayoutInflater i = getLayoutInflater(); LinearLayout list = (LinearLayout) findViewById(R.id.pickup_list); list.removeAllViews();/*from w ww. j a v a 2 s.c om*/ for (final PickupInfo p : from) { Medicine m = DB.medicines().findById(p.medicine().getId()); Patient pat = DB.patients().findById(m.patient().id()); if (selectedPatientIdx == 0 || pat.id() == selectedPatientId) { View v = i.inflate(R.layout.calendar_pickup_list_item, null); TextView tv1 = ((TextView) v.findViewById(R.id.textView)); TextView tv2 = ((TextView) v.findViewById(R.id.textView2)); ImageView avatar = ((ImageView) v.findViewById(R.id.avatar)); String interval = getResources().getString(R.string.pickup_interval, p.to().toString(df)); if (p.taken()) { interval += " "; tv1.setAlpha(0.5f); } else { tv1.setAlpha(1f); tv2.setAlpha(1f); } tv1.setText(p.medicine().name()); tv2.setText(interval); avatar.setImageResource(AvatarMgr.res(pat.avatar())); tv1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { p.taken(!p.taken()); DB.pickups().save(p); showPickupsInfo(date); } }); list.addView(v); } } nestedScrollView.scrollBy(0, bottomSheet.getHeight()); showBottomSheet(); int total = list.getChildCount(); title.setText( total + " " + getResources().getString(R.string.title_pickups_bottom_sheet, date.toString(df))); appBarLayout.setExpanded(false, true); return true; } return false; }
From source file:es.usc.citius.servando.calendula.activities.ReminderNotification.java
License:Open Source License
private static Pair<Intent, Intent> getIntentsForRoutine(Context context, Routine r, LocalDate date) { // delay intent sent on click delay button final Intent delay = new Intent(context, ConfirmActivity.class); delay.putExtra(CalendulaApp.INTENT_EXTRA_ACTION, "delay"); delay.putExtra(CalendulaApp.INTENT_EXTRA_ROUTINE_ID, r.getId()); delay.putExtra("date", date.toString(AlarmIntentParams.DATE_FORMAT)); // delay intent sent on click delay button final Intent cancel = new Intent(context, NotificationEventReceiver.class); cancel.putExtra(CalendulaApp.INTENT_EXTRA_ACTION, CalendulaApp.ACTION_CANCEL_ROUTINE); cancel.putExtra(CalendulaApp.INTENT_EXTRA_ROUTINE_ID, r.getId()); cancel.putExtra("date", date.toString(AlarmIntentParams.DATE_FORMAT)); return new Pair<>(delay, cancel); }
From source file:es.usc.citius.servando.calendula.activities.ReminderNotification.java
License:Open Source License
private static Pair<Intent, Intent> getIntentsForSchedule(Context context, Schedule schedule, LocalDate date, LocalTime time) {/*from ww w . j a v a2s . com*/ final Intent delay = new Intent(context, ConfirmActivity.class); delay.putExtra(CalendulaApp.INTENT_EXTRA_ACTION, "delay"); delay.putExtra(CalendulaApp.INTENT_EXTRA_SCHEDULE_ID, schedule.getId()); delay.putExtra(CalendulaApp.INTENT_EXTRA_SCHEDULE_TIME, date.toString("kk:mm")); delay.putExtra("date", date.toString(AlarmIntentParams.DATE_FORMAT)); final Intent cancel = new Intent(context, NotificationEventReceiver.class); cancel.putExtra(CalendulaApp.INTENT_EXTRA_ACTION, CalendulaApp.ACTION_CANCEL_HOURLY_SCHEDULE); cancel.putExtra(CalendulaApp.INTENT_EXTRA_SCHEDULE_ID, schedule.getId()); cancel.putExtra(CalendulaApp.INTENT_EXTRA_SCHEDULE_TIME, time.toString("kk:mm")); cancel.putExtra("date", date.toString(AlarmIntentParams.DATE_FORMAT)); return new Pair<>(delay, cancel); }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java
License:Open Source License
void setScheduleStart(LocalDate start) { schedule.setStart(start);// w ww. j a va 2 s . c o m if (start == null) { buttonScheduleStart.setText(getString(R.string.button_schedule_repeat_today)); clearStartButton.setVisibility(View.INVISIBLE); } else { buttonScheduleStart.setText(start.toString(getString(R.string.schedule_limits_date_format))); clearStartButton.setVisibility(View.VISIBLE); } }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java
License:Open Source License
void setScheduleEnd(LocalDate end) { if (end == null) { buttonScheduleEnd.setText(getString(R.string.never)); schedule.rule().iCalRule().setUntil(null); clearEndButton.setVisibility(View.INVISIBLE); } else {// w w w . ja v a 2 s.c om DateValue v = new DateTimeValueImpl(end.getYear(), end.getMonthOfYear(), end.getDayOfMonth(), 0, 0, 0); schedule.rule().iCalRule().setUntil(v); buttonScheduleEnd.setText(end.toString(getString(R.string.schedule_limits_date_format))); clearEndButton.setVisibility(View.VISIBLE); } }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleSummaryFragment.java
License:Open Source License
public void updateSummary() { int color = DB.patients().getActive(getActivity()).color(); Log.d(TAG, "updateSummary ScheduleSUmmaryFragment"); View rootView = getView();/* ww w .ja v a2s . c o m*/ Medicine med = ScheduleHelper.instance().getSelectedMed(); Schedule s = ScheduleHelper.instance().getSchedule(); List<ScheduleItem> items = ScheduleHelper.instance().getScheduleItems(); final TextView summaryTitle = (TextView) rootView.findViewById(R.id.summaryTitle); final TextView medNameTv = (TextView) rootView.findViewById(R.id.sched_summary_medname); final TextView medDaysTv = (TextView) rootView.findViewById(R.id.sched_summary_medi_days); final TextView medDailyFreqTv = (TextView) rootView.findViewById(R.id.sched_summary_medi_dailyfreq); final ImageView medIconImage = (ImageView) rootView.findViewById(R.id.sched_summary_medicon); final Button showCalendarButton = (Button) rootView.findViewById(R.id.button_show_calendar); if (med != null) { medNameTv.setText(med.name()); } medDaysTv.setText(s.toReadableString(getActivity())); medIconImage.setImageDrawable(iconFor(med != null ? med.presentation() : Presentation.PILLS)); if (s.type() != Schedule.SCHEDULE_TYPE_HOURLY) { String freq = ScheduleUtils.getTimesStr(items != null ? items.size() : 0, getActivity()); medDailyFreqTv.setText(freq); } else { String freq = ScheduleUtils.getTimesStr(24 / s.rule().interval(), getActivity()); medDailyFreqTv.setText(freq); } showCalendarButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Schedule s = ScheduleHelper.instance().getSchedule(); LocalDate start = s.start(); Intent i = new Intent(getActivity(), SummaryCalendarActivity.class); if (start != null) { i.putExtra("start", start.toString(SummaryCalendarActivity.START_DATE_FORMAT)); } if (s.type() == Schedule.SCHEDULE_TYPE_CYCLE) { i.putExtra("active_days", s.getCycleDays()); i.putExtra("rest_days", s.getCycleRest()); } else { i.putExtra("rule", s.rule().toIcal()); } startActivity(i); } }); summaryTitle.setTextColor(color); medNameTv.setTextColor(color); medDailyFreqTv.setTextColor(color); summaryTitle.setVisibility(View.VISIBLE); medNameTv.setVisibility(View.VISIBLE); medDailyFreqTv.setVisibility(View.VISIBLE); medIconImage.setVisibility(View.VISIBLE); }
From source file:es.usc.citius.servando.calendula.persistence.Medicine.java
License:Open Source License
public String nextPickup() { LocalDate np = nextPickupDate(); return np != null ? np.toString("dd MMMM") : null; }
From source file:es.usc.citius.servando.calendula.scheduling.AlarmIntentParams.java
License:Open Source License
public static AlarmIntentParams forRoutine(Long routineId, LocalDate date, boolean delayed) { AlarmIntentParams params = new AlarmIntentParams(); params.action = delayed ? CalendulaApp.ACTION_ROUTINE_DELAYED_TIME : CalendulaApp.ACTION_ROUTINE_TIME; params.routineId = routineId;//from w w w .j av a 2 s.c om params.date = date.toString(DATE_FORMAT); Log.d(TAG, "forRoutine: " + params.toString()); return params; }
From source file:es.usc.citius.servando.calendula.scheduling.AlarmIntentParams.java
License:Open Source License
public static AlarmIntentParams forSchedule(Long scheduleId, LocalTime time, LocalDate date, boolean delayed) { AlarmIntentParams params = new AlarmIntentParams(); params.action = delayed ? CalendulaApp.ACTION_HOURLY_SCHEDULE_DELAYED_TIME : CalendulaApp.ACTION_HOURLY_SCHEDULE_TIME; params.scheduleId = scheduleId;/*from www . j ava2 s .co m*/ params.scheduleTime = time.toString(TIME_FORMAT); params.date = date.toString(DATE_FORMAT); Log.d(TAG, "forSchedule: " + params.toString()); return params; }