| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <?xml version="1.0" encoding="UTF-8"?>
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- exclude-result-prefixes="xs"
- version="2.0">
-
-
- <xsl:template name="detect_outgoing">
- <xsl:param name="proces_id"/>
- <xsl:param name="parent_id"/>
- <xsl:param name="current_sort_prio"/>
- <xsl:param name="position"/>
-
-
-
- <!--
- Przygotowanie struktury procesow pod widok bpmn
- IF proces nie ma dziecka
- IF proces ma kolejny proces
- OUTPUT=kolejny proces
- ELSE
- OUTPUT=end_event
- ELSE output=dziecko
-
- -->
-
- <xsl:variable name="outgoings">
- <xsl:choose>
- <!-- IF proces nie ma dziecka -->
- <xsl:when test="not (../item[PARENT_ID=$proces_id])">
-
- <xsl:choose>
- <!-- IF proces ma kolejny proces nizej -->
- <xsl:when test="../item[PARENT_ID=$parent_id][$position+1]">
- <!-- out=kolejny proces -->
- <xsl:variable name="position_next" select="$position+1"/>
- <xsl:for-each select="../item[PARENT_ID=$parent_id]">
- <xsl:if test="position()=$position+1"> <!-- bug xslt nie mozna zrobic selecta z position! -->
-
-
- <xsl:element name="outgoing_id">
- <xsl:value-of select="ID"/>
- </xsl:element>
- <xsl:element name="outgoing_name">
- <xsl:value-of select="concat('Task_',ID)"/>
- </xsl:element>
-
-
- </xsl:if>
-
- </xsl:for-each>
-
- </xsl:when>
- <xsl:otherwise>
- <!-- out=end event -->
-
- <xsl:element name="outgoing_name">
- <xsl:value-of select="concat('EndEvent_',$proces_id)"/>
- </xsl:element>
-
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <!-- out=dziecko -->
-
- <xsl:for-each select="../item[PARENT_ID=$proces_id and position()>$position ]">
-
- <xsl:element name="outgoing_id">
- <xsl:value-of select="ID"/>
- </xsl:element>
- <xsl:element name="outgoing_name">
- <xsl:value-of select="concat('Task_',ID)"/>
- </xsl:element>
-
- </xsl:for-each>
-
- <!-- TODO this is bug of engine?!?
- <xsl:element name="outgoing">
- <xsl:value-of select="../item/ID[../PARENT_ID=$proces_id ] [1]"/>
- </xsl:element>
- -->
- </xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="GOTO_event">
- <xsl:for-each select="../item[ID=$proces_id and IF_TRUE_GOTO!='' and IF_TRUE_GOTO!=0 and IF_TRUE_GOTO!='0']" xpath-default-namespace="">
- <xsl:element name="IF_TRUE_GOTO">
- <xsl:element name="GOTO_ID">
- <xsl:value-of select="IF_TRUE_GOTO"/>
- </xsl:element>
- <xsl:element name="IF_TRUE_GOTO_FLAG">
- <xsl:value-of select="IF_TRUE_GOTO_FLAG"/>
- </xsl:element>
-
- <xsl:variable name="IF_TRUE_GOTO" select="IF_TRUE_GOTO"/>
- <!-- wykrycie czy goto idzie do proces_init czy do kroku procesu -->
- <xsl:for-each select="../../items/item[ID=$IF_TRUE_GOTO]">
- <xsl:element name="GOTO_NEXT_PROCES_TYPE">
- <xsl:value-of select="TYPE"/>
- </xsl:element>
- <xsl:element name="outgoing_name">
- <xsl:choose>
- <xsl:when test="TYPE='PROCES_INIT'">
- <xsl:value-of select="concat('StartEvent_',$IF_TRUE_GOTO)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="concat('Task_',$IF_TRUE_GOTO)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:element>
-
- </xsl:for-each>
- </xsl:element>
- </xsl:for-each>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="$outgoings/outgoing_id">
- <xsl:copy-of select="$outgoings/*"/>
- <xsl:copy-of select="$GOTO_event/*"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:choose>
- <xsl:when test="$GOTO_event/IF_TRUE_GOTO">
- <xsl:copy-of select="$GOTO_event/*"/>
- </xsl:when>
- <xsl:otherwise>
- <!-- jest koniec procesu -->
- <xsl:copy-of select="$outgoings/outgoing_name"/>
- <xsl:element name="EndEvent">
- <xsl:value-of select="$outgoings/outgoing_name"/>
- </xsl:element>
- <xsl:element name="TaskName">
- <xsl:value-of select="$outgoings/outgoing_name"/>
- </xsl:element>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:choose>
- <xsl:when test="$GOTO_event/IF_TRUE_GOTO/GOTO_NEXT_PROCES_TYPE='PROCES'">
- <xsl:element name="outgoing_id">
- <xsl:value-of select="$GOTO_event/IF_TRUE_GOTO/GOTO_ID"/>
- </xsl:element>
- <xsl:element name="outgoing_name">
- <xsl:value-of select="concat('Task_',$GOTO_event/IF_TRUE_GOTO/GOTO_ID)"/>
- </xsl:element>
- </xsl:when>
- <xsl:when test="$GOTO_event/IF_TRUE_GOTO/GOTO_NEXT_PROCES_TYPE='PROCES_INIT'">
- <xsl:element name="outgoing_id">
- <xsl:value-of select="$GOTO_event/IF_TRUE_GOTO/GOTO_ID"/>
- </xsl:element>
- <xsl:element name="outgoing_name">
- <xsl:value-of select="concat('StartEvent_',$GOTO_event/IF_TRUE_GOTO/GOTO_ID)"/>
- </xsl:element>
- </xsl:when>
- </xsl:choose>
-
- </xsl:template>
-
-
-
- <xsl:template name="find_child_proces">
- <xsl:param name="proces_id" />
- <xsl:param name="count"/>
-
-
- <xsl:choose>
- <xsl:when test="$count > 0">
-
- <xsl:for-each select="/data/items/item[TYPE='PROCES' and A_STATUS!='DELETED' and PARENT_ID=$proces_id]">
- <xsl:sort select="concat(PARENT_ID,SORT_PRIO)"/>
- <!--<xsl:text>
</xsl:text>-->
- <xsl:element name="childs">
-
- <xsl:call-template name="detect_outgoing">
- <xsl:with-param name="proces_id" select="ID"/>
- <xsl:with-param name="parent_id" select="PARENT_ID"/>
- <xsl:with-param name="current_sort_prio" select="SORT_PRIO"/>
- <xsl:with-param name="position" select="position()"/>
- </xsl:call-template>
-
- <xsl:element name="DESC">
- <xsl:value-of select="DESC"/>
- </xsl:element>
- <xsl:element name="child">
- <xsl:value-of select="ID"/>
- </xsl:element>
- <xsl:element name="Task">
- <xsl:value-of select="concat('Task_',ID)"/>
- </xsl:element>
- <xsl:element name="TaskName">
- <xsl:value-of select="concat('Task_',ID)"/>
- </xsl:element>
- <xsl:element name="PARENT_ID">
- <xsl:value-of select="PARENT_ID"/>
- </xsl:element>
- <xsl:element name="incoming_name">
- <xsl:value-of select="concat('Task_',PARENT_ID)"/>
- </xsl:element>
- <xsl:element name="SORT_PRIO">
- <xsl:value-of select="SORT_PRIO"/>
- </xsl:element>
- <xsl:element name="current_root">
- <xsl:value-of select="position()"/>
- </xsl:element>
-
- <xsl:call-template name="Pools">
- <xsl:with-param name="proces_id" select="ID"/>
- </xsl:call-template>
- </xsl:element>
- <xsl:call-template name="find_child_proces">
- <xsl:with-param name="proces_id" select="ID"/>
- <xsl:with-param name="count" select="$count - 1"/>
- </xsl:call-template>
- </xsl:for-each>
-
- </xsl:when>
- <xsl:otherwise>
- Error in loop!!!(<xsl:value-of select="$count"/>)
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
- </xsl:stylesheet>
|