@@ -119,50 +119,46 @@ public ScaleEntity updateEntity(ScaleEntity entity, ScaleBaseClass scale) throws
119119
120120 ontologyService .updateOntologyReference (entity , scale .getOntologyReference ());
121121
122- if (scale .getValidValues () != null ) {
123- if (scale .getValidValues ().isPresent ()) {
124- ScaleBaseClassValidValues validValues = scale .getValidValues ().get ();
125-
126- Integer maxInt = NumberUtils .isCreatable (entity .getValidValueMax ())
127- ? Integer .parseInt (entity .getValidValueMax ())
128- : null ;
129- Optional .ofNullable (UpdateUtility .replaceField (validValues .getMax (), maxInt ))
130- .ifPresent (t -> entity .setValidValueMax (t .toString ()));
131- entity .setValidValueMax (UpdateUtility .replaceField (validValues .getMaximumValue (), entity .getValidValueMax ()));
132-
133- Integer minInt = NumberUtils .isCreatable (entity .getValidValueMin ())
134- ? Integer .parseInt (entity .getValidValueMin ())
135- : null ;
136- Optional .ofNullable (UpdateUtility .replaceField (validValues .getMin (), minInt ))
137- .ifPresent (t -> entity .setValidValueMin (t .toString ()));
138- entity .setValidValueMin (UpdateUtility .replaceField (validValues .getMinimumValue (), entity .getValidValueMin ()));
139-
140- if (validValues .getCategories () != null ) {
141- if (validValues .getCategories ().isPresent ()) {
142- List <ScaleBaseClassValidValuesCategories > categories = validValues .getCategories ().get ();
143-
144- if (entity .getValidValueCategories () != null ) {
145- for (ScaleValidValueCategoryEntity catEntity : entity .getValidValueCategories ()) {
146- catEntity .setScale (null );
147- }
148- }
149- entity .setValidValueCategories (new ArrayList <>());
150- entity .setValidValueCategories (categories .stream ().map (cat -> {
151- ScaleValidValueCategoryEntity catEntity = new ScaleValidValueCategoryEntity ();
152- catEntity .setLabel (cat .getLabel ());
153- catEntity .setValue (cat .getValue ());
154- catEntity .setScale (entity );
155- return catEntity ;
156- }).collect (Collectors .toList ()));
157- } else {
158- entity .setValidValueCategories (null );
122+ if (scale .getValidValues () != null && scale .getValidValues ().isPresent ()) {
123+ ScaleBaseClassValidValues validValues = scale .getValidValues ().get ();
124+
125+ Integer maxInt = NumberUtils .isCreatable (entity .getValidValueMax ())
126+ ? Integer .parseInt (entity .getValidValueMax ())
127+ : null ;
128+ Optional .ofNullable (UpdateUtility .replaceField (validValues .getMax (), maxInt ))
129+ .ifPresent (t -> entity .setValidValueMax (t .toString ()));
130+ entity .setValidValueMax (UpdateUtility .replaceField (validValues .getMaximumValue (), entity .getValidValueMax ()));
131+
132+ Integer minInt = NumberUtils .isCreatable (entity .getValidValueMin ())
133+ ? Integer .parseInt (entity .getValidValueMin ())
134+ : null ;
135+ Optional .ofNullable (UpdateUtility .replaceField (validValues .getMin (), minInt ))
136+ .ifPresent (t -> entity .setValidValueMin (t .toString ()));
137+ entity .setValidValueMin (UpdateUtility .replaceField (validValues .getMinimumValue (), entity .getValidValueMin ()));
138+
139+ if (validValues .getCategories () != null && validValues .getCategories ().isPresent ()) {
140+ List <ScaleBaseClassValidValuesCategories > categories = validValues .getCategories ().get ();
141+
142+ if (entity .getValidValueCategories () != null ) {
143+ for (ScaleValidValueCategoryEntity catEntity : entity .getValidValueCategories ()) {
144+ catEntity .setScale (null );
159145 }
160146 }
147+ entity .setValidValueCategories (new ArrayList <>());
148+ entity .setValidValueCategories (categories .stream ().map (cat -> {
149+ ScaleValidValueCategoryEntity catEntity = new ScaleValidValueCategoryEntity ();
150+ catEntity .setLabel (cat .getLabel ());
151+ catEntity .setValue (cat .getValue ());
152+ catEntity .setScale (entity );
153+ return catEntity ;
154+ }).collect (Collectors .toList ()));
161155 } else {
162156 entity .setValidValueCategories (null );
163- entity .setValidValueMax (null );
164- entity .setValidValueMin (null );
165157 }
158+ } else {
159+ entity .setValidValueCategories (null );
160+ entity .setValidValueMax (null );
161+ entity .setValidValueMin (null );
166162 }
167163
168164 return entity ;
0 commit comments