Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation')
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/Activator.java71
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/CategoryImpl.java105
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintCategoryImpl.java72
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java223
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintProviderImpl.java78
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ValidationRuleImpl.java231
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/WrongStereotypeException.java33
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Category.java64
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintProvider.java55
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintsCategory.java44
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintsManager.java55
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IValidationRule.java108
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Mode.java26
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Severity.java24
-rw-r--r--extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java255
15 files changed, 0 insertions, 1444 deletions
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/Activator.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/Activator.java
deleted file mode 100644
index c66ddb9e9dd..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/Activator.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model;
-
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class Activator extends AbstractUIPlugin {
-
- /**
- * PluginID
- * */
- public static final String PLUGIN_ID = "org.eclipse.papyrus.dsml.validation.model"; //$NON-NLS-1$
-
- // The shared instance
- private static Activator plugin;
-
- /**
- * The constructor
- */
- public Activator() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
- * )
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
- * )
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- super.stop(context);
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static Activator getDefault() {
- return plugin;
- }
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/CategoryImpl.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/CategoryImpl.java
deleted file mode 100644
index 9d40c238d94..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/CategoryImpl.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) patrick.Tessuier@cea.fr - modification
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category;
-
-/**
- * Implementation of a category interface.
- *
- *
- */
-public class CategoryImpl implements Category {
-
-
- private List<Category> subCategories = new ArrayList<Category>();
-
- private Category parentCategory;
- private String id;
-
-
- /**
- *
- * Constructor.
- *
- * @param name
- * the name of the category
- * @param parentCategory
- */
- public CategoryImpl(String name, Category parentCategory) {
- this.id = name;
- this.name = name;
- this.isMandatory = false;
- this.parentCategory = parentCategory;
- }
-
- /**
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category#getID()
- *
- */
- public String getID() {
- return this.id;
- }
-
- /**
- *
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category#getName()
- *
- */
- public String getName() {
- return this.name;
- }
-
- private String name;
-
- /**
- *
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category#isMandatory()
- *
- */
- public boolean isMandatory() {
- return this.isMandatory;
- }
-
- private boolean isMandatory;
-
- /**
- *
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category#getSubcategories()
- *
- */
- public List<Category> getSubcategories() {
- return subCategories;
- }
-
- /**
- *
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category#addSubcategories(java.util.List)
- *
- */
- public void addSubcategories(List<Category> subCategories) {
- this.subCategories.addAll(subCategories);
- }
-
- /**
- *
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category#getParentCategory()
- *
- */
- public Category getParentCategory() {
- return this.parentCategory;
- }
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintCategoryImpl.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintCategoryImpl.java
deleted file mode 100644
index 65adcbcf313..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintCategoryImpl.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier( CEA LIST) patrick.tessier@cea.fr - modification
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintsCategory;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IValidationRule;
-
-/**
- * Implementation of a constraint category interface.
- *
- *
- */
-public class ConstraintCategoryImpl extends CategoryImpl implements IConstraintsCategory {
-
- private List<IValidationRule> constraints = new ArrayList<IValidationRule>();
-
- private String categoriesList;
-
-
- /**
- *
- * Constructor.
- *
- * @param category
- */
- public ConstraintCategoryImpl(String name, Category parentCategory) {
- super(name, parentCategory);
- }
-
- /**
- *
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintsCategory#getCategoriesList()
- *
- */
- public String getCategoriesList() {
- return this.categoriesList;
- }
-
- /**
- *
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintsCategory#getConstraints()
- *
- */
- public List<IValidationRule> getConstraints() {
- return constraints;
- }
-
- /**
- *
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintsCategory#addConstraints(java.util.List)
- *
- * @param constraints
- */
- public void addConstraints(List<IValidationRule> constraints) {
- this.constraints.addAll(constraints);
- }
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java
deleted file mode 100644
index 768232e0df4..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintManagerImpl.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.impl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintProvider;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintsManager;
-import org.eclipse.papyrus.dsml.validation.model.profilenames.Utils;
-import org.eclipse.papyrus.uml.tools.utils.StaticProfileUtil;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Element;
-import org.eclipse.uml2.uml.NamedElement;
-import org.eclipse.uml2.uml.Profile;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * Management of validationRules assigned to the stereotypes specified in the
- * defined profile.
- * ContraintProvider=Category=profile or subprofile
- *
- *
- */
-public class ConstraintManagerImpl implements IConstraintsManager {
-
- private List<IConstraintProvider> constraintsProviders = new ArrayList<IConstraintProvider>();
-
- private Map<Stereotype, List<Constraint>> constraintsOfStereotype = new HashMap<Stereotype, List<Constraint>>();
- private Map<Constraint, ValidationRuleImpl> validationRuleMap = new HashMap<Constraint, ValidationRuleImpl>();
-
-
-
- public Map<Constraint, ValidationRuleImpl> getValidationRuleMap() {
- return validationRuleMap;
- }
-
- public Map<Stereotype, List<Constraint>> getConstraintsOfStereotype() {
- return constraintsOfStereotype;
- }
-
-
- private Category primeCategory;
-
- private IConstraintProvider constraintProvider;
-
-
-
- /**
- *
- * Constructor.
- *
- * @param profile
- */
- public ConstraintManagerImpl(Profile profile) {
-
- extractElements(profile);
-
- }
-
- /**
- * Method to get all the elements from the model, necessary to build a
- * plugin for validationRules validation.
- *
- * @param root
- * root profile for which the validation plugin will be generated
- */
- private void extractElements(Profile root) {
-
- // get the list of validationRules for each stereotype
- createStereotypeToConstraintsMapping(root);
-
- // the top profile becomes the prime category
- primeCategory = new CategoryImpl(root.getName().toLowerCase(), null);
-
- // construct all sub categories
- relateCategoriesWithConstraints(root, primeCategory);
- }
-
- /**
- * Recursive function to relate categories with the validationRules
- * a profile becomes a category= a constraint Provider
- * a stereotype becomes a category
- *
- * @param element
- * element for which function will find validationRules and its
- * related categories
- * @param category
- * category for a group of validationRules
- */
- private void relateCategoriesWithConstraints(Element element, Category category) {
-
- if (element instanceof Profile) {
- Profile profile = (Profile) element;
-
- // creation of a category
- ConstraintCategoryImpl subCategory = new ConstraintCategoryImpl(((Profile) element).getName(), category);
- // add the category to the list of category
- category.getSubcategories().add(subCategory);
- // creation of a provider
- // construct one constraint provider
- constraintProvider = new ConstraintProviderImpl();
- // associate validation to category to provider
- constraintProvider.getConstraintsCategories().add(subCategory);
- constraintsProviders.add(constraintProvider);
- StaticProfileUtil staticProfile = new StaticProfileUtil(profile);
- Utils.setStaticProfile(staticProfile);
- if (staticProfile.getDefinition() != null) {
- constraintProvider.setEPackage(staticProfile.getDefinition());
- }
- else if (profile.getDefinition() != null) {
- constraintProvider.setEPackage(profile.getDefinition());
- }
-
- // iterate on all direct element of the profile
- for (NamedElement subElement : ((Profile) element).getOwnedMembers()) {
-
- // this a profile
- if (subElement instanceof Profile) {
- this.relateCategoriesWithConstraints(subElement, subCategory);
- } else if (subElement instanceof Stereotype) {
-
- // create validation rules
- if (this.constraintsOfStereotype.get(subElement) != null) {
- for (Constraint constraint : this.constraintsOfStereotype.get(subElement)) {
- try {
- ValidationRuleImpl rule = new ValidationRuleImpl(constraint, subCategory);
- validationRuleMap.put(constraint, rule);
- subCategory.getConstraints().add(rule);
- } catch (WrongStereotypeException e) {
- e.printStackTrace();
- }
- }
- }
-
- }
- }
-
- }
- }
-
- /**
- * create a category from the owner category and the sub-element that will becomes a category
- *
- * @param category
- * the category owner
- * @param subElement
- * the element that will become a category
- * @return the category
- */
- protected Category createCategory(Category category, NamedElement subElement) {
- Category subCategory;
- subCategory = new CategoryImpl(category.getName() + "." + subElement.getName().toLowerCase(), category);
- return subCategory;
- }
-
- /**
- * Recursive method that finds validationRules of each stereotype defined in the
- * model.
- * it add validationRules only if there are stereotype validationRules
- *
- * @param profile
- * root profile with stereotypes for which validationRules defined in
- * the model will be found
- */
- private void createStereotypeToConstraintsMapping(Profile profile) {
-
- for (Element element : profile.allOwnedElements()) {
-
- if (element instanceof Constraint) {
- // don't restrict to elements that apply validation rule stereotype, see bug
- // 464249 - [..] The validation plugin generator silently ignores constraints without ValidationRule stereotype
- // if (element.getAppliedStereotype(IDSMLValidation.VALIDATIONRULE_STEREOTYPE) != null) {
-
- Element contextElement = ((Constraint) element).getContext();
-
- // get the stereotype to add the constraint
- if (contextElement instanceof Stereotype) {
- if (this.constraintsOfStereotype.keySet().contains(contextElement)) {
- this.constraintsOfStereotype.get(contextElement).add((Constraint) element);
- } else {
- List<Constraint> constraintsList = new ArrayList<Constraint>();
- constraintsList.add((Constraint) element);
- this.constraintsOfStereotype.put((Stereotype) contextElement, constraintsList);
- }
- }
- }
- }
- }
-
- /**
- *
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintsManager#getConstraintsProviders()
- *
- */
-
- public List<IConstraintProvider> getConstraintsProviders() {
- return this.constraintsProviders;
- }
-
-
- /**
- *
- * @see org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintsManager#getPrimeCategory()
- *
- */
- public Category getPrimeCategory() {
- return this.primeCategory;
- }
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintProviderImpl.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintProviderImpl.java
deleted file mode 100644
index e022bc0a3bd..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ConstraintProviderImpl.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr modification
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintProvider;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IConstraintsCategory;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Mode;
-
-/**
- * this is constraint constraint provider see extension point
- *
- */
-public class ConstraintProviderImpl implements IConstraintProvider {
-
- private List<IConstraintsCategory> constraintsCategories = new ArrayList<IConstraintsCategory>();
- private Mode mode;
- private boolean cache;
- private EPackage ePackage = null;
-
-
- /**
- *
- * Constructor.
- *
- */
- public ConstraintProviderImpl() {
-
- this.mode = Mode.Batch;
-
- this.cache = false;
-
- }
-
- public Mode getMode() {
- // TODO Auto-generated method stub
- return this.mode;
- }
-
- public boolean getCache() {
- // TODO Auto-generated method stub
- return this.cache;
- }
-
-
- public List<IConstraintsCategory> getConstraintsCategories() {
- // TODO Auto-generated method stub
- return constraintsCategories;
- }
-
-
- public void addConstraintCategories(
- List<IConstraintsCategory> constraintCategories) {
- // TODO Auto-generated method stub
- this.constraintsCategories.addAll(constraintCategories);
- }
-
- public EPackage getEPackage() {
- return ePackage;
- }
-
- public void setEPackage(EPackage ePackage) {
- this.ePackage = ePackage;
- }
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ValidationRuleImpl.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ValidationRuleImpl.java
deleted file mode 100644
index 0fb87c1252a..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/ValidationRuleImpl.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - modifications
- * Ansgar Radermacher (CEA LIST) ansgar.radermacher@cea.fr - clean-up, bug 464249 (constraints without ValidationRule stereotype)
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.util.Enumerator;
-import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;
-import org.eclipse.papyrus.dsml.validation.IDSMLValidation;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Category;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.IValidationRule;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Mode;
-import org.eclipse.papyrus.dsml.validation.model.elements.interfaces.Severity;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * Implementation of an interface relating to the ValidationRule interface.
- *
- */
-public class ValidationRuleImpl implements IValidationRule {
-
- /**
- *
- */
- private static final String CONSTRAINT_POSTFIX = "Constraint";
-
- /**
- *
- */
- private static final String DPT = ".";
-
- /**
- *
- */
- private static final String CONSTRAINT_PKG = "constraints";
-
- /**
- * Attributes of stereotype ValidationRule
- */
- private static final String SA_TARGET = "target"; //$NON-NLS-1$
-
- private static final String SA_ID = "id"; //$NON-NLS-1$
-
- private static final String SA_STATUS_CODE = "statusCode"; //$NON-NLS-1$
-
- private static final String SA_SEVERITY = "severity"; //$NON-NLS-1$
-
- private static final String SA_MODE = "mode"; //$NON-NLS-1$
-
- private static final String SA_IS_ENABLED_BY_DEFAULT = "isEnabledByDefault"; //$NON-NLS-1$
-
- private static final String SA_DESCRIPTION = "description"; //$NON-NLS-1$
-
- private static final String SA_MESSAGE = "message"; //$NON-NLS-1$
-
- private String id;
-
- private Constraint constraint;
-
- private Stereotype stereotype;
-
- private List<String> targets;
-
- private String implementingClass;
-
- /**
- * Constructor which takes as an parameter constraint from the model.
- *
- * @param constraint
- * constraint from the model
- * @throws WrongStereotypeException
- * exception in case when constraint passed to the constructor
- * is not stereotyped with IValidationRule stereotype
- */
- public ValidationRuleImpl(Constraint constraint) throws WrongStereotypeException {
- this.constraint = constraint;
- stereotype = constraint.getAppliedStereotype(IDSMLValidation.VALIDATIONRULE_STEREOTYPE);
- if (stereotype == null) {
- // throw new WrongStereotypeException(ERROR);
- }
- }
-
- /**
- * Constructor which takes as an parameter constraint from the model and
- * category to which this constraint will belong.
- *
- * @param constraint
- * constraint from the model
- * @param parentCategory
- * parent category
- * @throws WrongStereotypeException
- * exception in case when constraint passed to the constructor
- * is not stereotyped with IValidationRule stereotype
- */
- @SuppressWarnings("rawtypes")
- public ValidationRuleImpl(Constraint constraint, Category parentCategory) throws WrongStereotypeException {
-
- this(constraint);
-
- /*
- * If the value of id has not been declared by the user, generated id
- * value will be assigned and saved in the model.
- */
- if ((getStereoAttribValue(SA_ID) instanceof String) && ((String) getStereoAttribValue(SA_ID)).length() > 0) {
- id = (String) getStereoAttribValue(SA_ID);
- }
- else {
- String qname = constraint.getQualifiedName().replace("::", DPT);
- id = qname;
- }
-
- implementingClass = CONSTRAINT_PKG + DPT + this.getName() + CONSTRAINT_POSTFIX;
-
- // unused
- // this.contextID = parentCategory.getID();
-
- targets = new ArrayList<String>();
-
- /*
- * If there is no target specified, plugin will automatically assign as
- * a target for a constraint, those elements which are extended by the
- * stereotype to which the constraint applies.
- */
- Object targetsObj = getStereoAttribValue(SA_TARGET);
- if ((targetsObj instanceof EDataTypeUniqueEList) && ((EDataTypeUniqueEList) targetsObj).size() > 0) {
- for (Object target : (EDataTypeUniqueEList) targetsObj) {
- if (target instanceof String) {
- targets.add((String) target);
- }
- }
- }
- }
-
- public String getName() {
- return constraint.getName();
- }
-
- public String getID() {
- return id == null ? (String) getStereoAttribValue(SA_ID) : id;
- }
-
- public Integer getStatusCode() {
- Integer statusCode = (Integer) getStereoAttribValue(SA_STATUS_CODE);
- return statusCode == null ? new Integer(1) : statusCode;
- }
-
- public Severity getSeverity() {
- Object severityObj = getStereoAttribValue(SA_SEVERITY);
- if (severityObj instanceof Enumerator) {
- Enumerator severity = (Enumerator) severityObj;
-
- String severityType = severity.getName();
-
- if (severityType.compareTo(Severity.INFO.name()) == 0) {
- return Severity.INFO;
- } else if (severityType.compareTo(Severity.WARNING.name()) == 0) {
- return Severity.WARNING;
- } else if (severityType.compareTo(Severity.CANCEL.name()) == 0) {
- return Severity.CANCEL;
- }
- }
- return Severity.ERROR;
- }
-
- public String getImplementingClass() {
- return implementingClass;
- }
-
- public Mode getMode() {
- Object modeObj = (stereotype != null) ? constraint.getValue(stereotype, SA_MODE) : null;
- if (modeObj instanceof Enumerator) {
- Enumerator mode = (Enumerator) modeObj;
-
- String modeType = mode.getName();
-
- if (modeType.compareTo(Mode.Batch.name()) == 0) {
- return Mode.Batch;
- } else if (modeType.compareTo(Mode.Live.name()) == 0) {
- return Mode.Live;
- }
- }
- return Mode.Batch;
- }
-
- public boolean isEnabledByDefault() {
- Object enabledByDefault = getStereoAttribValue(SA_IS_ENABLED_BY_DEFAULT);
- return enabledByDefault instanceof Boolean ? ((Boolean) enabledByDefault).booleanValue() : true;
- }
-
- public String getMessage() {
- return (String) getStereoAttribValue(SA_MESSAGE);
- }
-
- public String getDescription() {
- return (String) getStereoAttribValue(SA_DESCRIPTION);
- }
-
- public List<String> getTargets() {
- return targets;
- }
-
- public Constraint getConstraint() {
- return this.constraint;
- }
-
- /**
- * Helper function that returns the value of the ValidationRule stereotype,
- * if applied to the underlying constraint
- * @param attributeName the name of the stereotype attribute
- * @return null or value of stereotype attribute
- */
- public Object getStereoAttribValue(String attributeName) {
- if (stereotype != null) {
- return constraint.getValue(stereotype, attributeName);
- }
- return null;
- }
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/WrongStereotypeException.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/WrongStereotypeException.java
deleted file mode 100644
index 14121c58c8d..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/impl/WrongStereotypeException.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - modifications
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.impl;
-
-/**
- * Exception which is thrown in case specific model element is not stereotype
- * with and expected stereotype.
- *
- *
- */
-public class WrongStereotypeException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- public WrongStereotypeException() {
- super("Element is not stereotyped with applicable stereotype");
- }
-
- public WrongStereotypeException(String msg) {
- super(msg);
- }
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Category.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Category.java
deleted file mode 100644
index 648fff008cc..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Category.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier( CEA LIST) patrick.tessier@cea.fr - modification
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.interfaces;
-
-import java.util.List;
-
-/**
- * Interface representing category from the EMF Validation Framework.
- *
- *
- */
-public interface Category {
-
- /**
- *
- *
- * @return ID of a category
- */
- public String getID();
-
- /**
- *
- *
- * @return Name of a category
- */
- public String getName();
-
- /**
- *
- * @return Information whether category is mandatory
- */
- public boolean isMandatory();
-
- /**
- *
- * @return Sub-categories of a given category
- */
- public List<Category> getSubcategories();
-
-
- /**
- * Adding list of sub-categories
- *
- * @param subCategories
- * list of sub-categories to add
- */
- public void addSubcategories(List<Category> subCategories);
-
- /**
- * @return Access to parent category
- */
- public Category getParentCategory();
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintProvider.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintProvider.java
deleted file mode 100644
index d5d28120bde..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintProvider.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - modification
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.interfaces;
-
-import java.util.List;
-
-import org.eclipse.emf.ecore.EPackage;
-
-/**
- * Interface representing constraint provider from the EMF Validation Framework
- */
-public interface IConstraintProvider {
- /**
- *
- * @return the mode of this provider
- */
- public Mode getMode();
-
- /**
- *
- * @return the cache of the provider
- */
- public boolean getCache();
-
-
- public EPackage getEPackage();
-
- public void setEPackage(EPackage ePackage);
-
- /**
- *
- * @return the list of categories
- */
- public List<IConstraintsCategory> getConstraintsCategories();
-
- /**
- * add categories
- *
- * @param constraintCategories
- * a list of categories
- */
- public void addConstraintCategories(
- List<IConstraintsCategory> constraintCategories);
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintsCategory.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintsCategory.java
deleted file mode 100644
index 94af58b573d..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintsCategory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - modification
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.interfaces;
-
-import java.util.List;
-
-/**
- * Interface representing constraint category from EMF Validation Framework
- *
- *
- */
-public interface IConstraintsCategory extends Category {
- /**
- *
- * @return constraints
- */
-
- public List<IValidationRule> getConstraints();
-
- /**
- *
- * @return the list of categories as a string
- */
- public String getCategoriesList();
-
-
- /**
- * add a list of constraint
- *
- * @param constraints
- */
- public void addConstraints(List<IValidationRule> constraints);
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintsManager.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintsManager.java
deleted file mode 100644
index dd5a037abde..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IConstraintsManager.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - modification
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.interfaces;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.papyrus.dsml.validation.model.elements.impl.ValidationRuleImpl;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Stereotype;
-
-/**
- * Interface which specifies methods for the manager taking charge of a
- * constraints defined in a profile.
- *
- */
-public interface IConstraintsManager {
-
-
- /**
- * Access to the list of constraint providers which are necessary for the
- * specification of a validation plugin.
- *
- * @return list of constraint providers
- */
- public List<IConstraintProvider> getConstraintsProviders();
-
- public Map<Constraint, ValidationRuleImpl> getValidationRuleMap();
-
-
- /**
- * Access to the prime category.
- *
- * @return prime category
- */
- public Category getPrimeCategory();
-
-
- /**
- *
- * @return the hashmap of constraint per stereotype
- */
- public Map<Stereotype, List<Constraint>> getConstraintsOfStereotype();
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IValidationRule.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IValidationRule.java
deleted file mode 100644
index c96f67e8bef..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/IValidationRule.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - modification
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.interfaces;
-
-import java.util.List;
-
-import org.eclipse.uml2.uml.Constraint;
-
-/**
- * Interface representing constraints specified in a profile model
- *
- *
- */
-public interface IValidationRule {
-
- /**
- * Getting the name of a constraint
- *
- * @return name of a constraint
- */
- public String getName();
-
- /**
- * Getting the id of a constraint
- *
- * @return id of a constraint
- */
- public String getID();
-
- /**
- * Getting the status code of a constraint
- *
- * @return status code of a constraint
- */
- public Integer getStatusCode();
-
- /**
- * Getting the severity of a constraint (ERROR, INFO, WARNING or CANCEL)
- *
- * @return severity of a constraint
- */
- public Severity getSeverity();
-
- /**
- * Getting the name of a Java class that implements the method validating
- * the constraint
- *
- * @return name of a Java class
- */
- public String getImplementingClass();
-
- /**
- * Getting the mode of a constraint (Batch or Live)
- *
- * @return mode of a constraint
- */
- public Mode getMode();
-
- /**
- * Getting the value that tells whether the constraint validation will be
- * triggered
- *
- * @return value specifying triggering of a constraint
- */
- public boolean isEnabledByDefault();
-
- /**
- * Getting the message that is displayed in the Properties view if the
- * constraint was violated
- *
- * @return message displayed in case when constraint was violated
- */
- public String getMessage();
-
- /**
- * Getting the natural language description of a constraint
- *
- * @return natural language description of a constraint
- */
- public String getDescription();
-
- /**
- * Getting the targets, namely the names of model elements against which the
- * constraint will be validated
- *
- * @return names of model elements for which the constraint applies
- */
- public List<String> getTargets();
-
-
- /**
- * Constraint from the model represented by this interface
- *
- * @return model constraint
- */
- public Constraint getConstraint();
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Mode.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Mode.java
deleted file mode 100644
index da15b7b08d2..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Mode.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - modification
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.interfaces;
-
-/**
- * Enumeration that specifies modes for the constraints validation: Batch -
- * constraints validation is triggered on user demand Live - constraints
- * validation is triggered every time when change in the model occures
- *
- *
- */
-public enum Mode {
-
- Batch, Live;
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Severity.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Severity.java
deleted file mode 100644
index 22234391b89..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/elements/interfaces/Severity.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - modification
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.elements.interfaces;
-
-/**
- * Enumeration that specifies different types of a constraint violation.
- *
- *
- */
-public enum Severity {
-
- INFO, WARNING, ERROR, CANCEL
-
-}
diff --git a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java b/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java
deleted file mode 100644
index d1018c3fd5d..00000000000
--- a/extraplugins/dsml.validation/org.eclipse.papyrus.dsml.validation.model/src/org/eclipse/papyrus/dsml/validation/model/profilenames/Utils.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2011 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:
- * Ernest Wozniak (CEA LIST) ernest.wozniak@cea.fr - Initial API and implementation
- * Patrick Tessier (CEA LIST) patrick.tessier@cea.fr - modifications
- *****************************************************************************/
-package org.eclipse.papyrus.dsml.validation.model.profilenames;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.papyrus.uml.tools.utils.StaticProfileUtil;
-import org.eclipse.uml2.uml.Constraint;
-import org.eclipse.uml2.uml.Namespace;
-import org.eclipse.uml2.uml.OpaqueExpression;
-import org.eclipse.uml2.uml.Stereotype;
-import org.eclipse.uml2.uml.ValueSpecification;
-
-/**
- * Provision of functionality for management of constraints.
- *
- *
- */
-public class Utils {
-
- private static final String DOT = "."; //$NON-NLS-1$
- private static final String JAVA_LANGUAGE = "JAVA"; //$NON-NLS-1$
- private static final String OCL_LANGUAGE = "OCL"; //$NON-NLS-1$
-
- /*
- * Map holding relations between String representing the qualified name of a
- * constraint and name of a package to which it belongs. Package name in
- * this case is built from the predefined prefix and names of the profiles
- * in which considered constraint is included. Name of this package is used
- * for the specification of a package in which java class implementing the
- * constraint is located.
- */
- private static Map<String, String> constraintToItsPackage = new HashMap<String, String>();
-
- /**
- * Retrieval of a java constraint body.
- *
- * @param valueSpecification
- * ValueSpecification which contains specification of a java code
- * validating the constraint.
- * @return string representing the java code validating constraint
- */
- public static String getJavaConstraintBody(ValueSpecification valueSpecification) {
-
- if (valueSpecification == null
- || !(valueSpecification instanceof OpaqueExpression)) {
- return null;
- }
-
- int index = 0;
- for (String language : ((OpaqueExpression) valueSpecification)
- .getLanguages()) {
- if (language.compareTo(JAVA_LANGUAGE) == 0) {
- return ((OpaqueExpression) valueSpecification).getBodies().get(index);
- }
- index++;
- }
-
- return null;
- }
-
- /**
- * This method performs check whether for specific constraint exists
- * specification of a java code.
- *
- * @param constraint
- * constraint for which check for existing java code is performed
- * @return true if there is an existing specification of a java code
- * validating constraint
- */
- public static Boolean hasSpecificationForJava(Constraint constraint) {
-
- ValueSpecification valueSpec = constraint.getSpecification();
-
- if (valueSpec == null || !(valueSpec instanceof OpaqueExpression)) {
- return false;
- }
-
- for (String language : ((OpaqueExpression) valueSpec).getLanguages()) {
- if (language.compareTo(JAVA_LANGUAGE) == 0) {
- return true;
- }
- }
-
- return false;
- }
-
- /**
- * return the qualified name of the stereotype that is the context of the constraint.
- *
- * @param constraint
- * the constraint
- * @return the qualified name of the constraint or ""
- */
- public static String getConstraintForStereotype(Constraint constraint) {
-
- Namespace nameSpace = constraint.getContext();
- if (nameSpace instanceof Stereotype) {
- if (staticProfile != null) {
- String basePackage = staticProfile.getBasePackage();
- if (basePackage != null) {
- String packageName = staticProfile.getPackageName();
- if (packageName != null) {
- return basePackage + DOT + packageName + DOT + nameSpace.getName();
- } else {
- return basePackage + DOT + nameSpace.getQualifiedName();
- }
- }
- }
- return nameSpace.getQualifiedName();
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Return true if the constraint is to validate something about a stereotype
- *
- * @param constraint
- * the constraint
- * @return true if the context of the constraint is a stereotype
- */
- public static Boolean isConstraintForStereotype(Constraint constraint) {
-
- Namespace nameSpace = constraint.getContext();
- if (nameSpace instanceof Stereotype) {
- return true;
- }
- return false;
-
- }
-
- /**
- * Retrieval of an OCL constraint body.
- *
- * @param constraint
- * constraint for which OCL body is retrieved
- * @return OCL constraint body
- */
- public static String getOCLConstraintBody(Constraint constraint) {
-
- int index = 0;
- ValueSpecification valueSpec = constraint.getSpecification();
-
- if (valueSpec != null && valueSpec instanceof OpaqueExpression) {
-
- for (String language : ((OpaqueExpression) valueSpec)
- .getLanguages()) {
-
- if (language.compareTo(OCL_LANGUAGE) == 0) {
- return ((OpaqueExpression) valueSpec).getBodies()
- .get(index);
- }
- index++;
- }
- }
-
- return null;
-
- }
-
- /**
- * Check whether there is specification of an OCL specification
- *
- * @param constraint
- * constraint for which check is performed
- * @return true if there is an existing specification of an OCL expression
- * validating the constraint
- */
- public static Boolean hasSpecificationForOCL(Constraint constraint) {
-
- ValueSpecification valueSpec = constraint.getSpecification();
-
- if (valueSpec == null || !(valueSpec instanceof OpaqueExpression)) {
- return false;
- }
-
- for (String language : ((OpaqueExpression) valueSpec).getLanguages()) {
- if (language.compareTo(OCL_LANGUAGE) == 0) {
- return true;
- }
- }
-
- return false;
- }
-
-
- /**
- * Method to insert the correspondence between the constraint and the
- * package in which the java class validating the constraint will be placed.
- *
- * @param constraint
- * constraint for which the package is being assigned
- * @param pkg
- * package in which java code validating the constraint will be
- * placed
- */
- public static void putMappnig(Constraint constraint, String pkg) {
-
- Utils.getConstraintToItsPackage().put(constraint.getQualifiedName(),
- pkg);
- }
-
- /**
- * Getter for constraintToItsPackage map.
- *
- * @return
- */
- public static Map<String, String> getConstraintToItsPackage() {
- return constraintToItsPackage;
- }
-
- /**
- * Setter for constraintToItsPackage map.
- *
- * @param constraintToItsPackage
- */
- public static void setConstraintToItsPackage(
- Map<String, String> constraintToItsPackage) {
- Utils.constraintToItsPackage = constraintToItsPackage;
- }
-
- /**
- * @return the top level package. It corresponds to the pluginID in lower case. Used by Acceleo template that generates the contents of selectors
- */
- public static String getTopPkg() {
- return pluginID.toLowerCase();
- }
-
- public static void setPluginID(String ID) {
- pluginID = ID;
- }
-
- public static boolean isStaticProfile() {
- return staticProfile.getDefinition() != null;
- }
-
- public static void setStaticProfile(StaticProfileUtil staticProfile) {
- Utils.staticProfile = staticProfile;
- }
-
- private static String pluginID;
-
- private static StaticProfileUtil staticProfile;
-}

Back to the top