aboutsummaryrefslogtreecommitdiffstats
path: root/winery/org.eclipse.winery.repository/src/main/java/org/eclipse/winery/repository/resources/interfaces/ParameterResource.java
blob: 46662fd7ca0024cd3cdaec785eba1a9386fd1666 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*******************************************************************************
 * Copyright (c) 2012-2013,2015 University of Stuttgart.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * and the Apache License 2.0 which both accompany this distribution,
 * and are available at http://www.eclipse.org/legal/epl-v10.html
 * and http://www.apache.org/licenses/LICENSE-2.0
 *
 * Contributors:
 *     Oliver Kopp - initial API and implementation
 *******************************************************************************/
package org.eclipse.winery.repository.resources.interfaces;

import java.util.List;

import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

import org.eclipse.winery.model.tosca.TBoolean;
import org.eclipse.winery.model.tosca.TParameter;
import org.eclipse.winery.repository.backend.BackendUtils;
import org.eclipse.winery.repository.resources._support.IPersistable;
import org.eclipse.winery.repository.resources._support.collections.IIdDetermination;
import org.eclipse.winery.repository.resources._support.collections.withid.EntityWithIdResource;

public class ParameterResource extends EntityWithIdResource<TParameter> {
	
	public ParameterResource(IIdDetermination<TParameter> idDetermination, TParameter o, int idx, List<TParameter> list, IPersistable res) {
		super(idDetermination, o, idx, list, res);
	}
	
	@GET
	@Path("type")
	public String getType() {
		return this.o.getType();
	}
	
	@PUT
	@Path("type")
	public Response putType(@FormParam(value = "type") String type) {
		this.o.setType(type);
		return BackendUtils.persist(this.res);
	}
	
	@GET
	@Path("required")
	public String getRequired() {
		return this.o.getRequired().toString();
	}
	
	@PUT
	@Path("required")
	public Response putRequired(@FormParam(value = "required") String required) {
		TBoolean tb = TBoolean.valueOf(required);
		this.o.setRequired(tb);
		return BackendUtils.persist(this.res);
	}
	
}