00a8d24491da08c2ef7c4979536ff2e25756d885
[vfc/nfvo/wfengine.git] /
1 /*******************************************************************************
2  * Copyright (c) 2012-2013 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
8  *
9  * Contributors:
10  *     Oliver Kopp - initial API and implementation
11  *******************************************************************************/
12 package org.eclipse.winery.repository.resources.entitytypes.properties.winery;
13
14 import java.util.List;
15
16 import javax.ws.rs.FormParam;
17 import javax.ws.rs.GET;
18 import javax.ws.rs.PUT;
19 import javax.ws.rs.Path;
20 import javax.ws.rs.core.Response;
21
22 import org.eclipse.winery.common.propertydefinitionkv.PropertyDefinitionKV;
23 import org.eclipse.winery.repository.backend.BackendUtils;
24 import org.eclipse.winery.repository.resources.AbstractComponentInstanceResource;
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;
28 import org.restdoc.annotations.RestDoc;
29
30 /**
31  * Models a definition of one property
32  * 
33  * This is NOT in line with CSPRD01, which forces one element of one type
34  */
35 public class PropertyDefinitionKVResource extends EntityWithIdResource<PropertyDefinitionKV> {
36         
37         public PropertyDefinitionKVResource(IIdDetermination<PropertyDefinitionKV> idDetermination, PropertyDefinitionKV o, int idx, List<PropertyDefinitionKV> list, AbstractComponentInstanceResource res) {
38                 super(idDetermination, o, idx, list, res);
39         }
40         
41         public PropertyDefinitionKVResource(IIdDetermination<PropertyDefinitionKV> idDetermination, PropertyDefinitionKV o, int idx, List<PropertyDefinitionKV> list, IPersistable res) {
42                 super(idDetermination, o, idx, list, res);
43         }
44         
45         @GET
46         @RestDoc(methodDescription = "@return type is the 'id' of the type ('shortType'), not the full type name")
47         @Path("type")
48         public String getType() {
49                 return this.o.getType();
50         }
51         
52         @PUT
53         @RestDoc(methodDescription = "@return type is the 'id' of the type ('shortType'), not the full type name")
54         @Path("type")
55         public Response setType(@FormParam("type") String type) {
56                 this.o.setType(type);
57                 return BackendUtils.persist(this.res);
58         }
59 }