| /***************************************************************************** |
| * Copyright (c)2020 CEA LIST, Committer Name, and others. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * CEA LIST - Initial API and implementation |
| * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr |
| * Gabriel Pedroza (CEA LIST) gabriel.pedroza@cea.fr |
| *****************************************************************************/ |
| package org.eclipse.pdp4eng.req.gdprananalysis.internal; |
| |
| import java.util.ArrayList; |
| |
| import org.eclipse.emf.common.command.Command; |
| import org.eclipse.emf.common.command.IdentityCommand; |
| import org.eclipse.emf.transaction.TransactionalEditingDomain; |
| import org.eclipse.papyrus.pdp4eng.req.profile.constraints.TraceabilityIndexer; |
| import org.eclipse.papyrus.pdp4eng.req.profile.pdp4engReqGDPR.ProcessRequirement; |
| import org.eclipse.papyrus.requirements.sysml14.traceability.commands.DerivationReqCreateCommand; |
| import org.eclipse.papyrus.sysml14.requirements.Requirement; |
| import org.eclipse.uml2.uml.DirectedRelationship; |
| import org.eclipse.uml2.uml.NamedElement; |
| |
| public class PDP4EngTraceabilityFactory { |
| public static Command addTraceabilityToLFR(TransactionalEditingDomain domain, ProcessRequirement processRequirement, Requirement createdRequirement ) { |
| ArrayList<DirectedRelationship> upwardLinks=TraceabilityIndexer.getInstance().getUpwardTraceabiltiy(processRequirement.getBase_NamedElement()); |
| if( upwardLinks==null||upwardLinks.size()==0) { |
| return IdentityCommand.INSTANCE; |
| } |
| |
| return new DerivationReqCreateCommand(domain,createdRequirement.getBase_Class() ,(NamedElement)upwardLinks.get(0).getTargets().get(0)); |
| } |
| |
| } |