Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Model serialization problem
Model serialization problem [message #1776416] Thu, 16 November 2017 10:02 Go to next message
mind calm is currently offline mind calmFriend
Messages: 42
Registered: July 2017
Member
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?


Best regards!

by Keep Mind Calm

[Updated on: Thu, 16 November 2017 10:03]

Report message to a moderator

Re: Model serialization problem [message #1776418 is a reply to message #1776416] Thu, 16 November 2017 10:17 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12110
Registered: July 2009
Senior Member
But the type is required in the grammar ?!?

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Model serialization problem [message #1776648 is a reply to message #1776418] Mon, 20 November 2017 01:33 Go to previous messageGo to next message
mind calm is currently offline mind calmFriend
Messages: 42
Registered: July 2017
Member
Yes, the 'type' is required in the grammar.

Whether we can serialize the model without 'type' or with the 'type' empty?


Best regards!

by Keep Mind Calm
Re: Model serialization problem [message #1776655 is a reply to message #1776648] Mon, 20 November 2017 04:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12110
Registered: July 2009
Senior Member
But that model would be broken?

Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Model serialization problem [message #1776656 is a reply to message #1776655] Mon, 20 November 2017 05:38 Go to previous messageGo to next message
mind calm is currently offline mind calmFriend
Messages: 42
Registered: July 2017
Member
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.


Best regards!

by Keep Mind Calm
Re: Model serialization problem [message #1776660 is a reply to message #1776656] Mon, 20 November 2017 06:14 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 12110
Registered: July 2009
Senior Member
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?


Need professional support for Xtext, Xpand, EMF?
Go to: https://xtext.itemis.com
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Mon, 20 November 2017 06:15]

Report message to a moderator

Re: Model serialization problem [message #1776666 is a reply to message #1776660] Mon, 20 November 2017 07:35 Go to previous message
mind calm is currently offline mind calmFriend
Messages: 42
Registered: July 2017
Member
Ok, got it, now the only way is to change the grammar. thanks for your reply.

Best regards!

by Keep Mind Calm
Previous Topic:Internal error occurred during: "Launching Launch Runtime Eclipse"
Next Topic:Xtext web editor is disabled
Goto Forum:
  


Current Time: Thu Jul 19 15:01:52 GMT 2018

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

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

Back to the top