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.getBasePackageForUtilitiesGeneration())})
override fun generateDiffTraces(similarObj : ${ctx.getKevoreeContainer().get()}?, inter : Boolean) : List {
var similarObjCasted : ${FQNHelper.fqn($ctx, $currentClass)}? = null
#if($ctx.getJS())
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.HashSet? = null;
var hashResult : java.util.HashSet? = null;
#foreach( $att in $currentClass.eAllAttributes )
attVal = get${att.getName().substring(0, 1).toUpperCase()}${att.getName().substring(1)}()
attVal2 = similarObjCasted?.get${att.getName().substring(0, 1).toUpperCase()}${att.getName().substring(1)}()
if(attVal != attVal2){
if(!inter){
traces.add(org.kevoree.modeling.api.trace.ModelSetTrace(path()!!,${FQNHelper.fqn($ctx, $ctx.getBasePackageForUtilitiesGeneration())}.util.Constants.Att_$att.getName(),null,attVal2?.toString(),null))
}
} else {
//att similar
if(inter){
traces.add(org.kevoree.modeling.api.trace.ModelSetTrace(path()!!,${FQNHelper.fqn($ctx, $ctx.getBasePackageForUtilitiesGeneration())}.util.Constants.Att_$att.getName(),null,attVal2?.toString(),null))
}
}
#end
#foreach( $ref in $currentClass.eAllReferences )
#if(!$ref.isContainment());
#if($ref.isMany())
hashLoop = java.util.HashSet()
hashResult = java.util.HashSet()
for(elem in get${ref.getName().substring(0, 1).toUpperCase()}${ref.getName().substring(1)}()){
val elemPath = elem.path()
if(elemPath != null){
hashLoop!!.add(elemPath)
}
}
if(similarObjCasted != null){
for(elem in similarObjCasted!!.get${ref.getName().substring(0, 1).toUpperCase()}${ref.getName().substring(1)}()){
val elemPath = elem.path()
if(elemPath != null){
if(hashLoop!!.contains(elemPath)){
if(inter){
hashResult!!.add(elemPath)
}
} else {
if(!inter){
hashResult!!.add(elemPath)
}
}
}
}
}
if(hashResult!!.size != 0){
traces.add(org.kevoree.modeling.api.trace.ModelAddAllTrace(path()!!,${FQNHelper.fqn($ctx, $ctx.getBasePackageForUtilitiesGeneration())}.util.Constants.Ref_$ref.getName(),hashResult!!.toList(),null))
}
#else
attVal = null;
attVal = get${ref.getName().substring(0, 1).toUpperCase()}${ref.getName().substring(1)}()?.path();
attVal2 = null;
attVal2 = similarObjCasted?.get${ref.getName().substring(0, 1).toUpperCase()}${ref.getName().substring(1)}()?.path()
if(attVal2 != null){
attVal2String = attVal2.toString()
} else {
attVal2String = null
}
if(attVal != attVal2){
if(!inter){
traces.add(org.kevoree.modeling.api.trace.ModelSetTrace(path()!!,${FQNHelper.fqn($ctx, $ctx.getBasePackageForUtilitiesGeneration())}.util.Constants.Ref_$ref.getName(),attVal2String,null,null))
}
} else {
//att similar
if(inter){
traces.add(org.kevoree.modeling.api.trace.ModelSetTrace(path()!!,${FQNHelper.fqn($ctx, $ctx.getBasePackageForUtilitiesGeneration())}.util.Constants.Ref_$ref.getName(),attVal2String,null,null))
}
}
#end
#end
#end
return traces;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy