Tony CHEMIT pushed to branch develop at ultreiaio / ird-observe
Commits:
-
d3e61f87
by tchemit at 2020-04-01T11:18:20+02:00
3 changed files:
- client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/GearUseFeatureMeasurementCellEditor.java
- client-datasource-editor-common/src/main/java/fr/ird/observe/client/datasource/editor/content/data/GearUseFeatureMeasurementCellRenderer.java
- dto/src/main/java/fr/ird/observe/dto/referential/common/GearCaracteristicTypeAware.java
Changes:
| ... | ... | @@ -133,7 +133,7 @@ public class GearUseFeatureMeasurementCellEditor implements TableCellEditor { |
| 133 | 133 |
GearCaracteristicTypeReference gearCaracteristicType = caracteristicRef.getGearCaracteristicType();
|
| 134 | 134 |
Map<String, TableCellEditor> editors = getEditorsByGearCaracteristicId(table);
|
| 135 | 135 |
editor = editors.get(gearCaracteristicType.getId());
|
| 136 |
- value = gearCaracteristicType.getTypeValue(value);
|
|
| 136 |
+ value = gearCaracteristicType.getOptionalTypeValue(value).orElse(null);
|
|
| 137 | 137 |
}
|
| 138 | 138 |
return editor.getTableCellEditorComponent(table, value, isSelected, row, column);
|
| 139 | 139 |
}
|
| ... | ... | @@ -82,7 +82,7 @@ public class GearUseFeatureMeasurementCellRenderer implements TableCellRenderer |
| 82 | 82 |
} else {
|
| 83 | 83 |
GearCaracteristicTypeReference gearCaracteristicType = caracteristicRef.getGearCaracteristicType();
|
| 84 | 84 |
tableCellRenderer = renderersByCaracteristicTypeId.get(gearCaracteristicType.getId());
|
| 85 |
- value = gearCaracteristicType.getTypeValue(value);
|
|
| 85 |
+ value = gearCaracteristicType.getOptionalTypeValue(value).orElse(null);
|
|
| 86 | 86 |
}
|
| 87 | 87 |
return tableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
| 88 | 88 |
}
|
| ... | ... | @@ -26,7 +26,10 @@ import com.google.common.collect.ImmutableSet; |
| 26 | 26 |
import fr.ird.observe.dto.DtoAndReferenceAware;
|
| 27 | 27 |
import fr.ird.observe.dto.ProtectedIds;
|
| 28 | 28 |
import fr.ird.observe.dto.reference.DtoReferenceAware;
|
| 29 |
+import org.apache.logging.log4j.LogManager;
|
|
| 30 |
+import org.apache.logging.log4j.Logger;
|
|
| 29 | 31 |
|
| 32 |
+import java.util.Optional;
|
|
| 30 | 33 |
import java.util.Set;
|
| 31 | 34 |
|
| 32 | 35 |
/**
|
| ... | ... | @@ -35,6 +38,8 @@ import java.util.Set; |
| 35 | 38 |
*/
|
| 36 | 39 |
public interface GearCaracteristicTypeAware extends DtoReferenceAware, DtoAndReferenceAware {
|
| 37 | 40 |
|
| 41 |
+ Logger log = LogManager.getLogger(GearCaracteristicTypeAware.class);
|
|
| 42 |
+ |
|
| 38 | 43 |
Set<String> INTEGER_IDS = ImmutableSet.of(ProtectedIds.COMMON_GEAR_CARACTERISTIC_TYPE_INTEGER_UNSIGNED, ProtectedIds.COMMON_GEAR_CARACTERISTIC_TYPE_INTEGER_SIGNED);
|
| 39 | 44 |
Set<String> FLOAT_IDS = ImmutableSet.of(ProtectedIds.COMMON_GEAR_CARACTERISTIC_TYPE_FLOAT_UNSIGNED, ProtectedIds.COMMON_GEAR_CARACTERISTIC_TYPE_FLOAT_SIGNED);
|
| 40 | 45 |
Set<String> BOOLEAN_IDS = ImmutableSet.of(ProtectedIds.COMMON_GEAR_CARACTERISTIC_TYPE_BOOLEAN);
|
| ... | ... | @@ -63,4 +68,13 @@ public interface GearCaracteristicTypeAware extends DtoReferenceAware, DtoAndRef |
| 63 | 68 |
}
|
| 64 | 69 |
return value;
|
| 65 | 70 |
}
|
| 71 |
+ |
|
| 72 |
+ default Optional<Object> getOptionalTypeValue( Object value) {
|
|
| 73 |
+ try {
|
|
| 74 |
+ return Optional.ofNullable(getTypeValue( value));
|
|
| 75 |
+ } catch (Exception e) {
|
|
| 76 |
+ log.error(String.format("Could not get editor value from: %s", value), e);
|
|
| 77 |
+ return Optional.empty();
|
|
| 78 |
+ }
|
|
| 79 |
+ }
|
|
| 66 | 80 |
}
|