toJsonMap method

Map<String, Object> toJsonMap()

Implementation

Map<String, Object> toJsonMap() {
  Map<String, Object> entityMap = <String, Object>{};
  for (Parent parent in _concept!.parents.whereType<Parent>()) {
    Entity? parentEntity = getParent(parent.code!) as Entity?;
    if (parentEntity != null) {
      var reference = <String, String>{};
      reference['oid'] = parentEntity.oid.toString();
      reference['parent'] = parentEntity.concept.code!;
      reference['entry'] = parentEntity.concept.entryConcept.code!;
      entityMap[parent.code!] = reference;
    } else {
      entityMap[parent.code!] = 'null';
    }
  }
  entityMap['oid'] = _oid.toString();
  entityMap['code'] = _code ?? '';
  entityMap['whenAdded'] = _whenAdded.toString();
  entityMap['whenSet'] = _whenSet.toString();
  entityMap['whenRemoved'] = _whenRemoved.toString();

  for (var k in _attributeMap.keys) {
    entityMap[k] = getStringFromAttribute(k);
  }

  for (var k in _internalChildMap.keys) {
    entityMap[k] = (getInternalChild(k) as Entities).toJsonList();
  }
  return entityMap;
}