Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Definition of Java-Constraints in UML Profile
Definition of Java-Constraints in UML Profile [message #1768683] Fri, 21 July 2017 13:32 Go to next message
Sven Peldszus is currently offline Sven PeldszusFriend
Messages: 7
Registered: February 2017
Junior Member
Hello everyone,

I statically defined a UML profile to annotate UML elements with features. Now I am trying to define some live checks on the stereotypes tags but I am not able to get a working solution.

As I have to use some external resources (e.g. a feature model specifying which features are available) I have to use constraints defined in Java and cannot use e.g. OCL constraints.

Unfortunately, I am not able to get a working solution.

By now I tried as well the specification of constrains with Java directly inside of Papyrus as well as the DSML profile of Papyrus. But due to the lack of good tutorial I haven't been able to get a working solution.

My Java-constraint looks like this:

index.php/fa/30068/0/

However in the generated model code I can only fin the code I entered there in the comments above the method Constraint_Conditional_Element(DiagnosticChain diagnostics, Map<Object, Object> context):boolean in the interface Conditional_Element. The implementation of this method seems to be never called.

My DSML trial looks like this:

index.php/fa/30069/0/

Unfortunately, I haven't found any explanation to what values I should set the tags of this stereotype. In the according plugin.xml is the following reference carisma.profile.umlsec.variability.UMLsec_VariabilityProfile.Conditional_Element.Constraint1 but I don't know what I have to do with this reference. The ID occurs nowhere else in my workspace.

I hope you can help me.

Thank you

Sven
Re: Definition of Java-Constraints in UML Profile [message #1769418 is a reply to message #1768683] Mon, 31 July 2017 12:25 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 461
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Hi Sven,

the DSML profile attributes are used to customize the error message and the severity of this error. So, this should not be the root of the problem. However, I see that the "constrained element" reference of your constraint is empty. It should point to the stereotype. Can you please retry the validation plugin generation after setting the reference and post your results?
Re: Definition of Java-Constraints in UML Profile [message #1770635 is a reply to message #1769418] Tue, 15 August 2017 11:22 Go to previous message
Sven Peldszus is currently offline Sven PeldszusFriend
Messages: 7
Registered: February 2017
Junior Member
Hi Ansgar,

thank you very much for your help.

The suggested solution is working.

The generated code looks now like this:

public class Constraint_Conditional_CriticalConstraint extends AbstractModelConstraint {

	public IStatus validate(IValidationContext ctx) {
		EObject target = ctx.getTarget();

		if (target instanceof carisma.profile.umlsec.variability.Conditional_Critical) {
			if (evaluateConstraint((carisma.profile.umlsec.variability.Conditional_Critical) target)) {
				return ctx.createSuccessStatus();
			}
			else {
				return ctx.createFailureStatus(""); //$NON-NLS-1$ failure message is in plugin.xml
			}
		}
		return ctx.createSuccessStatus();
	}

	private boolean evaluateConstraint(carisma.profile.umlsec.variability.Conditional_Critical self) {
		return this != null;
	}

}


Now I have one remaining problem and one additional question.

1) I declared the constraint as live constraint but it is only executed if manually execute it over "validation -> validate model". How can I fix this?

2) Is it possible to show custom error messages created during validation and not only the one statically defined on the <<ValidationRule>> stereotype?

Thanks,

Sven
Previous Topic:Code generation
Next Topic:Papyrus Architecture Model - Oxygen (Creation Command Class issue)
Goto Forum:
  


Current Time: Thu Apr 25 16:49:17 GMT 2024

Powered by FUDForum. Page generated in 0.02957 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top