What is the M2DOC Eclipse Capella command to maximize an image in a Word page? - m2doc

What is the M2DOC Eclipse Capella command to maximize an image in a Word page?
I try this code:
{m:for rep | lc.representationByDescriptionName('Logical Architecture Blank')}
{m:if rep.getHeight() > rep.getWidth()}
{m:rep.asImage().setHeight(600)}
{m:else}
{m:rep.asImage().setWidth(400)}
{m:endif}
But give me this error:
{m:if rep.getHeight() >= rep.getWidth()} Invalid if statement: Couldn't find the 'getHeight(org.eclipse.sirius.viewpoint.DRepresentation)' serviceInvalid if statement: Couldn't find the 'getWidth(org.eclipse.sirius.viewpoint.DRepresentation)' serviceInvalid if statement: The predicate never evaluates to a boolean type ([]).
But I have insert all the sirius package uri.
Thank you so much!

You are using the DRepresentation to call the service getHeight(), you should call it on the MImage:
rep.asImage().getHeight()
But for optimization, you can use a let:
{m:for rep | lc.representationByDescriptionName('Logical Architecture Blank')}
{m:let image = rep.asImage()}
{m:if image.getHeight() > image.getWidth()}
{m:image.setHeight(600)}
{m:else}
{m:image.setWidth(400)}
{m:endif}
{m:endlet}
{m:endfor}

Related

Is it possible to format the colour of parts of my git branch name inside the prompt?

In my .zshrc file I have the following lines that parse my current git branch and display it in the terminal, the .zshrc file looks like this:
# Load version control information
autoload -Uz vcs_info
precmd() { vcs_info }
# Set up the prompt (with git branch name)
setopt PROMPT_SUBST
PROMPT='%n in ${PWD/#$HOME/~} ${vcs_info_msg_0_} > '
# Format the vcs_info_msg_0_ variable
zstyle ':vcs_info:git:*' formats '(%b)'
So my terminal ends up looking like this:
me in ~/repos/myrepo (feat/MYISSUE-123/fix-the-broken-stuff) >
I would like to modify the script above so MYISSUE-123 has a different colour to the rest of the branch name.
How can I do that?
Try this ... change precmd to:
precmd() {
vcs_info
psvar=(${(s:/:)vcs_info_msg_0_})
# in case there are more than three components:
psvar[3]=${(j:/:)psvar[3,-1]}
}
Make sure precmd() is being called prior to each prompt display by adding it to the hook:
autoload -Uz add-zsh-hook
add-zsh-hook precmd precmd
And change PROMPT to:
PROMPT='%n in ${PWD/#$HOME/~} %1v/%F{red}%2v%f/%3v > '
There are some notes about psvar in this answer: https://stackoverflow.com/a/64094551/9307265.
The (s) and (j) parameter expansion flags are documented in the zshexpn man page.
Please let me know if there are any issues.

Migrate taxonomy reference field into entity reference

Am trying to migrate a taxonomy-reference field attached to a field_collection entity-type (Drupal 7) into an entity-reference field attached to a paragraphs entity-type (Drupal 8.6).
Although it seems one of the basic tasks to do while migration but I couldn't find a clear reference of how to do it.
id: d7_field_collection_field_name
label: My Field name
migration_tags:
- Drupal 7
migration_group: migrate_drupal_7
source:
plugin: d7_custom_source_plugin
process:
field_title:
plugin: get
source: field_title
field_job_category:
plugin: get
source: field_job_category
destination:
plugin: 'entity_reference_revisions:paragraph'
default_bundle: my_paragraphs_bundle
migration_dependencies:
required:
- upgrade_d7_field
- upgrade_d7_node_type
- upgrade_d7_field_collection_type
- upgrade_d7_field_instance
The migration process is explained here: https://www.mtech-llc.com/blog/ada-hernandez/migration-field-collection-d7-paragraphs-node-d8
So, field_job_category is not working. I tried so many ways in process plugins without luck. For example I used:
field_job_category:
plugin: migration_lookup
migration: upgrade_d7_taxonomy_term_job_categories
source: term_id
Then tried to use sources since am using Drupal 8.6
field_job_category:
plugin: migration_lookup
migration: upgrade_d7_taxonomy_term_job_categories
sources:
upgrade_d7_taxonomy_term_job_categories:
- term_id
I believe its a configuration mistake under field_job_category, but i couldn't figure it out yet.
Your help is much appreciated!
This has been resolved by doing two things.
First, use sub_process process plugin for my field.
field_job_category:
-
plugin: sub_process
source: field_job_category
process:
target_id: tid
Finally, implement hook_migrate_prepare_row() to provide data with right structure to be consumed by the above sub_process
$row->setSourceProperty($field_name, $new_value);
And $new_value should be
Array
(
[0] => Array
(
[tid] => Term ID
)
)
Hope this helps! Cheers.

