46662fd7ca0024cd3cdaec785eba1a9386fd1666
[vfc/nfvo/wfengine.git] /
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
8  *
9  * Contributors:
10  *     Oliver Kopp - initial API and implementation
11  *******************************************************************************/
12 package org.eclipse.winery.repository.resources.interfaces;
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.model.tosca.TBoolean;
23 import org.eclipse.winery.model.tosca.TParameter;
24 import org.eclipse.winery.repository.backend.BackendUtils;
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
29 public class ParameterResource extends EntityWithIdResource<TParameter> {
30         
31         public ParameterResource(IIdDetermination<TParameter> idDetermination, TParameter o, int idx, List<TParameter> list, IPersistable res) {
32                 super(idDetermination, o, idx, list, res);
33         }
34         
35         @GET
36         @Path("type")
37         public String getType() {
38                 return this.o.getType();
39         }
40         
41         @PUT
42         @Path("type")
43         public Response putType(@FormParam(value = "type") String type) {
44                 this.o.setType(type);
45                 return BackendUtils.persist(this.res);
46         }
47         
48         @GET
49         @Path("required")
50         public String getRequired() {
51                 return this.o.getRequired().toString();
52         }
53         
54         @PUT
55         @Path("required")
56         public Response putRequired(@FormParam(value = "required") String required) {
57                 TBoolean tb = TBoolean.valueOf(required);
58                 this.o.setRequired(tb);
59                 return BackendUtils.persist(this.res);
60         }
61         
62 }