Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Divide CompleteOCL document into different documents
Divide CompleteOCL document into different documents [message #1800896] Wed, 09 January 2019 13:47 Go to next message
Florian Amberg is currently offline Florian AmbergFriend
Messages: 6
Registered: November 2018
Junior Member
My question is if it is possible to split up OCL files and reuse methods of another OCL document.
Example:
import 'transitive_test.ecore'

package transitive_test

context Bank

def:
collectionToString(col : Collection(OclAny)) : String =
col->iterate(obj : OclAny; result : String = '' |
	result.concat(obj.toString()).concat('\n')
)

inv Valid_Customer:
collectionToString(self.customer)

endpackage


Now I would like to split up this OCL file into an OCL file with utility methods and the invariants.

OCLDocument1:
import 'transitive_test.ecore'

package transitive_test

context Bank

def:
collectionToString(col : Collection(OclAny)) : String =
col->iterate(obj : OclAny; result : String = '' |
	result.concat(obj.toString()).concat('\n')
)

endpackage


And OCLDocument2:
import 'transitive_test.ecore'

--pseudocode
using module1

package transitive_test

context Bank

inv Valid_Customer:
	collectionToString(self.customer)

endpackage


The reason is I have a kind of large OCL document(500+ lines) and I would like to separate the invariants from the utility methods. I could not find anything related to "modularizing" OCL so i presume it's not possible, but I wanted to ask anyway.

Regards
Re: Divide CompleteOCL document into different documents [message #1800907 is a reply to message #1800896] Wed, 09 January 2019 15:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6538
Registered: July 2009
Senior Member
Hi

Possible: absolutely. You could go as fine-grained as one 'context' per partitioned document.

Quote:
result.concat(obj.toString()).concat('\n')


OCL added String::+ long ago so:

Quote:
result + obj.toString() + '\n'


Practically, the following may give you some help

/org.eclipse.ocl.xtext.completeocl.ui/src/org/eclipse/ocl/xtext/completeocl/ui/commands/ExportCompleteOCLHandler.java
/org.eclipse.ocl.xtext.completeocl/src/org/eclipse/ocl/xtext/completeocl/as2cs/CompleteOCLSplitter.java

See https://bugs.eclipse.org/bugs/show_bug.cgi?id=500551 where I have added the possibility that the Export Complete OCL from *.ecore/*.uml/*.oclinecore could be extended to support export of selected declarations (contributions welcome).

Regards

Ed Willink


Re: Divide CompleteOCL document into different documents [message #1801202 is a reply to message #1800907] Tue, 15 January 2019 09:48 Go to previous message
Florian Amberg is currently offline Florian AmbergFriend
Messages: 6
Registered: November 2018
Junior Member
Thank you, I will take a look at the links!
Previous Topic:Standalone compiled OCL
Next Topic:OCL jars from Maven
Goto Forum:
  


Current Time: Fri Dec 13 00:56:56 GMT 2019

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

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

Back to the top