CONCAT with COUNT, SUM,

In a complex query, I have a subquery to count/summarize children:
->addSelect('(SELECT CONCAT(COUNT(c.id), \'|\', SUM(c.field1), \'|\', SUM(c.field2), \'|\', SUM(c.field3)) FROM App\Entity\Child c WHERE c.parent = p.id GROUP BY c.parent)')
This query worked perfectly until I upgraded to the new version of Symfony (4.2) and doctrine orm 2.6.1. I got the following error:
[Syntax Error] line 0, col 25: Error: Expected StateFieldPathExpression | string | InputParameter | FunctionsReturningStrings | AggregateExpression, got 'COUNT'
I tried to use CAST ... AS CHAR(25) but it doesn't work (got the same error).
Anyone can help me please?
Best regards,
Jonathan
Looks Like it is regression in doctrine StringPrimary parser function.
After looking at code I have made comment with my observation in issue related to this problem (while not entierly describing it).
Essentially new function missing this part, and defaulting to error when encountering any aggregate functions:
default:
if ($this->isAggregateFunction($lookaheadType)) {
return $this->AggregateExpression();
}
PS. link to the related issue:
https://github.com/doctrine/doctrine2/issues/7205
I found a workaround: I install doctrine extensions and I replace CONCAT by CONCAT_WS (DoctrineExtensions\Query\Mysql\ConcatWs).
Best regards

Does webstorm have some shortcut for console.log or console.info?

