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
10 * Oliver Kopp - initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.winery.repository.resources.interfaces;
14 import java.util.List;
16 import javax.ws.rs.Path;
18 import org.eclipse.winery.model.tosca.TInterface;
19 import org.eclipse.winery.model.tosca.TOperation;
20 import org.eclipse.winery.model.tosca.TOperation.InputParameters;
21 import org.eclipse.winery.model.tosca.TOperation.OutputParameters;
22 import org.eclipse.winery.repository.resources._support.IPersistable;
23 import org.eclipse.winery.repository.resources._support.collections.IIdDetermination;
24 import org.eclipse.winery.repository.resources._support.collections.withid.EntityWithIdResource;
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
28 public class OperationResource extends EntityWithIdResource<TOperation> {
30 private static final Logger logger = LoggerFactory.getLogger(OperationResource.class);
33 public OperationResource(IIdDetermination<TOperation> idDetermination, TOperation o, int idx, List<TOperation> list, IPersistable res) {
34 super(idDetermination, o, idx, list, res);
38 * @return TOperation object for the corresponding object of operationName
39 * in the operation list contained in the given interface. null if
40 * interface could not be found in list
42 public static TOperation getTOperation(String operationName, TInterface iface) {
43 List<TOperation> operationList = iface.getOperation();
44 for (TOperation op : operationList) {
45 if (op.getName().equals(operationName)) {
52 @Path("inputparameters/")
53 public ParametersResource getInputparameters() {
54 InputParameters inputParameters = this.o.getInputParameters();
55 if (inputParameters == null) {
56 inputParameters = new InputParameters();
57 this.o.setInputParameters(inputParameters);
59 return new ParametersResource(inputParameters.getInputParameter(), this.res);
62 @Path("outputparameters/")
63 public ParametersResource getOutputparameters() {
64 OutputParameters outputParameters = this.o.getOutputParameters();
65 if (outputParameters == null) {
66 outputParameters = new OutputParameters();
67 this.o.setOutputParameters(outputParameters);
69 return new ParametersResource(outputParameters.getOutputParameter(), this.res);