Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package fr.ird.observe.entities;
/*-
* #%L
* ObServe Toolkit :: Common Persistence
* %%
* Copyright (C) 2017 - 2020 IRD, Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* .
* #L%
*/
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import fr.ird.observe.dto.IdDto;
import fr.ird.observe.dto.data.DataDto;
import fr.ird.observe.dto.reference.DataDtoReference;
import fr.ird.observe.dto.reference.ReferentialDtoReference;
import fr.ird.observe.dto.referential.ReferentialDto;
import fr.ird.observe.dto.referential.ReferentialLocale;
import fr.ird.observe.entities.data.DataEntity;
import fr.ird.observe.entities.referential.ReferentialEntity;
import fr.ird.observe.spi.DbModelHelper;
import fr.ird.observe.spi.context.DataDtoEntityContext;
import fr.ird.observe.spi.context.ReferentialDtoEntityContext;
import org.apache.commons.collections4.CollectionUtils;
import org.nuiton.topia.persistence.TopiaEntities;
import javax.sql.rowset.serial.SerialBlob;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import java.util.Set;
/**
* Some useful methods on entities (mainly to transform them to/from dto).
*
* @author Tony Chemit - [email protected]
* @since 4
*/
public class EntityHelper {
public static void toDto(Entity entity, D dto) {
dto.setId(entity.getTopiaId());
dto.setVersion(entity.getTopiaVersion());
dto.setCreateDate(entity.getTopiaCreateDate());
dto.setLastUpdateDate(entity.getLastUpdateDate());
}
public static void fromDto(Entity entity, D dto) {
entity.setTopiaId(dto.getId());
entity.setTopiaVersion(dto.getVersion());
entity.setTopiaCreateDate(dto.getCreateDate());
Date lastUpdateDate = dto.getLastUpdateDate();
if (lastUpdateDate == null) {
lastUpdateDate = new Date();
}
entity.setLastUpdateDate(lastUpdateDate);
}
public static
, EE extends ReferentialEntity
> EE toReferentialEntity(RR reference) {
EE entity = null;
if (reference != null) {
ReferentialDtoEntityContext