Using non-scalar variables in BuildMaster otter-script plans - buildmaster

I'm pulling my hair out trying to get some very basic iteration working using non-execution set variables (ie setting things at Global with potential to override at lower scope).
Setting a $variable to some value works fine but I need to do something like...
foreach $DeployConfigKey in #MapKeys(%DeployConfigs)
{
...
}
So far I'm getting nowhere fast with execution errors saying "Invalid value for property Map; expected map."
Further doing something like set %executionvar = %DeployConfigs complains that a map cannot be set to a scaler value.
The variable, DeployConfigs looks like ...
%{"Web.config": ["Web.Beta.config", "Web.Release.config"]}
and is defined at Global scope.
What am I doing wrong?
I'm using buildmaster 5.7.3

Maps are specified as %(key: value), here is an example plan that should help:
set %map = %(Web.config: #("Web.Beta.config", "Web.Release.config"));
foreach $key in #MapKeys(%map)
{
set #values = %map[$key];
Log-Information `$key = $key;
Log-Information `#values = $Join(", ", #values);
}
Sleep 3;

Related

GMS2 returns instance_create_layer :: specified layer "text_layer" does not exist even though the layer exists how do i fix this?

heres the code
var _obj;
if (instance_exists(obj_text)) _obj = obj_txt_queued; else _obj = obj_text;
with (instance_create_layer(0, 0, "text_layer", _obj))
{
msg = argument[0];
if (instance_exists(other)) originInstance = other.id else originInstance = noone;
if (argument_count > 1) background = argument[1]; else background = 1;
}
with (obj_phae)
{ if (state != scr_player_state_lock)
{
lastState = state;
state = scr_player_state_lock;
}
}
[layers](https://i.stack.imgur.com/9u9tD.png)
I tried removing any extra rooms that were not needed and I tried changing the layer name to something else.
I also tried using var instance_create_layer() but that obviously didn't work
I'm a bit confused at this part:
with (instance_create_layer(0, 0, "text_layer", _obj))
Especially the with(), as that function will go through every object in the room if it sees an object within the parameter, since you suggested to create a new object with it, I'm surprised it doesn't create an infinite loop. Maybe it works, I've never tried it myself, but I think there's a more logical way to assign variables from one object to a newly created object.
Assuming you want to use the With() statement to address the variables within the _obj, I think you can manage something similair through this function:
var object = instance_create_layer(0, 0, "text_layer", _obj)
object.msg = argument[0];
object.originInstance = id
if (argument_count > 1) object.background = argument[1]; else object.background = 1;
It's probably a given at this point, but double-check that this part of code can only run if it's in the same room that has a layer called "text_layer"
In the worst case, you may also try out instance_create_depth() and use the build-in depth variable from the object instead of the layer names. Using depth is more flexible, but less organised than layers.

How to use MDX constants/functions in icCube Reporting?

I have several functions/constants defined in the schema. An example is:
_latestPeriodWithData() which returns a date.
Goal: I want to use this value in the Reporting to set a Guide in a chart, using the demo example 'On Widget Options':
This is what I tried so far:
I have assigned this function as 'MDX / Value' for a Report Constant _lastDate and obtained the value for this constant using the java script function: context.eventValue('_lastDate'); but that just gives me the caption. The function context.eventObject("_lastDate").options.asMdx gives me _latestPeriodWithData(), but not its value.
On Widget Options
/**
* Result will be used while rendering.
*/
function(context, options, $box) {
// for debugging purpose
console.log(context.eventObject("_lastDate").options.asMdx);
options.guides[0].value = context.eventObject("_lastDate").options.asMdx; // <-- gives me _latestPeriodeWith data
// but not its value
options.guides[0].toValue = context.eventObject("_lastDate").options.asMdx;
options.guides[0].lineAlpha = 1;
options.guides[0].lineColor = "#c44";
return options;
}

How to collect values for multi-valued queryparam in apigee?

For a request with a multi-valued queryparam like: https://test.apigee.net?storeIds=abc&storeIds=xyz, how can someone setup an extract variable policy so that there will be a storeIds array like: storeIds=["abc","xyz"]?
Update #1:
Using the following in javascript for Apigee:
var arrayOfStoreIds = [];
for (i = 0; i < context.proxyRequest.queryParams['storeIds'].length; i++) {
arrayOfStoreIds.push(context.proxyRequest.queryParams['storeIds'][i]);
}
Yields an error:
`Execution of script failed with error:
Javascript runtime error:
"TypeError: Cannot find default value for object ... at line ##"`
The line # referenced points to the 1st line of the for loop
Update #2:
Incorrect documentation at http://apigee.com/docs/api-services/reference/javascript-object-model:
context.proxyRequest.queryParams['city'].length; // == 2
Correct syntax at https://github.com/ap-andrew/DevGuide/blob/master/javascript_new.html#L141
context.proxyRequest.queryParams['city'].length(); // == 2
So with this context.proxyRequest.queryParams['storeIds'].length() it works! At least in javascript ... I still don't know how to do this via an extract variable policy...
Truth be told, there is no spec on using duplicate query parameters. However, you can clearly see there's an issue when trying to retrieve them; you'd encounter this in php using $_GET, in JavaScript, Node.js, et al.
I'd suggest if you can, do something using pipe or comma separation: storeIds=abc,xyz. Then to extract query parameters using an ExtractVariables policy, you would do something like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<ExtractVariables async="false" continueOnError="true" enabled="true" name="productsVariables">
<DisplayName>Extract</DisplayName>
<URIPath>
<QueryParam name="storeIds">
<Pattern ignoreCase="true">{storeIdsArray}</Pattern>
</QueryParam>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</ExtractVariables>
In your javascript, you could then do:
try {
var storeIdsArray = context.getVariable('storeIdsArray').split(',');
storeIdsArray.forEach(function(storeId) {
// do something with storeId
}
}
catch (e) {
// storeIdsArray wasn't defined or not an array or something else went wrong
}
In raw CGI you can split multiple values with the same queryparam on NULL, but in Apigee, by the time it gets to the Message Processor, the queryparam only contains the first value. So the only way to do this is brute force using the full message.querystring.
If I sent in:
testme?myQueryParam=Y&myQueryParam=X
I have to do a double split using JavaScript and loop through each queryparam doing something like this:
var text = "";
var myQueryParams = context.getVariable('message.querystring');
var myQueryParamArray = myQueryParams.split(/\&/);
for (i = 0; i < myQueryParamArray.length; i++) {
var myvals = myQueryParamArray[i].split(/\=/);
text += myvals[1] + ", ";
}
context.setVariable('mytext', text);
In this example I create a variable named mytext with the value of "X, Y,"

global variable not getting set with proper values in another function in flex

I have a global variable 'csId' of string type. In the code below under drawChart() function, in for loop, csID variable should be set to '1' by the modelLocator when i=0 and csId should be set to '2' by modelLocator when i=1.(considering lengh=2).
Alert in drawchart() (for csId) seems to be printing the right 'csid' values(both 1 and 2) but in the dataFunction() 'columnSeries_labelFunc' i am always getting the csId Alert value as '2' and never as '1'.
Please find the code below:
drawchart() function::
public function drawChart():void
{
var cs:ColumnSeries= new ColumnSeries();
var lenght:Number=AppModelLocator.getInstance().ctsModel.productSummary.getItemAt(0).collMgmtOfcList.length;
myChart.series = [cs];
var tempObj:Object;
for(csLoop=0;csLoop<lenght;csLoop++)
{
cs = new ColumnSeries();
this.csId= new String(String(AppModelLocator.getInstance().ctsModel.productSummary.getItemAt(0).collMgmtOfcList[csLoop]));
Alert.show("csId="+this.csId);
cs.id=this.csId;
cs.displayName = 'Exposure';
cs.dataFunction=columnSeries_labelFunc;
myChart.series[csLoop] = cs;
}
columnSeries_labelFunc() function::
private function columnSeries_labelFunc(series:Series, item:Object, fieldName:String):Object {
var col:Number=0;
Alert.show("value of csid in columnSeries_labelFunc="+this.csId);
if(fieldName == "yValue" && series.id==csId){
return(item.exposureUSDList[0]);
}else if(fieldName == "yValue" && series.id==csId) {
return(item.exposureUSDList[1]);
}else if(fieldName == "xValue"){
return(item.rptType);
}else
return null;
}
Please Help!!!
First: Assigning a value to a global variable repeatedly inside a loop is a bad idea. Nothing good will happen from that.
It's hard to tell from the context here, but the most likely reason that you're having this problem is that the flow of execution is as follows:
drawChart() executes synchronously, counting through each step in the loop, creating the ColumnSeries, which are each invalidated, meaning they will redraw on the next frame. The function ends, with csID at the last value it held.
The app goes into the next step in the elastic racetrack and validates the invalidated components.
columnSeries_labelFunc is called, with csID still holding the terminal value from the loop.
The end result being that columnSeries_labelFunc isn't called until you're already completely finished in drawChart.
The simplest fix would be to read the id that you're setting on the series in the label function, rather than relying on a global variable at all.

Drupal filter is not working properly

I'm not sure how to ask it, so if you need anymore additional information, please ask for it!
Situation
I've got a website in three languages. I got a lot of customer cases online each connected to a sector (depending in which sector they belong). Each sector and reference has it's own unique nid.
In my template.php it's stated like this:
if ('sector' == $vars['node']->type) {
$lang = '/'.$vars['language'].'/';
$key_path = $_SERVER['REQUEST_URI'];
$key_path = substr_count($key_path, $lang) ? substr($key_path, strlen($lang)) : $key_path;
if (strpos($key_path, '?')) $key_path = substr_replace($key_path, '', strpos($key_path, '?'));
if (strpos($key_path, 'sectors-references') === 0) {
$view = views_get_view('references');
if (!empty($view)) {
$view->set_arguments((int)$vars['node']->nid);
$vars['content']['suffix'] = $view->render();
}
}
}
And yet, every sector shows me the same references... What do I have to change to get the correct reference under the right sector?
Usually arguments are passed to set_arguments using an array, if you pass a non-array the argument will probably be ignored which is why you're always getting the same result. Try:
$view->set_arguments(array((int)$vars['node']->nid));

Resources