Skip to content

Commit e6ef364

Browse files
committed
ST6RI-178 Added model load from branches to Eclipse
1 parent 6e61024 commit e6ef364

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

org.omg.sysml.xtext.ui/src/org/omg/sysml/xtext/ui/handlers/PullRepositoryProject.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.Optional;
2929
import java.util.Properties;
3030
import java.util.Set;
31+
import java.util.UUID;
3132
import java.util.stream.Stream;
3233

3334
import org.eclipse.core.commands.AbstractHandler;
@@ -49,7 +50,6 @@
4950
import org.eclipse.ui.handlers.HandlerUtil;
5051
import org.eclipse.xtext.ui.resource.IResourceSetProvider;
5152
import org.omg.sysml.util.repository.EObjectUUIDTracker;
52-
import org.omg.sysml.ApiException;
5353
import org.omg.sysml.util.repository.APIModel;
5454
import org.omg.sysml.util.repository.EMFModelDelta;
5555
import org.omg.sysml.util.repository.ProjectRepository;
@@ -66,6 +66,7 @@ public class PullRepositoryProject extends AbstractHandler {
6666

6767
public static final String REPOSITORY_CONFIGURATION_FILE = ".settings/org.omg.sysml.remote.properties";
6868
private static final String REPOSITORY_PROJECT_ID_PROPERTY = "remote.projectId";
69+
private static final String REPOSITORY_BRANCH_ID_PROPERTY = "remote.branchId";
6970
private static final String REPOSITORY_BASE_URL_PROPERTY = "base.url";
7071

7172
@Inject
@@ -115,7 +116,8 @@ private void tryPullRemoteFor(IProject project, IProgressMonitor monitor) {
115116
properties.load(repositoryPropertiesFile.getContents());
116117

117118
String repositoryUrl = properties.getProperty(REPOSITORY_BASE_URL_PROPERTY);
118-
String projectName = properties.getProperty(REPOSITORY_PROJECT_ID_PROPERTY);
119+
String projectId = properties.getProperty(REPOSITORY_PROJECT_ID_PROPERTY);
120+
String branchId = properties.getProperty(REPOSITORY_BRANCH_ID_PROPERTY);
119121
String targetPath = project.getFullPath().toString();
120122

121123
Set<IFile> libraryResources = new HashSet<>();
@@ -128,9 +130,14 @@ private void tryPullRemoteFor(IProject project, IProgressMonitor monitor) {
128130
tracker.trackLibraryUUIDs(resourceSet.getResources());
129131

130132
ProjectRepository projectRepository = new ProjectRepository(repositoryUrl);
131-
RemoteProject repositoryProject = projectRepository.getProjectById(projectName);
133+
RemoteProject remoteProject = projectRepository.getProjectById(projectId);
132134

133-
RemoteBranch defaultBranch = repositoryProject.getDefaultBranch();
135+
final RemoteBranch defaultBranch;
136+
if (branchId == null) {
137+
defaultBranch = remoteProject.getDefaultBranch();
138+
} else {
139+
defaultBranch = remoteProject.getBranch(UUID.fromString(branchId));
140+
}
134141
Revision headRevision = defaultBranch.getHeadRevision();
135142
APIModel model = headRevision.fetchRemote();
136143
EMFModelRefresher repositoryFetcher = new EMFModelRefresher(model, tracker);
@@ -139,8 +146,6 @@ private void tryPullRemoteFor(IProject project, IProgressMonitor monitor) {
139146
}
140147
} catch (IOException | CoreException e) {
141148
e.printStackTrace();
142-
} catch (UnsupportedOperationException e) {
143-
e.printStackTrace();
144149
}
145150
}
146151

0 commit comments

Comments
 (0)