if (contents.isEmpty() || !(contents.get(0) instanceof DocumentRoot)) {
TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(resource);
if (domain != null) {
final DocumentRoot docRoot = FACTORY.createDocumentRoot();
final Definitions definitions = FACTORY.createDefinitions();
// definitions.setId(EcoreUtil.generateUUID());
ModelUtil.setID(definitions,resource);
Collaboration collaboration = FACTORY.createCollaboration();
// collaboration.setId(EcoreUtil.generateUUID());
ModelUtil.setID(collaboration,resource);
Participant participant = FACTORY.createParticipant();
// participant.setId(EcoreUtil.generateUUID());
ModelUtil.setID(participant,resource);
participant.setName("Internal");
collaboration.getParticipants().add(participant);
definitions.getRootElements().add(collaboration);
domain.getCommandStack().execute(new RecordingCommand(domain) {
@Override
protected void doExecute() {
docRoot.setDefinitions(definitions);