/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.flowable.cmmn.model;

/**
 * @author Joram Barrez
 */
public class RepetitionRule extends PlanItemRule {
    
    public static final String DEFAULT_REPETITION_COUNTER_VARIABLE_NAME = "repetitionCounter";
    
    protected String repetitionCounterVariableName;

    public String getRepetitionCounterVariableName() {
        if (repetitionCounterVariableName != null) {
            return repetitionCounterVariableName;
        } else {
            return DEFAULT_REPETITION_COUNTER_VARIABLE_NAME;
        }
    }

    public void setRepetitionCounterVariableName(String repetitionCounterVariableName) {
        this.repetitionCounterVariableName = repetitionCounterVariableName;
    }

    @Override
    public String toString() {
        return "RepetitionRule{" +
                "repetitionCounterVariableName='" + repetitionCounterVariableName + '\'' +
                "} " + super.toString();
    }
}

@@ -615,16 +615,40 @@
  Barrez%0A
+ * @author Micha Kiener%0A
  */%0Apubl
@@ -698,112 +698,519 @@
 e %7B%0A
+%0A
     
-%0A    public static final String DEFAULT_REPETITION_COUNTER_VARIABLE_NAME = %22repetitionCounter%22;%0A    
+public static final String MAX_INSTANCE_COUNT_ONE = %22one%22;%0A    public static final String MAX_INSTANCE_COUNT_UNLIMITED = %22unlimited%22;%0A%0A    public static final String DEFAULT_REPETITION_COUNTER_VARIABLE_NAME = %22repetitionCounter%22;%0A    public static final String DEFAULT_REPETITION_ELEMENT_VARIABLE_NAME = %22item%22;%0A    public static final String DEFAULT_REPETITION_ELEMENT_INDEX_VARIABLE_NAME = %22itemIndex%22;%0A    public static final String DEFAULT_REPETITION_MAX_INSTANCE_COUNT_VALUE = MAX_INSTANCE_COUNT_ONE;%0A
 %0A   
@@ -1262,47 +1262,128 @@
 me;%0A
-%0A
     p
-ublic String getRepetitionCounter
+rotected String collectionVariableName;%0A    protected String elementVariableName;%0A    protected String elementIndex
 Vari
@@ -1394,26 +1394,72 @@
 Name
-() %7B
+;
 %0A    
-    if (r
+protected String maxInstanceCount;%0A%0A    public String getR
 epet
@@ -1486,16 +1486,9 @@
 Name
- != null
+(
 ) %7B%0A
@@ -1495,27 +1495,20 @@
         
-    return 
+if (
 repetiti
@@ -1532,24 +1532,17 @@
 Name
-;%0A        %7D else
+ == null)
  %7B%0A 
@@ -1611,16 +1611,62 @@
       %7D%0A
+        return repetitionCounterVariableName;%0A
     %7D%0A%0A 
@@ -1832,24 +1832,1287 @@
 ame;%0A    %7D%0A%0A
+    public String getCollectionVariableName() %7B%0A        return collectionVariableName;%0A    %7D%0A%0A    public void setCollectionVariableName(String collectionVariableName) %7B%0A        this.collectionVariableName = collectionVariableName;%0A    %7D%0A%0A    public String getElementVariableName() %7B%0A        if (elementVariableName == null) %7B%0A            return DEFAULT_REPETITION_ELEMENT_VARIABLE_NAME;%0A        %7D%0A        return elementVariableName;%0A    %7D%0A%0A    public void setElementVariableName(String elementVariableName) %7B%0A        this.elementVariableName = elementVariableName;%0A    %7D%0A%0A    public String getElementIndexVariableName() %7B%0A        if (elementIndexVariableName == null) %7B%0A            return DEFAULT_REPETITION_ELEMENT_INDEX_VARIABLE_NAME;%0A        %7D%0A        return elementIndexVariableName;%0A    %7D%0A%0A    public void setElementIndexVariableName(String elementIndexVariableName) %7B%0A        this.elementIndexVariableName = elementIndexVariableName;%0A    %7D%0A%0A    public String getMaxInstanceCount() %7B%0A        if (maxInstanceCount == null) %7B%0A            return DEFAULT_REPETITION_MAX_INSTANCE_COUNT_VALUE;%0A        %7D%0A        return maxInstanceCount;%0A    %7D%0A%0A    public void setMaxInstanceCount(String maxInstanceCount) %7B%0A        this.maxInstanceCount = maxInstanceCount;%0A    %7D%0A%0A
     @Overrid
@@ -3196,16 +3196,82 @@
        %22
+ maxInstanceCount='%22 + maxInstanceCount + %22'%22 +%0A                %22 
 repetiti
@@ -3333,32 +3333,261 @@
 e + 
-'%5C'' +%0A                %22
+%22'%22 +%0A                %22 collectionVariableName='%22 + collectionVariableName + %22'%22 +%0A                %22 elementVariableName='%22 + elementVariableName + %22'%22 +%0A                %22 elementIndexVariableName='%22 + elementIndexVariableName + %22'%22 +%0A                %22 
 %7D %22 

add extended repetition rule attributes to the model