Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2893 Add model validation rules from Thales-LAS-France_AMS #2911

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
168 changes: 167 additions & 1 deletion core/plugins/org.polarsys.capella.core.data.cs.validation/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<!--
Copyright (c) 2006, 2020 THALES GLOBAL SERVICES.
Copyright (c) 2006, 2024 THALES GLOBAL SERVICES.

This program and the accompanying materials are made available under the
terms of the Eclipse Public License 2.0 which is available at
Expand Down Expand Up @@ -930,6 +930,172 @@ Interface should be linked to the realized ExchangeItem.
</description>
</constraint>
</constraints>
<constraints
categories="capella.category/description.and.summary/mandatory.description">
<constraint
class="org.polarsys.capella.core.data.cs.validation.component.DSC_Component"
id="DS_1-1"
isEnabledByDefault="false"
lang="Java"
mode="Batch"
name="DS_1-1 - Components"
severity="WARNING"
statusCode="1">
<message>
{0} "{1}" must have a description
</message>
<description>
Ensure that Components have a description
</description>
<target
class="LogicalComponent">
</target>
<target
class="PhysicalComponent">
</target>
</constraint>
<constraint
class="org.polarsys.capella.core.data.cs.validation.interface_.DSC_Interface"
id="DS_1-5"
isEnabledByDefault="false"
lang="Java"
mode="Batch"
name="DS_1-5 - Interfaces"
severity="WARNING"
statusCode="1">
<message>
{0} "{1}" must have a description
</message>
<description>
Ensure that Interfaces have a description
</description>
<target
class="Interface">
</target>
</constraint>
<constraint
class="org.polarsys.capella.core.data.cs.validation.component.DSC_Actor"
id="DS_1-10"
isEnabledByDefault="false"
lang="Java"
mode="Batch"
name="DS_1-10 - Actors should have a description"
severity="WARNING"
statusCode="1">
<message>
{0} "{1}" must have a description.
</message>
<description>
Actors should have a description.
</description>
<target
class="Component">
</target>
</constraint>
</constraints>
<constraints
categories="capella.category/description.and.summary/mandatory.summary">
<constraint
class="org.polarsys.capella.core.data.cs.validation.component.SUM_Component"
id="DS_2-1"
isEnabledByDefault="false"
lang="Java"
mode="Batch"
name="DS_2-1 - Components"
severity="WARNING"
statusCode="1">
<message>
{0} "{1}" must have a summary
</message>
<description>
Ensure that Components have a summary
</description>
<target
class="LogicalComponent">
</target>
<target
class="PhysicalComponent">
</target>
</constraint>
<constraint
class="org.polarsys.capella.core.data.cs.validation.interface_.SUM_Interface"
id="DS_2-4"
isEnabledByDefault="false"
lang="Java"
mode="Batch"
name="DS_2-4 - Interfaces"
severity="WARNING"
statusCode="1">
<message>
{0} "{1}" must have a summary
</message>
<description>
Ensure that Interfaces have a summary
</description>
<target
class="Interface">
</target>
</constraint>
</constraints>
<constraints categories="capella.category/functional/coherence">
<constraint
class="org.polarsys.capella.core.data.cs.validation.component.CompsWithOneCE"
id="FC_1"
isEnabledByDefault="false"
lang="Java"
mode="Batch"
name="FC_1 - Components and actors should be connected by at least one CE"
severity="WARNING"
statusCode="1">
<message>
Component/Actor "{0}" should be connected by at least one Component Exchange.
</message>
<description>
Components and actors should be connected by at least one CE.
</description>
<target
class="Component">
</target>
</constraint>
<constraint
class="org.polarsys.capella.core.data.cs.validation.component.ActorNameUnicity"
id="FC_11"
isEnabledByDefault="false"
lang="Java"
mode="Batch"
name="FC_11 - Actors name shall be unique"
severity="WARNING"
statusCode="1">
<message>
Actor name shall be unique, "{0}" conflicting with "{1}".
</message>
<description>
Actors name shall be unique.
</description>
<target
class="Component">
</target>
</constraint>
<constraint
class="org.polarsys.capella.core.data.cs.validation.interface_.InterfaceEIsSameAsItsCEsEIs"
id="FC_12"
isEnabledByDefault="false"
lang="Java"
mode="Batch"
name="FC_12 - The interface EI shall be identical at SA to the CE EI allocated"
severity="WARNING"
statusCode="1">
<message>
Interface "{0}" has allocated EIs different from it's related ComponentExchanges EIs : EI "{1}" is allocated to {2} only
</message>
<description>
The interface EI shall be identical at SA to the CE EI allocated.
</description>
<target
class="Interface">
</target>
</constraint>
</constraints>
</constraintProvider>


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*******************************************************************************
* Copyright (c) 2016, 2024 Thales LAS France SAS.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.core.data.cs.validation.component;

