Skip to content

Commit

Permalink
kie-remote: Fixing deployment operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Rietveld committed May 29, 2014
1 parent 65b8372 commit 1509b17
Show file tree
Hide file tree
Showing 11 changed files with 651 additions and 121 deletions.
Expand Up @@ -29,6 +29,7 @@
import org.kie.services.client.serialization.jaxb.impl.audit.JaxbNodeInstanceLog;
import org.kie.services.client.serialization.jaxb.impl.audit.JaxbProcessInstanceLog;
import org.kie.services.client.serialization.jaxb.impl.audit.JaxbVariableInstanceLog;
import org.kie.services.client.serialization.jaxb.impl.deploy.JaxbDeploymentDescriptor;
import org.kie.services.client.serialization.jaxb.impl.deploy.JaxbDeploymentJobResult;
import org.kie.services.client.serialization.jaxb.impl.deploy.JaxbDeploymentUnit;
import org.kie.services.client.serialization.jaxb.impl.deploy.JaxbDeploymentUnitList;
Expand Down Expand Up @@ -78,6 +79,7 @@ public class JaxbSerializationProvider implements SerializationProvider {
JaxbDeploymentJobResult.class,
JaxbDeploymentUnit.class,
JaxbDeploymentUnitList.class,
JaxbDeploymentDescriptor.class,

// process
JaxbProcessIdList.class,
Expand Down
@@ -0,0 +1,200 @@
/*
* Copyright 2014 JBoss Inc
*
* 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.kie.services.client.serialization.jaxb.impl.deploy;

import java.util.List;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;

import org.kie.internal.deployment.DeploymentUnit.RuntimeStrategy;
import org.kie.internal.runtime.conf.AuditMode;
import org.kie.internal.runtime.conf.NamedObjectModel;
import org.kie.internal.runtime.conf.ObjectModel;
import org.kie.internal.runtime.conf.PersistenceMode;

@XmlRootElement(name="deployment-descriptor")
@XmlAccessorType(XmlAccessType.FIELD)
public class JaxbDeploymentDescriptor {

@XmlElement(name="persistence-unit")
@XmlSchemaType(name="string")
private String persistenceUnit;

@XmlElement(name="audit-persistence-unit")
@XmlSchemaType(name="string")
private String auditPersistenceUnit;

@XmlElement(name="audit-mode")
private AuditMode auditMode = AuditMode.JPA;

@XmlElement(name="persistence-mode")
private PersistenceMode persistenceMode = PersistenceMode.JPA;

@XmlElement(name="runtime-strategy")
private RuntimeStrategy runtimeStrategy = RuntimeStrategy.SINGLETON;

@XmlElement(name="marshalling-strategy")
@XmlElementWrapper(name="marshalling-strategies")
private List<ObjectModel> marshallingStrategies;

@XmlElement(name="event-listener")
@XmlElementWrapper(name="event-listeners")
private List<ObjectModel> eventListeners;

@XmlElement(name="task-event-listener")
@XmlElementWrapper(name="task-event-listeners")
private List<ObjectModel> taskEventListeners;

@XmlElement(name="global")
@XmlElementWrapper(name="globals")
private List<NamedObjectModel> globals;

@XmlElement(name="work-item-handler")
@XmlElementWrapper(name="work-item-handlers")
private List<NamedObjectModel> workItemHandlers;

@XmlElement(name="environment-entry")
@XmlElementWrapper(name="environment-entries")
private List<NamedObjectModel> environmentEntries;

@XmlElement(name="configuration")
@XmlElementWrapper(name="configurations")
private List<NamedObjectModel> configuration;

@XmlElement(name="required-role")
@XmlElementWrapper(name="required-roles")
private List<String> requiredRoles;

public JaxbDeploymentDescriptor() {
// fox jaxb only
}

public JaxbDeploymentDescriptor(String defaultPU) {
this.persistenceUnit = defaultPU;
this.auditPersistenceUnit = defaultPU;
}

public String getPersistenceUnit() {
return persistenceUnit;
}

public void setPersistenceUnit(String persistenceUnit) {
this.persistenceUnit = persistenceUnit;
}

public String getAuditPersistenceUnit() {
return auditPersistenceUnit;
}

public void setAuditPersistenceUnit(String auditPersistenceUnit) {
this.auditPersistenceUnit = auditPersistenceUnit;
}

public AuditMode getAuditMode() {
return auditMode;
}

public void setAuditMode(AuditMode auditMode) {
this.auditMode = auditMode;
}

public PersistenceMode getPersistenceMode() {
return persistenceMode;
}

public void setPersistenceMode(PersistenceMode persistenceMode) {
this.persistenceMode = persistenceMode;
}

public RuntimeStrategy getRuntimeStrategy() {
return runtimeStrategy;
}

public void setRuntimeStrategy(RuntimeStrategy runtimeStrategy) {
this.runtimeStrategy = runtimeStrategy;
}

public List<ObjectModel> getMarshallingStrategies() {
return marshallingStrategies;
}

public void setMarshallingStrategies(List<ObjectModel> marshallingStrategies) {
this.marshallingStrategies = marshallingStrategies;
}

public List<ObjectModel> getEventListeners() {
return eventListeners;
}

public void setEventListeners(List<ObjectModel> eventListeners) {
this.eventListeners = eventListeners;
}

public List<ObjectModel> getTaskEventListeners() {
return taskEventListeners;
}

public void setTaskEventListeners(List<ObjectModel> taskEventListeners) {
this.taskEventListeners = taskEventListeners;
}

public List<NamedObjectModel> getGlobals() {
return globals;
}

public void setGlobals(List<NamedObjectModel> globals) {
this.globals = globals;
}

public List<NamedObjectModel> getWorkItemHandlers() {
return workItemHandlers;
}

public void setWorkItemHandlers(List<NamedObjectModel> workItemHandlers) {
this.workItemHandlers = workItemHandlers;
}

public List<NamedObjectModel> getEnvironmentEntries() {
return environmentEntries;
}

public void setEnvironmentEntries(List<NamedObjectModel> environmentEntries) {
this.environmentEntries = environmentEntries;
}

public List<NamedObjectModel> getConfiguration() {
return configuration;
}

public void setConfiguration(List<NamedObjectModel> configuration) {
this.configuration = configuration;
}

public List<String> getRequiredRoles() {
return requiredRoles;
}

public void setRequiredRoles(List<String> requiredRoles) {
this.requiredRoles = requiredRoles;
}

}
Expand Up @@ -6,25 +6,42 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;


@XmlRootElement(name="deployment-job-result")
@XmlAccessorType(XmlAccessType.FIELD)
@JsonIgnoreProperties({"jobId"})
public class JaxbDeploymentJobResult {

/**
* An internal field used to track the job on the server side
*/
private transient String jobId;

/**
* The id of the jbpm-executor job
*/
@XmlElement
@XmlSchemaType(name="long")
private Long identifier;
private volatile Long identifier;

/**
* The operation (deploy, undeploy) requested
*/
@XmlElement
@XmlSchemaType(name="string")
private String operation;


/**
* Information about the deployment unit
*/
@XmlElement(type = JaxbDeploymentUnit.class)
private JaxbDeploymentUnit deploymentUnit;

@XmlElement
@XmlSchemaType(name="boolean")
private boolean success;
private volatile Boolean success;

@XmlElement
@XmlSchemaType(name="string")
Expand All @@ -34,12 +51,12 @@ public JaxbDeploymentJobResult() {
// default
}

public JaxbDeploymentJobResult(Long id, String explanation, boolean success, JaxbDeploymentUnit depUnit, String operation ) {
public JaxbDeploymentJobResult(String jobId, String explanation, JaxbDeploymentUnit depUnit, String operation ) {
this.jobId = jobId;
this.explanation = explanation;
this.success = success;
this.deploymentUnit = depUnit;
this.operation = operation;
this.identifier = id;
}

public String getOperation() {
Expand All @@ -66,11 +83,11 @@ public void setExplanation(String explanation) {
this.explanation = explanation;
}

public boolean isSuccess() {
public Boolean isSuccess() {
return success;
}

public void setSuccess(boolean success) {
public void setSuccess(Boolean success) {
this.success = success;
}

Expand All @@ -81,4 +98,9 @@ public Long getIdentifier() {
public void setIdentifier(Long identifier) {
this.identifier = identifier;
}

public String getJobId() {
return jobId;
}

}
Expand Up @@ -7,12 +7,15 @@
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.drools.core.util.StringUtils;
import org.kie.internal.deployment.DeploymentUnit;


@XmlRootElement(name="deployment-unit")
@XmlAccessorType(XmlAccessType.FIELD)
@JsonIgnoreProperties({"identifier"})
public class JaxbDeploymentUnit implements DeploymentUnit {

@XmlElement
Expand Down Expand Up @@ -43,11 +46,12 @@ public class JaxbDeploymentUnit implements DeploymentUnit {
private String identifier;

@XmlElement(type = JaxbDeploymentStatus.class)
private JaxbDeploymentStatus status;
private volatile JaxbDeploymentStatus status;

@XmlEnum
public static enum JaxbDeploymentStatus {
NONEXISTENT,
ACCEPTED,
DEPLOYING,
DEPLOYED,
DEPLOY_FAILED,
Expand Down
Expand Up @@ -461,6 +461,8 @@ public void nodeInstanceLogNpeTest() throws Exception {

@Test
public void deploymentObjectsTest() throws Exception {
Assume.assumeFalse(TestType.YAML.equals(getType()));

// for test at end, fill during test
JaxbDeploymentUnitList depUnitList = new JaxbDeploymentUnitList();

Expand All @@ -479,9 +481,11 @@ public void deploymentObjectsTest() throws Exception {
depUnit.setStatus(JaxbDeploymentStatus.NONEXISTENT);
depUnitList.getDeploymentUnitList().add(depUnit);

jaxbJob = new JaxbDeploymentJobResult(null, "test", false, depUnit, "deploy");
jaxbJob = new JaxbDeploymentJobResult(null, "test", depUnit, "deploy");
jaxbJob.setIdentifier(23L);
jaxbJob.setSuccess(false);
JaxbDeploymentJobResult copyJaxbJob = testRoundTrip(jaxbJob);
ComparePair.compareObjectsViaFields(jaxbJob, copyJaxbJob, "identifier");
ComparePair.compareObjectsViaFields(jaxbJob, copyJaxbJob, "jobId", "identifier");

depUnit = new JaxbDeploymentUnit("g", "a", "v");
depUnit.setKbaseName("kbase");
Expand All @@ -494,13 +498,14 @@ public void deploymentObjectsTest() throws Exception {

ComparePair.compareObjectsViaFields(depUnit, copyDepUnit, "identifier");

JaxbDeploymentJobResult depJob = new JaxbDeploymentJobResult(null, "testing stuff", true, copyDepUnit, "test");
JaxbDeploymentJobResult depJob = new JaxbDeploymentJobResult(null, "testing stuff", copyDepUnit, "test");
depJob.setSuccess(true);
JaxbDeploymentJobResult copyDepJob = testRoundTrip(depJob);

ComparePair.compareObjectsViaFields(copyDepJob, depJob, "identifier");
ComparePair.compareObjectsViaFields(copyDepJob, depJob, "jobId", "identifier");

JaxbDeploymentUnitList roundTripUnitList = testRoundTrip(depUnitList);
ComparePair.compareObjectsViaFields(depUnitList.getDeploymentUnitList().get(0), roundTripUnitList.getDeploymentUnitList().get(0), "identifier");
ComparePair.compareObjectsViaFields(depUnitList.getDeploymentUnitList().get(0), roundTripUnitList.getDeploymentUnitList().get(0), "jobId", "identifier");
}

@Test
Expand Down
5 changes: 5 additions & 0 deletions kie-remote/kie-services-remote/pom.xml
Expand Up @@ -134,6 +134,11 @@
<groupId>org.jbpm</groupId>
<artifactId>jbpm-executor</artifactId>
</dependency>
<dependency>
<groupId>org.apache.deltaspike.core</groupId>
<artifactId>deltaspike-core-api</artifactId>
<version>0.7</version>
</dependency>

<!-- TEST -->
<dependency>
Expand Down

0 comments on commit 1509b17

Please sign in to comment.