5cfe754b72068eb29c8ea2e9762ddc186ba4bc76
[vfc/nfvo/wfengine.git] /
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
8  *
9  * Contributors:
10  *     Oliver Kopp - initial API and implementation
11  *******************************************************************************/
12 package org.eclipse.winery.common.interfaces;
13
14 import java.util.Collection;
15 import java.util.List;
16 import java.util.SortedSet;
17
18 import javax.xml.namespace.QName;
19
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;
25
26 /**
27  * This interface is used by the repository client to get access to the
28  * repository.
29  * 
30  * This interface should be removed and the client should be able to use
31  * "IWineryRepositoryCommon" only.
32  */
33 public interface IWineryRepository extends IWineryRepositoryCommon {
34         
35         /**
36          * Returns all namespaces used by all known TOSCA components and namespaces
37          * where a prefix is defined for
38          * 
39          * String is used as return type as Java's QName also uses String as
40          * parameter to denote a namespace
41          */
42         public SortedSet<String> getNamespaces();
43         
44         /**
45          * Returns a list of the QNames of all available types. Types can be node
46          * types, service templates, artifact types, artifact templates.
47          * 
48          * This method obsoletes methods like "getQNameListOfAllArtifactTypes": One
49          * just has to call getQNameListOfAllTypes(TArtifactType.class)
50          * 
51          * @return List of QNames of all types
52          */
53         <T extends TEntityType> List<QName> getQNameListOfAllTypes(Class<T> type);
54         
55         /**
56          * Get the TEntityType belonging to the given QName
57          * 
58          * @return null if there is no data on the server
59          */
60         <T extends TEntityType> T getType(QName qname, Class<T> type);
61         
62         /**
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
65          * carry a name.
66          * 
67          * If the component instance does not carry an explicit name, the localName
68          * of the QName is used as name.
69          * 
70          * @param type the type to get all instances of
71          * @return a collection of QName/name pairs
72          */
73         Collection<QNameWithName> getListOfAllInstances(Class<? extends TOSCAComponentId> type);
74         
75         /**
76          * Returns the associated name for the given id.
77          * 
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,
80          * null is returned.
81          * 
82          * @param id references the entity to query for a name
83          * @return the name or null if no name is available
84          */
85         String getName(GenericId id);
86         
87         /**
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.
91          * 
92          * This method obsoletes methods like "getAllArtifactTypes": One just has to
93          * call getallTypes(TArtifactType.class)
94          * 
95          * @return List of all types
96          */
97         <T extends TEntityType> Collection<T> getAllTypes(Class<T> type);
98         
99         /**
100          * @return List of all types with associated elements (such as deployment
101          *         artifacts). Each type is nested in a separate Definitions Element
102          */
103         <T extends TEntityType> Collection<TDefinitions> getAllTypesWithAssociatedElements(Class<T> type);
104         
105         /**
106          * Returns the topology template associated to the given service template
107          * 
108          * @param serviceTemplate a QName of the sericeTemplate with full namespace
109          * @return null if nothing is found
110          */
111         TTopologyTemplate getTopologyTemplate(QName serviceTemplate);
112         
113         /**
114          * Replaces (or creates) the provided topology template
115          * 
116          * @param serviceTemplate the service template the given topolgoy template
117          *            belongs to
118          * @param topologyTemplate the topology template to use
119          */
120         void setTopologyTemplate(QName serviceTemplate, TTopologyTemplate topologyTemplate) throws Exception;
121         
122         /**
123          * Returns a reference to the artifact type registered for the given file
124          * extensions. Returns null if no such artifact type exists.
125          * 
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.
129          */
130         QName getArtifactTypeQNameForExtension(String extension);
131         
132         /**
133          * Creates a component of the type idClass.
134          * 
135          * @param qname
136          * @param type
137          * @throws QNameAlreadyExistsException
138          */
139         void createComponent(QName qname, Class<? extends TOSCAComponentId> idClass) throws QNameAlreadyExistsException;
140         
141         /**
142          * Creates the specified artifact template
143          * 
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
147          */
148         void createArtifactTemplate(QName qname, QName artifactType) throws QNameAlreadyExistsException;
149 }