import org.eclipse.emf.ecore.EObject;
import org.polarsys.capella.core.data.cs.Component;
import org.polarsys.capella.core.validation.rule.AbstractNameUnicity;

/**
* Functional Chains shall start from an End User and finish with an End User
*/
public class ActorNameUnicity extends AbstractNameUnicity {

@Override
protected boolean testMetaClass(final EObject theTarget) {
return ((theTarget instanceof Component) && (((Component) theTarget).isActor()));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*******************************************************************************
* Copyright (c) 2014, 2024 Thales LAS France SAS.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.core.data.cs.validation.component;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.validation.IValidationContext;
import org.polarsys.capella.core.data.capellacore.Classifier;
import org.polarsys.capella.core.data.capellacore.Feature;
import org.polarsys.capella.core.data.cs.Component;
import org.polarsys.capella.core.data.ctx.SystemComponent;
import org.polarsys.capella.core.data.fa.ComponentPort;
import org.polarsys.capella.core.data.la.LogicalComponent;
import org.polarsys.capella.core.data.pa.PhysicalComponent;
import org.polarsys.capella.core.data.pa.PhysicalComponentNature;
import org.polarsys.capella.core.data.pa.PhysicalNode;
import org.polarsys.capella.core.validation.rule.AbstractValidationRule;

/**
* A component/actor should be connected by at least one CE.
*/
public class CompsWithOneCE extends AbstractValidationRule {

@Override
public IStatus validate(IValidationContext ctx) {
if (((ctx.getTarget() instanceof Component) && (((Component) ctx.getTarget()).isActor()))
|| ctx.getTarget() instanceof SystemComponent || ctx.getTarget() instanceof LogicalComponent
|| this.isPcButNotNode(ctx.getTarget())) {
Classifier cl = (Classifier) ctx.getTarget();

boolean atLeastOnePortFound = false;
for (Feature feature : cl.getOwnedFeatures()) {
if (feature instanceof ComponentPort) {
ComponentPort p = (ComponentPort) feature;
if (p.getComponentExchanges().size() > 0) {
atLeastOnePortFound = true;
break;
}
}
}
if (!atLeastOnePortFound)
return ctx.createFailureStatus(new Object[] { cl.getName() });
}

return ctx.createSuccessStatus();
}

private boolean isPcButNotNode(EObject obj) {
if (obj instanceof PhysicalNode) {
return false;
}
if (obj instanceof PhysicalComponent) {
PhysicalComponent comp = (PhysicalComponent) obj;
if (comp.getNature() == PhysicalComponentNature.NODE) {
return false;
}
return true;
}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*******************************************************************************
* Copyright (c) 2016, 2024 Thales LAS France SAS.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.core.data.cs.validation.component;

import org.eclipse.emf.ecore.EObject;
import org.polarsys.capella.core.data.cs.Component;
import org.polarsys.capella.core.validation.rule.AbstractDescriptionCheckingRule;
import org.polarsys.capella.core.validation.rule.AbstractValidationRuleOnSystemAnalysis;

/**
* Actors should have a description
*/
public class DSC_Actor extends AbstractDescriptionCheckingRule {

@Override
protected boolean isApplicable(final EObject eObj) {
if (eObj instanceof Component) {
final Component comp = (Component) eObj;

if (comp.isActor())
return AbstractValidationRuleOnSystemAnalysis.belongsToSA(eObj);
return false;
}
return false;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright (c) 2013, 2024 Thales LAS France SAS.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.core.data.cs.validation.component;

import org.polarsys.capella.core.validation.rule.AbstractDescriptionCheckingRule;

/**
* DSC: Description
*/
public class DSC_Component extends AbstractDescriptionCheckingRule {
// Empty class, needed for reference in the plugin definition.
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*******************************************************************************
* Copyright (c) 2013, 2024 Thales LAS France SAS.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Thales - initial API and implementation
*******************************************************************************/
package org.polarsys.capella.core.data.cs.validation.component;

import org.polarsys.capella.core.validation.rule.AbstractSummaryCheckingRule;

/**
* SUM: Summary
*/
public class SUM_Component extends AbstractSummaryCheckingRule {
// Empty class, needed for reference in the plugin definition.
}
Loading