Annotating column tag in azure data catalog - azure-data-catalog

I am able to annotate description of a table by using asset URL (Location of the table in ADC).
Http request I am using is:
{table_location_url}/descriptions?api-version=2016-03-30
Json object is:
private static string DescriptionJson(string description)
{
return string.Format(#"
{{
""properties"" : {{
""key"": ""{0}"",
""fromSourceSystem"": false,
""description"": ""{1}""
}}
}}
", Guid.NewGuid().ToString("N"), description);
}
Annotating description for table is successful.
Now I am trying to annotate tag for a column using,
Http request: {table_location_url}/columnTags?api-version=2016-03-30
static string SampleAnnotationJson(string name)
{
return string.Format(#"
{{
""properties"" : {{
""key"": ""{0}"",
""fromSourceSystem"": false,
""columnName"": ""on_hold_text_key"",
""termId"": ""https://1194df16-3ae0-49aa-b48b-5c4da6e13689-imss-data-catalog.api.datacatalog.azure.com/catalogs/IMSS-Data-Catalog/glossaries/IMSS-Data-Catalog/terms/4b8fe89d-c92a-4aee-abe1-691a2cd52458"",
}}
", Guid.NewGuid().ToString("N"));
}
I am getting bad request erro r(400).
Am I missing anything?

The issue is with the json request, flower brackets are not closed properly. It works fine with the correction.

Related

serenity-js / cucumber / chai Promise AssertionError need some assistance

Im losing it, I feel like im doing this right BUT cant figure out why this simple test fails
I got a feature file like so
Scenario: List all accounts in the tenant
Given that Keith has navigated to the tenant account list
When he views the accounts in the table that include name, name, name
Then he should also see 1,2,3 in the list
I got a definition file like so
this.When(/^(.*?) views the accounts in the table that include (.*)$/, (name: string, accountInformation: string) => {
return stage.theActorCalled(name).attemptsTo(
ViewAllAccountNames.inTheTableOf(listOf(accountInformation)),
);
});
I got a pageObject file like so
export class AccountTable {
// static displayingAll = Text.ofAll(AccountListUI.accountListView);
// static isDisplayingAllNames = Text.ofAll(Target.the('account names in the table').located(by.css('table tbody tr td:nth-child(2)')));
static AccountNames = Target.the('account names in the table').located(by.css('table tbody tr td:nth-child(2)'));
static AccountNumbers = Target.the('account numbers in the table').located(by.css('table tbody tr td:nth-child(1)'));
static isDisplayingAllNames = Text.ofAll(AccountTable.AccountNames);
static isDisplayingAllNumbers = Text.ofAll(AccountTable.AccountNumbers);
}
here is my class that does the work
constructor(private accName: string[]) {
}
static inTheTableOf(accName: string) {
return new ViewAllAccountNames(accName);
}
performAs(actor: PerformsTasks): PromiseLike<void> {
return actor.attemptsTo(
See.if(AccountTable.isDisplayingAllNames, items => expect(items).to.eventually.contain(this.accName))
);
}
}
when i debug through webstorm inside class ViewAllAccountNames i get
static inTheTableOf(accName: string) { accName: Array(3)
return new ViewAllAccountNames(accName); accName: Array(3)
}
then when i get to my See.if function I get
performAs(actor: PerformsTasks): PromiseLike<void> {
return actor.attemptsTo(
See.if(AccountTable.isDisplayingAllNames, items => expect(items).to.eventually.contain(this.accName)) AccountTable.isDisplayingAllNames: undefined
);
}
so my dilemma is this:
and I think it stems to my See.if function isnt setup in the correct way?
See.if(AccountTable.isDisplayingAllNames, items => expect(items).to.eventually.contain(this.accName))
Cucumber test run has failed.
1) Scenario: List all accounts in the tenant - e2e\features\get_account_list\get_all_accounts.feature:10
Step: When he views the accounts in the table that include name, name, name - e2e\features\get_account_list\get_all_accounts.feature:12
Step Definition: node_modules\serenity-js\src\serenity-cucumber\webdriver_synchroniser.ts:47
Message:
AssertionError: expected [ Array(5) ] to include [ 'name', 'name', 'name' ]
From: Task: <anonymous>
i am an idiot, I was using the wrong function, had to use the function
.to.eventually.contain.members
similar answer and description found here:
Answer

Pomm Twig and relation

For a project I'm using pommbundle, it's perfect for generating entities with an existing database.
In my controller:
$catalogues = $this->get('pomm')['my_db1']
->getModel('\AppBundle\Entity\MyDb1\PublicSchema\CatalogueModel')
->findAll();
return this->render(
'SiteBundle:Default:homePage.html.twig',
array('catalogues'=>$catalogues));
But how can I access the variable inside my view (Twig)
{% for catalogue in catalogues %}
{{dump(catalogue)}} --> value inside
{% endfor %}
Result dump
Catalogue {#1132 ▼
#container: array:13 [▼
"ID" => 8
"Code" => "MATIÈRE PREMIÈRE"
"Actif" => true
"DateAjout" => DateTime {#1212 ▶}
"Index" => 0
"PriseCommande" => false
"Description" => ""
"Couleur" => "Green"
"CouleurText" => "#000000"
"Tarif" => null
"WebActif" => false
"WebTitre" => null
"WebDescription" => null ]
-status: 1 }
catalogue.ID (not working) catalogue.container.ID (not working)
with catalogue.get('ID') works but it's the best way?
Other question
If my entity has a relation, e.g. WebActif -> relation with another table,
How to access Webactif because the dump returns only an ID.Do I have to create my own method?
Is it possible to show a basic example?
The Model::findAll method returns an iterator on database results. When this iterator is traversed, it returns entities filled with converted values.
Note: you’d better not use upper case letters in your column names as it will lead to confusion and it will not work properly with Pomm flexible entities. (same applies for table names).
<dl>
{% if catalogues.isEmpty() %}
<dt>No results found.</dt>
{% else %}
<dt>There are {{ catalogues.count() }} results:</dt>
{% for catalogue in catalogues %}
<dd>{{ catalogue.code }} (added the {{ catalogue.date_ajout.format('d-m-Y') }}){% if catalogue.actif %} OK {% endif %}</dd>
{% endfor %}
{% endif %}
</dl>
Edit: Since your comment says your database contains capitalized column names here is an additional explanation on how flexible entities work.
(Official documentation about flexible entities is here)
When a flexible entity is hydrated by the iterator values, they are converted and then pushed with their name in the entity. This is why you can use the generic accessor $entity->get('MyColumn') because keys are preserved.
But flexible entities are strange beasts because they can change depending on the SELECT that decides the data sent to them. When such entity is created the getters and setters are virtually created using PHP’s __get and __set and __call functions.
This can seem weird but look at this example:
<?php
$entity = new MyEntity(['first_name' = 'John', 'last_name' => 'Doe']);
$entity['first_name']; // calls $entity->getFirstName() which defaults to $this->get('first_name');
It is then possible to override default accessors:
<?php
class MyEntity extends FlexibleEntity
{
/*
* Triggered by $entity['first_name']
* or $entity->first_name
*/
public function getFirstName(): string
{
return uc_words($this->get('first_name'));
}
public function getLastName(): string
{
return strtoupper($this->get('last_name'));
}
public function getName(): string
{
return sprintf("%s %s", $this->getFirstName(), $this->getLastName());
}
}
Then, in twig it is possible to simply do {{ entity.name }} to trigger the getName function.
As you can see, the column names are camel cased to create the virtual accessors, this operation can be reversed only if the original column names are in lower case.

Sending variable from volt to custom function

I have created a custom function I can access from the volt. The function seems to work fine, but I cannot manage to send the variable to the function. It sends the variable as text instead of its value.
The twig function:
$volt->getCompiler()->addFunction('getusergroup', function ($user) {
return \Models\User::getUserGroup($user);
});
The function in the Model:
public static function getUserGroup($user) {
return UserGroup::find(array('conditions' => 'user_id = ' . $user));
}
The lines in Twig to call the function:
{% for member in getusergroup(staff.id) %}
{{ member.Group.name }}
{% endfor %}
The error I get:
'Scanning error before 'staff->id' when parsing: SELECT
[Models\UserGroup].* FROM [Models\UserGroup] WHERE user_id =
$staff->id (78)' (length=131)
As you can see, in stead of $staff->id being an integer, it's the text.
How do I go about sending the actual ID to the function?
By the way, I am using twig in combination with Phalcon and followed the instructions in this article: http://phalcontip.com/discussion/60/extending-volt-functions
If you dump $user inside of your method public static function getUserGroup($user), you will receive this $staff->id, but you actually want something like 42.
To avoid this register the Volt function like this:
$volt->getCompiler()->addFunction('getusergroup', function ($resolvedArgs, $exprArgs) {
return 'Models\User::getUserGroup(' . $resolvedArgs . ')';
});
More info on Extending Volt Functions

Template 'content template 'checked' defined by XXX returned null for args: '[]'

I'm using Geb and Spock to writing my Integration Test and here are my codes:
ITCase.groovy:
waitFor {
documents && documents[index]?.displayed && documents[index].checked?.displayed
}
documents[index].checked.click()
Page.groovy:
static content = {
documents {
moduleList DocumentListItemModule, $("#documents-list table tbody tr")
}
}
DocumentListItemModule.groovy:
static content = {
checked { $(".tst-doc-checkbox").find { it.displayed }}
}
Usually it worked well, but occasionally there will be error at line documents[index].checked.click():
Template 'content template 'checked' defined by XXX returned null for args: '[]'
How can I solve this problem?
I faced the same issue and solved it by waiting for the element. So in your case, I would try something like
static content = {
checked(wait: true) { $(".tst-doc-checkbox").find { it.displayed }}
}

How to use multiple helpers in handlebars

I have written two helpers namely i18n and toLowerCase as following:
/*
* Returns lowercase of a string
*/
Handlebars.registerHelper('toLowerCase', function(value) {
if (value && typeof value === 'string') {
return value.toLowerCase();
} else {
return '';
}
});
I have a string which should be converted to lowercase first and then should be localized using i18n helper. Both these helpers work/run fine.
These lines are working fine. (Tested)
{{toLowerCase status }}
{{i18n status}}
But I want something like this.I have tried this:
{{i18n {{toLowerCase status }} }}
But this throws syntax error as
Uncaught Error: Parse error on line 88:
..div> {{ i18n {{toLowerCase stat
----------------------^
Expecting 'CLOSE', 'CLOSE_UNESCAPED', 'STRING', 'INTEGER', 'BOOLEAN', 'ID', 'DATA', 'SEP', got 'OPEN'
Any suggestions ?
Handlesbars supports Subexpressions now, so you could just do:
{{i18n (toLowerCase status) }}
(notice, those are parens (), not curly braces {}, for the inside helper)
You could try using https://github.com/mateusmaso/handlebars.nested (be aware that it allows only one level of nesting, though). As far as I know, there's no built-in support on Handlebars for this, though you can use some of the workarounds in the question I linked in comments.

Resources