Skip to content

Commit

Permalink
BZ-1221491: fixing marshalling of additional commands
Browse files Browse the repository at this point in the history
  • Loading branch information
etirelli committed Jun 3, 2015
1 parent 3d3042b commit d69fce6
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,7 @@
import org.drools.core.command.runtime.process.CompleteWorkItemCommand;
import org.drools.core.command.runtime.process.SignalEventCommand;
import org.drools.core.command.runtime.process.StartProcessCommand;
import org.drools.core.command.runtime.rule.DeleteCommand;
import org.drools.core.command.runtime.rule.FireAllRulesCommand;
import org.drools.core.command.runtime.rule.GetObjectCommand;
import org.drools.core.command.runtime.rule.GetObjectsCommand;
import org.drools.core.command.runtime.rule.InsertElementsCommand;
import org.drools.core.command.runtime.rule.InsertObjectCommand;
import org.drools.core.command.runtime.rule.ModifyCommand;
import org.drools.core.command.runtime.rule.QueryCommand;
import org.drools.core.command.runtime.rule.*;
import org.kie.api.command.BatchExecutionCommand;
import org.kie.internal.command.Context;
import org.kie.api.runtime.ExecutionResults;
Expand Down Expand Up @@ -97,39 +90,44 @@ public BatchExecutionCommandImpl( List<GenericCommand<?>> commands, String looku
}

@XmlElements({
@XmlElement(name = "abort-work-item", type = AbortWorkItemCommand.class),
@XmlElement(name = "signal-event", type = SignalEventCommand.class),
@XmlElement(name = "start-process", type = StartProcessCommand.class),
@XmlElement(name = "retract", type = DeleteCommand.class),
@XmlElement(name = "get-global", type = GetGlobalCommand.class),
@XmlElement(name = "set-global", type = SetGlobalCommand.class),
@XmlElement(name = "insert-elements", type = InsertElementsCommand.class),
@XmlElement(name = "query", type = QueryCommand.class),
@XmlElement(name = "insert", type = InsertObjectCommand.class),
@XmlElement(name = "modify", type = ModifyCommand.class),
@XmlElement(name = "get-object", type = GetObjectCommand.class),
@XmlElement(name = "fire-all-rules", type = FireAllRulesCommand.class),
@XmlElement(name = "complete-work-item", type = CompleteWorkItemCommand.class),
@XmlElement(name = "get-objects", type = GetObjectsCommand.class)
})
@XmlElement(name = "abort-work-item", type = AbortWorkItemCommand.class),
@XmlElement(name = "signal-event", type = SignalEventCommand.class),
@XmlElement(name = "start-process", type = StartProcessCommand.class),
@XmlElement(name = "retract", type = DeleteCommand.class),
@XmlElement(name = "get-global", type = GetGlobalCommand.class),
@XmlElement(name = "set-global", type = SetGlobalCommand.class),
@XmlElement(name = "insert-elements", type = InsertElementsCommand.class),
@XmlElement(name = "query", type = QueryCommand.class),
@XmlElement(name = "insert", type = InsertObjectCommand.class),
@XmlElement(name = "modify", type = ModifyCommand.class),
@XmlElement(name = "get-object", type = GetObjectCommand.class),
@XmlElement(name = "fire-all-rules", type = FireAllRulesCommand.class),
@XmlElement(name = "complete-work-item", type = CompleteWorkItemCommand.class),
@XmlElement(name = "get-objects", type = GetObjectsCommand.class),
@XmlElement(name = "set-focus", type = AgendaGroupSetFocusCommand.class),
@XmlElement(name = "clear-activation-group", type = ClearActivationGroupCommand.class),
@XmlElement(name = "clear-agenda", type = ClearAgendaCommand.class),
@XmlElement(name = "clear-agenda-group", type = ClearAgendaGroupCommand.class),
@XmlElement(name = "clear-ruleflow-group", type = ClearRuleFlowGroupCommand.class)
})
protected List<GenericCommand<?>> commands;

