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.List;
16 import org.eclipse.winery.common.ids.definitions.ArtifactTemplateId;
17 import org.eclipse.winery.common.ids.definitions.ArtifactTypeId;
18 import org.eclipse.winery.model.tosca.TDeploymentArtifact;
19 import org.eclipse.winery.repository.backend.BackendUtils;
20 import org.eclipse.winery.repository.resources._support.IPersistable;
21 import org.eclipse.winery.repository.resources._support.collections.IIdDetermination;
23 public class DeploymentArtifactResource extends GenericArtifactResource<TDeploymentArtifact> {
25 private final TDeploymentArtifact a;
29 * Converts the given artifactId to an DeploymentArtifact.
31 * <em>SIDE EFFECT</em> Adds it to the DeploymentArtifacts list if it does
34 private static TDeploymentArtifact getDeploymentArtifact(String artifactId, List<TDeploymentArtifact> deploymentArtifacts) {
35 for (TDeploymentArtifact ia : deploymentArtifacts) {
36 if (ia.getName().equals(artifactId)) {
40 // DA does not exist in list
41 TDeploymentArtifact ia = new TDeploymentArtifact();
42 ia.setName(artifactId);
43 deploymentArtifacts.add(ia);
47 public DeploymentArtifactResource(String artifactId, List<TDeploymentArtifact> deploymentArtifacts, IPersistable res) {
48 this(DeploymentArtifactResource.getDeploymentArtifact(artifactId, deploymentArtifacts), deploymentArtifacts, res);
51 public DeploymentArtifactResource(IIdDetermination<TDeploymentArtifact> idDetermination, TDeploymentArtifact o, int idx, List<TDeploymentArtifact> list, IPersistable res) {
52 super(idDetermination, o, idx, list, res);
56 public DeploymentArtifactResource(TDeploymentArtifact deploymentArtifact, List<TDeploymentArtifact> deploymentArtifacts, IPersistable res) {
57 this(new IIdDetermination<TDeploymentArtifact>() {
60 public String getId(TDeploymentArtifact e) {
63 }, deploymentArtifact, deploymentArtifacts.indexOf(deploymentArtifact), deploymentArtifacts, res);
66 public TDeploymentArtifact getDeploymentArtifact() {
71 public void setArtifactType(ArtifactTypeId artifactTypeId) {
72 this.getDeploymentArtifact().setArtifactType(artifactTypeId.getQName());
73 BackendUtils.persist(this.res);
77 public void setArtifactTemplate(ArtifactTemplateId artifactTemplateId) {
78 this.getDeploymentArtifact().setArtifactRef(artifactTemplateId.getQName());
79 BackendUtils.persist(this.res);
83 public TDeploymentArtifact getA() {