(block, context, actions, scans)
| 470 | //----------------------------------------------------------- |
| 471 | |
| 472 | function buildActions(block, context, actions, scans) { |
| 473 | let {unprovided} = context; |
| 474 | let actionObjects = []; |
| 475 | for(let action of actions) { |
| 476 | if(action.type === "record") { |
| 477 | let projection = []; |
| 478 | if(action.extraProjection) { |
| 479 | for(let proj of action.extraProjection) { |
| 480 | let variable = context.getValue(proj); |
| 481 | projection[variable.id] = variable; |
| 482 | } |
| 483 | } |
| 484 | let entity = context.getValue(action.variable); |
| 485 | for(let attribute of action.attributes) { |
| 486 | let impl; |
| 487 | if(action.action === "<-") { |
| 488 | impl = ActionImplementations[":="]; |
| 489 | // doing foo <- [#bar] shouldn't remove all the other tags that record has |
| 490 | // same for names |
| 491 | if(attribute.attribute === "name" || attribute.attribute === "tag") { |
| 492 | impl = ActionImplementations["+="]; |
| 493 | } |
| 494 | } else { |
| 495 | impl = ActionImplementations[action.action]; |
| 496 | } |
| 497 | if(attribute.value.type === "parenthesis") { |
| 498 | for(let item of attribute.value.items) { |
| 499 | let value = context.getValue(item) |
| 500 | if(value instanceof join.Variable) { |
| 501 | if(!attribute.nonProjecting && !attribute.value.nonProjecting && !item.nonProjecting) { |
| 502 | projection[value.id] = value; |
| 503 | } |
| 504 | } |
| 505 | let final = new impl(`${attribute.id}|${item.id}|build`, entity, attribute.attribute, value, undefined, action.scopes); |
| 506 | actionObjects.push(final); |
| 507 | item.buildId = final.id; |
| 508 | } |
| 509 | } else { |
| 510 | let value = context.getValue(attribute.value) |
| 511 | if(value instanceof join.Variable) { |
| 512 | if(!attribute.nonProjecting && !attribute.value.nonProjecting) { |
| 513 | projection[value.id] = value; |
| 514 | } |
| 515 | } |
| 516 | let final = new impl(`${attribute.id}|build`, entity, attribute.attribute, value, undefined, action.scopes); |
| 517 | actionObjects.push(final); |
| 518 | attribute.buildId = final.id; |
| 519 | } |
| 520 | } |
| 521 | // if this variable is unprovided, we need to generate an id |
| 522 | if(unprovided[entity.id]) { |
| 523 | projection = projection.filter((x) => x); |
| 524 | let klass = providers.get("generateId"); |
| 525 | scans.push(new klass(`${action.id}|${entity.id}|build`, projection, [entity])); |
| 526 | context.provide(entity); |
| 527 | } |
| 528 | } else if(action.type === "action") { |
| 529 | let {entity, value, attribute} = action; |
no test coverage detected