[OLINGO-1472]Support Scale having values variable and floating
This commit is contained in:
parent
7e1aa94d4e
commit
2b96e6e2a1
|
@ -71,6 +71,7 @@ class ClientCsdlProperty extends CsdlProperty implements Serializable {
|
||||||
final String scale = jp.nextTextValue();
|
final String scale = jp.nextTextValue();
|
||||||
property.setScale("variable".equalsIgnoreCase(scale) || "floating".equalsIgnoreCase(scale) ?
|
property.setScale("variable".equalsIgnoreCase(scale) || "floating".equalsIgnoreCase(scale) ?
|
||||||
0 : Integer.valueOf(scale));
|
0 : Integer.valueOf(scale));
|
||||||
|
property.setScaleAsString(scale);
|
||||||
} else if ("Unicode".equals(jp.getCurrentName())) {
|
} else if ("Unicode".equals(jp.getCurrentName())) {
|
||||||
property.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue()));
|
property.setUnicode(BooleanUtils.toBoolean(jp.nextTextValue()));
|
||||||
} else if ("SRID".equals(jp.getCurrentName())) {
|
} else if ("SRID".equals(jp.getCurrentName())) {
|
||||||
|
|
|
@ -585,7 +585,24 @@ public class MetadataTest extends AbstractTest {
|
||||||
assertEquals("UI.HeaderInfo", property.getAnnotations().get(0).getTerm().
|
assertEquals("UI.HeaderInfo", property.getAnnotations().get(0).getTerm().
|
||||||
getFullQualifiedName().getFullQualifiedNameAsString());
|
getFullQualifiedName().getFullQualifiedNameAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void readVariableFloatingDecimalProperty() {
|
||||||
|
final Edm edm = fetchEdm();
|
||||||
|
assertNotNull(edm);
|
||||||
|
EdmEntityType entity = edm.getEntityTypeWithAnnotations(
|
||||||
|
new FullQualifiedName("SEPMRA_SO_MAN2", "I_DraftAdministrativeDataType"));
|
||||||
|
EdmProperty VariableDecimalType = (EdmProperty) entity.getProperty("VariableDecimalType");
|
||||||
|
assertEquals("variable", VariableDecimalType.getScaleAsString());
|
||||||
|
assertEquals(Integer.valueOf(0), VariableDecimalType.getScale());
|
||||||
|
assertNull(VariableDecimalType.getPrecision());
|
||||||
|
|
||||||
|
EdmProperty FloatingDecimalType = (EdmProperty) entity.getProperty("FloatingDecimalType");
|
||||||
|
assertEquals("floating", FloatingDecimalType.getScaleAsString());
|
||||||
|
assertEquals(Integer.valueOf(0), FloatingDecimalType.getScale());
|
||||||
|
assertEquals(Integer.valueOf(7), FloatingDecimalType.getPrecision());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void readAnnotationOnActionImport() {
|
public void readAnnotationOnActionImport() {
|
||||||
final Edm edm = fetchEdm();
|
final Edm edm = fetchEdm();
|
||||||
|
|
|
@ -71,6 +71,8 @@
|
||||||
<Property Name="DraftIsCreatedByMe" Type="Edm.Boolean"/>
|
<Property Name="DraftIsCreatedByMe" Type="Edm.Boolean"/>
|
||||||
<Property Name="DraftIsLastChangedByMe" Type="Edm.Boolean"/>
|
<Property Name="DraftIsLastChangedByMe" Type="Edm.Boolean"/>
|
||||||
<Property Name="DraftIsProcessedByMe" Type="Edm.Boolean"/>
|
<Property Name="DraftIsProcessedByMe" Type="Edm.Boolean"/>
|
||||||
|
<Property Name="VariableDecimalType" Type="Edm.Decimal" Scale="variable"/>
|
||||||
|
<Property Name="FloatingDecimalType" Type="Edm.Decimal" Precision="7" Scale="floating"/>
|
||||||
<Property Name="CreatedByUserDescription" Type="Edm.String" MaxLength="80"/>
|
<Property Name="CreatedByUserDescription" Type="Edm.String" MaxLength="80"/>
|
||||||
<Property Name="LastChangedByUserDescription" Type="Edm.String" MaxLength="80"/>
|
<Property Name="LastChangedByUserDescription" Type="Edm.String" MaxLength="80"/>
|
||||||
<Property Name="InProcessByUserDescription" Type="Edm.String" MaxLength="80"/>
|
<Property Name="InProcessByUserDescription" Type="Edm.String" MaxLength="80"/>
|
||||||
|
|
|
@ -61,6 +61,11 @@ public interface EdmProperty extends EdmElement, EdmMappable, EdmAnnotatable {
|
||||||
*/
|
*/
|
||||||
Integer getScale();
|
Integer getScale();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the scale as an String or null if not specified
|
||||||
|
*/
|
||||||
|
String getScaleAsString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a non-negative integer or the special value <tt>variable</tt>
|
* @return a non-negative integer or the special value <tt>variable</tt>
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -50,6 +50,8 @@ public class CsdlProperty extends CsdlAbstractEdmItem implements CsdlNamed, Csdl
|
||||||
|
|
||||||
private Integer scale;
|
private Integer scale;
|
||||||
|
|
||||||
|
private String scaleAsString;
|
||||||
|
|
||||||
private boolean unicode = true;
|
private boolean unicode = true;
|
||||||
|
|
||||||
private SRID srid;
|
private SRID srid;
|
||||||
|
@ -232,6 +234,26 @@ public class CsdlProperty extends CsdlAbstractEdmItem implements CsdlNamed, Csdl
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets scaleAsString.
|
||||||
|
*
|
||||||
|
* @return the scaleAsString
|
||||||
|
*/
|
||||||
|
public String getScaleAsString() {
|
||||||
|
return scaleAsString;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets scaleAsString.
|
||||||
|
*
|
||||||
|
* @param scaleAsString the scaleAsString
|
||||||
|
* @return the scaleAsString
|
||||||
|
*/
|
||||||
|
public CsdlProperty setScaleAsString(final String scaleAsString) {
|
||||||
|
this.scaleAsString = scaleAsString;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is unicode.
|
* Is unicode.
|
||||||
*
|
*
|
||||||
|
|
|
@ -119,6 +119,11 @@ public class EdmPropertyImpl extends AbstractEdmNamed implements EdmProperty {
|
||||||
return property.getScale();
|
return property.getScale();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getScaleAsString() {
|
||||||
|
return property.getScaleAsString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SRID getSrid() {
|
public SRID getSrid() {
|
||||||
return property.getSrid();
|
return property.getSrid();
|
||||||
|
|
|
@ -57,6 +57,7 @@ public class EdmPropertyImplTest {
|
||||||
assertNull(property.getMaxLength());
|
assertNull(property.getMaxLength());
|
||||||
assertNull(property.getPrecision());
|
assertNull(property.getPrecision());
|
||||||
assertNull(property.getScale());
|
assertNull(property.getScale());
|
||||||
|
assertNull(property.getScaleAsString());
|
||||||
assertNull(property.getSrid());
|
assertNull(property.getSrid());
|
||||||
assertNotNull(property.getAnnotations());
|
assertNotNull(property.getAnnotations());
|
||||||
assertTrue(property.getAnnotations().isEmpty());
|
assertTrue(property.getAnnotations().isEmpty());
|
||||||
|
@ -172,6 +173,7 @@ public class EdmPropertyImplTest {
|
||||||
propertyProvider.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
|
propertyProvider.setType(EdmPrimitiveTypeKind.String.getFullQualifiedName());
|
||||||
propertyProvider.setPrecision(42);
|
propertyProvider.setPrecision(42);
|
||||||
propertyProvider.setScale(12);
|
propertyProvider.setScale(12);
|
||||||
|
propertyProvider.setScaleAsString("12");
|
||||||
propertyProvider.setMaxLength(128);
|
propertyProvider.setMaxLength(128);
|
||||||
propertyProvider.setUnicode(true);
|
propertyProvider.setUnicode(true);
|
||||||
propertyProvider.setNullable(false);
|
propertyProvider.setNullable(false);
|
||||||
|
@ -182,6 +184,7 @@ public class EdmPropertyImplTest {
|
||||||
assertNull(property.getMimeType());
|
assertNull(property.getMimeType());
|
||||||
assertEquals(Integer.valueOf(42), property.getPrecision());
|
assertEquals(Integer.valueOf(42), property.getPrecision());
|
||||||
assertEquals(Integer.valueOf(12), property.getScale());
|
assertEquals(Integer.valueOf(12), property.getScale());
|
||||||
|
assertEquals("12", property.getScaleAsString());
|
||||||
assertEquals(Integer.valueOf(128), property.getMaxLength());
|
assertEquals(Integer.valueOf(128), property.getMaxLength());
|
||||||
assertTrue(property.isUnicode());
|
assertTrue(property.isUnicode());
|
||||||
assertFalse(property.isNullable());
|
assertFalse(property.isNullable());
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class DynamicProperty implements EdmProperty {
|
||||||
private final EdmType propertyType;
|
private final EdmType propertyType;
|
||||||
private Integer precision;
|
private Integer precision;
|
||||||
private Integer scale;
|
private Integer scale;
|
||||||
|
private String scaleAsString;
|
||||||
|
|
||||||
/** Creates a dynamic property with a mandatory name and an optional type. */
|
/** Creates a dynamic property with a mandatory name and an optional type. */
|
||||||
public DynamicProperty(final String name, final EdmType type) {
|
public DynamicProperty(final String name, final EdmType type) {
|
||||||
|
@ -88,6 +89,11 @@ public class DynamicProperty implements EdmProperty {
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getScaleAsString() {
|
||||||
|
return scaleAsString;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SRID getSrid() {
|
public SRID getSrid() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -132,4 +138,9 @@ public class DynamicProperty implements EdmProperty {
|
||||||
this.scale = scale;
|
this.scale = scale;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DynamicProperty setScaleAsString(String scaleAsString) {
|
||||||
|
this.scaleAsString = scaleAsString;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue