#**##parse( "jmi/default:storyPattern/link/import.vm" )
#**#
#**### multilink
#**##if ( $targetMulti.ContainerObject.equals($source) )
#*   *#	#if ( $targetMulti.Type == 2 )## DIRECT
#*      *#		#set( $range = $targetMulti.SourceObject.ObjectName )
#*      *#		#set( $cmulti = "AfterOf" )
#*   *#	#end
#**##elseif ( $sourceMulti.ContainerObject.equals($source)  && $targetMulti )
#*   *#	#if ( $sourceMulti.Type == 2 )## DIRECT
#*      *#		#set( $range = $sourceMulti.TargetObject.ObjectName )
#*      *#		#set( $cmulti = "BeforeOf" )
#*   *#	#end
#**##end
#**##if ($first)
#*   *#	#set( $range = "0" )
#**##end
#**#
#**### $role.Assoc.Name = name of association
#**##set( $sourceRole = $link.getCorrespondingRole($source) )
#**##set( $sourceRoleName = $mofutility.upFirstChar($sourceRole.getAttrName()) )
#**#
#**##set( $isCreateAlternateToManyLinks = $mofutility.isCreateAlternateToManyLinks() )
#**#
#**###reference
#**##set( $linkClassName = $link.InstanceOf.Class.Name)
#**#
#**###range
#**##if($range)
#*   *#	#set($rangeIsInteger = $mofutility.isInteger($range) )
#**##end
#**#
#**###---------
#**###QUALIFIER
#**##if($role.Qualifier)
#*   *#	#set($qualifier = $role.Qualifier)
#*   *#	#set($name = $targetName)
#*   *#	#set($testOrdered = $mofutility.isOrdered($role))
#**##else
#*   *#	#set($qualifier = $partnerRole.Qualifier)
#*   *#	#set($name = $sourceName)
#*   *#	#set($testOrdered = $mofutility.isOrdered($partnerRole))
#**##end
#**##if( $qualifier && $range)
#*   *#	#if( $testOrdered && $rangeIsInteger)
#*      *#		#set( $createQualified = false)
#*   *#	#else
#*      *#		#set( $createQualified = true)
#*      *#		#set( $valueOfQualifier = $range)
#*      *#		#set( $attrName = $mofutility.upFirstChar($qualifier.Name))
#*   *#	#end
#**##end
#**###--------------
#**#
#**##if ($toOne)
#*   *#// create to-one link
#*   *#	##----------
#*   *#	## REFERENCE TO ONE
#*   *#
#*   *#	#if($linkClassName.equals("de.tu_darmstadt.fujaba.mof.adapter.FMAOpposite"))
#*      *#		${sourceName}.set${targetRoleName}(${targetName});
#*      *#
#*      *#		##------------
#*      *#		## ASSOCIATION TO ONE
#*      *#	
#*   *#	#else
#*      *#		#if($ref)
#*         *#			${sourceName}.set${targetRoleName}($targetName);
#*      *#		#else
#*         *#			fujaba_temp1 = ${getX1}"${getXparameter}"${getX2};
#*         *#			#if($role == $role.Assoc.RightRole)
#*            *#				if(fujaba_temp1 != null){
#*            *#				${getX1}"${getXparameter}"))).remove($sourceName,($fullJavaNameOfTargetType)fujaba_temp1);
#*            *#}
#*            *#				#if($targetName != "null")
#*               *#					${getX1}"${getXparameter}"))).add($sourceName, $targetName);
#*            *#				#end
#*         *#			#else
#*            *#				if(fujaba_temp1 != null){
#*            *#				${getX1}"${getXparameter}"))).remove(($fullJavaNameOfTargetType)fujaba_temp1, $sourceName);
#*            *#}
#*            *#				#if($targetName != "null")
#*               *#					${getX1}"${getXparameter}"))).add($targetName, $sourceName);
#*            *#				#end
#*         *#			#end
#*      *#		#end
#*   *#	#end
#*   *#
#**##else
#*   *#// create to-many link
#*   *#	##-------------
#*   *#	## REFERENCE TO MANY
#*   *#
#*   *#	#if($linkClassName.equals("de.tu_darmstadt.fujaba.mof.adapter.FMAOpposite"))
#*      *#		## reference
#*      *#		${sourceName}.get${targetRoleName}().add(${targetName});
#*   *#	#else
#*      *#
#*      *#		##---------------
#*      *#		## ASSOCIATION TO MANY
#*      *#
#*      *#		#if($rangeIsInteger || $cmulti)
#*         *#			#if($cmulti)
#*            *#				try{
#*         *#			#end
#*      *#			fujaba_cond = #if($ref)${getX}#else${getX1}"${getXparameter}"${getX2}#end.contains($targetName);
#*         *#			#if($cmulti)
#*         *#				fujaba_index = #if($ref)${getX}#else${getX1}"${getXparameter}"${getX2}#end.indexOf($range);
#*         *#			#end
#*         *#			if(fujaba_cond == true){
#*         *#			${getX1}"${getXparameter}"${getX2}.remove($targetName);
#*         *#}
#*      *#		#end
#*      *#
#*      *#		#if($rangeIsInteger && !$cmulti)
#*         *#			if($range >= 0){
#*      *#			if($range <= #if($ref)${getX}#else${getX1}"${getXparameter}"${getX2}#end.size()){
#*      *#		#end
#*      *#
#*      *#		#if(($cmulti || $rangeIsInteger || !$isCreateAlternateToManyLinks) && !$createQualified)
#*      *#			${getX1}"${getXparameter}"${getX2}.add(#if($cmulti)fujaba_index #if($cmulti == "AfterOf")+1#end,#elseif($rangeIsInteger)$range,#end $targetName);
#*      *#		#else
#*         *#			## alternate method for creating to-many links
#*         *#			## call add-method of association instead of operating on the memberEnd collections
#*         *#			#if($createQualified)
#*            *#				// set qualifier
#*            *#				${name}.set${attrName}($valueOfQualifier);
#*         *#			#end
#*         *#			${getX1}"${getXparameter}"))).add##
#*         *#			#if($role == $role.Assoc.RightRole)
#*            *#				($sourceName, $targetName);
#*         *#			#else
#*            *#				($targetName, $sourceName);
#*         *#			#end
#*      *#		#end
#*      *#		
#*      *#		#if($rangeIsInteger && !$cmulti)
#*         *#			}
#*         *#			else{
#*         *#			${getX1}"${getXparameter}"${getX2}.add($targetName);
#*         *#			}
#*         *#			}
#*         *#			else{
#*         *#			throw new IndexOutOfBoundsException();
#*         *#			}
#*      *#		#end
#*      *#		#if($cmulti)
#*         *#		}
#*         *#		catch(IndexOutOfBoundsException e){}
#*      *#		#end
#*   *#	#end
#**##end