@Test void toEntityDateTimeStringValueValid() throws ParseException { Attribute dateAttr = when(mock(Attribute.class).getName()).thenReturn("dateAttr").getMock(); when(dateAttr.getDataType()).thenReturn(DATE_TIME); Instant expected = Instant.parse("2000-12-31T10:34:56.789Z"); assertEquals(expected, restService.toEntityValue(dateAttr, "2000-12-31T10:34:56.789Z", "test")); }
public Object toEntityValue(Attribute attr, Object paramValue, Object id) { if ((paramValue instanceof String) && ((String) paramValue).isEmpty()) { paramValue = null; } Object value; AttributeType attrType = attr.getDataType(); switch (attrType) { case BOOL: value = convertBool(attr, paramValue); break; case EMAIL: case ENUM: case HTML: case HYPERLINK: case SCRIPT: case STRING: case TEXT: value = convertString(attr, paramValue); break; case CATEGORICAL: case XREF: value = convertRef(attr, paramValue); break; case CATEGORICAL_MREF: case MREF: case ONE_TO_MANY: value = convertMref(attr, paramValue); break; case DATE: value = convertDate(attr, paramValue); break; case DATE_TIME: value = convertDateTime(attr, paramValue); break; case DECIMAL: value = convertDecimal(attr, paramValue); break; case FILE: value = convertFile(attr, paramValue, id); break; case INT: value = convertInt(attr, paramValue); break; case LONG: value = convertLong(attr, paramValue); break; case COMPOUND: throw new IllegalAttributeTypeException(attrType); default: throw new UnexpectedEnumException(attrType); } return value; }
RestService { public Object toEntityValue(Attribute attr, Object paramValue, Object id) { if ((paramValue instanceof String) && ((String) paramValue).isEmpty()) { paramValue = null; } Object value; AttributeType attrType = attr.getDataType(); switch (attrType) { case BOOL: value = convertBool(attr, paramValue); break; case EMAIL: case ENUM: case HTML: case HYPERLINK: case SCRIPT: case STRING: case TEXT: value = convertString(attr, paramValue); break; case CATEGORICAL: case XREF: value = convertRef(attr, paramValue); break; case CATEGORICAL_MREF: case MREF: case ONE_TO_MANY: value = convertMref(attr, paramValue); break; case DATE: value = convertDate(attr, paramValue); break; case DATE_TIME: value = convertDateTime(attr, paramValue); break; case DECIMAL: value = convertDecimal(attr, paramValue); break; case FILE: value = convertFile(attr, paramValue, id); break; case INT: value = convertInt(attr, paramValue); break; case LONG: value = convertLong(attr, paramValue); break; case COMPOUND: throw new IllegalAttributeTypeException(attrType); default: throw new UnexpectedEnumException(attrType); } return value; } }
RestService { public Object toEntityValue(Attribute attr, Object paramValue, Object id) { if ((paramValue instanceof String) && ((String) paramValue).isEmpty()) { paramValue = null; } Object value; AttributeType attrType = attr.getDataType(); switch (attrType) { case BOOL: value = convertBool(attr, paramValue); break; case EMAIL: case ENUM: case HTML: case HYPERLINK: case SCRIPT: case STRING: case TEXT: value = convertString(attr, paramValue); break; case CATEGORICAL: case XREF: value = convertRef(attr, paramValue); break; case CATEGORICAL_MREF: case MREF: case ONE_TO_MANY: value = convertMref(attr, paramValue); break; case DATE: value = convertDate(attr, paramValue); break; case DATE_TIME: value = convertDateTime(attr, paramValue); break; case DECIMAL: value = convertDecimal(attr, paramValue); break; case FILE: value = convertFile(attr, paramValue, id); break; case INT: value = convertInt(attr, paramValue); break; case LONG: value = convertLong(attr, paramValue); break; case COMPOUND: throw new IllegalAttributeTypeException(attrType); default: throw new UnexpectedEnumException(attrType); } return value; } RestService(
      DataService dataService,
      IdGenerator idGenerator,
      FileStore fileStore,
      FileMetaFactory fileMetaFactory,
      EntityManager entityManager,
      ServletUriComponentsBuilderFactory servletUriComponentsBuilderFactory); }
RestService { public Object toEntityValue(Attribute attr, Object paramValue, Object id) { if ((paramValue instanceof String) && ((String) paramValue).isEmpty()) { paramValue = null; } Object value; AttributeType attrType = attr.getDataType(); switch (attrType) { case BOOL: value = convertBool(attr, paramValue); break; case EMAIL: case ENUM: case HTML: case HYPERLINK: case SCRIPT: case STRING: case TEXT: value = convertString(attr, paramValue); break; case CATEGORICAL: case XREF: value = convertRef(attr, paramValue); break; case CATEGORICAL_MREF: case MREF: case ONE_TO_MANY: value = convertMref(attr, paramValue); break; case DATE: value = convertDate(attr, paramValue); break; case DATE_TIME: value = convertDateTime(attr, paramValue); break; case DECIMAL: value = convertDecimal(attr, paramValue); break; case FILE: value = convertFile(attr, paramValue, id); break; case INT: value = convertInt(attr, paramValue); break; case LONG: value = convertLong(attr, paramValue); break; case COMPOUND: throw new IllegalAttributeTypeException(attrType); default: throw new UnexpectedEnumException(attrType); } return value; } RestService(
      DataService dataService,
      IdGenerator idGenerator,
      FileStore fileStore,
      FileMetaFactory fileMetaFactory,
      EntityManager entityManager,
      ServletUriComponentsBuilderFactory servletUriComponentsBuilderFactory); Entity toEntity(final EntityType meta, final Map<String, Object> request); Object toEntityValue(Attribute attr, Object paramValue, Object id); void updateMappedByEntities(@Nonnull Entity entity); void updateMappedByEntities(
      @Nonnull Entity entity, @Nullable @CheckForNull Entity existingEntity); }
RestService { public Object toEntityValue(Attribute attr, Object paramValue, Object id) { if ((paramValue instanceof String) && ((String) paramValue).isEmpty()) { paramValue = null; } Object value; AttributeType attrType = attr.getDataType(); switch (attrType) { case BOOL: value = convertBool(attr, paramValue); break; case EMAIL: case ENUM: case HTML: case HYPERLINK: case SCRIPT: case STRING: case TEXT: value = convertString(attr, paramValue); break; case CATEGORICAL: case XREF: value = convertRef(attr, paramValue); break; case CATEGORICAL_MREF: case MREF: case ONE_TO_MANY: value = convertMref(attr, paramValue); break; case DATE: value = convertDate(attr, paramValue); break; case DATE_TIME: value = convertDateTime(attr, paramValue); break; case DECIMAL: value = convertDecimal(attr, paramValue); break; case FILE: value = convertFile(attr, paramValue, id); break; case INT: value = convertInt(attr, paramValue); break; case LONG: value = convertLong(attr, paramValue); break; case COMPOUND: throw new IllegalAttributeTypeException(attrType); default: throw new UnexpectedEnumException(attrType); } return value; } RestService(
      DataService dataService,
      IdGenerator idGenerator,
      FileStore fileStore,
      FileMetaFactory fileMetaFactory,
      EntityManager entityManager,
      ServletUriComponentsBuilderFactory servletUriComponentsBuilderFactory); Entity toEntity(final EntityType meta, final Map<String, Object> request); Object toEntityValue(Attribute attr, Object paramValue, Object id); void updateMappedByEntities(@Nonnull Entity entity); void updateMappedByEntities(
      @Nonnull Entity entity, @Nullable @CheckForNull Entity existingEntity);  }