4.0.0 catalog-be war org.openecomp.sdc sdc-main 1.1.0-SNAPSHOT 2.1.0-M2 com.fasterxml.jackson.dataformat jackson-dataformat-yaml ${jackson.yaml.version} compile com.fasterxml.jackson.core jackson-databind ${jackson.version} compile com.fasterxml.jackson.core jackson-core ${jackson.version} compile com.fasterxml.jackson.core jackson-annotations ${jackson.annotations.version} compile org.glassfish.jersey.media jersey-media-multipart ${jersey-bom.version} compile org.openecomp.sdc security-utils ${project.version} compile com.tinkerpop.blueprints blueprints-sail-graph 2.5.0 true org.slf4j slf4j-log4j12 com.tinkerpop.blueprints blueprints-graph-sail 2.5.0 true io.swagger swagger-jersey2-jaxrs compile 1.5.15 org.openecomp.sdc common-app-api ${project.version} compile org.openecomp.sdc.be common-be ${project.version} compile org.openecomp.sdc.be catalog-dao ${project.version} compile org.openecomp.sdc.be catalog-model ${project.version} compile org.slf4j slf4j-api ${slf4j-api.version} compile ch.qos.logback logback-classic ${logback.version} compile ch.qos.logback logback-core ${logback.version} compile org.yaml snakeyaml ${snakeyaml.version} compile org.apache.commons commons-jci-core ${commons-jci-core.version} compile com.google.code.gson gson ${gson.version} compile org.glassfish.jersey.media jersey-media-json-jackson ${jersey-bom.version} compile org.glassfish.jersey.containers jersey-container-servlet-core ${jersey-bom.version} compile org.apache.httpcomponents httpclient ${httpclient.version} compile org.apache.httpcomponents httpcore ${httpcore.version} compile commons-logging commons-logging ${commons-logging} compile commons-codec commons-codec ${commons-codec} compile javax.servlet servlet-api ${servlet-api.version} provided org.eclipse.jgit org.eclipse.jgit 3.4.1.201406201815-r org.springframework spring-core ${spring.version} compile org.springframework spring-context ${spring.version} compile org.springframework spring-web ${spring.version} compile org.springframework spring-webmvc ${spring.version} compile org.springframework sp
/*-
 * ============LICENSE_START=======================================================
 * SDC
 * ================================================================================
 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
 * ================================================================================
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ============LICENSE_END=========================================================
 */
/**
 * Created by obarda on 3/7/2016.
 */
'use strict';
import {ComponentInstance, ServiceInstance, ResourceInstance, Component} from "../models";
import {LeftPaletteComponent} from "../models/components/displayComponent";

export class ComponentInstanceFactory {

    static createComponentInstance(componentInstance:ComponentInstance):ComponentInstance {
        let newComponentInstance:ComponentInstance;
        switch (componentInstance.originType) {
            case 'SERVICE':
                newComponentInstance = new ServiceInstance(componentInstance);
                break;

            default :
                newComponentInstance = new ResourceInstance(componentInstance);
                break;
        }
        return newComponentInstance;
    };

    public createEmptyComponentInstance = (componentInstanceType?:string):ComponentInstance => {
        let newComponentInstance:ComponentInstance;
        switch (componentInstanceType) {
            case 'SERVICE':
                newComponentInstance = new ServiceInstance();
                break;

            default :
                newComponentInstance = new ResourceInstance();
                break;
        }
        return newComponentInstance;
    };

    public createComponentInstanceFromComponent = (component:LeftPaletteComponent):ComponentInstance => {
        let newComponentInstance:ComponentInstance = this.createEmptyComponentInstance(component.componentType);
        newComponentInstance.uniqueId = component.uniqueId + (new Date()).getTime();
        newComponentInstance.posX = 0;
        newComponentInstance.posY = 0;
        newComponentInstance.name = component.name;
        newComponentInstance.componentVersion = component.version;