Skip to content
Snippets Groups Projects
Commit 52f588c6 authored by Florian Spreckelsen's avatar Florian Spreckelsen
Browse files

ENH: Add isReference and getUnit

parent b24b3945
No related branches found
No related tags found
1 merge request!1ENH: Add property and entity classes
......@@ -70,9 +70,13 @@ export class Property {
return this.wrappedProperty.getId();
}
getUnit() {
return this.wrappedProperty.getUnit();
}
getValue() {
const wrappedValue = this.wrappedProperty.getValue();
if (value === undefined) {
if (wrappedValue === undefined) {
// Empty values are undefined regardless of data type
return undefined;
}
......@@ -84,11 +88,21 @@ export class Property {
case dtypeCases.ATOMIC_DATA_TYPE:
return _getScalarValue(wrappedValue.getScalarValue());
case dtypeCases.LIST_DATA_TYPE:
return _getListValue(wrappedDataType.getListDataTypeCase(), wrappedValue.getListValues().getValuesList());
return _getListValue(wrappedDataType.getListDataType(), wrappedValue.getListValues().getValuesList());
case dtypeCases.REFERENCE_DATA_TYPE:
return _getScalarValue(wrappedValue.getScalarValue());
default:
throw `Unkown data type ${wrappedDataType.getDataTypeCase()}.`;
throw `Unknown data type ${wrappedDataType.getDataTypeCase()}.`;
}
}
isReference() {
const wrappedDataType = this.wrappedProperty.getDataType()
const dtypeCase = wrappedDataType.getDataTypeCase();
return (
(dtypeCase === api.v1.DataType.DataTypeCase.REFERENCE_DATA_TYPE) ||
(dtypeCase === api.v1.DataType.DataTypeCase.LIST_DATA_TYPE &&
wrappedDataType.getListDataType().getListDataTypeCase() === api.v1.ListDataType.ListDataTypeCase.REFERENCE_DATA_TYPE)
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment