How to concatenate existing variable and string in Template Variables Dialog (PhpStorm) - phpstorm

I have a live template like this
<div>$name$: $id$</div>
Now I want to set the default value of $id$ to name + "_id".
But when I put the default value of $id$ as name + "_id", in the "Edit Template Variables Dialog", the autocomplete does not concatenate value of name and (string) "_id" together. It only uses the value of name and ignored the "_id" part (for default value of $id$).
How can I make the default value of $id$ as name + "_id" in my live templates?

You can try to create a variable and concat the values into it.
Something like:
#set( $your_var = $NAME + '_id')
<div>$name$: $your_var$</div>

Not sure about phpstorm, but I was just looking for the solution to this problem in webstorm and there is a concat(expressions...) function. So, solution to the problem could be to put in the 'Expression' field:
concat(name,"_id")

You can just do this:
<div>$name$: $name$_id</div>

Related

Json contains with exclusion or wildcard

Is there a way to either wildcard or exclude fields in a json_contains statement (postgres w/ sqlalchemy)?
For example, lets say one of the rows of my database has a field called MyField which has a typical json value of ...
MyField : {Store: "HomeDepot", Location: "New York"}
Now, I am doing a json contains on that with a larger json variable called larger_json...
larger_json : {Store: "HomeDepot", Location: "New York", Customer: "Bob" ... }
In sqlalchemy, I could use a MyTable.MyField.comparator.contained_by(larger_json) and in this case, that would work fine. But what if, for example, I later removed Location as a field in my variable... so I still have the value in my database, but it no longer exists in larger_json:
MyField : {Store: "HomeDepot", Location: "New York"}
larger_json : {Store: "HomeDepot", Customer: "Bob" ... }
Assume that I know when this happens, i.e. I know that the database has Location but the larger_json does not. Is there a way for me to either wildcard Location, i.e. something like this...
{Store: "HomeDepot", Location: "*", Customer: "Bob" ... }
or to exclude it from the json value? Something like this?
MyTable.MyField.exclude_fields().comparator.contained_by(larger_json)
Or is there another recommended approach for dealing with this?
Not sure if that's what you need, but you could remove Location as a key from the values you search:
... WHERE (tab.myfield - 'Location') <# larger_json

Read html select value into jenkins Active Choices Reactive Parameter

I saw many examples for Active Choices Reactive Parameter using formatted html, but none of these use the HTML select input type.
Here is my html snippet (simplified input of json_files for brevity):
def json_files = ["a", "b", "c"]
html_to_be_rendered = """<select id="config" name="config">"""
json_files.each { json_file ->
html_to_be_rendered = """
${html_to_be_rendered}
<option value="${json_file}">${json_file}</option>
"""
}
return "${html_to_be_rendered}</select>"
I thought I should be able to read the selected value using ${config}, but seems that doesn't work.
This is how I define it in the jenkins GUI:
What am I missing?
The only problem you have is the name attribute of the select should be hard-coded to value.
no need for the id attribute.

if-then in kotlin's #JsonProperty?

I want to do something weird... :)
I have a json file that will have either 1 key name OR another keyname. I want to detect which one is actually there, and assign to kotlin variable in class. Only one OR the other will be there. So,
data class CED(
#JsonProperty("rev_env")
var revision: Any? = null,
#JsonProperty("rev")
var revision: Any? = null,
.
.
.
So, either rev_env OR rev will be in the json file, but whichever is there, their mapping always goes to "revision".
Any way to do that?
You can use #JsonAlias.
For example:
data class A(
#JsonAlias(value = ["rev", "rev_env"])
val rev: Any? = null
)

OpenEdge ABL reserved keyword as temp-table field name (inferred from JSON data)

I am stuck with the following situation:
My method receives a response from external REST API call. The JSON response structure is as below:
{
"members": [
{
"email_address": "random#address.org",
"status": "randomstatus"
},
...etc...
]}
I am reading this to temp-table with READ-JSON (Inferring ABL schema from JSON data) and try to process the temp-table. And this is where I am stuck:
when I am trying to put together a query that contains temp-table field "status", the error is raised.
Example:
hQuery:QUERY-PREPARE('FOR EACH ' + httSubscriber:NAME + ' WHERE ' + hBuffer:BUFFER-FIELD(iStatus):NAME + ' = "randomstatus"').
gives:
**Unable to understand after -- "members WHERE".(247)
I have tried referencing directly by name as well, same result.
Probably the "status" is a reserved keyword in ABL. Might that be the case? And how can I get over this issue to reference that "status" field?
Unfortunately the format and key names of JSON response are not under my control and I have to work with that.
You could use SERIALIZE-NAME in the temp-table definition to internally rename the field in question. Then you would have to refer to the field with another name but in it's serialized form it would still be known as status.
Here's an example where the status-field is renamed to exampleStatus.
DEFINE TEMP-TABLE ttExample NO-UNDO
FIELD exampleStatus AS CHARACTER SERIALIZE-NAME "status".
/* Code to read json goes here... */
/* Access the field */
FOR EACH ttExample:
DISPLAY ttExample.exampleStatus.
END.
I've been known to do silly things like this:
JSONData = replace( JSONData, '"status":', '"xstatus":' ).
Try naming the temp-table (hard-coded or via string appending) + '.' + hBuffer:BUFFER-FIELD(iStatus):NAME (...)
It should help the compiler understand you're talking about the field. Since it's not restricted, this should force its hand and allow you to query.

set content of tinymce with a string of html

I have a JSF Renderer that uses responsewriter to generate a jsf page .
In this class I create a String that contains html code , something like this :
String s = "<b>hello</b> <i>world</i>" .
when I create a tinymce editor and set the value of it with responsewriter like this :
responseWriter.writeText(value, null);
it show exactly the same String (showing HTML tag) instead of HTML format of it.
I know it's Wrong to use writeText for writing HTML but I don't know what to use instead.
Try setContent.
responseWriter.setContent(s);
More information here: http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent
finally I solved my problem in this way :
I set the value in a hidden like this :
responseWriter.startElement("input", null);
responseWriter.writeAttribute("type", "hidden", null);
responseWriter.writeAttribute("id", "tinymcevalue" , null);
responseWriter.writeAttribute("name", "required-" + filerRichTextEditor.getSchemaName(), null);
responseWriter.writeAttribute("value", getDocumentFieldValue(filerUIComponent.getSchemaName()), null);
responseWriter.endElement("input");
and then I set it in my JSF :
tinyMCE.activeEditor.setContent(document.getElementById("tinymcevalue").value);