Package com.nomagic.magicdraw.esi
Class EsiUtils
java.lang.Object
com.nomagic.magicdraw.esi.EsiUtils
API to work with Teamwork Cloud server. Before working with users and projects there must be established connection to Teamwork Cloud server.
Connection is established with this code:
EsiUtils.getTeamworkService().login(new ServerLoginInfo("localhost", "user", "password", false), false);
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
A structure that is produced by theapplyProjectState(Project, Project)
and which holds information about the result of the operationstatic interface
Branch information.static class
Offline project descriptor. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addCommitTags
(List<String> tags, ProjectDescriptor descriptor, long version) Add tags for given version.static com.nomagic.ci.persistence.IPrimaryProject
Add project to the Teamwork Cloud server and open it.static com.nomagic.ci.persistence.IPrimaryProject
addToESI
(Project project, String esiProjectName, String category, String comment, List<String> tags, Collection<ResolveLocalModuleInfo> resolveInfos) Add project to the Teamwork Cloud server and open itapplyDisconnectedProjectState
(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.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, String... categories) Adds or remove project to/from categories.static org.eclipse.emf.common.util.URI
cloneProject
(org.eclipse.emf.common.util.URI sourceURI, String targetName, String targetDescription) Clones project, new project is created it contains copy of source project with regenerated element ids.static org.eclipse.emf.common.util.URI
cloneProject
(org.eclipse.emf.common.util.URI sourceURI, String targetName, String targetDescription, String targetCategoryID) Deprecated.static org.eclipse.emf.common.util.URI
cloneProject
(org.eclipse.emf.common.util.URI sourceURI, String targetName, String targetDescription, UUID targetCategoryID) Clones project, new project is created it contains copy of source project with regenerated element ids.static org.eclipse.emf.common.util.URI
cloneProjectWithUsages
(org.eclipse.emf.common.util.URI sourceURI, String targetName, Map<String, String> usedProjectTargetNames, String targetDescription, UUID targetCategoryID) Clones project and its usages, new projects are created, they contain copy of source project and its non standard/system usages with regenerated element ids.static void
commitProject
(Project project, String comment, Collection<Element> unlockElements, Collection<ModuleUsage> unlockModules, boolean unlockDecomposition, List<String> tags) Commit project.static Project
convertToLocal
(Project project, File file) Convert given project to local, save and reopen it.static void
createBranch
(ProjectDescriptor descriptor, long version, String branchName, String branchDescription) Create new branch for given project.static void
createCategory
(String name, String description) Create projects category in the server.static Project
createProject
(String name, String category) Create Teamwork Cloud project.static void
deleteBranch
(ProjectDescriptor descriptor, String branchName) Delete project branch.static void
deleteCategory
(String name) Delete category with given name.static void
deleteProject
(ProjectDescriptor project) Delete project from repository.static com.nomagic.ci.persistence.IAttachedProject
exportEsiModule
(Project project, Collection<Package> packages, String description, String moduleName) Exports module.static List<com.nomagic.esi.api.info.TagInfo>
getAllCommitTagsInfo
(ProjectDescriptor descriptor) Get all tags for project.static Collection<EsiUtils.EsiBranchInfo>
getBranches
(ProjectDescriptor descriptor) Get all branches for given project.static Collection<EsiUtils.EsiBranchInfo>
getBranches
(ProjectDescriptor descriptor, ProgressStatus status) Get all branches for given project.static UUID
getBranchID
(org.eclipse.emf.common.util.URI locationURI) Gets project branch ID.static Set<CategoryInfo>
static Map<String,
List<ProjectDescriptor>> Get categories for projects.static UUID
getCategory
(String resourceID) Gets category ID for specified twc project resource ID.static String
getCategoryID
(String resourceID) Deprecated.static CategoryInfo
getCategoryInfoByResourceID
(String resourceID) GetCategoryInfo
for specified twc project resource ID.static CommandLinePasswordManager
getCommandLinePasswordManager
(ProjectDescriptor descriptor) Gets password manager for command line utilities If session is not present thennull
will be returned.getCommitTags
(ProjectDescriptor descriptor, long version) Get tags names for project version.static List<com.nomagic.esi.api.info.TagInfo>
getCommitTagsInfo
(ProjectDescriptor descriptor, long version) Get tags for project version.static EsiUtils.EsiBranchInfo
getCurrentBranch
(com.nomagic.ci.persistence.IProject project) Gets branch information for the given TWC project part.static ProjectDescriptor
getDescriptorByBranchID
(ProjectDescriptor project, UUID branchID) Get project descriptor for given branch.static ProjectDescriptor
getDescriptorForBranch
(ProjectDescriptor project, String branchName) Get project descriptor for given branch.static ProjectDescriptor
getDescriptorForVersion
(ProjectDescriptor projectDescriptor, com.nomagic.ci.persistence.versioning.IVersionDescriptor versionDescriptor) Get descriptor for specific version.static long
getLastVersion
(ProjectDescriptor descriptor) Get last project version number.static com.nomagic.ci.persistence.versioning.IVersionDescriptor
getLastVersionDescriptor
(ProjectDescriptor descriptor) Get last project version descriptor.static ILockProjectService
getLockService
(Project project) Provides api to check, request and release locks on various project data.static String
Returns the currently logged Teamwork Cloud user name.Get logged in users if current user has rights to access user list.static com.nomagic.esi.api.info.BranchInfo
getNewBranch
(ProjectDescriptor descriptor, long version, String branchName, String branchDescription) Create new branch for given project.getNotifyOnNewTags
(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject) Method returns application's notify tags about available project usage update.getOfflineProject
(Project project) Returns offline project descriptor of the specified project or null if the project is not saved to offline.Returns all available offline project descriptors.static void
getProjectDescriptorsWithBranches
(ProjectDescriptor descriptor, Collection<ProjectDescriptor> descriptorsWithBranches) Collects all project descriptors with branch info for the given project descriptor into the provided collection.static void
getProjectDescriptorsWithBranches
(ProjectDescriptor descriptor, Collection<ProjectDescriptor> descriptorsWithBranches, ProgressStatus status) Collects all project descriptors with branch info for the given project descriptor into the provided collection.static Collection<ProjectDescriptor>
getProjectDescriptorsWithBranches
(Iterable<ProjectDescriptor> projectDescriptors) Invocation of this method returns aCollection
ofProjectDescriptor
s of each branch in the givenprojectDescriptors
.static String
getProjectName
(org.eclipse.emf.common.util.URI locationURI) Return project name for given URI.static List<ProjectDescriptor>
Returns descriptors of projects stored on server.static ConnectionInfo
getServerInfo
(Project project) Get server information for given projectstatic ITeamworkService
Get service for working with Teamwork Cloud.Get all users if current user has rights to access user list.static List<com.nomagic.ci.persistence.versioning.IVersionDescriptor>
getVersions
(ProjectDescriptor descriptor) Get all versions of given project.static boolean
isModuleUsageNew
(com.nomagic.ci.persistence.IProject fromProject, com.nomagic.ci.persistence.IProject toProject) Checks if the project usage exists and is new (not yet committed to server).static boolean
isNotifyOnNew
(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject) Method returns if application should notify about available project usage update.static boolean
isProjectChanged
(Project project) Method returnstrue
when twcloud project has some changed objects in its resource, or local project'sStateChangeHandler.isDirty(IProject)
returnstrue
static Project
loadFromOffline
(EsiUtils.OfflineProjectDescriptor descriptor, ProgressStatus status) Loads the offline project.static void
moveToUsedProject
(Project project, Map<PackageableElement, Element> moveMap, boolean silentMode) Moves elements to used project(s).static void
removeCommitTags
(ProjectDescriptor descriptor, long version) Remove all tags from project version.saveToOffline
(Project project, ProgressStatus status, boolean delete) Saves the specified project to offline.static void
setNotifyOnNew
(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject, boolean notifyOnNew) Method sets if application should notify about available project usage update.static void
setNotifyOnNewTags
(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject, Collection<String> tags) Method sets application's notify tags about available project usage update.static void
setNotifyOnNewTags
(com.nomagic.magicdraw.esi.project.project.EsiPrimaryProject project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject, Collection<String> tags) Method sets application's notify tags about available project usage update.static void
setProjectName
(ProjectDescriptor project, String newName) Rename project.static void
updateModule
(Project project, com.nomagic.ci.persistence.IAttachedProject module, ProjectDescriptor descriptor, long version) Change given module to another version or branch.static void
updateModule
(Project project, com.nomagic.ci.persistence.IAttachedProject module, org.eclipse.emf.common.util.URI updateFrom, long version) Change given module to another version or branch.static void
updateProject
(Project project) Updates given project.updateRequiredProjectUsages
(Project project) This method updates project usages to newest version.
-
Constructor Details
-
EsiUtils
public EsiUtils()
-
-
Method Details
-
getTeamworkService
Get service for working with Teamwork Cloud.- Returns:
- service for working with Teamwork Cloud.
-
getLockService
Provides api to check, request and release locks on various project data.- Returns:
- lock service.
-
createProject
@CheckForNull public static Project createProject(@Nonnull String name, @CheckForNull String category) throws com.nomagic.ci.persistence.PersistenceException Create Teamwork Cloud project. Project is created only if currently logged user rights allows to create projects.- Parameters:
name
- project name.category
- project category.- Returns:
- crated project.
- Throws:
com.nomagic.ci.persistence.PersistenceException
-
commitProject
public static void commitProject(Project project, String comment, @CheckForNull Collection<Element> unlockElements, @CheckForNull Collection<ModuleUsage> unlockModules, boolean unlockDecomposition, @CheckForNull List<String> tags) Commit project.- Parameters:
project
- projectcomment
- comment.unlockElements
- elements to unlock when committing. The collection specifies which locked elements should be unlocked after successful commit.null
means that no elements should be unlocked.unlockModules
- modules to unlock when committing. The collection specifies which project usages (modules) should be unlocked after successful commit.null
means that no project usages should be unlocked.unlockDecomposition
- true if decomposition needs to be unlocked when committing.tags
- version tags to set.
-
exportEsiModule
@CheckForNull public static com.nomagic.ci.persistence.IAttachedProject exportEsiModule(Project project, Collection<Package> packages, String description, String moduleName) throws Exception Exports module.- Parameters:
project
- project.packages
- packages to export.description
- module description.moduleName
- name of module.- Returns:
- exported module attached project.
- Throws:
Exception
- in case of some problem
-
getRemoteProjectDescriptors
Returns descriptors of projects stored on server.- Returns:
- list of remote project descriptors.
- Throws:
RemoteException
- in case of some problemException
-
getVersions
public static List<com.nomagic.ci.persistence.versioning.IVersionDescriptor> getVersions(@Nonnull ProjectDescriptor descriptor) Get all versions of given project.- Parameters:
descriptor
- project descriptor.- Returns:
- list of version information.
-
addCommitTags
Add tags for given version.- Parameters:
tags
- tags to add.descriptor
- project for which version tags is set.version
- version for which tags will be added.
-
getCommitTags
Get tags names for project version.- Parameters:
descriptor
- project descriptor.version
- version.- Returns:
- list of tags for given version.
-
getCommitTagsInfo
public static List<com.nomagic.esi.api.info.TagInfo> getCommitTagsInfo(ProjectDescriptor descriptor, long version) Get tags for project version.- Parameters:
descriptor
- project descriptor.version
- version.- Returns:
- list of tags for given version.
-
getAllCommitTagsInfo
public static List<com.nomagic.esi.api.info.TagInfo> getAllCommitTagsInfo(ProjectDescriptor descriptor) Get all tags for project.- Parameters:
descriptor
- project descriptor.- Returns:
- list of tags for given version.
-
removeCommitTags
Remove all tags from project version.- Parameters:
descriptor
- project descriptor.version
- version.
-
updateProject
Updates given project. Project is activated before update.- Parameters:
project
- teamwork project to update.
-
getProjectName
Return project name for given URI.- Parameters:
locationURI
- project location.- Returns:
- project name.
-
setProjectName
public static void setProjectName(ProjectDescriptor project, String newName) throws com.nomagic.ci.persistence.PersistenceException Rename project.- Parameters:
project
- project descriptornewName
- new project name.- Throws:
com.nomagic.ci.persistence.PersistenceException
- in case of some problem
-
deleteProject
public static void deleteProject(ProjectDescriptor project) throws com.nomagic.ci.persistence.PersistenceException Delete project from repository.- Parameters:
project
- project to delete.- Throws:
com.nomagic.ci.persistence.PersistenceException
-
getCategories
- Returns:
- all categories from server.
-
getCategoriesToProjects
Get categories for projects.- Returns:
- projects in categories.
- Throws:
Exception
- in case of some problem
-
getCategory
Gets category ID for specified twc project resource ID.- Parameters:
resourceID
- twc project resource ID- Returns:
- category ID or
null
if project is not in category
-
getCategoryID
Deprecated.Gets category ID for specified twc project resource ID.- Parameters:
resourceID
- twc project resource ID- Returns:
- category ID or
null
if project is not in category
-
getCategoryInfoByResourceID
GetCategoryInfo
for specified twc project resource ID.- Parameters:
resourceID
- twc project resource ID- Returns:
- instance of
CategoryInfo
ornull
-
createCategory
Create projects category in the server.- Parameters:
name
- category namedescription
- category description
-
assignProjectToCategory
public static void assignProjectToCategory(ProjectDescriptor project, String... categories) throws Exception Adds or remove project to/from categories. After this method project belongs only to categories specified for this method.- Parameters:
project
- project to assign or remove from category.categories
- categories to which project will be assigned.- Throws:
Exception
- in case of some problem
-
deleteCategory
Delete category with given name.- Parameters:
name
- category name.
-
getBranches
Get all branches for given project.- Parameters:
descriptor
- project descriptor.- Returns:
- branches for given project.
-
getBranches
public static Collection<EsiUtils.EsiBranchInfo> getBranches(ProjectDescriptor descriptor, ProgressStatus status) Get all branches for given project.- Parameters:
descriptor
- project descriptor.status
- progress status.- Returns:
- branches for given project.
-
createBranch
public static void createBranch(ProjectDescriptor descriptor, long version, String branchName, String branchDescription) Create new branch for given project.- Parameters:
descriptor
- project descriptor.version
- version from which branchbranchName
- new branch name.branchDescription
- description of new branch.- Throws:
RuntimeException
- in case network or server error occurs when creating branch.InsufficientPermissionsException
- if currently logged in user does not have Administer Resources permission
-
getNewBranch
public static com.nomagic.esi.api.info.BranchInfo getNewBranch(ProjectDescriptor descriptor, long version, String branchName, String branchDescription) Create new branch for given project.- Parameters:
descriptor
- project descriptor.version
- version from which branchbranchName
- new branch name.branchDescription
- description of new branch.- Returns:
- branch info for specified branch
- Throws:
RuntimeException
- in case network or server error occurs when creating branch.InsufficientPermissionsException
- if currently logged in user does not have Administer Resources permission
-
getDescriptorByBranchID
Get project descriptor for given branch. This descriptor can be used to load project from branch.- Parameters:
project
- project descriptor.branchID
- branch id.- Returns:
- project descriptor for given branch.
-
getDescriptorForBranch
public static ProjectDescriptor getDescriptorForBranch(ProjectDescriptor project, String branchName) Get project descriptor for given branch. This descriptor can be used to load project from branch.- Parameters:
project
- project descriptor.branchName
- branch name.- Returns:
- project descriptor for given branch.
-
getDescriptorForVersion
public static ProjectDescriptor getDescriptorForVersion(ProjectDescriptor projectDescriptor, com.nomagic.ci.persistence.versioning.IVersionDescriptor versionDescriptor) Get descriptor for specific version. Can be used to open historic project version.- Parameters:
projectDescriptor
- project descriptor.versionDescriptor
- version.- Returns:
- descriptor for specific version.
-
deleteBranch
Delete project branch.- Parameters:
descriptor
- project which branch will be deleted.branchName
- branch name to delete.- Throws:
InsufficientPermissionsException
- if currently logged in user does not have Administer Resources permission
-
addToESI
public static com.nomagic.ci.persistence.IPrimaryProject addToESI(Project project, String esiProjectName) throws com.nomagic.ci.persistence.PersistenceException Add project to the Teamwork Cloud server and open it.- Parameters:
project
- project to add.esiProjectName
- project name in teamwork cloud server.- Returns:
- opened teamwork cloud project.
- Throws:
com.nomagic.ci.persistence.PersistenceException
- in case of some problem
-
addToESI
public static com.nomagic.ci.persistence.IPrimaryProject addToESI(Project project, String esiProjectName, @CheckForNull String category, @CheckForNull String comment, @CheckForNull List<String> tags, @Nonnull Collection<ResolveLocalModuleInfo> resolveInfos) throws com.nomagic.ci.persistence.PersistenceException Add project to the Teamwork Cloud server and open it- Parameters:
project
- the project to addesiProjectName
- the name for the new Teamwork Cloud projectcategory
- the category to add the project tocomment
- the commit commenttags
- the commit tagsresolveInfos
- the module resolve info list- Returns:
- the added project
- Throws:
com.nomagic.ci.persistence.PersistenceException
- exception if add fails
-
convertToLocal
Convert given project to local, save and reopen it.- Parameters:
project
- project to convertfile
- project file- Returns:
- local project
-
getLoggedUserName
Returns the currently logged Teamwork Cloud user name.- Returns:
- user name
-
getServerInfo
Get server information for given project- Parameters:
project
- project- Returns:
- server information or null when project is not server project
-
getLoggedUserNames
Get logged in users if current user has rights to access user list.- Returns:
- all user names.
-
getUserNames
Get all users if current user has rights to access user list.- Returns:
- logged in user names.
-
updateModule
public static void updateModule(Project project, com.nomagic.ci.persistence.IAttachedProject module, ProjectDescriptor descriptor, long version) throws Exception Change given module to another version or branch.- Parameters:
project
- project which module is switched.module
- module to switch.descriptor
- new module descriptor.version
- new module version- Throws:
Exception
- in case of some problem
-
updateModule
public static void updateModule(Project project, com.nomagic.ci.persistence.IAttachedProject module, org.eclipse.emf.common.util.URI updateFrom, long version) throws Exception Change given module to another version or branch.- Parameters:
project
- project which module is switched.module
- module to switch.updateFrom
- project location URI.version
- new module version- Throws:
Exception
- in case of some problem
-
setNotifyOnNew
public static void setNotifyOnNew(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject, boolean notifyOnNew) Method sets if application should notify about available project usage update.- Parameters:
project
- Project to which's usage setting is applied.iAttachedProject
- Usage's attached project to which setting is applied.notifyOnNew
- Should notification be shown.
-
isNotifyOnNew
public static boolean isNotifyOnNew(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject) Method returns if application should notify about available project usage update. Returnfalse
by default.- Parameters:
project
- Project to which's usage setting is applied.iAttachedProject
- Usage's attached project to which setting is applied.- Returns:
- Should notification be shown. Returns
false
by default.
-
isProjectChanged
Method returnstrue
when twcloud project has some changed objects in its resource, or local project'sStateChangeHandler.isDirty(IProject)
returnstrue
- Parameters:
project
- project to check for presence of changes- Returns:
true
when project is changed
-
setNotifyOnNewTags
public static void setNotifyOnNewTags(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject, @CheckForNull Collection<String> tags) Method sets application's notify tags about available project usage update.- Parameters:
project
- Project to which's usage setting is applied.iAttachedProject
- Usage's attached project to which setting is applied.tags
- Notify tags.
-
setNotifyOnNewTags
public static void setNotifyOnNewTags(com.nomagic.magicdraw.esi.project.project.EsiPrimaryProject project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject, @CheckForNull Collection<String> tags) Method sets application's notify tags about available project usage update.- Parameters:
project
- Project to which's usage setting is applied.iAttachedProject
- Usage's attached project to which setting is applied.tags
- Notify tags.
-
getNotifyOnNewTags
@CheckForNull public static List<String> getNotifyOnNewTags(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject) Method returns application's notify tags about available project usage update.- Parameters:
project
- Project to which's usage setting is applied.iAttachedProject
- Usage's attached project to which setting is applied.- Returns:
- Notify tags.
-
isModuleUsageNew
public static boolean isModuleUsageNew(com.nomagic.ci.persistence.IProject fromProject, com.nomagic.ci.persistence.IProject toProject) Checks if the project usage exists and is new (not yet committed to server).- Parameters:
fromProject
- the project the usage should be fromtoProject
- the project the usage should be to- Returns:
true
if the usage from specifed project exists to specified to project and if the specified to project is notnull
and if the usage is new (as defined above). Returnfalse
othewise
-
updateRequiredProjectUsages
public static Map<com.nomagic.ci.persistence.IAttachedProject,Boolean> updateRequiredProjectUsages(Project project) throws Exception This method updates project usages to newest version. Only usages which haveisNotifyOnNew(Project, IAttachedProject)
set totrue
are updated. It can be changed usingsetNotifyOnNew(Project, IAttachedProject, boolean)
. If project usages is locked by other user or can't be updated for other reasons its update will be skipped.- Parameters:
project
- Project which usages are updated.- Returns:
- Results map. Key - attached project which was updated, value - was update successful.
- Throws:
Exception
- in case of some problem- See Also:
-
applyProjectState
public static EsiUtils.ApplyProjectStateResult applyProjectState(Project source, Project target) throws IllegalArgumentException, ElementLockAcquisitionException, ModuleUsageLockAcquisitionException, OptionsLockAcquisitionException 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. The elements that are matched are updated, the not existing elements are removed, and new elements are added. Module usages are copied and modules are updated accordingly. To perform the operation successfully, all elements of the project, module usages, and options are locked. Any lock failure terminates the operation with a specific exception- Parameters:
source
- the source project from which the state is copiedtarget
- the target project to which the state is copied- Returns:
- a structure that holds the result of the operation
- Throws:
IllegalArgumentException
- if: 1. the projects are the same, 2. any of the projects are not ready, 3. any of the projects is not an Teamwork Cloud 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 locked
-
applyDisconnectedProjectState
public static EsiUtils.ApplyProjectStateResult applyDisconnectedProjectState(Project source, Project target) throws IllegalArgumentException, ElementLockAcquisitionException, ModuleUsageLockAcquisitionException, OptionsLockAcquisitionException 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. The elements that are matched are updated, the not existing elements are removed, and new elements are added. Module usages are copied and modules are updated accordingly. To perform the operation successfully, all elements of the project, module usages, and options are locked. Any lock failure terminates the operation with a specific exception- Parameters:
source
- the source project (local project) from which the state is copiedtarget
- the target project (server project) to which the state is copied- Returns:
- a structure that holds the result of the operation
- Throws:
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 lockedRuntimeException
- if the method invocation fails because of another reason. Cause of the exception should be checked in order find the actual reason of the failure.
-
getLastVersion
Get last project version number.- Parameters:
descriptor
- project descriptor for Teamwork Cloud server project.- Returns:
- last project version number, -1 - there is no such project or application is not connected to the server.
- Throws:
RuntimeException
- in case provided descriptor is not valid for current server.
-
getLastVersionDescriptor
@CheckForNull public static com.nomagic.ci.persistence.versioning.IVersionDescriptor getLastVersionDescriptor(ProjectDescriptor descriptor) Get last project version descriptor.- Parameters:
descriptor
- project descriptor for Teamwork Cloud server project.- Returns:
- last project version descriptor,
null
- when there is no such project or application is not connected to the server. - Throws:
RuntimeException
- in case provided descriptor is not valid for current server.
-
getProjectDescriptorsWithBranches
public static Collection<ProjectDescriptor> getProjectDescriptorsWithBranches(Iterable<ProjectDescriptor> projectDescriptors) Invocation of this method returns aCollection
ofProjectDescriptor
s of each branch in the givenprojectDescriptors
.- Parameters:
projectDescriptors
- descriptors of the projects, whose branchProjectDescriptor
s should be returned- Returns:
- project descriptors for each branch of the given
projectDescriptors
-
cloneProject
@CheckForNull public static org.eclipse.emf.common.util.URI cloneProject(org.eclipse.emf.common.util.URI sourceURI, String targetName, String targetDescription) throws Exception Clones project, new project is created it contains copy of source project with regenerated element ids. Application must be logged in the server, logged in user should have permission to create new project and read source project.- Parameters:
sourceURI
- source project URItargetName
- target project nametargetDescription
- target project description- Returns:
- cloned project URI
- Throws:
Exception
- exception in case clone fails
-
cloneProject
@Deprecated @CheckForNull public static org.eclipse.emf.common.util.URI cloneProject(org.eclipse.emf.common.util.URI sourceURI, String targetName, String targetDescription, @CheckForNull String targetCategoryID) throws Exception Deprecated.Clones project, new project is created it contains copy of source project with regenerated element ids. Application must be logged in the server, logged in user should have permission to create new project and read source project.- Parameters:
sourceURI
- source project URItargetName
- target project nametargetDescription
- target project descriptiontargetCategoryID
- target project category ID- Returns:
- cloned project URI
- Throws:
Exception
- exception in case clone fails
-
cloneProject
@CheckForNull public static org.eclipse.emf.common.util.URI cloneProject(org.eclipse.emf.common.util.URI sourceURI, String targetName, String targetDescription, @CheckForNull UUID targetCategoryID) throws Exception Clones project, new project is created it contains copy of source project with regenerated element ids. Application must be logged in the server, logged in user should have permission to create new project and read source project.- Parameters:
sourceURI
- source project URItargetName
- target project nametargetDescription
- target project descriptiontargetCategoryID
- target project category ID- Returns:
- cloned project URI
- Throws:
Exception
- exception in case clone fails
-
cloneProjectWithUsages
@CheckForNull public static org.eclipse.emf.common.util.URI cloneProjectWithUsages(org.eclipse.emf.common.util.URI sourceURI, String targetName, Map<String, String> usedProjectTargetNames, String targetDescription, @CheckForNull UUID targetCategoryID) throws ExceptionClones project and its usages, new projects are created, they contain copy of source project and its non standard/system usages with regenerated element ids. Application must be logged in the server, logged in user should have permission to create new project and read source project.- Parameters:
sourceURI
- source project URItargetName
- target project nameusedProjectTargetNames
- used project target names map. Key - used project id, value - target nametargetDescription
- target project descriptiontargetCategoryID
- target project category ID- Returns:
- cloned project URI
- Throws:
Exception
- exception in case clone fails
-
getProjectDescriptorsWithBranches
public static void getProjectDescriptorsWithBranches(ProjectDescriptor descriptor, Collection<ProjectDescriptor> descriptorsWithBranches) Collects all project descriptors with branch info for the given project descriptor into the provided collection.- Parameters:
descriptor
- project descriptor for which to collect project descriptors with branch infodescriptorsWithBranches
- collection where to add the result
-
getProjectDescriptorsWithBranches
public static void getProjectDescriptorsWithBranches(ProjectDescriptor descriptor, Collection<ProjectDescriptor> descriptorsWithBranches, ProgressStatus status) Collects all project descriptors with branch info for the given project descriptor into the provided collection.- Parameters:
descriptor
- project descriptor for which to collect project descriptors with branch infodescriptorsWithBranches
- collection where to add the resultstatus
- progress status
-
getBranchID
Gets project branch ID.- Parameters:
locationURI
- project location URI- Returns:
- branch ID
-
moveToUsedProject
public static void moveToUsedProject(Project project, Map<PackageableElement, Element> moveMap, boolean silentMode) throws ExceptionMoves elements to used project(s). The moved elements must be lockable by user, and must have an owner. The target package(s) must be in the directly used project, and be lockable by user. Each moved element can be moved to a different target package. In addition to the specified elements, additional elements (such as interrelations) might be selected to be moved together. SeeMoveRelationManager.collectRelationsToMove(java.util.Map<com.nomagic.uml2.ext.magicdraw.classes.mdkernel.PackageableElement, com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element>)
.- Parameters:
project
- the main projectmoveMap
- elements move mapsilentMode
- if true, will move in silent mode- Throws:
Exception
- in case moving elements fails
-
getCurrentBranch
@CheckForNull public static EsiUtils.EsiBranchInfo getCurrentBranch(com.nomagic.ci.persistence.IProject project) Gets branch information for the given TWC project part. If TWC project part is not linked with TWC project (like standard profiles) or user has no permission to read thennull
will be returned.- Parameters:
project
- project part- Returns:
- branch information
-
getCommandLinePasswordManager
@CheckForNull public static CommandLinePasswordManager getCommandLinePasswordManager(ProjectDescriptor descriptor) Gets password manager for command line utilities If session is not present thennull
will be returned.- Parameters:
descriptor
- versionable project descriptor- Returns:
- CommandLinePasswordManager or null if session is not initialized
-
saveToOffline
public static EsiUtils.OfflineProjectDescriptor saveToOffline(Project project, ProgressStatus status, boolean delete) throws IOException, com.nomagic.ci.persistence.PersistenceException Saves the specified project to offline.- Parameters:
project
- a project.status
- a progress status.delete
- delete previous saved offline project if true.- Returns:
- offline project descriptor.
- Throws:
IllegalArgumentException
- if the specified project is not a TWC project.IOException
- if any I/O errors occurs.com.nomagic.ci.persistence.PersistenceException
- if persistence related problem occurs.
-
loadFromOffline
@CheckForNull public static Project loadFromOffline(EsiUtils.OfflineProjectDescriptor descriptor, ProgressStatus status) throws Exception Loads the offline project.- Parameters:
descriptor
- specifies which offline project to load.status
- progress status.- Returns:
- loaded project or null if the offline project was not loaded.
- Throws:
Exception
- if offline project loading fails.
-
getOfflineProject
Returns offline project descriptor of the specified project or null if the project is not saved to offline.- Parameters:
project
- a project.- Returns:
- offline project descriptor.
- Throws:
IllegalArgumentException
- if the specified project is not a TWC project.
-
getOfflineProjects
Returns all available offline project descriptors.- Returns:
- collection of offline project descriptors.
-
cloneProject(URI, String, String, UUID)