| /******************************************************************************* |
| * Copyright (c) 2016 ALL4TEC & CEA LIST. |
| * 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: |
| * ALL4TEC & CEA LIST - initial API and implementation |
| ******************************************************************************/ |
| package org.polarsys.esf.core.profile.esfsafetyconcepts.util; |
| |
| import java.util.Iterator; |
| import java.util.List; |
| |
| import org.eclipse.emf.ecore.EObject; |
| import org.eclipse.uml2.uml.Model; |
| import org.eclipse.uml2.uml.Package; |
| import org.eclipse.uml2.uml.util.UMLUtil; |
| import org.polarsys.esf.esfsafetyconcepts.ISSafetyArtifacts; |
| |
| /** |
| * The utility class for dealing with SafetyArtifacts package. |
| * |
| * @author $Author: ymunoz $ |
| * @version $Revision: 168 $ |
| */ |
| public final class ESFSafetyConceptsUtil { |
| |
| /** |
| * Default constructor, private as it's a utility class. |
| */ |
| private ESFSafetyConceptsUtil() { |
| // Nothing to do |
| } |
| |
| /** |
| * Retrieve SafetyArtifacts. |
| * |
| * @param pESFModel ESFModel root |
| * @return The SafetyArtifacts |
| */ |
| public static ISSafetyArtifacts retrieveSafetyArtifacts(final Model pESFModel) { |
| ISSafetyArtifacts vSafetyArtifacts = null; |
| Boolean vFound = false; |
| List<Package> vPackagesList = pESFModel.getNestedPackages(); |
| Iterator<Package> vIterator = vPackagesList.iterator(); |
| |
| while (!vFound && vIterator.hasNext()) { |
| Package vPackage = vIterator.next(); |
| EObject vStereotypeApplication = UMLUtil.getStereotypeApplication(vPackage, ISSafetyArtifacts.class); |
| if (vStereotypeApplication != null) { |
| vFound = true; |
| vSafetyArtifacts = (ISSafetyArtifacts) vStereotypeApplication; |
| } |
| } |
| return vSafetyArtifacts; |
| } |
| |
| } |