org.objectweb.dsrg.sofa.repository
Class RepositoryUtil

java.lang.Object
  extended by org.objectweb.dsrg.sofa.repository.RepositoryUtil

public class RepositoryUtil
extends java.lang.Object

Contains convenient static methods for working with the repository.


Nested Class Summary
static class RepositoryUtil.ConnectionKind
          Constants for connection pseudo-kinds.
 
Field Summary
static char VERSIONDELIMITER
           
 
Constructor Summary
RepositoryUtil()
           
 
Method Summary
static boolean containsName(java.util.List<? extends NamedEntity> list, java.lang.String name)
          Tests if the given list contains an entity with the given name
static boolean containsNamedEntity(java.lang.String name, org.eclipse.emf.common.util.EList<NamedEntity> listOfEntities)
          Returns true if the given list contains object with the given name.
static java.util.List<Interface> getAllInterfaces(Architecture arch)
          Returns a list with all interfaces of all frames of the given architecture.
static java.util.List<Interface> getAllProvidedInterfaces(Architecture arch)
          Returns a list with all provided interfaces of all frames of the given architecture.
static java.util.List<Interface> getAllRequiredInterfaces(Architecture arch)
          Returns a list with all required interfaces of all frames of the given architecture.
static RepositoryUtil.ConnectionKind getConnectionKind(Connection con)
          Returns pseudo-kind of a connection.
static InstanceDeploymentDescription getDeploymentSubcomponentByName(InstanceDeploymentDescription instance, java.lang.String subCompName)
          Returns subcomponent with the given name
static Interface getInterfaceOfArchitecture(java.lang.String name, Architecture arch)
          Returns architecture's interface with the given name
static Interface getInterfaceOfFrame(java.lang.String name, Frame frame)
          Returns frames's interface with the given name
static VersionedEntity getLastHeadVersion(java.lang.String name, RepositoryQuery rq)
          Returns the last head version of the given object or null if object does not exist.
static java.lang.String[] getNameAndVersionParts(java.lang.String name_versionOrTag)
          Splits name and version/tag literal into separate strings.
static NamedEntity getNamedEntityInEList(java.lang.String name, org.eclipse.emf.common.util.EList<NamedEntity> listOfEntities)
          Searches named entity in the given list.
static Interface getProvidedInterfaceByName(java.lang.String name, Frame frame)
          Return provided frame's interface with the given name.
static Interface getRequiredInterfaceByName(java.lang.String name, Frame frame)
          Return required frame's interface with the given name.
static java.util.List<VersionedEntity> lookupEntitiesByUserToken(java.lang.String token, RepositoryQuery rq)
          Looks up entity specified by name,version,tag or wildcard.
static java.util.List<VersionedEntity> lookupEntitiesByUserTokens(java.lang.String[] tokens, RepositoryQuery rq)
          Looks up entities specified by names,versions,tags or wildcards.
static java.util.List<VersionedEntity> lookupEntitiesByUserTokens(java.lang.String tokens, RepositoryQuery rq)
          Looks up entities specified by names,versions,tags or wildcards.
static java.util.List<VersionedEntity> lookupNamedEntityByName(java.lang.String name, RepositoryQuery rq)
          Looks up all entities with the given name.
static VersionedEntity lookupNamedEntityByTag(java.lang.String name, java.lang.String tag, RepositoryQuery rq)
          Looks up entity with given name and version tag.
static VersionedEntity lookupNamedEntityByVersion(java.lang.String name, java.lang.String version, RepositoryQuery rq)
          Looks up entity with given name and version.
static VersionedEntity lookupNamedEntityByVersionOrTag(java.lang.String name, java.lang.String versionOrTag, RepositoryQuery rq)
          Looks up entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSIONDELIMITER

public static final char VERSIONDELIMITER
See Also:
Constant Field Values
Constructor Detail

RepositoryUtil

public RepositoryUtil()
Method Detail

containsNamedEntity

public static boolean containsNamedEntity(java.lang.String name,
                                          org.eclipse.emf.common.util.EList<NamedEntity> listOfEntities)
Returns true if the given list contains object with the given name.

Parameters:
name - name
listOfEntities - list of NamedEntities
Returns:
true if the given list contains oject with the given name

getNamedEntityInEList

public static NamedEntity getNamedEntityInEList(java.lang.String name,
                                                org.eclipse.emf.common.util.EList<NamedEntity> listOfEntities)
Searches named entity in the given list.

Parameters:
name - name of the entity
listOfEntities - list of named entities
Returns:
named entity or null

lookupNamedEntityByName

public static java.util.List<VersionedEntity> lookupNamedEntityByName(java.lang.String name,
                                                                      RepositoryQuery rq)
Looks up all entities with the given name.

Parameters:
name - name of an entity
rq - repository query object
Returns:
list with all entities with the given name or null

lookupNamedEntityByVersion

public static VersionedEntity lookupNamedEntityByVersion(java.lang.String name,
                                                         java.lang.String version,
                                                         RepositoryQuery rq)
Looks up entity with given name and version.

