Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Model serialization problem
Model serialization problem [message #1776416] Thu, 16 November 2017 05:02 Go to next message
Eclipse UserFriend
Hi,

I use xtext + sirius to edit my model.
part of Xtext defined in meta-model as flow:
Requirement returns Requirement:
	'Requirement'
	identifier=EString
	'{'
		('count' count=EInt)?
		('mandatory' mandatory=EBoolean)?
		'type' type=[ApplicationType|EString]
		('applications' '(' applications+=[ApplicationInstance|EString] ( "," applications+=[ApplicationInstance|EString])* ')' )?
	'}';

If i didn't set 'type' of a 'Requirement' in sirius diagram editor, then i can't save the model.
Values: identifier(1), count(0-1), mandatory(0-1)
Semantic Object: CyberPhysicalSystem.requests[0]->Request.requirements[0]->Requirement
URI: platform:/resource/cpsTest/f1.cyberphysicalsystem
Context: Requirement returns Requirement
	at org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic$ExceptionThrowingAcceptor.accept(ISerializationDiagnostic.java:131)
	at org.eclipse.xtext.serializer.sequencer.BacktrackingSemanticSequencer.createSequence(BacktrackingSemanticSequencer.java:480)
	at org.eclipse.viatra.examples.cps.model.dsl.serializer.CPSSemanticSequencer.sequence_Requirement(CPSSemanticSequencer.java:200)
	at org.eclipse.viatra.examples.cps.model.dsl.serializer.CPSSemanticSequencer.sequence(CPSSemanticSequencer.java:62)


I think in some scenarios, we should serialize the model successfully, even if there is some unset properties.
Is there any options or switch to ignore the null property in model?

[Updated on: Thu, 16 November 2017 05:03] by Moderator

Re: Model serialization problem [message #1776418 is a reply to message #1776416] Thu, 16 November 2017 05:17 Go to previous messageGo to next message
Eclipse UserFriend
But the type is required in the grammar ?!?
Re: Model serialization problem [message #1776648 is a reply to message #1776418] Sun, 19 November 2017 20:33 Go to previous messageGo to next message
Eclipse UserFriend
Yes, the 'type' is required in the grammar.

Whether we can serialize the model without 'type' or with the 'type' empty?
Re: Model serialization problem [message #1776655 is a reply to message #1776648] Sun, 19 November 2017 23:41 Go to previous messageGo to next message
Eclipse UserFriend
But that model would be broken?
Re: Model serialization problem [message #1776656 is a reply to message #1776655] Mon, 20 November 2017 00:38 Go to previous messageGo to next message
Eclipse UserFriend
I don't think model would be broken.
Such as the Requirement grammar mentioned above,
Requirement returns Requirement:
	'Requirement'
	identifier=EString
	'{'
		('count' count=EInt)?
		('mandatory' mandatory=EBoolean)?
		'type' type=[ApplicationType|EString]
		('applications' '(' applications+=[ApplicationInstance|EString] ( "," applications+=[ApplicationInstance|EString])* ')' )?
	'}';

in Sirius editor, if user did not set value of 'type' for a 'Requirement' instance, we can serialize it as blow:
    Requirement "requirement1" {
        count 0
        applications ("***", "***")
    }

there is no 'type' and 'mandatory' information.

Of course, if some property use as identifier, it must have a value.
Re: Model serialization problem [message #1776660 is a reply to message #1776656] Mon, 20 November 2017 01:14 Go to previous messageGo to next message
Eclipse UserFriend
no this model would be invalid.
the grammar says ther has to be a type?


so why dont you simply make it optional in the grammar?

[Updated on: Mon, 20 November 2017 01:15] by Moderator

Re: Model serialization problem [message #1776666 is a reply to message #1776660] Mon, 20 November 2017 02:35 Go to previous message
Eclipse UserFriend
Ok, got it, now the only way is to change the grammar. thanks for your reply.
Previous Topic:Internal error occurred during: "Launching Launch Runtime Eclipse"
Next Topic:Xtext web editor is disabled
Goto Forum:
  


Current Time: Wed Jul 16 04:30:20 EDT 2025

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

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

Back to the top