(docOrModel)
| 683 | modelToString (model) { return model.get('name') } |
| 684 | |
| 685 | formatDocument (docOrModel) { |
| 686 | if (docOrModel instanceof CocoModel) { return this.modelToString(docOrModel) } |
| 687 | if (this.settings.supermodel == null) { return 'Unknown' } |
| 688 | let m = this.getReferencedModel(this.getData(), this.workingSchema) |
| 689 | const data = this.getData() |
| 690 | if (_.isString(data)) { // LatestVersionOriginalReferenceNode just uses original |
| 691 | if (m.schema().properties.version) { |
| 692 | m = this.settings.supermodel.getModelByOriginal(m.constructor, data) |
| 693 | } else { |
| 694 | // get by id |
| 695 | m = this.settings.supermodel.getModel(m.constructor, data) |
| 696 | } |
| 697 | } else { |
| 698 | m = this.settings.supermodel.getModelByOriginalAndMajorVersion(m.constructor, data.original, data.majorVersion) |
| 699 | } |
| 700 | if (this.instance && !m) { |
| 701 | m = this.instance |
| 702 | this.settings.supermodel.registerModel(m) |
| 703 | } |
| 704 | if (!m) { return 'Unknown - ' + (data.original != null ? data.original : data) } |
| 705 | return this.modelToString(m) |
| 706 | } |
| 707 | |
| 708 | getReferencedModel (data, schema) { |
| 709 | if (schema.links == null) { return null } |
no test coverage detected