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;
14 import java.util.SortedSet;
15 import java.util.TreeSet;
17 import javax.ws.rs.GET;
18 import javax.ws.rs.Produces;
19 import javax.ws.rs.core.MediaType;
21 import org.eclipse.winery.common.ids.definitions.TOSCAComponentId;
22 import org.eclipse.winery.repository.backend.Repository;
24 import com.sun.jersey.api.view.Viewable;
27 * Class for managing inheritance properties: abstract, final, derivedFromn
29 * The linking in the resources tree is different than the others. Here, there
30 * is no additional Id generated.
32 * We separated the code here to have the collection of valid super types in a
33 * separate class. We think, this is less confusing than including this
35 * AbstractComponentInstanceResourceWithNameDerivedFromAbstractFinalDefinitionsBacked
37 public class InheritanceResource {
39 private AbstractComponentInstanceResourceWithNameDerivedFromAbstractFinal managedResource;
42 public InheritanceResource(AbstractComponentInstanceResourceWithNameDerivedFromAbstractFinal res) {
43 this.managedResource = res;
47 @Produces(MediaType.TEXT_HTML)
48 public Viewable getHTML() {
49 return new Viewable("/jsp/inheritance.jsp", this);
52 public String getIsAbstract() {
53 return this.managedResource.getIsAbstract();
56 public String getIsFinal() {
57 return this.managedResource.getIsAbstract();
60 public String getDerivedFrom() {
61 return this.managedResource.getDerivedFrom();
66 public SortedSet<? extends TOSCAComponentId> getPossibleSuperTypes() {
67 // sorted by Name, not by namespace
68 SortedSet<? extends TOSCAComponentId> allTOSCAcomponentIds = Repository.INSTANCE.getAllTOSCAComponentIds(this.managedResource.getId().getClass());
69 SortedSet<? extends TOSCAComponentId> res = new TreeSet<>(allTOSCAcomponentIds);
70 res.remove(this.managedResource.getId());
71 // FEATURE: Possibly exclude all subtypes to avoid circles. However, this could be disappointing for users who know what they are doing