templates.trace.TraceCompareMethod.vm Maven / Gradle / Ivy
#* @vtlvariable name="currentClass" type="org.eclipse.emf.ecore.EClass" *#
#* @vtlvariable name="FQNHelper" type="org.kevoree.modeling.kotlin.generator.ProcessorHelper" *#
#* @vtlvariable name="ctx" type="org.kevoree.modeling.kotlin.generator.GenerationContext" *#
#set($tracePack=${FQNHelper.fqn($ctx, $ctx.basePackageForUtilitiesGeneration)})
override fun generateDiffTraces(similarObj : ${ctx.kevoreeContainer}?, kmf_internal_inter : Boolean, kmf_internal_ref : Boolean) : List {
var similarObjCasted : ${FQNHelper.fqn($ctx, $currentClass)}? = null
#if($ctx.js)
if(similarObj != null && (similarObj is ${FQNHelper.fqn($ctx, $currentClass)} || similarObj is ${FQNHelper.fqn($ctx, $currentClass.getEPackage())}.impl.${currentClass.getName()}Impl) ){
#else
if(similarObj != null && (similarObj is ${FQNHelper.fqn($ctx, $currentClass)})){
#end
similarObjCasted = similarObj as ${FQNHelper.fqn($ctx, $currentClass)}
}
val traces = java.util.ArrayList()
var attVal : Any? = null;
var attVal2 : Any? = null;
var attVal2String : String? = null;
var hashLoop : java.util.HashMap? = null;
var hashResult : java.util.HashMap? = null;
if(!kmf_internal_ref){
#foreach( $att in $currentClass.eAllAttributes )
attVal = ${FQNHelper.protectReservedWords(${att.getName()})}
attVal2 = similarObjCasted?.${FQNHelper.protectReservedWords(${att.getName()})}
if(attVal2 != null){
attVal2String = attVal2.toString()
} else {
attVal2String = null
}
if(attVal != attVal2){
if(!kmf_internal_inter) {
traces.add(org.kevoree.modeling.api.trace.ModelSetTrace(path()!!,${FQNHelper.fqn($ctx, $ctx.basePackageForUtilitiesGeneration)}.util.Constants.Att_$att.getName(),null,attVal2String,null))
}
} else {
//att similar
if(kmf_internal_inter) {
traces.add(org.kevoree.modeling.api.trace.ModelSetTrace(path()!!,${FQNHelper.fqn($ctx, $ctx.basePackageForUtilitiesGeneration)}.util.Constants.Att_$att.getName(),null,attVal2String,null))
}
}
#end
} else {
#foreach( $kmf_internal_ref in $currentClass.eAllReferences )
#if(!$kmf_internal_ref.isContainment());
#if($kmf_internal_ref.isMany())
hashLoop = java.util.HashMap()
hashResult = java.util.HashMap()
for(elem in _${kmf_internal_ref.getName()}.values()){
val elemPath = elem.path()
if(elemPath != null){
hashLoop!!.put(elemPath,elem)
}
}
if(similarObjCasted != null){
for(elem in similarObjCasted!!.${FQNHelper.protectReservedWords(${kmf_internal_ref.getName()})}){
val elemPath = elem.path()
if(elemPath != null){
if(hashLoop!!.containsKey(elemPath)){
if(kmf_internal_inter){
hashResult!!.put(elemPath,elem)
}
} else {
if(!kmf_internal_inter){
hashResult!!.put(elemPath,elem)
}
}
}
}
}
if(hashResult!!.size != 0){
for(hashLoopRes in hashResult!!.keySet()){
traces.add(org.kevoree.modeling.api.trace.ModelAddTrace(path()!!,${FQNHelper.fqn($ctx, $ctx.basePackageForUtilitiesGeneration)}.util.Constants.Ref_$kmf_internal_ref.getName(),hashLoopRes,hashResult!!.get(hashLoopRes)!!.metaClassName()))
}
}
#else
attVal = null;
attVal = ${FQNHelper.protectReservedWords(${kmf_internal_ref.getName()})}?.path();
attVal2 = null;
attVal2 = similarObjCasted?.${FQNHelper.protectReservedWords(${kmf_internal_ref.getName()})}?.path()
if(attVal2 != null){
attVal2String = attVal2.toString()
} else {
attVal2String = null
}
if(attVal != attVal2){
if(!kmf_internal_inter){
traces.add(org.kevoree.modeling.api.trace.ModelSetTrace(path()!!,${FQNHelper.fqn($ctx, $ctx.basePackageForUtilitiesGeneration)}.util.Constants.Ref_$kmf_internal_ref.getName(),attVal2String,null,null))
}
} else {
//att similar
if(kmf_internal_inter){
traces.add(org.kevoree.modeling.api.trace.ModelSetTrace(path()!!,${FQNHelper.fqn($ctx, $ctx.basePackageForUtilitiesGeneration)}.util.Constants.Ref_$kmf_internal_ref.getName(),attVal2String,null,null))
}
}
#end
#end
#end
}
return traces;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy