@yellicode/elements
Version:
The meta model API for Yellicode - an extensible code generator.
51 lines (50 loc) • 1.88 kB
JavaScript
/*
* Copyright (c) 2020 Yellicode
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { UniqueId } from '@yellicode/core';
var Document = /** @class */ (function () {
function Document(modelDelegate) {
this.modelDelegate = modelDelegate;
this.id = '';
this.creator = '';
this.modelTypeName = '';
this.modelTypeVersion = '';
this.model = null;
this.profiles = null;
this.references = [];
}
/**
* Returns an Element representing the element whose id property matches the specified string.
* @returns {elements.Element} The model element matching the specified ID, or null if no matching
* element was found in the model.
* @param {string} id The ID of the element to search for.
*/
Document.prototype.findElementById = function (id) {
return this.modelDelegate.findElementById(id);
};
Document.prototype.setModel = function (name, initFn) {
var properties = { name: name };
this.model = this.modelDelegate.createElement('model', null, properties, initFn);
return this;
};
Document.prototype.setProfiles = function (name, initFn) {
var properties = { name: name };
this.profiles = this.modelDelegate.createElement('model', null, properties, initFn);
return this;
};
Document.create = function (modelDelegate, properties) {
var doc = new Document(modelDelegate);
if (properties)
Object.assign(doc, properties);
// Ensure a ID
if (!doc.id)
doc.id = UniqueId.create(6);
return doc;
};
return Document;
}());
export { Document };