Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/qompass/designer/org.eclipse.papyrus.qompass.designer.validation/src/org/eclipse/papyrus/qompass/designer/validation/constraints/SystemHasNoPorts.java')
-rw-r--r--extraplugins/qompass/designer/org.eclipse.papyrus.qompass.designer.validation/src/org/eclipse/papyrus/qompass/designer/validation/constraints/SystemHasNoPorts.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/extraplugins/qompass/designer/org.eclipse.papyrus.qompass.designer.validation/src/org/eclipse/papyrus/qompass/designer/validation/constraints/SystemHasNoPorts.java b/extraplugins/qompass/designer/org.eclipse.papyrus.qompass.designer.validation/src/org/eclipse/papyrus/qompass/designer/validation/constraints/SystemHasNoPorts.java
new file mode 100644
index 00000000000..dd2bcc2a892
--- /dev/null
+++ b/extraplugins/qompass/designer/org.eclipse.papyrus.qompass.designer.validation/src/org/eclipse/papyrus/qompass/designer/validation/constraints/SystemHasNoPorts.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * Copyright (c) 2013 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:
+ * Ansgar Radermacher ansgar.radermacher@cea.fr
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.qompass.designer.validation.constraints;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.emf.validation.AbstractModelConstraint;
+import org.eclipse.emf.validation.IValidationContext;
+import org.eclipse.papyrus.FCM.DeploymentPlan;
+import org.eclipse.papyrus.qompass.designer.core.deployment.DepUtils;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.InstanceSpecification;
+import org.eclipse.uml2.uml.Package;
+import org.eclipse.uml2.uml.util.UMLUtil;
+
+/**
+ * Check whether the specific system class. This class can be identified, since it is the
+ * classifier of the "main-instance" referenced by a deployment plan.
+ *
+ */
+public class SystemHasNoPorts extends AbstractModelConstraint {
+
+ @Override
+ public IStatus validate(IValidationContext ctx)
+ {
+ Package pkg = (Package) ctx.getTarget();
+
+ DeploymentPlan cdp = UMLUtil.getStereotypeApplication(pkg, DeploymentPlan.class);
+
+ if (cdp != null) {
+ InstanceSpecification mi = cdp.getMainInstance();
+ Class class_ = (Class) DepUtils.getClassifier(mi);
+
+ if (class_.getOwnedPorts().size() > 0) {
+ return ctx.createFailureStatus("The main instance (class '" + class_.getName() + "') of deployment plan '" + pkg.getName() + "' owns ports. It should not, since these ports remain unconnected.");
+ }
+ }
+ return ctx.createSuccessStatus();
+ }
+}

Back to the top