public ProjectXml (final @Nonnull Project project) { final Project.Builder builder = project.toBuilder(); this.id = builder.getId(); this.customerXml = new CustomerXml(builder.getCustomer()); this.name = builder.getName(); this.number = builder.getNumber(); this.description = builder.getDescription(); this.notes = builder.getNotes(); this.status = builder.getStatus(); this.hourlyRate = builder.getHourlyRate(); this.budget = builder.getBudget(); this.startDate = builder.getStartDate(); this.endDate = builder.getEndDate(); this.jobEventsXml = project.findChildren().stream().map(jobEvent -> new JobEventXml(jobEvent)).collect(toList()); }
/******************************************************************************************************************* * * Creates a {@link PresentationModel} for a {@link Project} injecting a {@link Selectable} role which fires a * {@link ProjectSelectedEvent} on selection. * * @param customer the {@code Project} * @return the {@code PresentationModel} * ******************************************************************************************************************/ @Nonnull @VisibleForTesting PresentationModel createPresentationModelFor (final @Nonnull Project project) { final Selectable publishEventOnSelection = () -> messageBus.publish(new ProjectSelectedEvent(project)); return project.as(Presentable).createPresentationModel(publishEventOnSelection); } }
/******************************************************************************************************************* * * Reacts to the notification that a {@link Project} has been selected by populating the presentation with * its job events. * * @param event the notification event * ******************************************************************************************************************/ @VisibleForTesting void onProjectSelectedEvent (final @Nonnull @ListensTo ProjectSelectedEvent event) { log.info("onProjectSelectedEvent({})", event); presentation.populate(event.getProject().findChildren() .stream() .map(jobEvent -> (JobEventSpi)jobEvent) .sorted(comparing(JobEventSpi::getDateTime)) .map(jobEvent -> jobEvent.as(Presentable).createPresentationModel()) .collect(toCompositePresentationModel())); } }
.withBillingAddress(a1) .create(); final Project p = Project.builder().withId(new Id("2")) .withBudget(new Money(10500, "EUR")) .withCustomer(c1)
private void dump (final @Nonnull Project project) { pw.printf("%s\n", toString(project)); dump(project.findChildren(), INDENT); }
final @Nonnull String prefix) List<? extends JobEvent> jobEvents = project.findChildren().results(); int x = jobEvents.size() / (invoiceCount + 1);
@VisibleForTesting void onProjectHourlyReportRequest (final @Nonnull @ListensTo ProjectHourlyReportRequest request) { final HourlyReport report = request.getProject().as(HourlyReportGenerator).createReport(); presentation.bind(); presentation.showUp(notificationWithFeedback().withCaption("Project Hourly Report")); presentation.populate(new DefaultPresentationModel(null, (PlainTextRenderableSupport8) (args) -> report.asString())); } }