Commit c6f08e07 authored by PECQUOT's avatar PECQUOT
Browse files

[fix] Remove rankOrderOnVessel from Landing and LandingVO

[enh] add LandingRepositoryImpl.findAllByObservedLocationId with natural sort on vessel registration code
parent 1f1ad377
sumaris.config.option.auth.allExtractionTypeAccess.role.description= sumaris.config.option.auth.allExtractionTypeAccess.role.description=
sumaris.config.option.extraction.accessNotSelfExtraction.role.description=
sumaris.config.option.extraction.cli.frequency.description= sumaris.config.option.extraction.cli.frequency.description=
sumaris.config.option.extraction.cli.output.format.description= sumaris.config.option.extraction.cli.output.format.description=
sumaris.config.option.extraction.enabled.description= sumaris.config.option.extraction.enabled.description=
......
sumaris.config.option.auth.allExtractionTypeAccess.role.description= sumaris.config.option.auth.allExtractionTypeAccess.role.description=
sumaris.config.option.extraction.accessNotSelfExtraction.role.description=
sumaris.config.option.extraction.cli.frequency.description= sumaris.config.option.extraction.cli.frequency.description=
sumaris.config.option.extraction.cli.output.format.description= sumaris.config.option.extraction.cli.output.format.description=
sumaris.config.option.extraction.enabled.description= sumaris.config.option.extraction.enabled.description=
......
...@@ -47,8 +47,6 @@ import org.hibernate.dialect.Dialect; ...@@ -47,8 +47,6 @@ import org.hibernate.dialect.Dialect;
import org.nuiton.i18n.I18n; import org.nuiton.i18n.I18n;
import org.nuiton.version.Version; import org.nuiton.version.Version;
import org.nuiton.version.Versions; import org.nuiton.version.Versions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessResourceFailureException; import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DataRetrievalFailureException; import org.springframework.dao.DataRetrievalFailureException;
...@@ -56,7 +54,7 @@ import org.springframework.jdbc.datasource.DataSourceUtils; ...@@ -56,7 +54,7 @@ import org.springframework.jdbc.datasource.DataSourceUtils;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.criteria.From; import javax.persistence.criteria.From;
import javax.persistence.criteria.Join; import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Path; import javax.persistence.criteria.Path;
import javax.persistence.criteria.Root; import javax.persistence.criteria.Root;
import javax.sql.DataSource; import javax.sql.DataSource;
...@@ -1717,25 +1715,35 @@ public class Daos { ...@@ -1717,25 +1715,35 @@ public class Daos {
public static <X> Path<X> composePath(Root<?> root, String attributePath) { public static <X> Path<X> composePath(Root<?> root, String attributePath) {
String[] paths = attributePath.split("\\."); String[] attributes = attributePath.split("\\.");
From<?, ?> from = root; // starting from root Path<?> path = root; // starting from root
Path<X> result = null; Path<X> result = null;
for (int i = 0; i < paths.length; i++) { for (int i = 0; i < attributes.length; i++) {
String path = paths[i]; String attribute = attributes[i];
if (i == paths.length - 1) { if (i == attributes.length - 1) {
// last path, find it // last path, find it
result = from.get(path); result = path.get(attribute);
} else { } else {
// need a join (find it from existing joins of from) if (path instanceof From) {
Join join = from.getJoins().stream() // find a join (find it from existing joins of from)
.filter(j -> j.getAttribute().getName().equals(path)) From<?, ?> from = (From<?, ?>) path;
.findFirst().orElse(null); try {
if (join == null) { path = from.getJoins().stream()
throw new IllegalArgumentException(String.format("the join %s from %s doesn't exists", path, from.getClass().getSimpleName())); .filter(j -> j.getAttribute().getName().equals(attribute))
.findFirst()
.orElseGet(() -> from.join(attribute, JoinType.LEFT));
continue;
} catch (IllegalArgumentException ignored) {
}
}
// find an attribute
try {
path = path.get(attribute);
} catch (IllegalArgumentException iae) {
throw new IllegalArgumentException(String.format("the join or attribute [%s] from [%s] doesn't exists", attribute, path.getJavaType()));
} }
from = join;
} }
} }
......
...@@ -26,6 +26,7 @@ package net.sumaris.core.util; ...@@ -26,6 +26,7 @@ package net.sumaris.core.util;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.*; import com.google.common.collect.*;
import lombok.extern.slf4j.Slf4j;
import net.sumaris.core.dao.technical.SortDirection; import net.sumaris.core.dao.technical.SortDirection;
import net.sumaris.core.dao.technical.model.IEntity; import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.exception.SumarisTechnicalException; import net.sumaris.core.exception.SumarisTechnicalException;
...@@ -51,6 +52,7 @@ import java.util.stream.Stream; ...@@ -51,6 +52,7 @@ import java.util.stream.Stream;
* helper class for beans (split by property, make sure list exists, ...) * helper class for beans (split by property, make sure list exists, ...)
* Created by blavenie on 13/10/15. * Created by blavenie on 13/10/15.
*/ */
@Slf4j
public class Beans { public class Beans {
protected Beans() { protected Beans() {
...@@ -397,7 +399,12 @@ public class Beans { ...@@ -397,7 +399,12 @@ public class Beans {
return (o1, o2) -> -1; return (o1, o2) -> -1;
} }
//public static Map<String, String[]> cacheCopyPropertiesIgnored; public static <T> T clone(T source, Class<T> sourceClass) {
T target = newInstance(sourceClass);
copyProperties(source, target);
return target;
}
public static Map<Class<?>, Map<Class<?>, String[]>> cacheCopyPropertiesIgnored = Maps.newConcurrentMap(); public static Map<Class<?>, Map<Class<?>, String[]>> cacheCopyPropertiesIgnored = Maps.newConcurrentMap();
/** /**
...@@ -446,6 +453,26 @@ public class Beans { ...@@ -446,6 +453,26 @@ public class Beans {
BeanUtils.copyProperties(source, target, ArrayUtils.addAll(ignoredProperties, exceptProperties)); BeanUtils.copyProperties(source, target, ArrayUtils.addAll(ignoredProperties, exceptProperties));
} }
public static boolean beanIsEmpty(Object bean, String... ignoredAttributes) {
if (bean == null)
return true;
return Arrays.stream(bean.getClass().getDeclaredFields())
.filter(field -> !ArrayUtils.contains(ignoredAttributes, field.getName()))
.allMatch(field -> {
Object property = getProperty(bean, field.getName());
if (property == null)
return true;
if (property.getClass().isArray()) {
return ArrayUtils.isEmpty((Object[]) property);
}
if (property instanceof Collection)
return CollectionUtils.isEmpty((Collection<?>) property);
log.warn(String.format("Unable to determinate if %s is null", property));
return false;
});
}
/** /**
* Compute equality of 2 Map * Compute equality of 2 Map
* should return true if : * should return true if :
......
...@@ -30,21 +30,15 @@ import net.sumaris.core.dao.administration.user.PersonRepository; ...@@ -30,21 +30,15 @@ import net.sumaris.core.dao.administration.user.PersonRepository;
import net.sumaris.core.dao.technical.Daos; import net.sumaris.core.dao.technical.Daos;
import net.sumaris.core.dao.technical.Pageables; import net.sumaris.core.dao.technical.Pageables;
import net.sumaris.core.dao.technical.SortDirection; import net.sumaris.core.dao.technical.SortDirection;
import net.sumaris.core.dao.technical.jpa.BindableSpecification;
import net.sumaris.core.dao.technical.jpa.IFetchOptions;
import net.sumaris.core.dao.technical.jpa.SumarisJpaRepositoryImpl; import net.sumaris.core.dao.technical.jpa.SumarisJpaRepositoryImpl;
import net.sumaris.core.dao.technical.model.IUpdateDateEntityBean; import net.sumaris.core.dao.technical.model.IUpdateDateEntityBean;
import net.sumaris.core.model.administration.user.Person; import net.sumaris.core.model.administration.user.Person;
import net.sumaris.core.model.data.IDataEntity; import net.sumaris.core.model.data.*;
import net.sumaris.core.model.data.IWithObserversEntity;
import net.sumaris.core.model.data.IWithVesselEntity;
import net.sumaris.core.model.data.IWithVesselSnapshotEntity;
import net.sumaris.core.model.referential.QualityFlag; import net.sumaris.core.model.referential.QualityFlag;
import net.sumaris.core.model.referential.QualityFlagEnum; import net.sumaris.core.model.referential.QualityFlagEnum;
import net.sumaris.core.util.Beans; import net.sumaris.core.util.Beans;
import net.sumaris.core.vo.administration.user.DepartmentVO; import net.sumaris.core.vo.administration.user.DepartmentVO;
import net.sumaris.core.vo.administration.user.PersonVO; import net.sumaris.core.vo.administration.user.PersonVO;
import net.sumaris.core.vo.data.DataFetchOptions;
import net.sumaris.core.vo.data.IDataFetchOptions; import net.sumaris.core.vo.data.IDataFetchOptions;
import net.sumaris.core.vo.data.IDataVO; import net.sumaris.core.vo.data.IDataVO;
import net.sumaris.core.vo.data.VesselSnapshotVO; import net.sumaris.core.vo.data.VesselSnapshotVO;
...@@ -68,7 +62,6 @@ import java.util.stream.Collectors; ...@@ -68,7 +62,6 @@ import java.util.stream.Collectors;
/** /**
* @author peck7 on 30/03/2020. * @author peck7 on 30/03/2020.
*/ */
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@NoRepositoryBean @NoRepositoryBean
@Slf4j @Slf4j
public abstract class DataRepositoryImpl<E extends IDataEntity<Integer>, V extends IDataVO<Integer>, F extends IDataFilter, O extends IDataFetchOptions> public abstract class DataRepositoryImpl<E extends IDataEntity<Integer>, V extends IDataVO<Integer>, F extends IDataFilter, O extends IDataFetchOptions>
...@@ -107,7 +100,7 @@ public abstract class DataRepositoryImpl<E extends IDataEntity<Integer>, V exten ...@@ -107,7 +100,7 @@ public abstract class DataRepositoryImpl<E extends IDataEntity<Integer>, V exten
@Override @Override
public Page<V> findAll(F filter, Pageable pageable, O fetchOptions) { public Page<V> findAll(F filter, Pageable pageable, O fetchOptions) {
return findAll(toSpecification(filter), pageable) return findAll(toSpecification(filter, fetchOptions), pageable)
.map(e -> this.toVO(e, fetchOptions)); .map(e -> this.toVO(e, fetchOptions));
} }
...@@ -276,6 +269,7 @@ public abstract class DataRepositoryImpl<E extends IDataEntity<Integer>, V exten ...@@ -276,6 +269,7 @@ public abstract class DataRepositoryImpl<E extends IDataEntity<Integer>, V exten
toVO(source, target, null, copyIfNull); toVO(source, target, null, copyIfNull);
} }
@SuppressWarnings("unchecked")
public void toVO(E source, V target, O fetchOptions, boolean copyIfNull) { public void toVO(E source, V target, O fetchOptions, boolean copyIfNull) {
Beans.copyProperties(source, target); Beans.copyProperties(source, target);
...@@ -291,13 +285,13 @@ public abstract class DataRepositoryImpl<E extends IDataEntity<Integer>, V exten ...@@ -291,13 +285,13 @@ public abstract class DataRepositoryImpl<E extends IDataEntity<Integer>, V exten
// Vessel // Vessel
if (source instanceof IWithVesselEntity && target instanceof IWithVesselSnapshotEntity) { if (source instanceof IWithVesselEntity && target instanceof IWithVesselSnapshotEntity) {
VesselSnapshotVO vesselSnapshot = new VesselSnapshotVO(); VesselSnapshotVO vesselSnapshot = new VesselSnapshotVO();
vesselSnapshot.setId((Integer) ((IWithVesselEntity) source).getVessel().getId()); vesselSnapshot.setId(((IWithVesselEntity<Integer, Vessel>) source).getVessel().getId());
((IWithVesselSnapshotEntity<Integer, VesselSnapshotVO>) target).setVesselSnapshot(vesselSnapshot); ((IWithVesselSnapshotEntity<Integer, VesselSnapshotVO>) target).setVesselSnapshot(vesselSnapshot);
} }
// Observers // Observers
if (source instanceof IWithObserversEntity && target instanceof IWithObserversEntity) { if (source instanceof IWithObserversEntity && target instanceof IWithObserversEntity) {
Set<Person> sourceObservers = ((IWithObserversEntity) source).getObservers(); Set<Person> sourceObservers = ((IWithObserversEntity<Integer, Person>) source).getObservers();
if ((fetchOptions == null || fetchOptions.isWithObservers()) && CollectionUtils.isNotEmpty(sourceObservers)) { if ((fetchOptions == null || fetchOptions.isWithObservers()) && CollectionUtils.isNotEmpty(sourceObservers)) {
Set<PersonVO> observers = sourceObservers.stream() Set<PersonVO> observers = sourceObservers.stream()
.map(personRepository::toVO) .map(personRepository::toVO)
......
...@@ -25,6 +25,7 @@ package net.sumaris.core.dao.data.landing; ...@@ -25,6 +25,7 @@ package net.sumaris.core.dao.data.landing;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.sumaris.core.dao.data.RootDataRepositoryImpl; import net.sumaris.core.dao.data.RootDataRepositoryImpl;
import net.sumaris.core.dao.referential.location.LocationRepository; import net.sumaris.core.dao.referential.location.LocationRepository;
import net.sumaris.core.dao.technical.Page;
import net.sumaris.core.model.data.Landing; import net.sumaris.core.model.data.Landing;
import net.sumaris.core.model.data.ObservedLocation; import net.sumaris.core.model.data.ObservedLocation;
import net.sumaris.core.model.data.Trip; import net.sumaris.core.model.data.Trip;
...@@ -39,6 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -39,6 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.domain.Specification;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
...@@ -74,6 +76,54 @@ public class LandingRepositoryImpl ...@@ -74,6 +76,54 @@ public class LandingRepositoryImpl
.and(hasExcludeVesselIds(filter.getExcludeVesselIds())); .and(hasExcludeVesselIds(filter.getExcludeVesselIds()));
} }
@Override
public List<LandingVO> findAllByObservedLocationId(int observedLocationId, Page page, DataFetchOptions fetchOptions) {
boolean sortByVesselRegistrationCode = Landing.Fields.VESSEL.equalsIgnoreCase(page.getSortBy());
StringBuilder queryBuilder = new StringBuilder();
queryBuilder.append("select l from Landing l ");
if (sortByVesselRegistrationCode) {
// add joins
queryBuilder.append("left outer join l.vessel v left outer join v.vesselRegistrationPeriods vrp ");
}
// single filter
queryBuilder.append("where l.observedLocation.id = :observedLocationId ");
if (sortByVesselRegistrationCode) {
// add natural order on vessel registration code
queryBuilder.append(
String.format(
"order by regexp_substr(vrp.registrationCode, '[^0-9]*') %1$s, to_number(regexp_substr(vrp.registrationCode, '[0-9]+')) %1$s nulls first",
page.getSortDirection()
)
);
} else {
// other sort
queryBuilder.append(
String.format(
"order by l.%s %s",
page.getSortBy(),
page.getSortDirection()
)
);
}
TypedQuery<Landing> query = getEntityManager().createQuery(queryBuilder.toString(), Landing.class);
query.setParameter("observedLocationId", observedLocationId);
return readPage(query, Landing.class, page.asPageable(), null)
.stream()
.map(landing -> toVO(landing, fetchOptions))
.collect(Collectors.toList())
;
}
@Override @Override
public List<LandingVO> saveAllByObservedLocationId(int observedLocationId, List<LandingVO> sources) { public List<LandingVO> saveAllByObservedLocationId(int observedLocationId, List<LandingVO> sources) {
// Load parent entity // Load parent entity
...@@ -153,15 +203,22 @@ public class LandingRepositoryImpl ...@@ -153,15 +203,22 @@ public class LandingRepositoryImpl
} }
} }
// RankOrderOnVessel // RankOrder
if (source.getRankOrderOnVessel() == null) { if (source.getRankOrder() == null) {
// must compute next rank order // must compute next rank order
target.setRankOrderOnVessel(getNextRankOrderOnVessel(target)); target.setRankOrder(getNextRankOrder(target));
} }
} }
private Integer getNextRankOrderOnVessel(Landing landing) { /**
* Compute rank order for this landing
* Default value = 1 and incremented if another landing with same vessel found
*
* @param landing landing to save
* @return next rank order
*/
private Integer getNextRankOrder(Landing landing) {
// Default value // Default value
int result = 1; int result = 1;
...@@ -179,9 +236,9 @@ public class LandingRepositoryImpl ...@@ -179,9 +236,9 @@ public class LandingRepositoryImpl
Optional<Integer> currentRankOrder = findAll(filter).stream() Optional<Integer> currentRankOrder = findAll(filter).stream()
// exclude itself // exclude itself
.filter(landingVO -> !landingVO.getId().equals(landing.getId())) .filter(landingVO -> !landingVO.getId().equals(landing.getId()))
.map(LandingVO::getRankOrderOnVessel) .map(LandingVO::getRankOrder)
.filter(Objects::nonNull) .filter(Objects::nonNull)
// find max rankOrderOnVessel // find max rankOrder
.max(Integer::compareTo); .max(Integer::compareTo);
if (currentRankOrder.isPresent()) { if (currentRankOrder.isPresent()) {
result = Math.max(result, currentRankOrder.get()); result = Math.max(result, currentRankOrder.get());
......
...@@ -23,9 +23,11 @@ package net.sumaris.core.dao.data.landing; ...@@ -23,9 +23,11 @@ package net.sumaris.core.dao.data.landing;
*/ */
import net.sumaris.core.dao.data.RootDataSpecifications; import net.sumaris.core.dao.data.RootDataSpecifications;
import net.sumaris.core.dao.technical.Page;
import net.sumaris.core.dao.technical.jpa.BindableSpecification; import net.sumaris.core.dao.technical.jpa.BindableSpecification;
import net.sumaris.core.dao.technical.model.IEntity; import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.model.data.Landing; import net.sumaris.core.model.data.Landing;
import net.sumaris.core.vo.data.DataFetchOptions;
import net.sumaris.core.vo.data.LandingVO; import net.sumaris.core.vo.data.LandingVO;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
...@@ -157,7 +159,8 @@ public interface LandingSpecifications extends RootDataSpecifications<Landing> { ...@@ -157,7 +159,8 @@ public interface LandingSpecifications extends RootDataSpecifications<Landing> {
}; };
} }
// Not tested List<LandingVO> findAllByObservedLocationId(int observedLocationId, Page page, DataFetchOptions fetchOptions);
List<LandingVO> saveAllByObservedLocationId(int observedLocationId, List<LandingVO> sources); List<LandingVO> saveAllByObservedLocationId(int observedLocationId, List<LandingVO> sources);
List<LandingVO> findAllByTripIds(List<Integer> tripIds); List<LandingVO> findAllByTripIds(List<Integer> tripIds);
......
...@@ -10,12 +10,12 @@ package net.sumaris.core.model.data; ...@@ -10,12 +10,12 @@ package net.sumaris.core.model.data;
* it under the terms of the GNU General Public License as * it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the * published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public * You should have received a copy of the GNU General Public
* License along with this program. If not, see * License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>. * <http://www.gnu.org/licenses/gpl-3.0.html>.
...@@ -105,9 +105,6 @@ public class Landing implements IRootDataEntity<Integer>, ...@@ -105,9 +105,6 @@ public class Landing implements IRootDataEntity<Integer>,
@Column(name = "rank_order") @Column(name = "rank_order")
private Integer rankOrder; private Integer rankOrder;
@Column(name = "rank_order_on_vessel")
private Integer rankOrderOnVessel;
@ManyToOne(fetch = FetchType.LAZY, targetEntity = Program.class) @ManyToOne(fetch = FetchType.LAZY, targetEntity = Program.class)
@JoinColumn(name = "program_fk", nullable = false) @JoinColumn(name = "program_fk", nullable = false)
private Program program; private Program program;
......
...@@ -154,7 +154,7 @@ public class AggregatedLandingServiceImpl implements AggregatedLandingService { ...@@ -154,7 +154,7 @@ public class AggregatedLandingServiceImpl implements AggregatedLandingService {
VesselActivityVO activity = new VesselActivityVO(); VesselActivityVO activity = new VesselActivityVO();
activity.setDate(date); activity.setDate(date);
activity.setRankOrder(landing.getRankOrderOnVessel()); activity.setRankOrder(landing.getRankOrder());
activity.setComments(landing.getComments()); activity.setComments(landing.getComments());
// Add parent links // Add parent links
...@@ -405,7 +405,7 @@ public class AggregatedLandingServiceImpl implements AggregatedLandingService { ...@@ -405,7 +405,7 @@ public class AggregatedLandingServiceImpl implements AggregatedLandingService {
private boolean createOrUpdateLandings(ObservedLocationVO observedLocation, List<LandingVO> landings, List<Integer> landingIdsToRemove, Integer vesselId, VesselActivityVO activity) { private boolean createOrUpdateLandings(ObservedLocationVO observedLocation, List<LandingVO> landings, List<Integer> landingIdsToRemove, Integer vesselId, VesselActivityVO activity) {
boolean landingsDirty = false; boolean landingsDirty = false;
LandingVO landing = landings.stream().filter(landingVO -> Objects.equals(landingVO.getRankOrderOnVessel(), activity.getRankOrder())).findFirst().orElse(null); LandingVO landing = landings.stream().filter(landingVO -> Objects.equals(landingVO.getRankOrder(), activity.getRankOrder())).findFirst().orElse(null);
// Get measurements // Get measurements
if (hasMeasurements(activity)) { if (hasMeasurements(activity)) {
...@@ -504,7 +504,7 @@ public class AggregatedLandingServiceImpl implements AggregatedLandingService { ...@@ -504,7 +504,7 @@ public class AggregatedLandingServiceImpl implements AggregatedLandingService {
private boolean createOrUpdateTrips(ObservedLocationVO observedLocation, List<LandingVO> landings, Integer vesselId, VesselActivityVO activity) { private boolean createOrUpdateTrips(ObservedLocationVO observedLocation, List<LandingVO> landings, Integer vesselId, VesselActivityVO activity) {
LandingVO landing = landings.stream().filter(landingVO -> Objects.equals(landingVO.getRankOrderOnVessel(), activity.getRankOrder())).findFirst().orElse(null); LandingVO landing = landings.stream().filter(landingVO -> Objects.equals(landingVO.getRankOrder(), activity.getRankOrder())).findFirst().orElse(null);
Preconditions.checkNotNull(landing, "The landing should already exists."); Preconditions.checkNotNull(landing, "The landing should already exists.");
Integer tripId = landing.getTrip() != null ? landing.getTrip().getId() : landing.getTripId(); Integer tripId = landing.getTrip() != null ? landing.getTrip().getId() : landing.getTripId();
// Check if trip ids corresponds (both null is ok) // Check if trip ids corresponds (both null is ok)
...@@ -697,7 +697,7 @@ public class AggregatedLandingServiceImpl implements AggregatedLandingService { ...@@ -697,7 +697,7 @@ public class AggregatedLandingServiceImpl implements AggregatedLandingService {
landing.setProgram(parent.getProgram()); landing.setProgram(parent.getProgram());
landing.setDateTime(parent.getStartDateTime()); landing.setDateTime(parent.getStartDateTime());
landing.setLocation(parent.getLocation()); landing.setLocation(parent.getLocation());
landing.setRankOrderOnVessel(activity.getRankOrder()); landing.setRankOrder(activity.getRankOrder());
landing.setComments(activity.getComments()); landing.setComments(activity.getComments());
landing.setRecorderDepartment(parent.getRecorderDepartment()); landing.setRecorderDepartment(parent.getRecorderDepartment());
landing.setRecorderPerson(parent.getRecorderPerson()); landing.setRecorderPerson(parent.getRecorderPerson());
......
...@@ -35,11 +35,12 @@ import net.sumaris.core.event.config.ConfigurationUpdatedEvent; ...@@ -35,11 +35,12 @@ import net.sumaris.core.event.config.ConfigurationUpdatedEvent;
import net.sumaris.core.event.entity.EntityDeleteEvent; import net.sumaris.core.event.entity.EntityDeleteEvent;
import net.sumaris.core.event.entity.EntityInsertEvent; import net.sumaris.core.event.entity.EntityInsertEvent;
import net.sumaris.core.event.entity.EntityUpdateEvent; import net.sumaris.core.event.entity.EntityUpdateEvent;
import net.sumaris.core.model.data.*; import net.sumaris.core.model.data.Landing;
import net.sumaris.core.model.data.LandingMeasurement;
import net.sumaris.core.model.data.Trip;
import net.sumaris.core.model.referential.pmfm.MatrixEnum; import net.sumaris.core.model.referential.pmfm.MatrixEnum;
import net.sumaris.core.util.Beans; import net.sumaris.core.util.Beans;
import net.sumaris.core.util.DataBeans; import net.sumaris.core.util.DataBeans;
import net.sumaris.core.util.StringUtils;
import net.sumaris.core.vo.data.*; import net.sumaris.core.vo.data.*;
import net.sumaris.core.vo.data.sample.SampleVO; import net.sumaris.core.vo.data.sample.SampleVO;
import net.sumaris.core.vo.filter.LandingFilterVO; import net.sumaris.core.vo.filter.LandingFilterVO;
...@@ -90,12 +91,10 @@ public class LandingServiceImpl implements LandingService { ...@@ -90,12 +91,10 @@ public class LandingServiceImpl implements LandingService {
if (page != null) {