Just tired of typing console.log again and again, and do not find a way like Sysout + Control + Space in Eclipse will create System.out.println().
There's a predefined Postfix template that allows you to type .log after a JavaScript expression or string and hit Tab to transform it to console.log().
You can also create a Live template (see Preferences | Editor | Live templates) that would expand into a code snippet once you type the selected abbreviation and hit Tab.
Update: there's now also a plugin that allows you to add console.log with a shortcut: https://plugins.jetbrains.com/plugin/10986-console-log
Yes it does,
<anything>.log and press Tab key. This will result in console.log(<anything>);
ie,
<anything>.log + Tab => console.log(<anything>);
eg1: variable
let my_var = 'Hello, World!';
my_var.log + Tab => console.log(my_var);
eg2: string
'hello'.log + Tab => console.log('hello');
eg3: string and variable
'hello', my_var.log + Tab => console.log('hello', my_var);
[UPDATE 2020]
Typing log + Enter autocompletes to console.log()
I made my own template that seems to work.
It may be useful for somebody.
Abbreviation: ll
Template text:
console.log('$NAME$ ', $VALUE$);
$END$
Variables: (just select the given field values by clicking drop down box)
NAME - jsDefineParameter()
VALUE - jsSuggestVariableName
I'm including what I find to be the most efficient, which I added via live templates -> javascript -> applicable to "Everything". Hopefully someone finds it useful.
console.log('L$LINE$ $MYSTRING$ ===', $MYVAR$);$END$
What it does:
When I type cl and press tab, it creates the log and the first thing you type fills both MYSTRING and MYVAR variables. If you tab again, it selects MYVAR where you can rewrite/delete as desired. The third time you hit tab will take you to the end of the line at $END.
This snippet also prints the line number like L123 but you can easily remove that if it isn't helpful because obviously most browsers show line number anyway.
You also have to set the variables' behaviour as seen in the image below:
Edit variables setup
use Macros!
https://www.jetbrains.com/help/webstorm/using-macros-in-the-editor.html
I recorded a macro that takes the name my cursor is on and create
console.log("#### name = ", name);
on the next line.
and assigned a keyboard shortcut to it :)
super easy, and couldn't get Live Template to get the same result with 1 action.
to create a new macro: Edit -> Macros -> Start Macro Recording. then record your next moves and create the desired result.
this is mine:
This is my solution, it somewhat mimics a turbo-console approach and gives you certain freedoms to build on it.
Step 1: Go to Editor > General > Postfix Completion;
Step 2: Click on JavaScript, click the + button, select JavaScript and TypeScript;
Step 3: In the Key input, type a alias for your command, I choose 'cl' for mine;
Step 4: In the 'Minimum language level' select your desired preference, I choose ECMAScript 6+;
Step 5: In the bellow text area, add your logic, for me it is console.log('$EXPR$', $EXPR$, '$END$');
Step 6: Customize however you like.
So what does all of this do?
Lets consider the following:
const willNeedToBeLogged = 'some value you want to check';
All you need to do for a console long is type
willNeedToBeLogged.cl + press (Tab, Enter or Spance)
And you will get this
console.log('willNeedToBeLogged', willNeedToBeLogged, '');
With your cursor being on the $END$ variable, where you could write, a line, or anything you like.
Have fun!
I made a custom template. This can help you.
Abbreviation: clog
Template code:
console.log("\n\n--------------------------------");
console.log($END$);
console.log("--------------------------------\n\n");
Simplest live template text:
console.log($END$);
Maybe it is a recent addition but you can write log and hit tab and console.log() will appear with the caret in between the braces.
The answer from Ekaterina Prigara (https://stackoverflow.com/a/32975087/5653914) was very useful to me but if you want to log a string like "Test" this method is quicker.
Try a logit plugin. It provides the next logging pattern by default:
const data = 'data';
console.log('-> data', data);
You can configure it.
Try Dot Log (vscode extension), It can automatically transfer aaa.log to console.log('aaa', aaa )

R: Countrycode package not supporting regex as the origin

I have a list of countries that i need to convert into standardized format (iso3c). Some have long names, others have 2 or 3 digit codes, and others do not display the whole country name like "Africa" instead of "South Africa". Ive done some research and come up to use countrycode package in R. However, when i tried to use "regex" R doesnt seem to recognize it. Im getting the error below:
> countrycode(data,"regex","iso3c", warn = TRUE)
Error in countrycode(data, "regex", "iso3c", :
Origin code not supported
Any other option I need to do?
Thanks!
You can view the README for the countrycode package here https://github.com/vincentarelbundock/countrycode, or you can pull up the help file in R by entering this into your R console ?countrycode::countrycode.
"regex" is not a valid 'origin' value (2nd argument in the countrycode() function). You must use one of "cowc", "cown", "eurostat", "fao", "fips105", "imf", "ioc", "iso2c", "iso3c", "iso3n", "p4_ccode", "p4_scode", "un", "wb", "wb_api2c", "wb_api3c", "wvs", "country.name", "country.name.de" (using latest version 0.19).
If you use either of the following 'origin' values, regex matching will be performed automatically: "country.name" or "country.name.de"
If you're using a custom dictionary with the new (as of version 0.19) custom_dict argument, you must set the origin_regex argument to TRUE for regex matching to occur.
In your example, this should do what you want:
countrycode(data, origin = "country.name", destination = "iso3c", warn = TRUE)