1 /*******************************************************************************
2 * Copyright (c) 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.common.interfaces;
14 import java.util.Collection;
15 import java.util.List;
16 import java.util.SortedSet;
18 import javax.xml.namespace.QName;
20 import org.eclipse.winery.common.ids.GenericId;
21 import org.eclipse.winery.common.ids.definitions.TOSCAComponentId;
22 import org.eclipse.winery.model.tosca.TDefinitions;
23 import org.eclipse.winery.model.tosca.TEntityType;
24 import org.eclipse.winery.model.tosca.TTopologyTemplate;
27 * This interface is used by the repository client to get access to the
30 * This interface should be removed and the client should be able to use
31 * "IWineryRepositoryCommon" only.
33 public interface IWineryRepository extends IWineryRepositoryCommon {
36 * Returns all namespaces used by all known TOSCA components and namespaces
37 * where a prefix is defined for
39 * String is used as return type as Java's QName also uses String as
40 * parameter to denote a namespace
42 public SortedSet<String> getNamespaces();
45 * Returns a list of the QNames of all available types. Types can be node
46 * types, service templates, artifact types, artifact templates.
48 * This method obsoletes methods like "getQNameListOfAllArtifactTypes": One
49 * just has to call getQNameListOfAllTypes(TArtifactType.class)
51 * @return List of QNames of all types
53 <T extends TEntityType> List<QName> getQNameListOfAllTypes(Class<T> type);
56 * Get the TEntityType belonging to the given QName
58 * @return null if there is no data on the server
60 <T extends TEntityType> T getType(QName qname, Class<T> type);
63 * Queries the repository for instances of the given type. Returns pairs of
64 * QNames and names. The names are added as some component instances do
67 * If the component instance does not carry an explicit name, the localName
68 * of the QName is used as name.
70 * @param type the type to get all instances of
71 * @return a collection of QName/name pairs
73 Collection<QNameWithName> getListOfAllInstances(Class<? extends TOSCAComponentId> type);
76 * Returns the associated name for the given id.
78 * Since not all TOSCA entities have names, this method may only be used for
79 * entities supporting names. If it is used for entities not having a name,
82 * @param id references the entity to query for a name
83 * @return the name or null if no name is available
85 String getName(GenericId id);
88 * Returns a list of all available types. Types can be node types, service
89 * templates, artifact types. Note that artifact templates are
90 * TEntityTemplates and thus cannot be retrieved by this method.
92 * This method obsoletes methods like "getAllArtifactTypes": One just has to
93 * call getallTypes(TArtifactType.class)
95 * @return List of all types
97 <T extends TEntityType> Collection<T> getAllTypes(Class<T> type);
100 * @return List of all types with associated elements (such as deployment
101 * artifacts). Each type is nested in a separate Definitions Element
103 <T extends TEntityType> Collection<TDefinitions> getAllTypesWithAssociatedElements(Class<T> type);
106 * Returns the topology template associated to the given service template
108 * @param serviceTemplate a QName of the sericeTemplate with full namespace
109 * @return null if nothing is found
111 TTopologyTemplate getTopologyTemplate(QName serviceTemplate);
114 * Replaces (or creates) the provided topology template
116 * @param serviceTemplate the service template the given topolgoy template
118 * @param topologyTemplate the topology template to use
120 void setTopologyTemplate(QName serviceTemplate, TTopologyTemplate topologyTemplate) throws Exception;
123 * Returns a reference to the artifact type registered for the given file
124 * extensions. Returns null if no such artifact type exists.
126 * @param extension the file extension to look up.
127 * @return Reference in the form of a QName to the artifact type matching
128 * the given file extension.
130 QName getArtifactTypeQNameForExtension(String extension);
133 * Creates a component of the type idClass.
137 * @throws QNameAlreadyExistsException
139 void createComponent(QName qname, Class<? extends TOSCAComponentId> idClass) throws QNameAlreadyExistsException;
142 * Creates the specified artifact template
144 * @param qname the namespace and name of the artifact template
145 * @param artifactType the artifact type of the artifact template
146 * @throws QNameAlreadyExistsException if the given QName already exists
148 void createArtifactTemplate(QName qname, QName artifactType) throws QNameAlreadyExistsException;