Content of file ProjectXml.java.html

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../../jacoco-resources/report.gif" type="image/gif"/><title>ProjectXml.java</title><link rel="stylesheet" href="../../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../../index.html" class="el_report">blueHour - UI</a> &gt; <a href="../index.html" class="el_bundle">it-tidalwave-accounting-marshalling-xml</a> &gt; <a href="index.source.html" class="el_package">it.tidalwave.accounting.exporter.xml.impl.xml</a> &gt; <span class="el_source">ProjectXml.java</span></div><h1>ProjectXml.java</h1><pre class="source lang-java linenums">/*
 * #%L
 * *********************************************************************************************************************
 *
 * blueHour
 * http://bluehour.tidalwave.it - git clone git@bitbucket.org:tidalwave/bluehour-src.git
 * %%
 * Copyright (C) 2013 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
 * %%
 * *********************************************************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations under the License.
 *
 * *********************************************************************************************************************
 *
 *
 * *********************************************************************************************************************
 * #L%
 */
package it.tidalwave.accounting.exporter.xml.impl.xml;

import javax.annotation.Nonnull;
import java.util.List;
import java.time.LocalDate;
import javax.xml.bind.annotation.XmlAccessorOrder;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlIDREF;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import it.tidalwave.util.Id;
import it.tidalwave.util.NotFoundException;
import it.tidalwave.accounting.model.Accounting;
import it.tidalwave.accounting.model.types.Money;
import it.tidalwave.accounting.model.Project;
import it.tidalwave.accounting.exporter.xml.impl.adapters.MoneyAdapter;
import it.tidalwave.accounting.exporter.xml.impl.adapters.LocalDateAdapter;
import it.tidalwave.accounting.exporter.xml.impl.adapters.IdAdapter;
import it.tidalwave.accounting.exporter.xml.impl.adapters.ProjectStatusAdapter;
import lombok.Getter;
import lombok.NoArgsConstructor;
import static java.util.stream.Collectors.toList;
import static javax.xml.bind.annotation.XmlAccessOrder.ALPHABETICAL;
import static javax.xml.bind.annotation.XmlAccessType.FIELD;

/***********************************************************************************************************************
 *
 * @author  Fabrizio Giudici
 *
 **********************************************************************************************************************/
//@Mutable
<span class="fc" id="L62">@NoArgsConstructor</span>
@XmlRootElement(name = &quot;project&quot;) @XmlAccessorType(FIELD) @XmlAccessorOrder(ALPHABETICAL)
public class ProjectXml 
  {
<span class="fc" id="L66">    @Getter // FIXME   </span>
@XmlAttribute(name = &quot;id&quot;) @XmlID @XmlJavaTypeAdapter(IdAdapter.class) private Id id; @XmlElement(name = &quot;customer&quot;) @XmlIDREF private CustomerXml customerXml; @XmlElement(name = &quot;name&quot;) private String name; @XmlElement(name = &quot;number&quot;) private String number; @XmlElement(name = &quot;description&quot;) private String description; @XmlElement(name = &quot;notes&quot;) private String notes; @XmlElement(name = &quot;status&quot;) @XmlJavaTypeAdapter(ProjectStatusAdapter.class) private Project.Status status; @XmlElement(name = &quot;hourlyRate&quot;) @XmlJavaTypeAdapter(MoneyAdapter.class) private Money hourlyRate; @XmlElement(name = &quot;amount&quot;) @XmlJavaTypeAdapter(MoneyAdapter.class) private Money budget; @XmlElement(name = &quot;startDate&quot;) @XmlJavaTypeAdapter(LocalDateAdapter.class) private LocalDate startDate; @XmlElement(name = &quot;endDate&quot;) @XmlJavaTypeAdapter(LocalDateAdapter.class) private LocalDate endDate; @XmlElementWrapper(name = &quot;events&quot;) @XmlElement(name = &quot;event&quot;) private List&lt;JobEventXml&gt; jobEventsXml; public ProjectXml (@Nonnull final Project project) <span class="fc" id="L113"> {</span> <span class="fc" id="L114"> final var builder = project.toBuilder();</span> <span class="fc" id="L115"> this.id = builder.getId();</span> <span class="fc" id="L116"> this.customerXml = new CustomerXml(builder.getCustomer());</span> <span class="fc" id="L117"> this.name = builder.getName();</span> <span class="fc" id="L118"> this.number = builder.getNumber();</span> <span class="fc" id="L119"> this.description = builder.getDescription();</span> <span class="fc" id="L120"> this.notes = builder.getNotes();</span> <span class="fc" id="L121"> this.status = builder.getStatus();</span> <span class="fc" id="L122"> this.hourlyRate = builder.getHourlyRate();</span> <span class="fc" id="L123"> this.budget = builder.getBudget();</span> <span class="fc" id="L124"> this.startDate = builder.getStartDate();</span> <span class="fc" id="L125"> this.endDate = builder.getEndDate();</span> <span class="fc" id="L126"> this.jobEventsXml = project.findChildren().stream().map(JobEventXml::new).collect(toList());</span> <span class="fc" id="L127"> }</span> @Nonnull public Project.Builder toBuilder (@Nonnull final Accounting accounting) { try { <span class="fc" id="L134"> final var customer = accounting.getCustomerRegistry().findCustomers().withId(customerXml.getId()).result();</span> <span class="fc" id="L135"> return new Project.Builder().withId(id)</span> <span class="fc" id="L136"> .withCustomer(customer) </span> <span class="fc" id="L137"> .withName(name)</span> <span class="fc" id="L138"> .withNumber(number)</span> <span class="fc" id="L139"> .withDescription(description)</span> <span class="fc" id="L140"> .withNotes(notes)</span> <span class="fc" id="L141"> .withStatus(status)</span> <span class="fc" id="L142"> .withHourlyRate(hourlyRate)</span> <span class="fc" id="L143"> .withBudget(budget)</span> <span class="fc" id="L144"> .withStartDate(startDate)</span> <span class="fc" id="L145"> .withEndDate(endDate)</span> <span class="fc" id="L146"> .withEvents(JobEventXml.toJobEvents(jobEventsXml));</span> } <span class="nc" id="L148"> catch (NotFoundException e) </span> { <span class="nc" id="L150"> throw new RuntimeException(e);</span> } } } </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.7.202105040129</span></div></body></html>