@OpenApiAll
public class EsiUtils
extends java.lang.Object
EsiUtils.getTeamworkService().login(new ServerLoginInfo("localhost", "user", "password", false), false);
Modifier and Type | Class and Description |
---|---|
static interface |
EsiUtils.ApplyProjectStateResult
A structure that is produced by the
applyProjectState(Project, Project) and
which holds information about the result of the operation |
static interface |
EsiUtils.EsiBranchInfo
Branch information.
|
Constructor and Description |
---|
EsiUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
addCommitTags(java.util.List<java.lang.String> tags,
ProjectDescriptor descriptor,
long version)
Add tags for given version.
|
static IPrimaryProject |
addToESI(Project project,
java.lang.String esiProjectName)
Add project to the ESI server and open it.
|
static IPrimaryProject |
addToESI(Project project,
java.lang.String esiProjectName,
java.lang.String category,
java.lang.String comment,
java.util.List<java.lang.String> tags,
java.util.Collection<ResolveLocalModuleInfo> resolveInfos)
Add project to the ESI server and open it
|
static EsiUtils.ApplyProjectStateResult |
applyDisconnectedProjectState(Project source,
Project target)
Applies the state of the source project (local project) to the target project (TWCloud server project), or in other words, overwrites
the content of the target project with the contents of the source project.
|
static EsiUtils.ApplyProjectStateResult |
applyProjectState(Project source,
Project target)
Applies the state of the source project to the target project, or in other words, overwrites
the content of the target project with the contents of the source project.
|
static void |
assignProjectToCategory(ProjectDescriptor project,
java.lang.String... categories)
Adds or remove project to/from categories.
|
static org.eclipse.emf.common.util.URI |
cloneProject(org.eclipse.emf.common.util.URI sourceURI,
java.lang.String targetName,
java.lang.String targetDescription)
Clones project, new project is created it contains copy of source project with regenerated element ids.
|
static void |
commitProject(Project project,
java.lang.String comment,
java.util.Collection<Element> unlockElements,
java.util.Collection<ModuleUsage> unlockModules,
boolean unlockDecomposition,
java.util.List<java.lang.String> tags)
Commit project.
|
static Project |
convertToLocal(Project project,
java.io.File file)
Convert given project to local, save and reopen it.
|
static void |
createBranch(ProjectDescriptor descriptor,
long version,
java.lang.String branchName,
java.lang.String branchDescription)
Create new branch for given project.
|
static void |
createCategory(java.lang.String name,
java.lang.String description)
Create projects category in the server.
|
static Project |
createProject(java.lang.String name,
java.lang.String category)
Create ESI project.
|
static void |
deleteBranch(ProjectDescriptor descriptor,
java.lang.String branchName)
Delete project branch.
|
static void |
deleteCategory(java.lang.String name)
Delete category with given name.
|
static void |
deleteProject(ProjectDescriptor project)
Delete project from repository.
|
static IAttachedProject |
exportEsiModule(Project project,
java.util.Collection<Package> packages,
java.lang.String description,
java.lang.String moduleName)
Exports module.
|
static java.util.List<com.nomagic.esi.api.info.TagInfo> |
getAllCommitTagsInfo(ProjectDescriptor descriptor)
Get all tags for project.
|
static java.util.Collection<EsiUtils.EsiBranchInfo> |
getBranches(ProjectDescriptor descriptor)
Get all branches for given project.
|
static java.util.UUID |
getBranchID(org.eclipse.emf.common.util.URI locationURI)
Gets project branch ID.
|
static java.util.Set<com.nomagic.teamwork.common.projects.CategoryInfo> |
getCategories() |
static java.util.Map<java.lang.String,java.util.List<ProjectDescriptor>> |
getCategoriesToProjects()
Get categories for projects.
|
static java.lang.String |
getCategoryID(java.lang.String resourceID)
Gets category ID for specified twc project resource ID.
|
static com.nomagic.teamwork.common.projects.CategoryInfo |
getCategoryInfoByResourceID(java.lang.String resourceID)
Get
CategoryInfo for specified twc project resource ID. |
static CommandLinePasswordManager |
getCommandLinePasswordManager(ProjectDescriptor descriptor)
Gets password manager for command line utilities
If session is not present then
null will be returned. |
static java.util.List<java.lang.String> |
getCommitTags(ProjectDescriptor descriptor,
long version)
Get tags names for project version.
|
static java.util.List<com.nomagic.esi.api.info.TagInfo> |
getCommitTagsInfo(ProjectDescriptor descriptor,
long version)
Get tags for project version.
|
static EsiUtils.EsiBranchInfo |
getCurrentBranch(IProject project)
Gets branch information for the given TWC project part.
|
static ProjectDescriptor |
getDescriptorByBranchID(ProjectDescriptor project,
java.util.UUID branchID)
Get project descriptor for given branch.
|
static ProjectDescriptor |
getDescriptorForBranch(ProjectDescriptor project,
java.lang.String branchName)
Get project descriptor for given branch.
|
static ProjectDescriptor |
getDescriptorForVersion(ProjectDescriptor projectDescriptor,
IVersionDescriptor versionDescriptor)
Get descriptor for specific version.
|
static long |
getLastVersion(ProjectDescriptor descriptor)
Get last project version number.
|
static ILockProjectService |
getLockService(Project project)
Provides api to check, request and release locks on various project data.
|
static java.lang.String |
getLoggedUserName()
Returns the currently logged ESI user name.
|
static java.util.Set<java.lang.String> |
getLoggedUserNames()
Get logged in users if current user has rights to access user list.
|
static java.util.Collection<ProjectDescriptor> |
getProjectDescriptorsWithBranches(java.lang.Iterable<ProjectDescriptor> projectDescriptors)
Invocation of this method returns a
Collection of ProjectDescriptor s of each
branch in the given projectDescriptors . |
static void |
getProjectDescriptorsWithBranches(ProjectDescriptor descriptor,
java.util.Collection<ProjectDescriptor> descriptorsWithBranches)
Collects all project descriptors with branch info for the given project descriptor into the provided collection.
|
static java.lang.String |
getProjectName(org.eclipse.emf.common.util.URI locationURI)
Return project name for given URI.
|
static java.util.List<ProjectDescriptor> |
getRemoteProjectDescriptors()
Returns descriptors of projects stored on server.
|
static ITeamworkService |
getTeamworkService()
Get service for working with CEDW.
|
static java.util.Set<java.lang.String> |
getUserNames()
Get all users if current user has rights to access user list.
|
static java.util.List<IVersionDescriptor> |
getVersions(ProjectDescriptor descriptor)
Get all versions of given project.
|
static boolean |
isModuleUsageNew(IProject fromProject,
IProject toProject)
Checks if the project usage exists and is new (not yet committed to server).
|
static boolean |
isNotifyOnNew(Project project,
IAttachedProject iAttachedProject)
Method returns if MagicDraw should notify about available project usage update.
|
static void |
moveToUsedProject(Project project,
java.util.Map<PackageableElement,Package> moveMap)
Moves primary project elements to the designated used ESI project.
|
static void |
removeCommitTags(ProjectDescriptor descriptor,
long version)
Remove all tags from project version.
|
static void |
setNotifyOnNew(Project project,
IAttachedProject iAttachedProject,
boolean notifyOnNew)
Method sets if MagicDraw should notify about available project usage update.
|
static void |
setProjectName(ProjectDescriptor project,
java.lang.String newName)
Rename project.
|
static void |
updateModule(Project project,
IAttachedProject module,
ProjectDescriptor descriptor,
long version)
Change given module to another version or branch.
|
static void |
updateProject(Project project)
Updates given project.
|
static java.util.Map<IAttachedProject,java.lang.Boolean> |
updateRequiredProjectUsages(Project project)
This method updates project usages to newest version.
|
public static ITeamworkService getTeamworkService()
@CheckForNull public static ILockProjectService getLockService(@CheckForNull Project project)
@CheckForNull public static Project createProject(@Nonnull java.lang.String name, @CheckForNull java.lang.String category) throws com.nomagic.ci.persistence.PersistenceException
name
- project name.category
- project category.com.nomagic.ci.persistence.PersistenceException
public static void commitProject(Project project, java.lang.String comment, @CheckForNull java.util.Collection<Element> unlockElements, @CheckForNull java.util.Collection<ModuleUsage> unlockModules, boolean unlockDecomposition, @CheckForNull java.util.List<java.lang.String> tags)
project
- projectcomment
- comment.unlockElements
- elements to unlock when committing.unlockModules
- modules to unlock when committing.unlockDecomposition
- true if decomposition needs to be unlocked when committing.tags
- version tags to set.@CheckForNull public static IAttachedProject exportEsiModule(Project project, java.util.Collection<Package> packages, java.lang.String description, java.lang.String moduleName) throws java.lang.Exception
project
- project.packages
- packages to export.description
- module description.moduleName
- name of module.java.lang.Exception
- in case of some problempublic static java.util.List<ProjectDescriptor> getRemoteProjectDescriptors() throws java.lang.Exception
java.rmi.RemoteException
- in case of some problemjava.lang.Exception
public static java.util.List<IVersionDescriptor> getVersions(@Nonnull ProjectDescriptor descriptor)
descriptor
- project descriptor.public static void addCommitTags(java.util.List<java.lang.String> tags, ProjectDescriptor descriptor, long version)
tags
- tags to add.descriptor
- project for which version tags is set.version
- version for which tags will be added.public static java.util.List<java.lang.String> getCommitTags(ProjectDescriptor descriptor, long version)
descriptor
- project descriptor.version
- version.public static java.util.List<com.nomagic.esi.api.info.TagInfo> getCommitTagsInfo(ProjectDescriptor descriptor, long version)
descriptor
- project descriptor.version
- version.public static java.util.List<com.nomagic.esi.api.info.TagInfo> getAllCommitTagsInfo(ProjectDescriptor descriptor)
descriptor
- project descriptor.public static void removeCommitTags(ProjectDescriptor descriptor, long version)
descriptor
- project descriptor.version
- version.public static void updateProject(Project project)
project
- teamwork project to update.@CheckForNull public static java.lang.String getProjectName(org.eclipse.emf.common.util.URI locationURI)
locationURI
- project location.public static void setProjectName(ProjectDescriptor project, java.lang.String newName) throws com.nomagic.ci.persistence.PersistenceException
project
- project descriptornewName
- new project name.com.nomagic.ci.persistence.PersistenceException
- in case of some problempublic static void deleteProject(ProjectDescriptor project) throws com.nomagic.ci.persistence.PersistenceException
project
- project to delete.com.nomagic.ci.persistence.PersistenceException
public static java.util.Set<com.nomagic.teamwork.common.projects.CategoryInfo> getCategories()
public static java.util.Map<java.lang.String,java.util.List<ProjectDescriptor>> getCategoriesToProjects() throws java.lang.Exception
java.lang.Exception
- in case of some problem@CheckForNull public static java.lang.String getCategoryID(java.lang.String resourceID)
resourceID
- twc project resource IDnull
if project is not in category@CheckForNull public static com.nomagic.teamwork.common.projects.CategoryInfo getCategoryInfoByResourceID(java.lang.String resourceID)
CategoryInfo
for specified twc project resource ID.resourceID
- twc project resource IDCategoryInfo
or null
public static void createCategory(java.lang.String name, java.lang.String description)
name
- category namedescription
- category descriptionpublic static void assignProjectToCategory(ProjectDescriptor project, java.lang.String... categories) throws java.lang.Exception
project
- project to assign or remove from category.categories
- categories to which project will be assigned.java.lang.Exception
- in case of some problempublic static void deleteCategory(java.lang.String name)
name
- category name.public static java.util.Collection<EsiUtils.EsiBranchInfo> getBranches(ProjectDescriptor descriptor)
descriptor
- project descriptor.public static void createBranch(ProjectDescriptor descriptor, long version, java.lang.String branchName, java.lang.String branchDescription)
descriptor
- project descriptor.version
- version from which branchbranchName
- new branch name.branchDescription
- description of new branch.java.lang.RuntimeException
- in case network or server error occurs when creating branch.InsufficientPermissionsException
- if currently logged in user does not have Administer Projects permissionpublic static ProjectDescriptor getDescriptorByBranchID(ProjectDescriptor project, java.util.UUID branchID)
project
- project descriptor.branchID
- branch id.public static ProjectDescriptor getDescriptorForBranch(ProjectDescriptor project, java.lang.String branchName)
project
- project descriptor.branchName
- branch name.public static ProjectDescriptor getDescriptorForVersion(ProjectDescriptor projectDescriptor, IVersionDescriptor versionDescriptor)
projectDescriptor
- project descriptor.versionDescriptor
- version.public static void deleteBranch(ProjectDescriptor descriptor, java.lang.String branchName)
descriptor
- project which branch will be deleted.branchName
- branch name to delete.InsufficientPermissionsException
- if currently logged in user does not have Administer Projects permissionpublic static IPrimaryProject addToESI(Project project, java.lang.String esiProjectName) throws com.nomagic.ci.persistence.PersistenceException
project
- project to add.esiProjectName
- project name in esi server.com.nomagic.ci.persistence.PersistenceException
- in case of some problempublic static IPrimaryProject addToESI(Project project, java.lang.String esiProjectName, @CheckForNull java.lang.String category, @CheckForNull java.lang.String comment, @CheckForNull java.util.List<java.lang.String> tags, @Nonnull java.util.Collection<ResolveLocalModuleInfo> resolveInfos) throws com.nomagic.ci.persistence.PersistenceException
project
- the project to addesiProjectName
- the name for the new ESI projectcategory
- the category to add the project tocomment
- the commit commenttags
- the commit tagsresolveInfos
- the module resolve info listcom.nomagic.ci.persistence.PersistenceException
- exception if add fails@CheckForNull public static Project convertToLocal(Project project, java.io.File file)
project
- project to convertfile
- project file@CheckForNull public static java.lang.String getLoggedUserName()
public static java.util.Set<java.lang.String> getLoggedUserNames()
public static java.util.Set<java.lang.String> getUserNames()
public static void updateModule(Project project, IAttachedProject module, ProjectDescriptor descriptor, long version) throws java.lang.Exception
project
- project which module is switched.module
- module to switch.descriptor
- new module descriptor.version
- new module versionjava.lang.Exception
- in case of some problempublic static void setNotifyOnNew(Project project, IAttachedProject iAttachedProject, boolean notifyOnNew)
project
- Project to which's usage setting is applied.iAttachedProject
- Usage's attached project to which setting is applied.notifyOnNew
- Should notification be shown.public static boolean isNotifyOnNew(Project project, IAttachedProject iAttachedProject)
false
by default.project
- Project to which's usage setting is applied.iAttachedProject
- Usage's attached project to which setting is applied.false
by default.public static boolean isModuleUsageNew(IProject fromProject, IProject toProject)
fromProject
- the project the usage should be fromtoProject
- the project the usage should be totrue
if the usage from specifed project exists to specified to project
and if the specified to project is not null
and if the usage is new
(as defined above). Return false
othewisepublic static java.util.Map<IAttachedProject,java.lang.Boolean> updateRequiredProjectUsages(Project project) throws java.lang.Exception
isNotifyOnNew(Project, IAttachedProject)
set to true
are updated. It can be changed using setNotifyOnNew(Project, IAttachedProject, boolean)
. If project
usages is locked by other user or can't be updated for other reasons its update will be skipped.project
- Project which usages are updated.java.lang.Exception
- in case of some problemisNotifyOnNew(Project, IAttachedProject)
,
setNotifyOnNew(Project, IAttachedProject, boolean)
public static EsiUtils.ApplyProjectStateResult applyProjectState(Project source, Project target) throws java.lang.IllegalArgumentException, ElementLockAcquisitionException, ModuleUsageLockAcquisitionException, OptionsLockAcquisitionException
source
- the source project from which the state is copiedtarget
- the target project to which the state is copiedjava.lang.IllegalArgumentException
- if: 1. the projects are the same, 2. any of the projects are
not ready, 3. any of the projects is not an ESI project, 4. the project IDs
differ, 5. the target project is not editableElementLockAcquisitionException
- if specific element could not be lockedModuleUsageLockAcquisitionException
- if specific module usage could not be lockedOptionsLockAcquisitionException
- if specific options could not be lockedpublic static EsiUtils.ApplyProjectStateResult applyDisconnectedProjectState(Project source, Project target) throws java.lang.IllegalArgumentException, ElementLockAcquisitionException, ModuleUsageLockAcquisitionException, OptionsLockAcquisitionException
source
- the source project (local project) from which the state is copiedtarget
- the target project (server project) to which the state is copiedjava.lang.IllegalArgumentException
- if: 1. the projects are the same, 2. any of the projects are
not ready, 3. the project IDs
differ, 4. the target project is not editableElementLockAcquisitionException
- if specific element could not be lockedModuleUsageLockAcquisitionException
- if specific module usage could not be lockedOptionsLockAcquisitionException
- if specific options could not be lockedpublic static long getLastVersion(ProjectDescriptor descriptor)
descriptor
- project descriptor for ESI server project.java.lang.RuntimeException
- in case provided descriptor is not valid for current server.public static java.util.Collection<ProjectDescriptor> getProjectDescriptorsWithBranches(java.lang.Iterable<ProjectDescriptor> projectDescriptors)
Collection
of ProjectDescriptor
s of each
branch in the given projectDescriptors
.projectDescriptors
- descriptors of the projects, whose branch ProjectDescriptor
s should
be returnedprojectDescriptors
@CheckForNull public static org.eclipse.emf.common.util.URI cloneProject(org.eclipse.emf.common.util.URI sourceURI, java.lang.String targetName, java.lang.String targetDescription) throws java.lang.Exception
sourceURI
- source project URItargetName
- target project nametargetDescription
- target project descriptionjava.lang.Exception
- exception in case clone failspublic static void getProjectDescriptorsWithBranches(ProjectDescriptor descriptor, java.util.Collection<ProjectDescriptor> descriptorsWithBranches)
descriptor
- project descriptor for which to collect project descriptors with branch infodescriptorsWithBranches
- collection where to add the resultpublic static java.util.UUID getBranchID(org.eclipse.emf.common.util.URI locationURI)
locationURI
- project location URI@CheckForNull public static EsiUtils.EsiBranchInfo getCurrentBranch(IProject project)
null
will be returned.project
- project partpublic static void moveToUsedProject(Project project, java.util.Map<PackageableElement,Package> moveMap) throws java.lang.IllegalArgumentException, ElementReadOnlyException, ElementLockedByOtherException, ModuleUsageLockedByOtherException, ElementLockAcquisitionException, ModuleUsageLockAcquisitionException, ElementRemovedInUsedProjectException, MovedElementRemovedOnServerException, ElementsExistInUsedProjectException, UsedProjectHasIncompatibleProfilesException, TargetPackagePermissionException, com.nomagic.ci.persistence.PersistenceException
project
- the main projectmoveMap
- elements move mapjava.lang.IllegalArgumentException
- if: 1. any of the moved elements do not belong to the
primary project, 2. any of the designated owners is not provided, 3. not all
designated owners belong to the same attached ESI project, 4. the designated
attached project is not directly used by the primary project, 5. the designated
attached project is currently open, 6. the designated attached project does not
exist on the serverElementReadOnlyException
- if current user does not have permissions to edit any of the
moved elementsElementLockedByOtherException
- if any of the moved elements or their contents is
locked by other userModuleUsageLockedByOtherException
- if the usage of the designated attached project is
locked by other userElementLockAcquisitionException
- if locking of any of the moved elements or their
contents fails; the exception is thrown for the first moved element for which
either itself or its contents failed to be lockedModuleUsageLockAcquisitionException
- if locking of the usage of the designated
attached project failsElementRemovedInUsedProjectException
- if any of the designated owners does not exist
in the latest version of the attached projectMovedElementRemovedOnServerException
- if any of the moved elements does not exist in
the latest version of the projectElementsExistInUsedProjectException
- if any of the moved elements already exist in the
designated attached projectUsedProjectHasIncompatibleProfilesException
- if the target used project has
incompatible system/standard profilesTargetPackagePermissionException
- if the target project package permissions prohibit
element movecom.nomagic.ci.persistence.PersistenceException
- if any other unexpected error occurs@CheckForNull public static CommandLinePasswordManager getCommandLinePasswordManager(ProjectDescriptor descriptor)
null
will be returned.descriptor
- versionable project descriptor