How to define a Mapp and a MappType


#1

I am defining a WorkflowActionStep and I need to give a parameter that is a map. I am defining my map as below using Mapp and MappType.

var mapargs = new C3.typesys.Mapp(new C3.typesys.MappType(
_ C3.typesys.PrimitiveType.String, AnyType));_

Then I add the following entries to the map using set(key, name) and I have two parameters that are dates.

startDate=Date.deserialize(‘2018-10-24T00:00:00’);
endDate=Date.deserialize(‘2018-10-25T00:00:00’);

mapargs.set(“filter”, “any_filter”);
mapargs.set(“start”, startDate);
mapargs.set(“end”, endDate);

However, the issue is that the (primitive) type assigned to the start and end dates values are not datetime, the mapp stores both types as string, although they are datetime, then it causes an issue when the WorkflowActionStep runs, below exception is thrown because it tries to pass the value of startdate as string because it stored its type as a string.

c3.love.exceptions.C3RuntimeException: Unable to coerce string value of MeterAssetAnalyticProcessor.runAnalyticsJob#start to datetime at c3.love.typesys.ValueType.coerceValue(ValueType.java:368) at c3.love.typesys.obj.ValueTypeImpl.coerceValueAndTypeCheck(ValueTypeImpl.java:266) at c3.love.typesys.obj.FunctionTypeImpl.coerceArguments(FunctionTypeImpl.java:277) at

Does anyone knows how should I provide the type of a value in a mapp?


#2

Unless you’re on a very old environment you shouldn’t need to do this complicated code…

try:
myType.myFunction({filter: 'any_filter', start: '2018-10-24', end: '2018-10-25'})

the client typesystem library should automatically convert this to a c3 mapp.


#3

Thanks Riley, this works to create the c3 mapp.

But the issue is for the start and end fields, their type will be stored as a string in the WorkflowActionStep Type that I am using it. Is there a way I can define or change the type?

{
  "batchSize": {
    "type": "int",
    "value": 10
  },
  "end": {
    "type": "string",
    "value": "2018-10-25T00:00:00.000"
  },
  "filter": {
    "type": "string",
    "value": any_filter"
  },
  "idSuffix": {
    "type": "string",
    "value": "any_suffix"
  },
  "start": {
    "type": "string",
    "value": "2018-10-24T00:00:00.000"
  }
}

#4

I see… its possible “workflow” only knows about ‘string’ arguments. One option is to manually convert these strings into dateTime objects inside the workflow code. something like: DateTime.fromString(options.end.value)

It sounds like a good enhancement request to natively have batch job understand DateTime


#5

I was able to make it work is by specifying the type explicitly like this - start":{“type”:“datetime”,“value”:“2018-10-21T00:00:00”}


#6

thanks both it worked making it explicitly as Venkat said.