Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e155365316a320c40f2fe9ec4d32aa2e69d40e0e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*******************************************************************************
 * Copyright (c) 2013 Atos
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Arthur Daussy - initial implementation
 *******************************************************************************/
package org.eclipse.papyrus.team.collaborative.strategy.stategies;

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.papyrus.team.collaborative.core.IExtendedURI;
import org.eclipse.papyrus.team.collaborative.core.utils.CollabFunctionsFactory;
import org.eclipse.papyrus.team.collaborative.core.utils.ModelsUtil;

import com.google.common.collect.Collections2;
import com.google.common.collect.Sets;


/**
 * Strategy that will lock the current triplet resource of the selection (uml,di,notation).
 * 
 * @author adaussy
 */
public class PapyrusCurrentResource extends AbstractResourceBaseStrategy {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.papyrus.team.collaborative.core.strategy.ILockingStrategy#getBusinessObject(java.util.Collection)
	 */
	public Set<IExtendedURI> getBusinessObject(Collection<EObject> eOjbects) {
		if(!eOjbects.isEmpty()) {
			ResourceSet ressourceSet = eOjbects.iterator().next().eResource().getResourceSet();
			Collection<URI> uris = new HashSet<URI>();
			for(EObject o : ModelsUtil.getRoots(eOjbects)) {
				URI uri = o.eResource().getURI();
				if(!uris.contains(uri)) {
					uris.add(uri);
					addExtraResources(ressourceSet, uris, uri);
				}
			}
			return Sets.newHashSet(Collections2.transform(uris, CollabFunctionsFactory.getURIToExtendedURI()));
		}
		return Collections.emptySet();
	}




}

Back to the top