summaryrefslogtreecommitdiffstats
path: root/asdctool/.gitignore
blob: 4a95481e611021403799e1b0a49ae9c4f18d2e2f (plain)
1
2
/bin/
/build/
-scheme: light) { .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/**
 * Created by obarda on 2/3/2016.
 */
'use strict';
import {InstancesInputsOrPropertiesMapData} from "../instance-inputs-properties-map";
import {PropertyModel} from "../properties";
import {DisplayModule} from "../modules/base-module";
import {InputModel} from "../inputs";
import {ResourceType} from "../../utils/constants";
import {Component} from "./component";
import {FileUploadModel} from "../../directives/file-upload/file-upload";
import {IResourceService} from "../../services/components/resource-service";
import {ComponentMetadata} from "../component-metadata";

export class Resource extends Component {

    public interfaces:any;
    public derivedFrom:Array<string>;
    public componentService:IResourceService;
    public resourceType:string;
    public payloadData:string;
    public payloadName:string;
    public importedFile:FileUploadModel;

    // Onboarding parameters
    public csarUUID:string;
    public csarVersion:string;
    public csarPackageType:string;
    public packageId:string;

    constructor(componentService:IResourceService, $q:ng.IQService, component?:Resource) {
        super(componentService, $q, component);
        if (component) {

            this.interfaces = component.interfaces;
            this.derivedFrom = component.derivedFrom;
            this.payloadData = component.payloadData ? component.payloadData : undefined;
            this.payloadName = component.payloadName ? component.payloadName : undefined;
            this.resourceType = component.resourceType;
            this.csarUUID = component.csarUUID;
            this.csarVersion = component.csarVersion;
            this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version + ' ' + this.resourceType;
            if (component.categories && component.categories[0] && component.categories[0].subcategories && component.categories[0].subcategories[0]) {
                component.mainCategory = component.categories[0].name;
                component.subCategory = component.categories[0].subcategories[0].name;
                this.selectedCategory = component.mainCategory + "_#_" + component.subCategory;
                this.importedFile = component.importedFile;
            }
        } else {
            this.resourceType = ResourceType.VF;
        }

        this.componentService = componentService;
        this.iconSprite = "sprite-resource-icons";
    }

    public setComponentMetadata(componentMetadata: ComponentMetadata) {
        super.setComponentMetadata(componentMetadata);
        this.resourceType = componentMetadata.resourceType;
        this.csarUUID = componentMetadata.csarUUID;
        this.csarVersion = componentMetadata.csarVersion;
        this.derivedFrom = componentMetadata.derivedFrom;
        this.setComponentDisplayData();
    };

    public getComponentSubType = ():string => {
        return this.resourceType;
    };

    public isComplex = ():boolean => {
        return this.resourceType === ResourceType.VF;
    };

    public isVl = ():boolean => {
        return ResourceType.VL == this.resourceType;
    };

    public isCsarComponent = ():boolean => {
        return !!this.csarUUID;
    };

    public createComponentOnServer = ():ng.IPromise<Component> => {
        let deferred = this.$q.defer();
        let onSuccess = (component:Resource):void => {
            this.payloadData = undefined;
            this.payloadName = undefined;
            deferred.resolve(component);
        };
        let onError = (error:any):void => {
            deferred.reject(error);
        };

        this.handleTags();
        if (this.importedFile) {
            this.payloadData = this.importedFile.base64;
            this.payloadName = this.importedFile.filename;
        }
        this.componentService.createComponent(this).then(onSuccess, onError);
        return deferred.promise;
    };


    public updateResourceGroupProperties = (module:DisplayModule, properties:Array<PropertyModel>):ng.IPromise<Array<PropertyModel>> => {
        let deferred = this.$q.defer();
        let onSuccess = (updatedProperties:Array<PropertyModel>):void => {
            _.forEach(updatedProperties, (property:PropertyModel) => { // Replace all updated properties on the module we needed to update
                _.extend(_.find(module.properties, {uniqueId: property.uniqueId}), property);

            });
            //_.extend(_.findWhere(this.groups, {uniqueId: module.uniqueId }), module); // replace the module on the component so all data will be updates if the module sent to the function is a copy
            deferred.resolve(updatedProperties);
        };
        let onError = (error:any):void => {
            deferred.reject(error);
        };

        this.componentService.updateResourceGroupProperties(this.uniqueId, module.uniqueId, properties).then(onSuccess, onError);
        return deferred.promise;
    };

    // For now we only implement the logic in service level
    public createInputsFormInstances = (instanceInputsPropertiesMap:InstancesInputsOrPropertiesMapData):ng.IPromise<Array<InputModel>> => {
        let deferred = this.$q.defer();
        return deferred.promise;
    };

    getTypeUrl():string {
        return 'resources/';
    }


    setComponentDisplayData():void {
        this.filterTerm = this.name + ' ' + this.description + ' ' + (this.tags ? this.tags.toString() : '') + ' ' + this.version + ' ' + this.resourceType;
        if (this.categories && this.categories[0] && this.categories[0].subcategories && this.categories[0].subcategories[0]) {
            this.mainCategory = this.categories[0].name;
            this.subCategory = this.categories[0].subcategories[0].name;
            this.selectedCategory = this.mainCategory + "_#_" + this.subCategory;
            this.iconSprite = "sprite-resource-icons";
        }
    };

    public toJSON = ():any => {
        this.componentService = undefined;
        this.filterTerm = undefined;
        this.iconSprite = undefined;
        this.mainCategory = undefined;
        this.subCategory = undefined;
        this.selectedInstance = undefined;
        this.showMenu = undefined;
        this.$q = undefined;
        this.selectedCategory = undefined;
        this.importedFile = undefined;
        return this;
    };
}