Parameters:
name - name of an entity
version - version
rq - repository query object
Returns:
requested entity or null

lookupNamedEntityByTag

public static VersionedEntity lookupNamedEntityByTag(java.lang.String name,
                                                     java.lang.String tag,
                                                     RepositoryQuery rq)
Looks up entity with given name and version tag.

Parameters:
name - name of an entity
tag - version tag
rq - repository query object
Returns:
requested entity or null

lookupNamedEntityByVersionOrTag

public static VersionedEntity lookupNamedEntityByVersionOrTag(java.lang.String name,
                                                              java.lang.String versionOrTag,
                                                              RepositoryQuery rq)
Looks up entity.

Parameters:
name - name of an entity
versionOrTag - version or version tag identifier of an entity
rq - repository query object
Returns:
entity or null

getLastHeadVersion

public static VersionedEntity getLastHeadVersion(java.lang.String name,
                                                 RepositoryQuery rq)
Returns the last head version of the given object or null if object does not exist.

Parameters:
name - name of the given object
rq - repository query object
Returns:
last head version or null

getAllProvidedInterfaces

public static java.util.List<Interface> getAllProvidedInterfaces(Architecture arch)
Returns a list with all provided interfaces of all frames of the given architecture.

Parameters:
arch - architecture
Returns:
list with all provided interfaces

getAllRequiredInterfaces

public static java.util.List<Interface> getAllRequiredInterfaces(Architecture arch)
Returns a list with all required interfaces of all frames of the given architecture.

Parameters:
arch - architecture
Returns:
list with all required interfaces

getAllInterfaces

public static java.util.List<Interface> getAllInterfaces(Architecture arch)
Returns a list with all interfaces of all frames of the given architecture.

Parameters:
arch - architecture
Returns:
list with all interfaces

getConnectionKind

public static RepositoryUtil.ConnectionKind getConnectionKind(Connection con)
Returns pseudo-kind of a connection.

Parameters:
con - connection
Returns:
pseudo-kind

getInterfaceOfArchitecture

public static Interface getInterfaceOfArchitecture(java.lang.String name,
                                                   Architecture arch)
Returns architecture's interface with the given name

Parameters:
name - interface name
arch - architecture
Returns:
interface or null

getInterfaceOfFrame

public static Interface getInterfaceOfFrame(java.lang.String name,
                                            Frame frame)
Returns frames's interface with the given name

Parameters:
name - interface name
frame - frame
Returns:
interface or null

getProvidedInterfaceByName

public static Interface getProvidedInterfaceByName(java.lang.String name,
                                                   Frame frame)
Return provided frame's interface with the given name.

Parameters:
name - interface name
frame - frame
Returns:
provided interface or null

getRequiredInterfaceByName

public static Interface getRequiredInterfaceByName(java.lang.String name,
                                                   Frame frame)
Return required frame's interface with the given name.

Parameters:
name - interface name
frame - frame
Returns:
required interface or null

containsName

public static boolean containsName(java.util.List<? extends NamedEntity> list,
                                   java.lang.String name)
Tests if the given list contains an entity with the given name

Parameters:
list - list of named entities
name - name
Returns:
true if the given list contains an entity with the given name

getDeploymentSubcomponentByName

public static InstanceDeploymentDescription getDeploymentSubcomponentByName(InstanceDeploymentDescription instance,
                                                                            java.lang.String subCompName)
Returns subcomponent with the given name

Parameters:
instance - instance description
subCompName - subcomponent name
Returns:
subcomponent instance or null

lookupEntitiesByUserTokens

public static java.util.List<VersionedEntity> lookupEntitiesByUserTokens(java.lang.String tokens,
                                                                         RepositoryQuery rq)
                                                                  throws EntityNotFoundException
Looks up entities specified by names,versions,tags or wildcards.

Parameters:
tokens - String in form of "name1:version1;name2:tag1;nameprefix*;..."
rq - repository query object
Returns:
requested entities or empty list
Throws:
EntityNotFoundException

lookupEntitiesByUserTokens

public static java.util.List<VersionedEntity> lookupEntitiesByUserTokens(java.lang.String[] tokens,
                                                                         RepositoryQuery rq)
                                                                  throws EntityNotFoundException
Looks up entities specified by names,versions,tags or wildcards.

Parameters:
tokens - Strings in form of name1:version1, name2:tag1, nameprefix* ...
rq - repository query object
Returns:
requested entities or empty list
Throws:
EntityNotFoundException

lookupEntitiesByUserToken

public static java.util.List<VersionedEntity> lookupEntitiesByUserToken(java.lang.String token,
                                                                        RepositoryQuery rq)
Looks up entity specified by name,version,tag or wildcard.

Parameters:
token - String in form of name1:version1, name2:tag1 or nameprefix*
rq - repository query object
Returns:
requested entities or empty list

getNameAndVersionParts

public static java.lang.String[] getNameAndVersionParts(java.lang.String name_versionOrTag)
Splits name and version/tag literal into separate strings.

Parameters:
name_versionOrTag -
Returns:
[0]-name [1]-version or tag