/**
* Gets the value of the abortWorkItemOrCompleteWorkItemOrFireAllRules property.
*
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the abortWorkItemOrCompleteWorkItemOrFireAllRules property.
*
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getCommand().add(newItem);
* </pre>
*
*
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link SetGlobalCommand }
Expand All @@ -144,15 +142,15 @@ public BatchExecutionCommandImpl( List<GenericCommand<?>> commands, String looku
* {@link InsertObjectCommand }
*/
public List<GenericCommand<?>> getCommands() {
if (commands == null) {
if ( commands == null ) {
commands = new ArrayList<GenericCommand<?>>();
}
return this.commands;
}

public ExecutionResults execute(Context context) {
for ( GenericCommand<?> command : commands ) {
((GenericCommand<?>)command).execute( context );
((GenericCommand<?>) command).execute( context );
}
return null;
}
Expand All @@ -167,8 +165,8 @@ public String getLookup() {

public String toString() {
return "BatchExecutionCommandImpl{" +
"lookup='" + lookup + '\'' +
", commands=" + commands +
'}';
"lookup='" + lookup + '\'' +
", commands=" + commands +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@
import org.kie.internal.command.Context;
import org.kie.api.runtime.KieSession;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class AgendaGroupSetFocusCommand implements GenericCommand<Void> {

@XmlAttribute(required=true)
private String name;

public AgendaGroupSetFocusCommand() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,25 @@
import org.kie.internal.command.Context;
import org.kie.api.runtime.KieSession;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class ClearActivationGroupCommand implements GenericCommand<Void> {

@XmlAttribute(required=true)
private String name;

public ClearActivationGroupCommand() {
}

public ClearActivationGroupCommand(String name) {
this.name = name;
}

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
import org.kie.internal.command.Context;
import org.kie.api.runtime.KieSession;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class ClearAgendaCommand implements GenericCommand<Void> {

public Void execute(Context context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,25 @@
import org.kie.internal.command.Context;
import org.kie.api.runtime.KieSession;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class ClearAgendaGroupCommand implements GenericCommand<Void> {

@XmlAttribute(name="name", required=true)
private String name;

public ClearAgendaGroupCommand() {
}

public ClearAgendaGroupCommand(String name) {
this.name = name;
}

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,25 @@
import org.kie.internal.command.Context;
import org.kie.api.runtime.KieSession;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class ClearRuleFlowGroupCommand implements GenericCommand<Void> {

@XmlAttribute(required=true)
private String name;

public ClearRuleFlowGroupCommand() {
}

public ClearRuleFlowGroupCommand(String name) {
this.name = name;
}

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@
import org.drools.core.command.runtime.process.CompleteWorkItemCommand;
import org.drools.core.command.runtime.process.SignalEventCommand;
import org.drools.core.command.runtime.process.StartProcessCommand;
import org.drools.core.command.runtime.rule.DeleteCommand;
import org.drools.core.command.runtime.rule.FireAllRulesCommand;
import org.drools.core.command.runtime.rule.GetObjectCommand;
import org.drools.core.command.runtime.rule.GetObjectsCommand;
import org.drools.core.command.runtime.rule.InsertElementsCommand;
import org.drools.core.command.runtime.rule.InsertObjectCommand;
import org.drools.core.command.runtime.rule.ModifyCommand;
import org.drools.core.command.runtime.rule.QueryCommand;
import org.drools.core.command.runtime.rule.*;
import org.drools.core.command.runtime.rule.ModifyCommand.SetterImpl;
import org.drools.core.common.DefaultFactHandle;
import org.drools.core.runtime.impl.ExecutionResultImpl;
Expand Down Expand Up @@ -78,5 +71,15 @@ public static void setAliases(XStream xstream) {
FlatQueryResults.class );
xstream.alias( "fact-handle",
DefaultFactHandle.class );
xstream.alias( "set-focus",
AgendaGroupSetFocusCommand.class );
xstream.alias( "clear-activation-group",
ClearActivationGroupCommand.class );
xstream.alias( "clear-agenda",
ClearAgendaCommand.class );
xstream.alias( "clear-agenda-group",
ClearAgendaGroupCommand.class );
xstream.alias( "clear-ruleflow-group",
ClearRuleFlowGroupCommand.class );
}
}

0 comments on commit d69fce6

Please sign in to comment.