Add winery source code
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / java / org / eclipse / winery / repository / resources / entitytypes / policytypes / PolicyTypeResource.java
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.policytypes;
13
14 import java.util.SortedSet;
15
16 import javax.ws.rs.Path;
17
18 import org.eclipse.winery.common.ids.definitions.PolicyTemplateId;
19 import org.eclipse.winery.common.ids.definitions.PolicyTypeId;
20 import org.eclipse.winery.model.tosca.TExtensibleElements;
21 import org.eclipse.winery.model.tosca.TPolicyType;
22 import org.eclipse.winery.repository.datatypes.select2.Select2OptGroup;
23 import org.eclipse.winery.repository.resources.EntityTypeResource;
24 import org.slf4j.Logger;
25 import org.slf4j.LoggerFactory;
26
27 public final class PolicyTypeResource extends EntityTypeResource {
28         
29         private static final Logger logger = LoggerFactory.getLogger(PolicyTypeResource.class);
30         
31         
32         /**
33          * Constructor has to be public because of test cases
34          */
35         public PolicyTypeResource(PolicyTypeId id) {
36                 super(id);
37         }
38         
39         /**
40          * Convenience method to avoid casting at the caller's side.
41          */
42         public TPolicyType getPolicyType() {
43                 return (TPolicyType) this.getElement();
44         }
45         
46         @Override
47         protected TExtensibleElements createNewElement() {
48                 return new TPolicyType();
49         }
50         
51         @Path("appliesto/")
52         public AppliesToResource getAppliesTo() {
53                 return new AppliesToResource(this);
54         }
55         
56         @Path("language/")
57         public LanguageResource getLanguage() {
58                 return new LanguageResource(this);
59         }
60         
61         @Override
62         public SortedSet<Select2OptGroup> getListOfAllInstances() {
63                 return this.getListOfAllInstances(PolicyTemplateId.class);
64         }
65         
66 }