Package com.nomagic.magicdraw.esi
Class EsiUtils
- java.lang.Object
-
- com.nomagic.magicdraw.esi.EsiUtils
-
@OpenApiAll public class EsiUtils extends java.lang.Object
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
Nested Classes Modifier and Type Class Description static interface
EsiUtils.ApplyProjectStateResult
A structure that is produced by theapplyProjectState(Project, Project)
and which holds information about the result of the operationstatic interface
EsiUtils.EsiBranchInfo
Branch information.static class
EsiUtils.OfflineProjectDescriptor
Offline project descriptor.
-
Constructor Summary
Constructors Constructor Description EsiUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
addCommitTags(java.util.List<java.lang.String> tags, ProjectDescriptor descriptor, long version)
Add tags for given version.static com.nomagic.ci.persistence.IPrimaryProject
addToESI(Project project, java.lang.String esiProjectName)
Add project to the Teamwork Cloud server and open it.static com.nomagic.ci.persistence.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 Teamwork Cloud server and open itstatic 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 org.eclipse.emf.common.util.URI
cloneProject(org.eclipse.emf.common.util.URI sourceURI, java.lang.String targetName, java.lang.String targetDescription, java.lang.String targetCategoryID)
Deprecated.static org.eclipse.emf.common.util.URI
cloneProject(org.eclipse.emf.common.util.URI sourceURI, java.lang.String targetName, java.lang.String targetDescription, java.util.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, java.lang.String targetName, java.util.Map<java.lang.String,java.lang.String> usedProjectTargetNames, java.lang.String targetDescription, java.util.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, 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 Teamwork Cloud 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 com.nomagic.ci.persistence.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.Collection<EsiUtils.EsiBranchInfo>
getBranches(ProjectDescriptor descriptor, ProgressStatus status)
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<CategoryInfo>
getCategories()
static java.util.Map<java.lang.String,java.util.List<ProjectDescriptor>>
getCategoriesToProjects()
Get categories for projects.static java.util.UUID
getCategory(java.lang.String resourceID)
Gets category ID for specified twc project resource ID.static java.lang.String
getCategoryID(java.lang.String resourceID)
Deprecated.static CategoryInfo
getCategoryInfoByResourceID(java.lang.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.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(com.nomagic.ci.persistence.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, com.nomagic.ci.persistence.versioning.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 Teamwork Cloud user name.static java.util.Set<java.lang.String>
getLoggedUserNames()
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, java.lang.String branchName, java.lang.String branchDescription)
Create new branch for given project.static java.util.List<java.lang.String>
getNotifyOnNewTags(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject)
Method returns application's notify tags about available project usage update.static EsiUtils.OfflineProjectDescriptor
getOfflineProject(Project project)
Returns offline project descriptor of the specified project or null if the project is not saved to offline.static java.util.Collection<EsiUtils.OfflineProjectDescriptor>
getOfflineProjects()
Returns all available offline project descriptors.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 void
getProjectDescriptorsWithBranches(ProjectDescriptor descriptor, java.util.Collection<ProjectDescriptor> descriptorsWithBranches, ProgressStatus status)
Collects all project descriptors with branch info for the given project descriptor into the provided collection.static java.util.Collection<ProjectDescriptor>
getProjectDescriptorsWithBranches(java.lang.Iterable<ProjectDescriptor> projectDescriptors)
Invocation of this method returns aCollection
ofProjectDescriptor
s of each branch in the givenprojectDescriptors
.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 com.nomagic.magicdraw.esi.session.ConnectionInfo
getServerInfo(Project project)
Get server information for given projectstatic ITeamworkService
getTeamworkService()
Get service for working with Teamwork Cloud.static java.util.Set<java.lang.String>
getUserNames()
Get all users if current user has rights to access user list.static java.util.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, java.util.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.static EsiUtils.OfflineProjectDescriptor
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, java.util.Collection<java.lang.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, java.util.Collection<java.lang.String> tags)
Method sets application's notify tags about available project usage update.static void
setProjectName(ProjectDescriptor project, java.lang.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.static java.util.Map<com.nomagic.ci.persistence.IAttachedProject,java.lang.Boolean>
updateRequiredProjectUsages(Project project)
This method updates project usages to newest version.
-
-
-
Method Detail
-
getTeamworkService
public static ITeamworkService getTeamworkService()
Get service for working with Teamwork Cloud.- Returns:
- service for working with Teamwork Cloud.
-
getLockService
@CheckForNull public static ILockProjectService getLockService(@CheckForNull Project project)
Provides api to check, request and release locks on various project data.- Returns:
- lock service.
-
createProject
@CheckForNull public static Project createProject(@Nonnull java.lang.String name, @CheckForNull java.lang.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, 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)
Commit project.- Parameters:
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.
-
exportEsiModule
@CheckForNull public static com.nomagic.ci.persistence.IAttachedProject exportEsiModule(Project project, java.util.Collection<Package> packages, java.lang.String description, java.lang.String moduleName) throws java.lang.Exception
Exports module.- Parameters:
project
- project.packages
- packages to export.description
- module description.moduleName
- name of module.- Returns:
- exported module attached project.
- Throws:
java.lang.Exception
- in case of some problem
-
getRemoteProjectDescriptors
public static java.util.List<ProjectDescriptor> getRemoteProjectDescriptors() throws java.lang.Exception
Returns descriptors of projects stored on server.- Returns:
- list of remote project descriptors.
- Throws:
java.rmi.RemoteException
- in case of some problemjava.lang.Exception
-
getVersions
public static java.util.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
public static void addCommitTags(java.util.List<java.lang.String> tags, ProjectDescriptor descriptor, long version)
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
public static java.util.List<java.lang.String> getCommitTags(ProjectDescriptor descriptor, long version)
Get tags names for project version.- Parameters:
descriptor
- project descriptor.version
- version.- Returns:
- list of tags for given version.
-
getCommitTagsInfo
public static java.util.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 java.util.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
public static void removeCommitTags(ProjectDescriptor descriptor, long version)
Remove all tags from project version.- Parameters:
descriptor
- project descriptor.version
- version.
-
updateProject
public static void updateProject(Project project)
Updates given project. Project is activated before update.- Parameters:
project
- teamwork project to update.
-
getProjectName
@CheckForNull public static java.lang.String getProjectName(org.eclipse.emf.common.util.URI locationURI)
Return project name for given URI.- Parameters:
locationURI
- project location.- Returns:
- project name.
-
setProjectName
public static void setProjectName(ProjectDescriptor project, java.lang.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
public static java.util.Set<CategoryInfo> getCategories()
- Returns:
- all categories from server.
-
getCategoriesToProjects
public static java.util.Map<java.lang.String,java.util.List<ProjectDescriptor>> getCategoriesToProjects() throws java.lang.Exception
Get categories for projects.- Returns:
- projects in categories.
- Throws:
java.lang.Exception
- in case of some problem
-
getCategory
@CheckForNull public static java.util.UUID getCategory(java.lang.String resourceID)
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 @CheckForNull public static java.lang.String getCategoryID(java.lang.String resourceID)
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
@CheckForNull public static CategoryInfo getCategoryInfoByResourceID(java.lang.String resourceID)
GetCategoryInfo
for specified twc project resource ID.- Parameters:
resourceID
- twc project resource ID- Returns:
- instance of
CategoryInfo
ornull
-
createCategory
public static void createCategory(java.lang.String name, java.lang.String description)
Create projects category in the server.- Parameters:
name
- category namedescription
- category description
-
assignProjectToCategory
public static void assignProjectToCategory(ProjectDescriptor project, java.lang.String... categories) throws java.lang.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:
java.lang.Exception
- in case of some problem
-
deleteCategory
public static void deleteCategory(java.lang.String name)
Delete category with given name.- Parameters:
name
- category name.
-
getBranches
public static java.util.Collection<EsiUtils.EsiBranchInfo> getBranches(ProjectDescriptor descriptor)
Get all branches for given project.- Parameters:
descriptor
- project descriptor.- Returns:
- branches for given project.
-
getBranches
public static java.util.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, java.lang.String branchName, java.lang.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:
java.lang.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, java.lang.String branchName, java.lang.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:
java.lang.RuntimeException
- in case network or server error occurs when creating branch.InsufficientPermissionsException
- if currently logged in user does not have Administer Resources permission
-
getDescriptorByBranchID
public static ProjectDescriptor getDescriptorByBranchID(ProjectDescriptor project, java.util.UUID branchID)
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, java.lang.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
public static void deleteBranch(ProjectDescriptor descriptor, java.lang.String branchName)
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, java.lang.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, 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
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
@CheckForNull public static Project convertToLocal(Project project, java.io.File file)
Convert given project to local, save and reopen it.- Parameters:
project
- project to convertfile
- project file- Returns:
- local project
-
getLoggedUserName
@CheckForNull public static java.lang.String getLoggedUserName()
Returns the currently logged Teamwork Cloud user name.- Returns:
- user name
-
getServerInfo
@CheckForNull public static com.nomagic.magicdraw.esi.session.ConnectionInfo getServerInfo(Project project)
Get server information for given project- Parameters:
project
- project- Returns:
- server information or null when project is not server project
-
getLoggedUserNames
public static java.util.Set<java.lang.String> getLoggedUserNames()
Get logged in users if current user has rights to access user list.- Returns:
- all user names.
-
getUserNames
public static java.util.Set<java.lang.String> 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 java.lang.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:
java.lang.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 java.lang.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:
java.lang.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
public static boolean isProjectChanged(Project project)
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 java.util.Collection<java.lang.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 java.util.Collection<java.lang.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 java.util.List<java.lang.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 java.util.Map<com.nomagic.ci.persistence.IAttachedProject,java.lang.Boolean> updateRequiredProjectUsages(Project project) throws java.lang.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:
java.lang.Exception
- in case of some problem- See Also:
isNotifyOnNew(Project, IAttachedProject)
,setNotifyOnNew(Project, IAttachedProject, boolean)
-
applyProjectState
public static EsiUtils.ApplyProjectStateResult applyProjectState(Project source, Project target) throws java.lang.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:
java.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 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 java.lang.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:
java.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 lockedjava.lang.RuntimeException
- 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
public static long getLastVersion(ProjectDescriptor descriptor)
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:
java.lang.RuntimeException
- in case provided descriptor is not valid for current server.
-
getProjectDescriptorsWithBranches
public static java.util.Collection<ProjectDescriptor> getProjectDescriptorsWithBranches(java.lang.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, java.lang.String targetName, java.lang.String targetDescription) throws java.lang.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:
java.lang.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, java.lang.String targetName, java.lang.String targetDescription, @CheckForNull java.lang.String targetCategoryID) throws java.lang.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:
java.lang.Exception
- exception in case clone fails
-
cloneProject
@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, @CheckForNull java.util.UUID targetCategoryID) throws java.lang.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:
java.lang.Exception
- exception in case clone fails
-
cloneProjectWithUsages
@CheckForNull public static org.eclipse.emf.common.util.URI cloneProjectWithUsages(org.eclipse.emf.common.util.URI sourceURI, java.lang.String targetName, java.util.Map<java.lang.String,java.lang.String> usedProjectTargetNames, java.lang.String targetDescription, @CheckForNull java.util.UUID targetCategoryID) throws java.lang.Exception
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. 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:
java.lang.Exception
- exception in case clone fails
-
getProjectDescriptorsWithBranches
public 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.- 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, java.util.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
public static java.util.UUID getBranchID(org.eclipse.emf.common.util.URI locationURI)
Gets project branch ID.- Parameters:
locationURI
- project location URI- Returns:
- branch ID
-
moveToUsedProject
public static void moveToUsedProject(Project project, java.util.Map<PackageableElement,Element> moveMap, boolean silentMode) throws java.lang.Exception
Moves 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:
java.lang.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 java.io.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:
java.lang.IllegalArgumentException
- if the specified project is not a TWC project.java.io.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 java.lang.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:
java.lang.Exception
- if offline project loading fails.
-
getOfflineProject
@CheckForNull public static EsiUtils.OfflineProjectDescriptor getOfflineProject(Project project)
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:
java.lang.IllegalArgumentException
- if the specified project is not a TWC project.
-
getOfflineProjects
public static java.util.Collection<EsiUtils.OfflineProjectDescriptor> getOfflineProjects()
Returns all available offline project descriptors.- Returns:
- collection of offline project descriptors.
-
-