Commit 6b14b528 authored by LAVENIER's avatar LAVENIER
Browse files

Merge branch 'release/1.10.0'

parents a2d8786b f842de97
......@@ -3,7 +3,7 @@
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>1.9.0</version>
<version>1.10.0</version>
<packaging>pom</packaging>
<name>SUMARiS</name>
<description>SUMARiS :: Maven parent</description>
......
......@@ -8,31 +8,23 @@ if [[ "_" == "_${PROJECT_DIR}" ]]; then
fi;
cd ${PROJECT_DIR}
### Control that the script is run on `dev` branch
branch=`git rev-parse --abbrev-ref HEAD`
if [[ ! "$branch" = "release/$version" ]];
then
echo ">> This script must be run under a release branch (release/$version)"
exit 1
fi
### Variables
task=$1
version=$2
release_description=$3
release_description=$2
PROJECT_NAME=sumaris-pod
REPO="sumaris-net/sumaris-pod"
REPO_API_URL=https://api.github.com/repos/$REPO
REPO_PUBLIC_URL=https://github.com/$REPO
### Get version to release
current=`grep -m1 -P "\<version>[0-9A−Z.]+(-\w*)?</version>" pom.xml | grep -oP "\d+.\d+.\d+(-\w*)?"`
if [[ "_$current" == "_" ]]; then
version=`grep -m1 -P "\<version>[0-9A−Z.]+(-\w*)?</version>" pom.xml | grep -oP "\d+.\d+.\d+(-\w*)?"`
if [[ "_$version" == "_" ]]; then
echo "ERROR: Unable to read 'version' in the file 'pom.xml'."
echo " - Make sure the file 'pom.xml' exists and is readable."
exit 1
fi
echo "Current version: $current"
echo "Project version (pom.xml): $version"
### get auth token
if [[ "_${GITHUB_TOKEN}" == "_" ]]; then
......@@ -51,7 +43,7 @@ fi
case "$task" in
del)
result=`curl -i "$REPO_API_URL/releases/tags/$current"`
result=`curl -i "$REPO_API_URL/releases/tags/$version"`
release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "$REPO_API_URL/releases/\d+"`
if [[ $release_url != "" ]]; then
echo "Deleting existing release..."
......@@ -61,6 +53,15 @@ case "$task" in
pre|rel)
### Control that the script is run on `dev` branch
branch=`git rev-parse --abbrev-ref HEAD`
echo "GIT branch: $branch"
if [[ ! "$branch" = "release/$version" ]];
then
echo ">> This script must be run under a release branch (release/$version)"
exit 1
fi
if [[ $1 = "pre" ]]; then
prerelease="true"
else
......@@ -69,10 +70,10 @@ case "$task" in
description=`echo $release_description`
if [[ "_$description" = "_" ]]; then
description="Release $current"
description="Release $version"
fi
result=`curl -s -H ''"$GITHUT_AUTH"'' "$REPO_API_URL/releases/tags/$current"`
result=`curl -s -H ''"$GITHUT_AUTH"'' "$REPO_API_URL/releases/tags/$version"`
release_url=`echo "$result" | grep -P "\"url\": \"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+/releases/\d+"`
if [[ "_$release_url" != "_" ]]; then
echo "Deleting existing release... $release_url"
......@@ -87,9 +88,9 @@ case "$task" in
fi
echo "Creating new release..."
echo " - tag: $current"
echo " - tag: $version"
echo " - description: $description"
result=`curl -H ''"$GITHUT_AUTH"'' -s $REPO_API_URL/releases -d '{"tag_name": "'"$current"'","target_commitish": "master","name": "'"$current"'","body": "'"$description"'","draft": false,"prerelease": '"$prerelease"'}'`
result=`curl -H ''"$GITHUT_AUTH"'' -s $REPO_API_URL/releases -d '{"tag_name": "'"$version"'","target_commitish": "master","name": "'"$version"'","body": "'"$description"'","draft": false,"prerelease": '"$prerelease"'}'`
upload_url=`echo "$result" | grep -P "\"upload_url\": \"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"`
if [[ "_$upload_url" = "_" ]]; then
......@@ -102,12 +103,12 @@ case "$task" in
### Sending files
echo "Uploading files to $upload_url ..."
WAR_FILE="${PROJECT_DIR}/sumaris-server/target/sumaris-server-$current.war"
WAR_FILE="${PROJECT_DIR}/sumaris-server/target/sumaris-server-$version.war"
if [[ ! -f "${WAR_FILE}" ]]; then
echo "ERROR: Missing WAR artifact: ${WAR_FILE}. Skipping upload"
missing_file=true
else
artifact_name="sumaris-pod-$current.war"
artifact_name="sumaris-pod-$version.war"
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${WAR_FILE}" "${upload_url}?name=${artifact_name}")
browser_download_url=`echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"`
SHA256=$(sha256sum "${WAR_FILE}" | sed 's/ /\n/gi' | head -n 1)
......@@ -117,12 +118,12 @@ case "$task" in
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: text/plain' -T "${WAR_FILE}.sha256" "${upload_url}?name=${artifact_name}.sha256")
fi
ZIP_FILE="${PROJECT_DIR}/sumaris-server/target/sumaris-server-$current-standalone.zip"
ZIP_FILE="${PROJECT_DIR}/sumaris-server/target/sumaris-server-$version-standalone.zip"
if [[ ! -f "${ZIP_FILE}" ]]; then
echo "ERROR: Missing ZIP artifact: ${ZIP_FILE}. Skipping upload"
missing_file=true
else
artifact_name="sumaris-pod-$current.zip"
artifact_name="sumaris-pod-$version.zip"
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${ZIP_FILE}" "${upload_url}?name=${ZIP_FILENAME}")
browser_download_url=`echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"`
SHA256=$(sha256sum "${ZIP_FILE}" | sed 's/ /\n/gi' | head -n 1)
......@@ -132,12 +133,12 @@ case "$task" in
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: text/plain' -T "${ZIP_FILE}.sha256" "${upload_url}?name=${artifact_name}.sha256")
fi
DB_FILE="${PROJECT_DIR}/sumaris-core/target/sumaris-db-$current.zip"
DB_FILE="${PROJECT_DIR}/sumaris-core/target/sumaris-db-$version.zip"
if [[ ! -f "${DB_FILE}" ]]; then
echo "ERROR: Missing DB ZIP artifact: ${DB_FILE}. Skipping uppload"
missing_file=true
else
artifact_name="sumaris-db-$current.zip"
artifact_name="sumaris-db-$version.zip"
result=$(curl -s -H ''"$GITHUT_AUTH"'' -H 'Content-Type: application/zip' -T "${DB_FILE}" "${upload_url}?name=${artifact_name}")
browser_download_url=`echo "$result" | grep -P "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "\"browser_download_url\":[ ]?\"[^\"]+" | grep -oP "https://[A-Za-z0-9/.-]+"`
SHA256=$(sha256sum "${DB_FILE}" | sed 's/ /\n/gi' | head -n 1)
......@@ -150,13 +151,13 @@ case "$task" in
if [[ ${missing_file} == true ]]; then
echo "-----------------------------------------"
echo "ERROR: missing some artifacts (see logs)"
echo " -> Release url: ${REPO_PUBLIC_URL}/releases/tag/${current}"
echo " -> Release url: ${REPO_PUBLIC_URL}/releases/tag/${version}"
# Continue if error
exit 1
else
echo "-----------------------------------------"
echo "Successfully uploading files !"
echo " -> Release url: ${REPO_PUBLIC_URL}/releases/tag/${current}"
echo " -> Release url: ${REPO_PUBLIC_URL}/releases/tag/${version}"
exit 0
fi
......
......@@ -33,7 +33,7 @@ if [[ ! $task =~ ^(pre|rel)$ || ! $version =~ ^[0-9]+.[0-9]+.[0-9]+(-(alpha|beta
exit 1
fi
echo "---- Starting release $version ($task)"...
echo "---- Creating release $version ($task)"...
echo ""
# Removing existing release branche
......@@ -79,6 +79,17 @@ git branch -d "release/$version"
echo "---- Push changes to upstream [OK]"
echo ""
# Uploading artifacts to Github
echo "---- Uploading artifacts to Github..."
# Pause (wait propagation to from gitlab to github)
echo " Waiting 40s, for propagation to github..." && sleep 40s
. ${PROJECT_DIR}/src/scripts/release-to-github.sh $task ''"$release_description"''
[[ $? -ne 0 ]] && exit 1
echo "---- Uploading artifacts to Github [OK]"
echo ""
echo "----------------------------------"
echo "RELEASE finished!"
echo "----------------------------------"
Subproject commit 7a81f76fac53e140fcd83394212b153bc9de24a0
Subproject commit 30fdc5272d3244cb244166f70e24c5f2904f86d2
......@@ -148,7 +148,7 @@ To change the Pod's configuration, follow this steps:
Your configuration file should have been processed.
## Build from source (database + Pod)
## Build from source
1. Installe project dependencies:
* Install build tools (Make, GCC, Git)
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>1.9.0</version>
<version>1.10.0</version>
</parent>
<artifactId>sumaris-core-extraction</artifactId>
......
......@@ -3,7 +3,7 @@
<parent>
<artifactId>sumaris-pod</artifactId>
<groupId>net.sumaris</groupId>
<version>1.9.0</version>
<version>1.10.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -3,7 +3,7 @@
<parent>
<artifactId>sumaris-pod</artifactId>
<groupId>net.sumaris</groupId>
<version>1.9.0</version>
<version>1.10.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>1.9.0</version>
<version>1.10.0</version>
</parent>
<artifactId>sumaris-core-shared</artifactId>
......
......@@ -47,8 +47,6 @@ import org.hibernate.dialect.Dialect;
import org.nuiton.i18n.I18n;
import org.nuiton.version.Version;
import org.nuiton.version.Versions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessResourceFailureException;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.dao.DataRetrievalFailureException;
......@@ -56,7 +54,7 @@ import org.springframework.jdbc.datasource.DataSourceUtils;
import javax.persistence.EntityManager;
import javax.persistence.criteria.From;
import javax.persistence.criteria.Join;
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Root;
import javax.sql.DataSource;
......@@ -1717,25 +1715,35 @@ public class Daos {
public static <X> Path<X> composePath(Root<?> root, String attributePath) {
String[] paths = attributePath.split("\\.");
From<?, ?> from = root; // starting from root
String[] attributes = attributePath.split("\\.");
Path<?> path = root; // starting from root
Path<X> result = null;
for (int i = 0; i < paths.length; i++) {
String path = paths[i];
for (int i = 0; i < attributes.length; i++) {
String attribute = attributes[i];
if (i == paths.length - 1) {
if (i == attributes.length - 1) {
// last path, find it
result = from.get(path);
result = path.get(attribute);
} else {
// need a join (find it from existing joins of from)
Join join = from.getJoins().stream()
.filter(j -> j.getAttribute().getName().equals(path))
.findFirst().orElse(null);
if (join == null) {
throw new IllegalArgumentException(String.format("the join %s from %s doesn't exists", path, from.getClass().getSimpleName()));
if (path instanceof From) {
// find a join (find it from existing joins of from)
From<?, ?> from = (From<?, ?>) path;
try {
path = from.getJoins().stream()
.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;
}
}
......
......@@ -37,7 +37,6 @@ import org.ehcache.core.statistics.DefaultStatisticsService;
import org.ehcache.core.statistics.TierStatistics;
import org.ehcache.jsr107.Eh107Configuration;
import org.springframework.cache.interceptor.SimpleKey;
import org.springframework.cache.jcache.JCacheCacheManager;
import org.springframework.data.util.CastUtils;
import javax.cache.Cache;
......@@ -219,7 +218,7 @@ public class Caches {
TierStatistics onHeapStatistics = tierStatistics.get("OnHeap");
if (onHeapStatistics != null) {
result.put("size", onHeapStatistics.getHits());
result.put("heapSize", onHeapStatistics.getAllocatedByteSize());
result.put("heapSize", Math.max(0, onHeapStatistics.getAllocatedByteSize()));
}
TierStatistics offHeapStatistics = tierStatistics.get("OffHeap");
if (offHeapStatistics != null) {
......
......@@ -26,6 +26,7 @@ package net.sumaris.core.util;
import com.google.common.base.Preconditions;
import com.google.common.collect.*;
import lombok.extern.slf4j.Slf4j;
import net.sumaris.core.dao.technical.SortDirection;
import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.exception.SumarisTechnicalException;
......@@ -51,6 +52,7 @@ import java.util.stream.Stream;
* helper class for beans (split by property, make sure list exists, ...)
* Created by blavenie on 13/10/15.
*/
@Slf4j
public class Beans {
protected Beans() {
......@@ -397,7 +399,12 @@ public class Beans {
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();
/**
......@@ -446,6 +453,26 @@ public class Beans {
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
* should return true if :
......
......@@ -4,7 +4,7 @@
<parent>
<groupId>net.sumaris</groupId>
<artifactId>sumaris-pod</artifactId>
<version>1.9.0</version>
<version>1.10.0</version>
</parent>
<artifactId>sumaris-core</artifactId>
......
......@@ -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.Pageables;
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.model.IUpdateDateEntityBean;
import net.sumaris.core.model.administration.user.Person;
import net.sumaris.core.model.data.IDataEntity;
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.data.*;
import net.sumaris.core.model.referential.QualityFlag;
import net.sumaris.core.model.referential.QualityFlagEnum;
import net.sumaris.core.util.Beans;
import net.sumaris.core.vo.administration.user.DepartmentVO;
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.IDataVO;
import net.sumaris.core.vo.data.VesselSnapshotVO;
......@@ -68,7 +62,6 @@ import java.util.stream.Collectors;
/**
* @author peck7 on 30/03/2020.
*/
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@NoRepositoryBean
@Slf4j
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
@Override
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));
}
......@@ -276,6 +269,7 @@ public abstract class DataRepositoryImpl<E extends IDataEntity<Integer>, V exten
toVO(source, target, null, copyIfNull);
}
@SuppressWarnings("unchecked")
public void toVO(E source, V target, O fetchOptions, boolean copyIfNull) {
Beans.copyProperties(source, target);
......@@ -291,13 +285,13 @@ public abstract class DataRepositoryImpl<E extends IDataEntity<Integer>, V exten
// Vessel
if (source instanceof IWithVesselEntity && target instanceof IWithVesselSnapshotEntity) {
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);
}
// Observers
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)) {
Set<PersonVO> observers = sourceObservers.stream()
.map(personRepository::toVO)
......
......@@ -22,9 +22,7 @@ package net.sumaris.core.dao.data;
* #L%
*/
import net.sumaris.core.model.data.BatchSortingMeasurement;
import net.sumaris.core.model.data.IDataEntity;
import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.model.data.IMeasurementEntity;
import net.sumaris.core.vo.data.MeasurementVO;
import net.sumaris.core.vo.data.QuantificationMeasurementVO;
......@@ -42,7 +40,7 @@ public interface MeasurementDao {
Class<? extends IMeasurementEntity> entityClass,
List<V> sources,
List<T> target,
IDataEntity<?> parent);
IEntity<?> parent);
<T extends IMeasurementEntity> List<T> getMeasurementEntitiesByParentId(Class<T> entityClass,
String parentPropertyName,
......@@ -96,6 +94,12 @@ public interface MeasurementDao {
List<MeasurementVO> saveSaleMeasurements(int saleId, List<MeasurementVO> sources);
Map<Integer, String> saveSaleMeasurementsMap(int saleId, Map<Integer, String> sources);
// Expected Sale
List<MeasurementVO> getExpectedSaleMeasurements(int saleId);
Map<Integer, String> getExpectedSaleMeasurementsMap(int saleId);
List<MeasurementVO> saveExpectedSaleMeasurements(int saleId, List<MeasurementVO> sources);
Map<Integer, String> saveExpectedSaleMeasurementsMap(int saleId, Map<Integer, String> sources);
// Landing
List<MeasurementVO> saveLandingMeasurements(int landingId, List<MeasurementVO> sources);
Map<Integer, String> saveLandingMeasurementsMap(final int landingId, Map<Integer, String> sources);
......
......@@ -344,6 +344,25 @@ public class MeasurementDaoImpl extends HibernateDaoSupport implements Measureme
);
}
@Override
public List<MeasurementVO> getExpectedSaleMeasurements(int saleId) {
return getMeasurementsByParentId(SaleMeasurement.class,
MeasurementVO.class,
SaleMeasurement.Fields.EXPECTED_SALE,
saleId,
SaleMeasurement.Fields.ID
);
}
@Override
public Map<Integer, String> getExpectedSaleMeasurementsMap(int saleId) {
return getMeasurementsMapByParentId(SaleMeasurement.class,
SaleMeasurement.Fields.EXPECTED_SALE,
saleId,
null
);
}
@Override
public <T extends IMeasurementEntity, V extends MeasurementVO> V toMeasurementVO(T source, Class<? extends V> voClass) {
if (source == null) return null;
......@@ -452,6 +471,18 @@ public class MeasurementDaoImpl extends HibernateDaoSupport implements Measureme
return saveMeasurementsMap(SaleMeasurement.class, sources, parent.getMeasurements(), parent);
}
@Override
public List<MeasurementVO> saveExpectedSaleMeasurements(int saleId, List<MeasurementVO> sources) {
ExpectedSale parent = getById(ExpectedSale.class, saleId);
return saveMeasurements(SaleMeasurement.class, sources, parent.getMeasurements(), parent);
}
@Override
public Map<Integer, String> saveExpectedSaleMeasurementsMap(int saleId, Map<Integer, String> sources) {
ExpectedSale parent = getById(ExpectedSale.class, saleId);
return saveMeasurementsMap(SaleMeasurement.class, sources, parent.getMeasurements(), parent);
}
@Override
public List<MeasurementVO> saveLandingMeasurements(final int landingId, List<MeasurementVO> sources) {
Landing parent = getById(Landing.class, landingId);
......@@ -603,7 +634,7 @@ public class MeasurementDaoImpl extends HibernateDaoSupport implements Measureme
final Class<? extends IMeasurementEntity> entityClass,
List<V> sources,
List<T> target,
final IDataEntity<?> parent) {
final IEntity<?> parent) {
final EntityManager em = getEntityManager();
......@@ -717,7 +748,7 @@ public class MeasurementDaoImpl extends HibernateDaoSupport implements Measureme
}
@SuppressWarnings("unchecked")
protected <T extends IDataEntity<?>> Class<T> getEntityClass(T source) {
protected <T extends IEntity<?>> Class<T> getEntityClass(T source) {
String classname = source.getClass().getName();
int index = classname.indexOf("$HibernateProxy");
if (index > 0) {
......@@ -736,7 +767,7 @@ public class MeasurementDaoImpl extends HibernateDaoSupport implements Measureme
final Class<? extends T> entityClass,
Map<Integer, String> sources,
List<T> target,
final IDataEntity<?> parent) {
final IEntity<?> parent) {
final EntityManager session = getEntityManager();
......@@ -1009,15 +1040,17 @@ public class MeasurementDaoImpl extends HibernateDaoSupport implements Measureme
}
}
protected void fillDefaultProperties(IDataEntity<?> parent, IMeasurementEntity target) {
protected void fillDefaultProperties(IEntity<?> parent, IMeasurementEntity target) {
// Recorder department
if (target.getRecorderDepartment() == null) {
if (parent.getRecorderDepartment() == null || parent.getRecorderDepartment().getId() == null) {
target.setRecorderDepartment(null);
}
else {
target.setRecorderDepartment(parent.getRecorderDepartment());
if (parent instanceof IDataEntity) {
IDataEntity<?> parentData = (IDataEntity<?>) parent;
// Recorder department
if (target.getRecorderDepartment() == null) {
if (parentData.getRecorderDepartment() == null || parentData.getRecorderDepartment().getId() == null) {
target.setRecorderDepartment(null);
} else {
target.setRecorderDepartment(parentData.getRecorderDepartment());
}
}
}
......
......@@ -25,14 +25,12 @@ package net.sumaris.core.dao.data.fishingArea;
import net.sumaris.core.dao.technical.jpa.BindableSpecification;
import net.sumaris.core.dao.technical.jpa.SumarisJpaRepository;
import net.sumaris.core.dao.technical.model.IEntity;
import net.sumaris.core.model.data.Batch;
import net.sumaris.core.model.data.FishingArea;
import net.sumaris.core.vo.data.FishingAreaVO;
import org.springframework.data.jpa.domain.Specification;