Commit 278a94d9 authored by LAVENIER's avatar LAVENIER
Browse files

[fix] CI: fix imagine build, using user/group

parent 9addba8b
......@@ -255,8 +255,8 @@ gitlab-release:
stage: docker
script:
# Build variables: set default values
- export IMAGE_GROUPID=${IMAGE_GROUPID:20001}
- export IMAGE_USERID=${IMAGE_USERID:20001}
- export IMAGINE_GROUPID=${IMAGINE_GROUPID:20001}
# Create the target directory, to build the image
- mkdir -p target/docker/config
- cp -rf ${APP_WAR_MODULE}/src/main/docker/* target/docker/
......@@ -266,7 +266,7 @@ gitlab-release:
- cd target/docker
# Build docker image
- docker pull ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} || true
- docker build --cache-from ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} --pull -t ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} --build-arg="USERID=${IMAGE_USERID}" --build-arg="GROUPID=${IMAGINE_GROUPID}" .
- docker build --cache-from ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} --pull -t ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} --build-arg="USERID=${IMAGE_USERID}" --build-arg="GROUPID=${IMAGE_GROUPID}" .
- docker push ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}
artifacts:
paths:
......@@ -300,7 +300,7 @@ docker:ifremer-isi-val:
variables:
IMAGE_TAG: $CI_COMMIT_TAG
IMAGE_USERID: 25484
IMAGINE_GROUPID: 10004
IMAGE_GROUPID: 10004
only:
- tags
- feature/imagine
......
......@@ -32,8 +32,12 @@
<!-- other fields -->
<select alias="START_DATE" type="date">APP.START_DATE</select>
<select alias="END_DATE" type="date">APP.END_DATE</select>
<!-- TODO: EFFORT à renommer en ??? -->
<select alias="EXPECTED_EFFORT" type="number">APP.ACQUISITION_NUMBER</select>
<select alias="REALIZED_EFFORT" type="number">count(distinct S.ID)</select>
<!--<select alias="SAMPLE_COUNT" type="number">count(distinct S.ID)</select>-->
<select alias="LANDING_COUNT" type="number">count(distinct L.ID)</select>
<!-- hidden columns -->
......
......@@ -275,34 +275,40 @@ public class StrategyRepositoryImpl
@Override
public String computeNextSampleLabelByStrategy(String strategyLabel, String labelSeparator, int nbDigit) {
Preconditions.checkNotNull(strategyLabel);
final String prefix = (labelSeparator == null) ? strategyLabel : strategyLabel + labelSeparator;
final String prefix = StringUtils.isNotBlank(labelSeparator) ? strategyLabel + labelSeparator : strategyLabel;
CriteriaBuilder builder = getEntityManager().getCriteriaBuilder();
CriteriaQuery<String> query = builder.createQuery(String.class);
Root<Sample> root = query.from(Sample.class);
ParameterExpression<Integer> idParam = builder.parameter(Integer.class);
ParameterExpression<String> valueParam = builder.parameter(String.class);
ParameterExpression<Integer> tagIdPmfmIdParam = builder.parameter(Integer.class);
ParameterExpression<Integer> strategyPmfmIdParam = builder.parameter(Integer.class);
ParameterExpression<String> strategyLabelParam = builder.parameter(String.class);
Join<Sample, Landing> landingInnerJoin = root.join(Sample.Fields.LANDING, JoinType.INNER);
Join<Landing, LandingMeasurement> measurementInnerJoin = landingInnerJoin.joinList(Landing.Fields.MEASUREMENTS, JoinType.INNER);
Join<Landing, LandingMeasurement> strategyMeasurementInnerJoin = landingInnerJoin.joinList(Landing.Fields.MEASUREMENTS, JoinType.INNER);
Join<Landing, LandingMeasurement> tagIdInnerJoin = landingInnerJoin.joinList(Landing.Fields.MEASUREMENTS, JoinType.INNER);
query.select(root.get(Sample.Fields.LABEL))
query.select(tagIdInnerJoin.get(LandingMeasurement.Fields.ALPHANUMERICAL_VALUE))
.distinct(true)
.where(
builder.and(
builder.equal(measurementInnerJoin.get(LandingMeasurement.Fields.PMFM).get(IEntity.Fields.ID), idParam),
builder.equal(measurementInnerJoin.get(LandingMeasurement.Fields.ALPHANUMERICAL_VALUE), valueParam)
// Tag id measurement
builder.equal(tagIdInnerJoin.get(LandingMeasurement.Fields.PMFM).get(IEntity.Fields.ID), tagIdPmfmIdParam),
// Strategy measurement
builder.equal(strategyMeasurementInnerJoin.get(LandingMeasurement.Fields.PMFM).get(IEntity.Fields.ID), strategyPmfmIdParam),
builder.equal(strategyMeasurementInnerJoin.get(LandingMeasurement.Fields.ALPHANUMERICAL_VALUE), strategyLabelParam)
));
String result = getEntityManager()
.createQuery(query)
.setParameter(idParam, PmfmEnum.STRATEGY_LABEL.getId())
.setParameter(valueParam, strategyLabel)
.getResultStream()
.max(String::compareTo)
.map(source -> StringUtils.removeStart(source, prefix))
.orElse("0");
.createQuery(query)
.setParameter(tagIdPmfmIdParam, PmfmEnum.TAG_ID.getId())
.setParameter(strategyPmfmIdParam, PmfmEnum.STRATEGY_LABEL.getId())
.setParameter(strategyLabelParam, strategyLabel)
.getResultStream()
.max(String::compareTo)
.map(source -> StringUtils.removeStart(source, prefix))
.orElse("0");
if (!StringUtils.isNumeric(result)) {
throw new SumarisTechnicalException(String.format("Unable to increment label '%s' on sample", prefix.concat(result)));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment