summaryrefslogtreecommitdiffstats
path: root/releases/1.4.0.yaml
blob: 45dc673add1833beaf3bf3a21d278a4c91a77124 (plain)
1
2
3
4
5
---
distribution_type: 'maven'
version: '1.4.0'
project: 'ccsdk-parent'
log_dir: 'ccsdk-parent-maven-stage-master/177/'
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 */ }
import {Injectable} from '@angular/core';
import {CacheService} from './cache.service';
import {ArtifactType} from "../../utils/constants";

@Injectable()
export class ArtifactConfigService {

  artifactConfigList:Array<object>;

  constructor(private cacheService: CacheService) {
    const uiConfiguration = cacheService.get('UIConfiguration');
    this.artifactConfigList = uiConfiguration.artifact;
  }

  public getConfig() {
    return this.artifactConfigList;
  }

  public findAllBy(artifactType?:ArtifactType, componentType?:string, resourceType?:string):Array<object> {
    return this.artifactConfigList.filter((artifactConfig:any) => {
      let hasCategory = true;
      if (artifactType) {
        hasCategory = artifactConfig.categories && artifactConfig.categories.some(value => value == artifactType);
      }
      let hasComponentType = true;
      if (componentType) {
        hasComponentType = artifactConfig.componentTypes && artifactConfig.componentTypes.some(value => value == componentType);
      }
      let hasResourceType = true;
      //resourceTypes are not restrictive, if it was not configured all resources are accepted.
      if (resourceType && artifactConfig.resourceTypes) {
        hasResourceType = artifactConfig.resourceTypes.some(value => value == resourceType);
      }
      return hasCategory && hasComponentType && hasResourceType;
    });
  }


  public findAllTypeBy(artifactType?:ArtifactType, componentType?:string, resourceType?:string):Array<string> {
    const artifactConfigList = this.findAllBy(artifactType, componentType, resourceType);
    if (artifactConfigList) {
      return artifactConfigList.map((element: any) => {
        return element.type;
      });
    }

    return [];
  }

}