Skip to content

Package: CDOBranchWrapper

CDOBranchWrapper

nameinstructionbranchcomplexitylinemethod
CDOBranchWrapper(InternalRepository, String)
M: 9 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
checkout(String, ECPProperties)
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getBranchPath()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getDefaultCheckoutName()
M: 14 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getName()
M: 18 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getProvider()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getRepository()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
toString()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011 Eike Stepper (Berlin, Germany) and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Eike Stepper - initial API and implementation
13: *******************************************************************************/
14: package org.eclipse.emf.ecp.cdo.internal.core;
15:
16: import org.eclipse.emf.ecp.core.ECPProvider;
17: import org.eclipse.emf.ecp.core.exceptions.ECPProjectWithNameExistsException;
18: import org.eclipse.emf.ecp.core.util.ECPCheckoutSource;
19: import org.eclipse.emf.ecp.core.util.ECPProperties;
20: import org.eclipse.emf.ecp.core.util.ECPUtil;
21: import org.eclipse.emf.ecp.spi.core.InternalRepository;
22:
23: /**
24: * Wraps are CDO branch for ECP, so it can be checked out.
25: *
26: * @author Eike Stepper
27: */
28: public class CDOBranchWrapper implements ECPCheckoutSource {
29:         private final InternalRepository repository;
30:
31:         private final String branchPath;
32:
33:         /**
34:          * Default constructor.
35:          *
36:          * @param repository the repository
37:          * @param branchPath the branch path
38:          */
39:         public CDOBranchWrapper(InternalRepository repository, String branchPath) {
40:                 this.repository = repository;
41:                 this.branchPath = branchPath;
42:         }
43:
44:         /** {@inheritDoc} */
45:         @Override
46:         public ECPProvider getProvider() {
47:                 return repository.getProvider();
48:         }
49:
50:         /** {@inheritDoc} */
51:         @Override
52:         public final InternalRepository getRepository() {
53:                 return repository;
54:         }
55:
56:         /**
57:          * Returns the branch path of the wrapped CDO branch.
58:          *
59:          * @return String of the path
60:          */
61:         public final String getBranchPath() {
62:                 return branchPath;
63:         }
64:
65:         /**
66:          * Return the name of the wrapped CDO branch.
67:          *
68:          * @return the name
69:          */
70:         public String getName() {
71:                 final int pos = branchPath.lastIndexOf('/');
72:•                if (pos == -1) {
73:                         return branchPath;
74:                 }
75:
76:                 return branchPath.substring(pos + 1);
77:         }
78:
79:         /** {@inheritDoc} */
80:         @Override
81:         public String getDefaultCheckoutName() {
82:                 return repository.getName() + "." + getName(); //$NON-NLS-1$
83:         }
84:
85:         /** {@inheritDoc} */
86:         @Override
87:         public void checkout(String projectName, ECPProperties projectProperties) throws ECPProjectWithNameExistsException {
88:                 projectProperties.addProperty("branchPath", branchPath); //$NON-NLS-1$
89:                 ECPUtil.getECPProjectManager().createProject(getRepository(), projectName, projectProperties);
90:         }
91:
92:         @Override
93:         public String toString() {
94:                 return getName();
95:         }
96: }