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.entitytypes.properties;
14 import java.util.List;
16 import org.eclipse.winery.common.propertydefinitionkv.PropertyDefinitionKV;
17 import org.eclipse.winery.common.propertydefinitionkv.WinerysPropertiesDefinition;
18 import org.eclipse.winery.model.tosca.TEntityType;
21 * Collects data used by the JSP
23 public class JSPData {
25 // FIXME: this is a quick hack and provides a fixed list of available
26 // property types only. This list has to be made dynamically updatable (and offer plugins to edit)
27 // currently only http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#built-in-datatypes are supported
28 private static final String[] availablePropertyTypes = {"xsd:string", "xsd:boolean", "xsd:decimal", "xsd:float", "xsd:anyURI", "xsd:QName"};
30 private final PropertiesDefinitionResource propertiesDefinitionResource;
31 private final WinerysPropertiesDefinition wpd;
34 public JSPData(PropertiesDefinitionResource propertiesDefinitionResource, WinerysPropertiesDefinition wpd) {
35 this.propertiesDefinitionResource = propertiesDefinitionResource;
39 public List<PropertyDefinitionKV> getPropertyDefinitionKVList() {
40 // as this method is used by the JSP, we have to initialize the list and not provide a fake list
41 // in other words: we are in the mode, where the user has chosen the winery property handling
42 assert (this.getIsWineryKeyValueProperties());
43 if (this.wpd.getPropertyDefinitionKVList() == null) {
44 return java.util.Collections.emptyList();
46 return this.wpd.getPropertyDefinitionKVList();
50 public Boolean getIsWineryKeyValueProperties() {
51 return (this.wpd != null);
52 // the jsp renders list data only if the list is existing
53 // we could (somehow) also always keep the old list, but we opted for keeping the choice between the four options also in the XML (and not storing stale data)
54 // in the case, the WPD is derived from XSD, the list is rendered nevertheless
57 public boolean getIsWineryKeyValuePropertiesDerivedFromXSD() {
58 return ((this.wpd != null) && (this.wpd.getIsDerivedFromXSD() != null));
61 public String[] getAvailablePropertyTypes() {
62 return JSPData.availablePropertyTypes;
65 public TEntityType getEntityType() {
66 return this.propertiesDefinitionResource.getEntityType();
69 public String getElementName() {
70 if (this.wpd == null) {
73 return this.wpd.getElementName();
77 public String getNamespace() {
78 if (this.wpd == null) {
81 return this.wpd.getNamespace();