nuagenetworks / monolithe

generic and extendable code generator from specifications.
BSD 3-Clause "New" or "Revised" License
16 stars 28 forks source link

Entity - added getInstanceFromID #89

Closed killanch closed 6 years ago

killanch commented 6 years ago

Sample generated code,

import NUAttribute from 'service/NUAttribute';
import ServiceClassRegistry from 'service/ServiceClassRegistry';
import NUEntity from 'service/NUEntity';

/* Represents Avatar entity
   Avatar
*/
export default class NUAvatar extends NUEntity {
    constructor(...args) {
        super(...args);
        this.defineProperties({
            type: null,
        });
    }

    static entityDescriptor = {
        description: `Avatar`,
        userlabel: `Avatar`,
    }

    static attributeDescriptors = {
        ...NUEntity.attributeDescriptors,
        type: new NUAttribute({
            localName: 'type',
            attributeType: NUAttribute.ATTR_TYPE_STRING,
            description: `The image type`,
            userlabel: `Type`,
        }),
    }

    static getClassName() {
        return 'NUAvatar';
    }

    static getAllowedJobCommands() {
        return [];
    }

    static supportsAlarms() {
        return false;
    }

    static getInstanceFromID(ID) {
        const instance = new NUAvatar();
        instance.ID = ID;
        return instance;
    }

    get RESTName() {
        return 'avatar';
    }

    get resourceName() {
        return 'avatars';
    }

    getClassName() {
        return NUAvatar.getClassName();
    }

    getAllowedJobCommands() {
        return NUAvatar.getAllowedJobCommands();
    }
}

ServiceClassRegistry.register(NUAvatar);