1 /*******************************************************************************
2 * Copyright (c) 2012-2013,2015 University of Stuttgart.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * Oliver Kopp - initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.winery.repository.resources.artifacts;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.List;
18 import org.eclipse.winery.model.tosca.TDeploymentArtifact;
19 import org.eclipse.winery.model.tosca.TDeploymentArtifacts;
20 import org.eclipse.winery.model.tosca.TNodeTemplate;
21 import org.eclipse.winery.repository.resources.INodeTemplateResourceOrNodeTypeImplementationResource;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 public class DeploymentArtifactsResource extends GenericArtifactsResource<DeploymentArtifactResource, TDeploymentArtifact> {
27 private static final Logger logger = LoggerFactory.getLogger(DeploymentArtifactsResource.class);
29 private List<TDeploymentArtifact> deploymentArtifacts;
32 public DeploymentArtifactsResource(List<TDeploymentArtifact> deploymentArtifact, INodeTemplateResourceOrNodeTypeImplementationResource res) {
33 super(DeploymentArtifactResource.class, TDeploymentArtifact.class, deploymentArtifact, res);
34 this.deploymentArtifacts = deploymentArtifact;
38 * Determines the list of DAs belonging to the given node template.
40 * If no DAs are existing, an empty list is created in the model for the
43 private static List<TDeploymentArtifact> getDeploymentArtifacts(TNodeTemplate nodeTemplate) {
44 TDeploymentArtifacts deploymentArtifacts = nodeTemplate.getDeploymentArtifacts();
45 final List<TDeploymentArtifact> res;
46 if (deploymentArtifacts == null) {
47 deploymentArtifacts = new TDeploymentArtifacts();
48 nodeTemplate.setDeploymentArtifacts(deploymentArtifacts);
50 res = deploymentArtifacts.getDeploymentArtifact();
54 public DeploymentArtifactsResource(TNodeTemplate nodeTemplate, INodeTemplateResourceOrNodeTypeImplementationResource res) {
55 this(DeploymentArtifactsResource.getDeploymentArtifacts(nodeTemplate), res);
59 public Collection<DeploymentArtifactResource> getAllArtifactResources() {
60 Collection<DeploymentArtifactResource> res = new ArrayList<DeploymentArtifactResource>(this.deploymentArtifacts.size());
61 for (TDeploymentArtifact da : this.deploymentArtifacts) {
62 DeploymentArtifactResource r = new DeploymentArtifactResource(da, this.deploymentArtifacts, this.res);
69 public String getId(TDeploymentArtifact entity) {
70 return entity.getName();