package org.jbpm.kie.services.impl;

import org.drools.core.util.StringUtils;
import org.jbpm.kie.services.api.DeploymentUnit;

public class KModuleDeploymentUnit implements DeploymentUnit {

    private String artifactId;
    private String groupId;
    private String version;
    private String kbaseName;
    private String ksessionName;
    
    private RuntimeStrategy strategy = RuntimeStrategy.SINGLETON;
    
    
    public KModuleDeploymentUnit(String groupId, String artifactId, String version) {
        this.groupId = groupId;
        this.artifactId = artifactId;
        this.version = version;
    }

    public KModuleDeploymentUnit(String groupId, String artifactId, 
            String version, String kbaseName, String ksessionName) {
        this.artifactId = artifactId;
        this.groupId = groupId;
        this.version = version;
        this.kbaseName = kbaseName;
        this.ksessionName = ksessionName;
    }

    @Override
    public String getIdentifier() {
        String id = getGroupId()+":"+getArtifactId()+":"+getVersion();
        if (!StringUtils.isEmpty(kbaseName)) {
            id = id.concat(":" + kbaseName);
        }
        if (!StringUtils.isEmpty(ksessionName)) {
            id = id.concat(":" + ksessionName);
        }
        return id;
    }

    @Override
    public RuntimeStrategy getStrategy() {
        return strategy;
    }

    public String getArtifactId() {
        return artifactId;
    }

    public void setArtifactId(String artifactId) {
        this.artifactId = artifactId;
    }

    public String getGroupId() {
        return groupId;
    }

    public void setGroupId(String groupId) {
        this.groupId = groupId;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getKsessionName() {
        return ksessionName;
    }

    public void setKsessionName(String ksessionName) {
        this.ksessionName = ksessionName;
    }

    public String getKbaseName() {
        return kbaseName;
    }

    public void setKbaseName(String kbaseName) {
        this.kbaseName = kbaseName;
    }

}

@@ -602,33 +602,37 @@
  version;%0A    %7D%0A
+    
 %0A
-
     public KModu
@@ -932,32 +932,433 @@
 ionName;%0A    %7D%0A%0A
+    public KModuleDeploymentUnit(String groupId, String artifactId, %0A            String version, String kbaseName, String ksessionName, String strategy) %7B%0A        this.artifactId = artifactId;%0A        this.groupId = groupId;%0A        this.version = version;%0A        this.kbaseName = kbaseName;%0A        this.ksessionName = ksessionName;%0A        this.strategy = RuntimeStrategy.valueOf(strategy);%0A    %7D%0A%0A
     @Override%0A  
@@ -1779,32 +1779,133 @@
 trategy;%0A    %7D%0A%0A
+    public void setStrategy(RuntimeStrategy strategy) %7B%0A        this.strategy = strategy;%0A    %7D%0A    %0A
     public Strin
@@ -2637,32 +2637,32 @@
 ng kbaseName) %7B%0A
-
         this.kba
@@ -2688,10 +2688,127 @@
 %0A    %7D%0A%0A
+    @Override%0A    public String toString() %7B%0A        return getIdentifier() + %22 %5Bstrategy=%22 + strategy + %22%5D%22;%0A    %7D%0A%0A
 %7D%0A

allow setting strategy on KmoduleDeploymentUnit