-
Notifications
You must be signed in to change notification settings - Fork 24
Feature/background job implementation #300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
b1b9252
fea7118
c09cf6d
9a415ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ public class RepositoryService implements IRepositoryService { | |
|
|
||
| private final String destinationId; | ||
| private final URI uri; | ||
| private String result; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This variable is not used. |
||
|
|
||
| public RepositoryService(String destinationId, URI uri) { | ||
| this.destinationId = destinationId; | ||
|
|
@@ -292,13 +293,17 @@ public IAbapGitPullModifiedObjects getModifiedObjects(IProgressMonitor monitor, | |
|
|
||
| } | ||
|
|
||
| // CHNG: Change it back to original pull relation | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the comment. |
||
| @Override | ||
| public IAbapObjects pullRepository(IRepository existingRepository, String branch, String transportRequest, String user, String password, | ||
| IAbapGitPullModifiedObjects selectedObjectsToPull, IProgressMonitor monitor) { | ||
| URI uriToRepo = getURIFromAtomLink(existingRepository, IRepositoryService.RELATION_PULL); | ||
| IRestResource restResource = AdtRestResourceFactory.createRestResourceFactory().createResourceWithStatelessSession(uriToRepo, | ||
| this.destinationId); | ||
|
|
||
| URI uriToRepo = getURIFromAtomLink(existingRepository, IRepositoryService.RELATION_PULL_WITHOUT_BG); | ||
| URI backgroundUri = AdtBackgroundRunUriDiscoveryFactory.createBackgroundRunUriDiscovery(this.destinationId) | ||
| .getBackgroundRunUriIfAuthorized(monitor); | ||
| IRestResource restResource = AdtBackgroundRestResourceFactory.createBackgroundRestResourceFactory() | ||
|
||
| .createResourceWithStatelessSession(backgroundUri, uriToRepo, this.destinationId); | ||
| // IRestResource restResource = AdtRestResourceFactory.createRestResourceFactory().createResourceWithStatelessSession(uriToRepo, | ||
| // this.destinationId); | ||
| IContentHandler<IAbapGitPullRequest> requestContentHandlerV1 = new AbapGitPullRequestContentHandler(); | ||
| restResource.addContentHandler(requestContentHandlerV1); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import org.abapgit.adt.backend.IApackManifest; | ||
| import org.abapgit.adt.backend.IApackManifest.IApackDependency; | ||
|
|
@@ -14,11 +15,15 @@ | |
| import org.abapgit.adt.backend.model.agitpullmodifiedobjects.IAbapGitPullModifiedObjects; | ||
| import org.abapgit.adt.ui.AbapGitUIPlugin; | ||
| import org.abapgit.adt.ui.internal.i18n.Messages; | ||
| import org.abapgit.adt.ui.internal.repositories.IRepositoryModifiedObjects; | ||
| import org.abapgit.adt.ui.internal.util.AbapGitUIServiceFactory; | ||
| import org.abapgit.adt.ui.internal.wizards.AbapGitWizard.CloneData; | ||
| import org.eclipse.core.resources.IProject; | ||
| import org.eclipse.core.runtime.Assert; | ||
| import org.eclipse.core.runtime.IProgressMonitor; | ||
| import org.eclipse.core.runtime.IStatus; | ||
| import org.eclipse.core.runtime.Status; | ||
| import org.eclipse.core.runtime.jobs.Job; | ||
| import org.eclipse.jface.dialogs.DialogPage; | ||
| import org.eclipse.jface.dialogs.IMessageProvider; | ||
| import org.eclipse.jface.dialogs.IPageChangingListener; | ||
|
|
@@ -148,61 +153,63 @@ public void addPages() { | |
| @Override | ||
| public boolean performFinish() { | ||
|
|
||
| try { | ||
| getContainer().run(true, true, new IRunnableWithProgress() { | ||
| // Extracting variable earlier to ensure consistency in asynchronous code flow | ||
| Set<IRepositoryModifiedObjects> overwriteObjects = AbapGitWizardPull.this.pageOverwriteObjectsSelection.getSelectedObjects(); | ||
| Set<IRepositoryModifiedObjects> packageWarningObjects = AbapGitWizardPull.this.pagePackageWarningObjectsSelection | ||
| .getSelectedObjects(); | ||
|
|
||
| @Override | ||
| public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { | ||
| Job pullRepoJob = new Job(Messages.AbapGitWizard_task_pulling_repository) { | ||
| @Override | ||
| protected IStatus run(IProgressMonitor monitor) { | ||
| try { | ||
| monitor.beginTask(Messages.AbapGitWizard_task_pulling_repository, IProgressMonitor.UNKNOWN); | ||
|
|
||
| IRepositoryService repoService = RepositoryServiceFactory.createRepositoryService(AbapGitWizardPull.this.destination, | ||
| monitor); | ||
|
|
||
| //get the selected objects to be pulled | ||
| // Get the selected objects to be pulled | ||
| AbapGitWizardPull.this.repoToSelectedObjects = AbapGitUIServiceFactory.createAbapGitPullService() | ||
| .getSelectedObjectsToPullforRepo(AbapGitWizardPull.this.pageOverwriteObjectsSelection.getSelectedObjects(), | ||
| AbapGitWizardPull.this.pagePackageWarningObjectsSelection.getSelectedObjects()); | ||
| .getSelectedObjectsToPullforRepo(overwriteObjects, packageWarningObjects); | ||
|
|
||
| //pull the selected objects | ||
| // Pull the selected objects | ||
| repoService.pullRepository(AbapGitWizardPull.this.selRepoData, AbapGitWizardPull.this.selRepoData.getBranchName(), | ||
| AbapGitWizardPull.this.transportPage.getTransportRequestNumber(), AbapGitWizardPull.this.cloneData.user, | ||
| AbapGitWizardPull.this.cloneData.pass, | ||
| AbapGitWizardPull.this.repoToSelectedObjects.get(AbapGitWizardPull.this.selRepoData.getUrl()), monitor); | ||
|
|
||
| // Pull dependencies if any | ||
| if (AbapGitWizardPull.this.cloneData.hasDependencies()) { | ||
| pullDependencies(monitor, repoService); | ||
| } | ||
|
|
||
| return Status.OK_STATUS; | ||
| } catch (ResourceException e) { | ||
| return new Status(IStatus.ERROR, AbapGitUIPlugin.PLUGIN_ID, e.getMessage(), e); | ||
| } | ||
| } | ||
|
|
||
| private void pullDependencies(IProgressMonitor monitor, IRepositoryService repoService) { | ||
| for (IApackDependency apackDependency : AbapGitWizardPull.this.cloneData.apackManifest.getDescriptor() | ||
| .getDependencies()) { | ||
| if (apackDependency.requiresSynchronization()) { | ||
| IRepository dependencyRepository = repoService.getRepositoryByURL(AbapGitWizardPull.this.cloneData.repositories, | ||
| apackDependency.getGitUrl()); | ||
| if (dependencyRepository != null) { | ||
| repoService.pullRepository(dependencyRepository, IApackManifest.MASTER_BRANCH, | ||
| AbapGitWizardPull.this.transportPage.getTransportRequestNumber(), | ||
| AbapGitWizardPull.this.cloneData.user, AbapGitWizardPull.this.cloneData.pass, | ||
| AbapGitWizardPull.this.repoToSelectedObjects.get(dependencyRepository.getUrl()), monitor); | ||
| private void pullDependencies(IProgressMonitor monitor, IRepositoryService repoService) { | ||
| for (IApackDependency apackDependency : AbapGitWizardPull.this.cloneData.apackManifest.getDescriptor().getDependencies()) { | ||
| if (apackDependency.requiresSynchronization()) { | ||
| IRepository dependencyRepository = repoService.getRepositoryByURL(AbapGitWizardPull.this.cloneData.repositories, | ||
| apackDependency.getGitUrl()); | ||
| if (dependencyRepository != null) { | ||
| repoService.pullRepository(dependencyRepository, IApackManifest.MASTER_BRANCH, | ||
| AbapGitWizardPull.this.transportPage.getTransportRequestNumber(), AbapGitWizardPull.this.cloneData.user, | ||
| AbapGitWizardPull.this.cloneData.pass, | ||
| AbapGitWizardPull.this.repoToSelectedObjects.get(dependencyRepository.getUrl()), monitor); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| return true; | ||
| }; | ||
|
|
||
| pullRepoJob.setUser(true); // Shows the job in progress view | ||
| pullRepoJob.schedule(); | ||
|
|
||
| return true; | ||
|
Comment on lines
+212
to
+214
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we somehow trigger a refresh of the view once the job has finished ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the AbapGitView I see a updateView(true) after pull action is triggered however I also don't see it actually refreshing once the pull is done. Will check why thats happening
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please check the callback related logic in other comment. What are your thoughts on it. |
||
|
|
||
| } catch (InterruptedException e) { | ||
| return false; | ||
| } catch (InvocationTargetException e) { | ||
| ((WizardPage) getContainer().getCurrentPage()).setPageComplete(false); | ||
| ((WizardPage) getContainer().getCurrentPage()).setMessage(e.getTargetException().getMessage(), DialogPage.ERROR); | ||
| return false; | ||
| } catch (ResourceException e) { | ||
| ((WizardPage) getContainer().getCurrentPage()).setPageComplete(false); | ||
| ((WizardPage) getContainer().getCurrentPage()).setMessage(e.getMessage(), DialogPage.ERROR); | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the URI as per backend, pull/v2