package org.eclipse.cmf.occi.core.xtext;

import org.eclipse.cmf.occi.core.Kind;
import org.eclipse.cmf.occi.core.OCCIPackage;
import org.eclipse.cmf.occi.core.Type;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.xtext.serializer.sequencer.LegacyTransientValueService;

import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;

public class CustomLegacyTransientValueService extends LegacyTransientValueService {
	
	@Override
	public ValueTransient isValueTransient(EObject semanticObject, EStructuralFeature feature) {
		if (feature == OCCIPackage.Literals.ATTRIBUTE__MUTABLE && semanticObject.eContainer() instanceof Type) {
			if ((boolean)semanticObject.eGet(feature)) {
				return ValueTransient.NO;
			}
		}
		return super.isValueTransient(semanticObject, feature);
	}
	
	@Override
	protected boolean defaultValueIsSerializeable(EStructuralFeature feature) {
		if (feature == OCCIPackage.Literals.ATTRIBUTE__MUTABLE) {
			return true;
		}
		return super.defaultValueIsSerializeable(feature);
	}

}

@@ -120,16 +120,61 @@
 ackage;%0A
+import org.eclipse.cmf.occi.core.RecordType;%0A
 import o
@@ -200,24 +200,24 @@
 .core.Type;%0A
-
 import org.e
@@ -538,18 +538,17 @@
 rvice %7B%0A
-%09
 %0A
+
 %09@Overri
@@ -636,32 +636,33 @@
 ture feature) %7B%0A
+%0A
 %09%09if (feature ==
@@ -705,11 +705,65 @@
 ABLE
- &&
+) %7B%0A%09%09%09if (semanticObject.eContainer() instanceof Type %7C%7C
  sem
@@ -802,16 +802,22 @@
 eof 
+Record
 Type) %7B%0A
 %09%09%09i
@@ -808,24 +808,25 @@
 cordType) %7B%0A
+%09
 %09%09%09if ((bool
@@ -865,16 +865,17 @@
 ) %7B%0A%09%09%09%09
+%09
 return V
@@ -892,16 +892,22 @@
 ent.NO;%0A
+%09%09%09%09%7D%0A
 %09%09%09%7D%0A%09%09%7D
@@ -968,17 +968,16 @@
 re);%0A%09%7D%0A
-%09
 %0A%09@Overr

add the case of recordField