Search in sources :

Example 56 with ObjectModel

use of org.kie.internal.runtime.conf.ObjectModel in project jbpm by kiegroup.

the class DeploymentDescriptorMerger method merge.

public DeploymentDescriptor merge(DeploymentDescriptor master, DeploymentDescriptor slave, MergeMode mode) {
    if (master == null || slave == null) {
        throw new IllegalArgumentException("Descriptors to merge must be provided");
    }
    DeploymentDescriptor merged = null;
    DeploymentDescriptorBuilder builder = master.getBuilder();
    builder.setBuildHandler(new MergeModeBuildHandler(mode));
    switch(mode) {
        case KEEP_ALL:
            // do nothing as master wins
            merged = master;
            break;
        case OVERRIDE_ALL:
            // do nothing as slave wins
            merged = slave;
            break;
        case OVERRIDE_EMPTY:
            builder.auditMode(slave.getAuditMode());
            builder.auditPersistenceUnit(slave.getAuditPersistenceUnit());
            builder.persistenceMode(slave.getPersistenceMode());
            builder.persistenceUnit(slave.getPersistenceUnit());
            builder.runtimeStrategy(slave.getRuntimeStrategy());
            builder.setConfiguration(slave.getConfiguration());
            builder.setEnvironmentEntries(slave.getEnvironmentEntries());
            builder.setEventListeners(slave.getEventListeners());
            builder.setGlobals(slave.getGlobals());
            builder.setMarshalingStrategies(slave.getMarshallingStrategies());
            builder.setTaskEventListeners(slave.getTaskEventListeners());
            builder.setWorkItemHandlers(slave.getWorkItemHandlers());
            builder.setRequiredRoles(slave.getRequiredRoles());
            builder.setClasses(slave.getClasses());
            builder.setLimitSerializationClasses(slave.getLimitSerializationClasses());
            merged = builder.get();
            break;
        case MERGE_COLLECTIONS:
            builder.auditMode(slave.getAuditMode());
            builder.auditPersistenceUnit(slave.getAuditPersistenceUnit());
            builder.persistenceMode(slave.getPersistenceMode());
            builder.persistenceUnit(slave.getPersistenceUnit());
            builder.runtimeStrategy(slave.getRuntimeStrategy());
            for (ObjectModel model : slave.getEventListeners()) {
                builder.addEventListener(model);
            }
            for (ObjectModel model : slave.getMarshallingStrategies()) {
                builder.addMarshalingStrategy(model);
            }
            for (ObjectModel model : slave.getTaskEventListeners()) {
                builder.addTaskEventListener(model);
            }
            for (NamedObjectModel model : slave.getConfiguration()) {
                builder.addConfiguration(model);
            }
            for (NamedObjectModel model : slave.getEnvironmentEntries()) {
                builder.addEnvironmentEntry(model);
            }
            for (NamedObjectModel model : slave.getGlobals()) {
                builder.addGlobal(model);
            }
            for (NamedObjectModel model : slave.getWorkItemHandlers()) {
                builder.addWorkItemHandler(model);
            }
            for (String requiredRole : slave.getRequiredRoles()) {
                builder.addRequiredRole(requiredRole);
            }
            for (String clazz : slave.getClasses()) {
                builder.addClass(clazz);
            }
            Boolean slaveLimit = slave.getLimitSerializationClasses();
            Boolean masterLimit = master.getLimitSerializationClasses();
            if (slaveLimit != null && masterLimit != null && (!slaveLimit || !masterLimit)) {
                builder.setLimitSerializationClasses(false);
            }
            merged = builder.get();
            break;
        default:
            break;
    }
    return merged;
}
Also used : NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) ObjectModel(org.kie.internal.runtime.conf.ObjectModel) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) DeploymentDescriptorBuilder(org.kie.internal.runtime.conf.DeploymentDescriptorBuilder)

Aggregations

ObjectModel (org.kie.internal.runtime.conf.ObjectModel)56 NamedObjectModel (org.kie.internal.runtime.conf.NamedObjectModel)40 Test (org.junit.Test)34 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)34 ArrayList (java.util.ArrayList)16 ObjectModelResolver (org.kie.internal.runtime.conf.ObjectModelResolver)10 HashMap (java.util.HashMap)9 SimpleCustomObject (org.jbpm.runtime.manager.impl.deploy.testobject.SimpleCustomObject)9 DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)6 EmbedingCustomObject (org.jbpm.runtime.manager.impl.deploy.testobject.EmbedingCustomObject)6 ThirdLevelCustomObject (org.jbpm.runtime.manager.impl.deploy.testobject.ThirdLevelCustomObject)6 KieServices (org.kie.api.KieServices)6 DeploymentDescriptorBuilder (org.kie.internal.runtime.conf.DeploymentDescriptorBuilder)6 ReleaseId (org.kie.api.builder.ReleaseId)5 KieMavenRepository (org.kie.scanner.KieMavenRepository)5 File (java.io.File)4 Before (org.junit.Before)4 Cacheable (org.kie.internal.runtime.Cacheable)4