Package com.nomagic.magicdraw.esi
Interface EsiUtils
@OpenApiAll
public interface 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
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA structure that is produced by theapplyProjectState(Project, Project)and which holds information about the result of the operationstatic interfaceBranch information.static classOffline project descriptor. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.nomagic.magicdraw.esi.project.project.EsiProjectRepositorystatic final String -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommitTags(List<String> tags, ProjectDescriptor descriptor, long version) Add tags for given version.default com.nomagic.ci.persistence.IPrimaryProjectAdd project to the Teamwork Cloud server and open it.com.nomagic.ci.persistence.IPrimaryProjectAdd project to the Teamwork Cloud server and open it.static com.nomagic.ci.persistence.IPrimaryProjectaddToESI(Project project, String esiProjectName, String category, String comment, List<String> tags, Collection<ResolveLocalModuleInfo> resolveInfos) Add project to the Teamwork Cloud server and open itstatic com.nomagic.ci.persistence.IPrimaryProjectaddToESI(Project project, String esiProjectName, String category, String comment, List<String> tags, Collection<ResolveLocalModuleInfo> resolveInfos, com.nomagic.magicdraw.esi.session.RepositorySession session) 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.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.voidassignProjectToCategory(ProjectDescriptor project, String... categories) Adds or remove project to/from categories.org.eclipse.emf.common.util.URIcloneProject(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.org.eclipse.emf.common.util.URIcloneProject(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.org.eclipse.emf.common.util.URIcloneProjectWithUsages(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 voidcommitProject(Project project, String comment, Collection<Element> unlockElements, Collection<ModuleUsage> unlockModules, boolean unlockDecomposition, List<String> tags) Commit project.static voidcommitProject(Project project, String comment, Collection<Element> unlockElements, Collection<ModuleUsage> unlockModules, boolean unlockDecomposition, List<String> tags, ProgressStatus monitor) Commit project with progress.static ProjectconvertToLocal(Project project, File file) Convert given project to local, save and reopen it.voidcreateBranch(ProjectDescriptor descriptor, long version, String branchName, String branchDescription) Create new branch for given project.createCategory(String name, String description) Create projects category in the server.createProject(String name, String category) Create Teamwork Cloud project.static ProjectDescriptorReturns descriptor of project with given idvoiddeleteBranch(ProjectDescriptor descriptor, String branchName) Delete project branch.voiddeleteCategory(String name) Delete category with given name.voiddeleteProject(ProjectDescriptor project) Delete project from repository.static com.nomagic.ci.persistence.IAttachedProjectexportEsiModule(Project project, Collection<Package> packages, String description, String moduleName) Exports module.static EsiUtilsget()Get instance from active sessionstatic EsiUtilsget(com.nomagic.ci.persistence.IPrimaryProject primary) Get instance for provided project sessionList<com.nomagic.esi.api.info.TagInfo> getAllCommitTagsInfo(ProjectDescriptor descriptor) Get all tags for project.getBranches(ProjectDescriptor descriptor) Get all branches for given project.getBranches(ProjectDescriptor descriptor, ProgressStatus status) Get all branches for given project.static UUIDgetBranchID(org.eclipse.emf.common.util.URI locationURI) Gets project branch ID.Get categories for projects.getCategoryInfoByResourceID(String resourceID) GetCategoryInfofor specified twc project resource ID.getCommitTags(ProjectDescriptor descriptor, long version) Get tags names for project version.List<com.nomagic.esi.api.info.TagInfo> getCommitTagsInfo(ProjectDescriptor descriptor, long version) Get tags for project version.static EsiUtils.EsiBranchInfogetCurrentBranch(com.nomagic.ci.persistence.IProject project) Gets branch information for the given TWC project part.static ProjectDescriptorgetDescriptorByBranchID(ProjectDescriptor project, UUID branchID) Get project descriptor for given branch.getDescriptorForBranch(ProjectDescriptor project, String branchName) Get project descriptor for given branch.static ProjectDescriptorgetDescriptorForVersion(ProjectDescriptor projectDescriptor, com.nomagic.ci.persistence.versioning.IVersionDescriptor versionDescriptor) Get descriptor for specific version.static org.eclipse.emf.common.util.URIgetEMFURI(ProjectDescriptor descriptor) List<com.nomagic.ci.persistence.versioning.IVersionDescriptor> getIVersionDescriptors(org.eclipse.emf.common.util.URI locationUri) Versions of given projectlonggetLastVersion(ProjectDescriptor descriptor) Get last project version number.com.nomagic.ci.persistence.versioning.IVersionDescriptorgetLastVersionDescriptor(ProjectDescriptor descriptor) Get last project version descriptor.static ILockProjectServicegetLockService(Project project) Provides api to check, request and release locks on various project data.Returns the currently logged Teamwork Cloud user name.Get logged in users if current user has rights to access user list.getNewEsiBranch(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.getPasswordManager(ProjectDescriptor descriptor) Gets password manager for command line utilities If session is not present thennullwill be returned.getProjectDescriptorByQualifiedName(String qualifiedName) Returns project descriptor for given project qualified name.static Collection<ProjectDescriptor> getProjectDescriptorsForEachBranch(ProjectDescriptor descriptor, Collection<EsiUtils.EsiBranchInfo> branches, ProgressStatus status) voidgetProjectDescriptorsWithBranches(ProjectDescriptor descriptor, Collection<ProjectDescriptor> descriptorsWithBranches) Collects all project descriptors with branch info for the given project descriptor into the provided collection.voidgetProjectDescriptorsWithBranches(ProjectDescriptor descriptor, Collection<ProjectDescriptor> descriptorsWithBranches, ProgressStatus status) Collects all project descriptors with branch info for the given project descriptor into the provided collection.getProjectDescriptorsWithBranches(Iterable<ProjectDescriptor> projectDescriptors) Invocation of this method returns aCollectionofProjectDescriptors of each branch in the givenprojectDescriptors.getProjectDescriptorsWithBranchesByProjectID(List<String> projectIDs) Returns project descriptors with available branches for given project IDs.default StringgetProjectIdByQualifiedName(String qualifiedName) Returns project id.getProjectName(org.eclipse.emf.common.util.URI locationURI) Return project name for given URI.Returns descriptors of projects stored on server.static UUIDgetResourceID(ProjectDescriptor projectDescriptor) static ConnectionInfogetServerInfo(Project project) Get server information for given projectstatic ITeamworkServiceGet service for working with Teamwork Cloud.Get all users if current user has rights to access user list.com.nomagic.ci.persistence.versioning.IVersionDescriptorgetVersion(Project project) Current version of given projectdefault List<com.nomagic.ci.persistence.versioning.IVersionDescriptor> getVersions(ProjectDescriptor descriptor) Get all versions of given project.static booleanisModuleUsageNew(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 booleanisNotifyOnNew(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject) Method returns if application should notify about available project usage update.static booleanisProjectChanged(Project project) Method returnstruewhen twcloud project has some changed objects in its resource, or local project'sStateChangeHandler.isDirty(IProject)returnstruestatic ProjectloadFromOffline(EsiUtils.OfflineProjectDescriptor descriptor, ProgressStatus status) Loads the offline project.static voidmoveToUsedProject(Project project, Map<PackageableElement, Element> moveMap, boolean silentMode) Moves elements to used project(s).voidremoveCommitTags(ProjectDescriptor descriptor, long version) Remove all tags from project version.saveToOffline(Project project, ProgressStatus status, boolean delete) Saves the specified project to offline.static voidsetNotifyOnNew(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject, boolean notifyOnNew) Method sets if application should notify about available project usage update.static voidsetNotifyOnNewTags(com.nomagic.ci.persistence.IPrimaryProject project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject, Collection<String> tags) Method sets application's notify tags about available project usage update.static voidsetNotifyOnNewTags(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject, Collection<String> tags) Method sets application's notify tags about available project usage update.static voidsetProjectName(ProjectDescriptor project, String newName) Rename project.static voidupdateModule(Project project, com.nomagic.ci.persistence.IAttachedProject module, ProjectDescriptor descriptor, long version) Change given module to another version or branch.static voidupdateModule(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 voidupdateProject(Project project) Updates given project.updateRequiredProjectUsages(Project project) This method updates project usages to newest version.
-
Field Details
-
mProjectRepository
static final com.nomagic.magicdraw.esi.project.project.EsiProjectRepository mProjectRepository -
NOTIFY_TAG_SEPARATOR
-
-
Method Details
-
get
Get instance from active session- Returns:
- EsiUtils instance
-
get
Get instance for provided project session- Parameters:
primary- project- Returns:
- EsiUtils instance
-
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 Project createProject(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
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.nullmeans 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.nullmeans that no project usages should be unlocked.unlockDecomposition- true if decomposition needs to be unlocked when committing.tags- version tags to set.
-
commitProject
static void commitProject(Project project, String comment, @CheckForNull Collection<Element> unlockElements, @CheckForNull Collection<ModuleUsage> unlockModules, boolean unlockDecomposition, @CheckForNull List<String> tags, @CheckForNull ProgressStatus monitor) Commit project with progress.- Parameters:
project- projectcomment- comment.unlockElements- elements to unlock when committing. The collection specifies which locked elements should be unlocked after successful commit.nullmeans 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.nullmeans that no project usages should be unlocked.unlockDecomposition- true if decomposition needs to be unlocked when committing.tags- version tags to set.monitor- progress status monitor.
-
exportEsiModule
@CheckForNull 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
-
getProjectIdByQualifiedName
Returns project id.- Parameters:
qualifiedName- project qualified name, unique name constructed from project name and it's branches.E.g:
"MyProject" with no branches = "MyProject"
"MyProject" branch ["release"] = "MyProject##release"
"MyProject" branch with subbranch ["release", "sp1"] = "MyProject##release##sp1"- Returns:
- project id
- Throws:
Exception- in case of some error
-
getProjectDescriptorByQualifiedName
@CheckForNull ProjectDescriptor getProjectDescriptorByQualifiedName(String qualifiedName) throws Exception Returns project descriptor for given project qualified name.- Parameters:
qualifiedName- project qualified name, unique name constructed from project name and its branches. Examples: "MyProject" with no branches = "MyProject" "MyProject" branch ["release"] = "MyProject##release" "MyProject" branch with subbranch ["release", "sp1"] = "MyProject##release##sp1"- Returns:
- ProjectDescriptor
- Throws:
Exception- in case of some error
-
getVersions
default List<com.nomagic.ci.persistence.versioning.IVersionDescriptor> getVersions(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
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
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
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
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
Set<CategoryInfo> getCategories()- Returns:
- all categories from server.
-
getCategoriesToProjects
Get categories for projects.- Returns:
- projects in categories.
- Throws:
Exception- in case of some problem
-
getCategoryInfoByResourceID
GetCategoryInfofor specified twc project resource ID.- Parameters:
resourceID- twc project resource ID- Returns:
- instance of
CategoryInfoornull
-
createCategory
Create projects category in the server.- Parameters:
name- category namedescription- category description
-
assignProjectToCategory
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
Get all branches for given project.- Parameters:
descriptor- project descriptor.status- progress status.- Returns:
- branches for given project.
-
createBranch
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
-
getNewEsiBranch
EsiUtils.EsiBranchInfo getNewEsiBranch(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.
-
getResourceID
-
getDescriptorForBranch
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
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
default 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
com.nomagic.ci.persistence.IPrimaryProject addToESI(Project project, String esiProjectName, boolean addStandardSystemProfiles) 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.addStandardSystemProfiles- if to add standard/system profiles too.- Returns:
- opened teamwork cloud project.
- Throws:
com.nomagic.ci.persistence.PersistenceException- in case of some problem
-
addToESI
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, @CheckForNull com.nomagic.magicdraw.esi.session.RepositorySession session) throws com.nomagic.ci.persistence.PersistenceException - Throws:
com.nomagic.ci.persistence.PersistenceException
-
addToESI
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
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
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
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 usage setting is applied.iAttachedProject- Usage's attached project to which setting is applied.notifyOnNew- Should notification be shown.
-
isNotifyOnNew
static boolean isNotifyOnNew(Project project, com.nomagic.ci.persistence.IAttachedProject iAttachedProject) Method returns if application should notify about available project usage update. Returnfalseby 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
falseby default.
-
isProjectChanged
Method returnstruewhen 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:
truewhen project is changed
-
setNotifyOnNewTags
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
static void setNotifyOnNewTags(com.nomagic.ci.persistence.IPrimaryProject 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 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
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:
trueif the usage from specifed project exists to specified to project and if the specified to project is notnulland if the usage is new (as defined above). Returnfalseothewise
-
updateRequiredProjectUsages
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 totrueare 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
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
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 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
Collection<ProjectDescriptor> getProjectDescriptorsWithBranches(Iterable<ProjectDescriptor> projectDescriptors) Invocation of this method returns aCollectionofProjectDescriptors of each branch in the givenprojectDescriptors.- Parameters:
projectDescriptors- descriptors of the projects, whose branchProjectDescriptors should be returned- Returns:
- project descriptors for each branch of the given
projectDescriptors
-
getProjectDescriptorsWithBranchesByProjectID
Collection<ProjectDescriptor> getProjectDescriptorsWithBranchesByProjectID(List<String> projectIDs) throws Exception Returns project descriptors with available branches for given project IDs.- Parameters:
projectIDs- list of project IDs- Returns:
- project descriptors with available branches
- Throws:
Exception- if any occurs
-
cloneProject
@CheckForNull 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
@CheckForNull 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 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
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
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
-
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
Collection<EsiUtils.OfflineProjectDescriptor> getOfflineProjects()Returns all available offline project descriptors.- Returns:
- collection of offline project descriptors.
-
getProjectDescriptorsForEachBranch
static Collection<ProjectDescriptor> getProjectDescriptorsForEachBranch(ProjectDescriptor descriptor, Collection<EsiUtils.EsiBranchInfo> branches, ProgressStatus status) -
getBranchID
Gets project branch ID.- Parameters:
locationURI- project location URI- Returns:
- branch ID
-
moveToUsedProject
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 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 thennullwill be returned.- Parameters:
project- project part- Returns:
- branch information
-
getPasswordManager
Gets password manager for command line utilities If session is not present thennullwill be returned.- Parameters:
descriptor- versionable project descriptor- Returns:
- PasswordManager or null if session is not initialized
-
getEMFURI
-
saveToOffline
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 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.
-
createProjectDescriptorById
Returns descriptor of project with given id- Parameters:
id- project id- Returns:
- descriptor
- Throws:
Exception
-
getIVersionDescriptors
List<com.nomagic.ci.persistence.versioning.IVersionDescriptor> getIVersionDescriptors(org.eclipse.emf.common.util.URI locationUri) Versions of given project- Parameters:
locationUri- location uri.- Returns:
- versions
-
getVersion
Current version of given project- Parameters:
project- project- Returns:
- versions
-