1 /*******************************************************************************
2 * Copyright (c) 2012-2014 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.entitytemplates;
14 import java.util.List;
16 import javax.ws.rs.GET;
17 import javax.ws.rs.Path;
18 import javax.ws.rs.core.Response;
19 import javax.xml.namespace.QName;
21 import org.eclipse.winery.model.tosca.TEntityTemplate;
22 import org.eclipse.winery.repository.backend.BackendUtils;
23 import org.eclipse.winery.repository.resources.AbstractComponentInstanceResource;
24 import org.eclipse.winery.repository.resources.IHasTypeReference;
25 import org.eclipse.winery.repository.resources._support.IPersistable;
26 import org.eclipse.winery.repository.resources._support.collections.IIdDetermination;
27 import org.eclipse.winery.repository.resources._support.collections.withid.EntityWithIdResource;
29 public class TEntityTemplateResource<E extends TEntityTemplate> extends EntityWithIdResource<E> implements IEntityTemplateResource<E>, IHasTypeReference {
32 * This constructor is used for both entity templates nested in an component
33 * instance as well as for entity templates being component instances
36 * As Java does not support multi-inheritance, we implemented a quick hack
37 * to re-use this class as inner implementation at templates extending
38 * AbstractComponentInstanceResourceDefinitionsBacked
40 public TEntityTemplateResource(IIdDetermination<E> idDetermination, E o, int idx, List<E> list, IPersistable res) {
41 super(idDetermination, o, idx, list, res);
44 // public String getId() {
45 // return this.template.getId();
48 // public void setId(String id) {
49 // // TODO: There is no check for uniqueness of the given id
50 // this.template.setId(id);
57 public QName getType() {
58 return this.o.getType();
63 public String getTypeAsQNameString() {
64 return this.getType().toString();
71 public Response setType(QName type) {
73 return BackendUtils.persist(this.res);
80 public Response setType(String typeStr) {
81 return this.setType(QName.valueOf(typeStr));
88 public PropertiesResource getPropertiesResource() {
89 return new PropertiesResource(this.o, (AbstractComponentInstanceResource) this.res);