Skip to content

Commit

Permalink
Merge pull request apache#23 from caponetto/KOGITO-4880
Browse files Browse the repository at this point in the history
KOGITO-4880: Fix add/delete data input/outputs
  • Loading branch information
caponetto authored Apr 6, 2021
2 parents 3738933 + 90c7531 commit 3ba039c
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@
<artifactId>errai-ui</artifactId>
</dependency>

<dependency>
<groupId>org.jboss.errai</groupId>
<artifactId>errai-marshalling</artifactId>
</dependency>

<dependency>
<groupId>org.uberfire</groupId>
<artifactId>uberfire-commons-editor-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import javax.enterprise.context.Dependent;
import javax.inject.Inject;

import org.jboss.errai.marshalling.client.Marshalling;
import org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.AssignmentData;
import org.kie.workbench.common.stunner.bpmn.client.forms.fields.model.AssignmentRow;
import org.kie.workbench.common.stunner.bpmn.client.forms.util.ListBoxValues;
Expand Down Expand Up @@ -84,8 +85,7 @@ public void handleOkClick() {
}

protected String marshallToJson(final AssignmentData data) {
//FIXME: tiago ???
return ""; // Marshalling.toJSON(data);
return Marshalling.toJSON(data);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.google.gwt.user.client.ui.HasValue;
import org.gwtbootstrap3.client.ui.Button;
import org.gwtbootstrap3.client.ui.TextBox;
import org.jboss.errai.marshalling.client.Marshalling;
import org.jboss.errai.ui.shared.api.annotations.DataField;
import org.jboss.errai.ui.shared.api.annotations.EventHandler;
import org.jboss.errai.ui.shared.api.annotations.Templated;
Expand Down Expand Up @@ -361,12 +362,11 @@ public void showDataIOEditor(final String datatypes) {
isSingleOutputVar);

ActivityDataIOEditor.GetDataCallback callback = assignmentDataJson -> {
// FIXME: tiago ???
// AssignmentData assignmentData1 = Marshalling.fromJSON(assignmentDataJson,
// AssignmentData.class);
// String assignmentsInfoString = createAssignmentsInfoString(assignmentData1);
// setValue(assignmentsInfoString,
// true);
AssignmentData assignmentData1 = Marshalling.fromJSON(assignmentDataJson,
AssignmentData.class);
String assignmentsInfoString = createAssignmentsInfoString(assignmentData1);
setValue(assignmentsInfoString,
true);
};

activityDataIOEditor.setCallback(callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,62 @@

package org.kie.workbench.common.stunner.bpmn.client.forms.fields.model;

//@ClientMarshaller(AssignmentData.class)
//@ServerMarshaller(AssignmentData.class)
// FIXME: tiago ???
import org.jboss.errai.common.client.protocols.SerializationParts;
import org.jboss.errai.marshalling.client.api.MarshallingSession;
import org.jboss.errai.marshalling.client.api.annotations.ClientMarshaller;
import org.jboss.errai.marshalling.client.api.annotations.ServerMarshaller;
import org.jboss.errai.marshalling.client.api.json.EJObject;
import org.jboss.errai.marshalling.client.api.json.EJValue;
import org.jboss.errai.marshalling.client.marshallers.AbstractNullableMarshaller;

@ClientMarshaller(AssignmentData.class)
@ServerMarshaller(AssignmentData.class)
public class AssignmentDataMarshaller
// extends AbstractNullableMarshaller<AssignmentData>
{
extends AbstractNullableMarshaller<AssignmentData> {

public static final String INPUT_VARIABLES = "inputVariables";
public static final String OUTPUT_VARIABLES = "outputVariables";
public static final String PROCESS_VARIABLES = "processVariables";
public static final String ASSIGNMENTS = "assignments";
public static final String DATA_TYPES = "dataTypes";
public static final String DISALLOWED_PROPERTY_NAMES = "disallowedPropertyNames";
public static final String VARIABLE_COUNTS_STRING = "variablecountsstring";

public AssignmentData doNotNullDemarshall(final EJValue o,
final MarshallingSession ctx) {
EJObject obj = o.isObject();
String inputVariables = obj.get(INPUT_VARIABLES).isString().stringValue();
String outputVariables = obj.get(OUTPUT_VARIABLES).isString().stringValue();
String processVariables = obj.get(PROCESS_VARIABLES).isString().stringValue();
String assignments = obj.get(ASSIGNMENTS).isString().stringValue();
String varCounts = obj.get(VARIABLE_COUNTS_STRING).isString().stringValue();
String dataTypes = obj.get(DATA_TYPES).isString().stringValue();
String disallowedPropertyNames = obj.get(DISALLOWED_PROPERTY_NAMES).isString().stringValue();
AssignmentData data = new AssignmentData(inputVariables,
outputVariables,
processVariables,
assignments,
dataTypes,
disallowedPropertyNames);
data.setVariableCountsString(varCounts);
return data;
}

public String doNotNullMarshall(final AssignmentData o,
final MarshallingSession ctx) {
return "{\"" + SerializationParts.ENCODED_TYPE + "\":\"" + AssignmentData.class.getName() + "\"," +
"\"" + SerializationParts.OBJECT_ID + "\":\"" + o.hashCode() + "\"," +
"\"" + INPUT_VARIABLES + "\":\"" + o.getInputVariablesString() + "\"," +
"\"" + OUTPUT_VARIABLES + "\":\"" + o.getOutputVariablesString() + "\"," +
"\"" + PROCESS_VARIABLES + "\":\"" + o.getProcessVariablesString() + "\"," +
"\"" + ASSIGNMENTS + "\":\"" + o.getAssignmentsString() + "\"," +
"\"" + VARIABLE_COUNTS_STRING + "\":\"" + o.getVariableCountsString() + "\"," +
"\"" + DATA_TYPES + "\":\"" + o.getDataTypesString() + "\"," +
"\"" + DISALLOWED_PROPERTY_NAMES + "\":\"" + o.getDisallowedPropertyNamesString() + "\"}";
}

// public static final String INPUT_VARIABLES = "inputVariables";
// public static final String OUTPUT_VARIABLES = "outputVariables";
// public static final String PROCESS_VARIABLES = "processVariables";
// public static final String ASSIGNMENTS = "assignments";
// public static final String DATA_TYPES = "dataTypes";
// public static final String DISALLOWED_PROPERTY_NAMES = "disallowedPropertyNames";
// public static final String VARIABLE_COUNTS_STRING = "variablecountsstring";
//
// public AssignmentData doNotNullDemarshall(final EJValue o,
// final MarshallingSession ctx) {
// EJObject obj = o.isObject();
// String inputVariables = obj.get(INPUT_VARIABLES).isString().stringValue();
// String outputVariables = obj.get(OUTPUT_VARIABLES).isString().stringValue();
// String processVariables = obj.get(PROCESS_VARIABLES).isString().stringValue();
// String assignments = obj.get(ASSIGNMENTS).isString().stringValue();
// String varCounts = obj.get(VARIABLE_COUNTS_STRING).isString().stringValue();
// String dataTypes = obj.get(DATA_TYPES).isString().stringValue();
// String disallowedPropertyNames = obj.get(DISALLOWED_PROPERTY_NAMES).isString().stringValue();
// AssignmentData data = new AssignmentData(inputVariables,
// outputVariables,
// processVariables,
// assignments,
// dataTypes,
// disallowedPropertyNames);
// data.setVariableCountsString(varCounts);
// return data;
// }
//
// public String doNotNullMarshall(final AssignmentData o,
// final MarshallingSession ctx) {
// return "{\"" + SerializationParts.ENCODED_TYPE + "\":\"" + AssignmentData.class.getName() + "\"," +
// "\"" + SerializationParts.OBJECT_ID + "\":\"" + o.hashCode() + "\"," +
// "\"" + INPUT_VARIABLES + "\":\"" + o.getInputVariablesString() + "\"," +
// "\"" + OUTPUT_VARIABLES + "\":\"" + o.getOutputVariablesString() + "\"," +
// "\"" + PROCESS_VARIABLES + "\":\"" + o.getProcessVariablesString() + "\"," +
// "\"" + ASSIGNMENTS + "\":\"" + o.getAssignmentsString() + "\"," +
// "\"" + VARIABLE_COUNTS_STRING + "\":\"" + o.getVariableCountsString() + "\"," +
// "\"" + DATA_TYPES + "\":\"" + o.getDataTypesString() + "\"," +
// "\"" + DISALLOWED_PROPERTY_NAMES + "\":\"" + o.getDisallowedPropertyNamesString() + "\"}";
// }
//
// @Override
// public AssignmentData[] getEmptyArray() {
// return new AssignmentData[0];
// }
@Override
public AssignmentData[] getEmptyArray() {
return new AssignmentData[0];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.jboss.errai</groupId>
<artifactId>errai-marshalling</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"http://google-web-toolkit.googlecode.com/svn/tags/2.8.2/distro-source/core/src/gwt-module.dtd">
<module>

<inherits name="org.jboss.errai.marshalling.ErraiMarshalling" />

<!-- Uberfire dependencies -->
<inherits name="org.uberfire.UberfireAPI"/>
<inherits name="org.uberfire.client.views.PatternFlyTheme"/>
Expand Down

0 comments on commit 3ba039c

Please sign in to comment.