Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 2c8119e2a7d9f4baa0e94fb71eae18feab28a5f6 (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
/*****************************************************************************
 * Copyright (c) 2017 CEA LIST and Others.
 *
 * 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:
 *	 Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.uml.service.types.helper.advice;

import org.eclipse.papyrus.uml.service.types.utils.ClassifierUtils;
import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Property;

/**
 * Association Composite Directed edit helper advice.
 */
public class AssociationCompositeDirectedEditHelperAdvice extends AssociationCompositeEditHelperAdvice {

	/**
	 * The source end must be navigable for directed association.
	 * {@inheritDoc}
	 * 
	 * @see org.eclipse.papyrus.uml.service.types.helper.advice.AssociationEditHelperAdvice#addSourceInModel(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Classifier, org.eclipse.uml2.uml.Classifier, org.eclipse.uml2.uml.Association)
	 */
	@Override
	protected void addSourceInModel(Property sourceEnd, Classifier owner, Classifier targetType, Association association) throws UnsupportedOperationException {
		ClassifierUtils.addOwnedAttribute(owner, sourceEnd);
		sourceEnd.setIsNavigable(true);
		sourceEnd.setLower(0);
		sourceEnd.setUpper(1);
	}

	/**
	 * <pre>
	 * {@inheritDoc}
	 *
	 * The currently created {@link Association} is Composite (manage by super class), and directed
	 * (meaning navigable in one direction only) which means the target end is owned by the association itself.
	 *
	 * Moreover this end name should not be set in that case, this latter rule is not followed here for now.
	 * </pre>
	 * 
	 * @see org.eclipse.papyrus.uml.service.types.helper.advice.AssociationEditHelperAdvice#addTargetInModel(org.eclipse.uml2.uml.Property, org.eclipse.uml2.uml.Classifier, org.eclipse.uml2.uml.Classifier, org.eclipse.uml2.uml.Association)
	 */
	@Override
	protected void addTargetInModel(Property targetEnd, Classifier owner, Classifier sourceType, Association association) {
		association.getOwnedEnds().add(targetEnd);
	}
}

Back to the top